summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
Diffstat (limited to 'ldso')
-rw-r--r--ldso/ldso/boot1.c60
-rw-r--r--ldso/ldso/dl-elf.c30
-rw-r--r--ldso/ldso/dl-hash.c12
-rw-r--r--ldso/ldso/hash.c12
-rw-r--r--ldso/ldso/hash.h28
-rw-r--r--ldso/ldso/i386/dl-sysdep.h8
-rw-r--r--ldso/ldso/i386/elfinterp.c44
-rw-r--r--ldso/ldso/i386/ld_sysdep.h8
-rw-r--r--ldso/ldso/i386/sysdep.h8
-rw-r--r--ldso/ldso/ld-uClibc.c60
-rw-r--r--ldso/ldso/ld_hash.h28
-rw-r--r--ldso/ldso/ld_syscall.h9
-rw-r--r--ldso/ldso/ldso.c60
-rw-r--r--ldso/ldso/linuxelf.h14
-rw-r--r--ldso/ldso/readelflib1.c30
-rw-r--r--ldso/ldso/syscall.h9
-rw-r--r--ldso/libdl/dlib.c600
-rw-r--r--ldso/libdl/libdl.c600
-rw-r--r--ldso/util/ldd.c6
19 files changed, 795 insertions, 831 deletions
diff --git a/ldso/ldso/boot1.c b/ldso/ldso/boot1.c
index 948a6e159..ca8bdbab4 100644
--- a/ldso/ldso/boot1.c
+++ b/ldso/ldso/boot1.c
@@ -120,9 +120,9 @@ void *(*_dl_malloc_function) (int size) = NULL;
struct r_debug *_dl_debug_addr = NULL;
-unsigned int *_dl_brkp;
+unsigned long *_dl_brkp;
-unsigned int *_dl_envp;
+unsigned long *_dl_envp;
#define DL_MALLOC(SIZE) ((void *) (malloc_buffer += SIZE, malloc_buffer - SIZE))
/*
@@ -130,7 +130,7 @@ unsigned int *_dl_envp;
* platforms we may need to increase this to 8, but this is good enough for
* now. This is typically called after DL_MALLOC.
*/
-#define REALIGN() malloc_buffer = (char *) (((unsigned int) malloc_buffer + 3) & ~(3))
+#define REALIGN() malloc_buffer = (char *) (((unsigned long) malloc_buffer + 3) & ~(3))
@@ -161,31 +161,29 @@ void _dl_debug_state()
return;
}
-void _dl_boot(int args);
-
-void _dl_boot(int args)
+void _dl_boot(unsigned long args)
{
- unsigned int argc;
+ unsigned long argc;
char **argv, **envp;
int status;
- unsigned int load_addr;
- unsigned int *got;
- unsigned int *aux_dat;
+ unsigned long load_addr;
+ unsigned long *got;
+ unsigned long *aux_dat;
int goof = 0;
elfhdr *header;
struct elf_resolve *tpnt;
struct dyn_elf *rpnt;
struct elf_resolve *app_tpnt;
- unsigned int brk_addr;
- unsigned int dl_data[AT_EGID + 1];
+ unsigned long brk_addr;
+ unsigned long dl_data[AT_EGID + 1];
unsigned char *malloc_buffer, *mmap_zero;
int (*_dl_atexit) (void *);
- int *lpnt;
+ unsigned long *lpnt;
Elf32_Dyn *dpnt;
- unsigned int *hash_addr;
+ unsigned long *hash_addr;
struct r_debug *debug_addr;
- unsigned int *chains;
+ unsigned long *chains;
int indx;
int _dl_secure;
@@ -204,7 +202,7 @@ void _dl_boot(int args)
dl_data[AT_UID] = -1; /* check later to see if it is changed */
while (*aux_dat)
{
- unsigned int *ad1;
+ unsigned long *ad1;
ad1 = aux_dat + 1;
if (*aux_dat <= AT_EGID)
@@ -282,7 +280,7 @@ void _dl_boot(int args)
}
app_tpnt->dynamic_info[dpnt->d_tag] = dpnt->d_un.d_val;
if (dpnt->d_tag == DT_DEBUG)
- dpnt->d_un.d_val = (int) debug_addr;
+ dpnt->d_un.d_val = (unsigned long) debug_addr;
if (dpnt->d_tag == DT_TEXTREL || SVR4_BUGCOMPAT)
app_tpnt->dynamic_info[DT_TEXTREL] = 1;
dpnt++;
@@ -293,7 +291,7 @@ void _dl_boot(int args)
/* Get some more of the information that we will need to dynamicly link
this module to itself */
- hash_addr = (unsigned int *) (tpnt->dynamic_info[DT_HASH] + load_addr);
+ hash_addr = (unsigned long *) (tpnt->dynamic_info[DT_HASH] + load_addr);
tpnt->nbucket = *hash_addr++;
tpnt->nchain = *hash_addr++;
tpnt->elf_buckets = hash_addr;
@@ -317,7 +315,7 @@ void _dl_boot(int args)
_dl_mprotect((void *) (load_addr +
(ppnt->p_vaddr & 0xfffff000)),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
@@ -329,7 +327,7 @@ void _dl_boot(int args)
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) (ppnt->p_vaddr & 0xfffff000),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
@@ -342,10 +340,10 @@ void _dl_boot(int args)
for (indx = 0; indx < 2; indx++) {
int i;
ELF_RELOC *rpnt;
- unsigned int *reloc_addr;
- unsigned int symbol_addr;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr;
int symtab_index;
- unsigned int rel_addr, rel_size;
+ unsigned long rel_addr, rel_size;
#ifdef ELF_USES_RELOCA
@@ -371,7 +369,7 @@ void _dl_boot(int args)
/* Now parse the relocation information */
rpnt = (ELF_RELOC *) (rel_addr + load_addr);
for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
- reloc_addr = (int *) (load_addr + (int) rpnt->r_offset);
+ reloc_addr = (unsigned long *) (load_addr + (unsigned long) rpnt->r_offset);
symtab_index = ELF32_R_SYM(rpnt->r_info);
symbol_addr = 0;
if (symtab_index) {
@@ -430,7 +428,7 @@ void _dl_boot(int args)
fixed up by now. Still no function calls outside of this library ,
since the dynamic resolver is not yet ready. */
- lpnt = (int *) (tpnt->dynamic_info[DT_PLTGOT] + load_addr);
+ lpnt = (unsigned long *) (tpnt->dynamic_info[DT_PLTGOT] + load_addr);
INIT_GOT(lpnt, tpnt);
/* OK, this was a big step, now we need to scan all of the user images
@@ -494,7 +492,7 @@ void _dl_boot(int args)
rpnt->dyn = _dl_loaded_modules;
app_tpnt->usage_count++;
app_tpnt->symbol_scope = _dl_symbol_tables;
- lpnt = (int *) (app_tpnt->dynamic_info[DT_PLTGOT]);
+ lpnt = (unsigned long *) (app_tpnt->dynamic_info[DT_PLTGOT]);
#ifdef ALLOW_ZERO_PLTGOT
if (lpnt)
#endif
@@ -812,14 +810,14 @@ void _dl_boot(int args)
up each symbol individually. */
- _dl_brkp = (unsigned int *) _dl_find_hash("___brk_addr", NULL, 1, NULL, 0);
+ _dl_brkp = (unsigned long *) _dl_find_hash("___brk_addr", NULL, 1, NULL, 0);
if (_dl_brkp)
*_dl_brkp = brk_addr;
_dl_envp =
- (unsigned int *) _dl_find_hash("__environ", NULL, 1, NULL, 0);
+ (unsigned long *) _dl_find_hash("__environ", NULL, 1, NULL, 0);
if (_dl_envp)
- *_dl_envp = (unsigned int) envp;
+ *_dl_envp = (unsigned long) envp;
{
int i;
@@ -834,7 +832,7 @@ void _dl_boot(int args)
_dl_mprotect((void *) (tpnt->loadaddr +
(ppnt->p_vaddr & 0xfffff000)),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
LXFLAGS(ppnt->p_flags));
}
@@ -974,7 +972,7 @@ void *_dl_malloc(int size)
* Align memory to 4 byte boundary. Some platforms require this, others
* simply get better performance.
*/
- _dl_malloc_addr = (char *) (((unsigned int) _dl_malloc_addr + 3) & ~(3));
+ _dl_malloc_addr = (char *) (((unsigned long) _dl_malloc_addr + 3) & ~(3));
return retval;
}
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index d9b900809..4689e51f2 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -121,8 +121,8 @@ int _dl_unmap_cache(void)
* Used to return error codes back to dlopen et. al.
*/
-unsigned int _dl_error_number;
-unsigned int _dl_internal_error_number;
+unsigned long _dl_error_number;
+unsigned long _dl_internal_error_number;
struct elf_resolve *_dl_load_shared_library(int secure,
struct elf_resolve *tpnt, char *full_libname)
@@ -166,7 +166,7 @@ struct elf_resolve *_dl_load_shared_library(int secure,
if (tpnt->libtype == elf_executable) {
pnt1 = (char *) tpnt->dynamic_info[DT_RPATH];
if (pnt1) {
- pnt1 += (unsigned int) tpnt->loadaddr +
+ pnt1 += (unsigned long) tpnt->loadaddr +
tpnt->dynamic_info[DT_STRTAB];
while (*pnt1) {
pnt2 = mylibname;
@@ -314,8 +314,8 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
char *libname, int flag)
{
elfhdr *epnt;
- unsigned int dynamic_addr = 0;
- unsigned int dynamic_size = 0;
+ unsigned long dynamic_addr = 0;
+ unsigned long dynamic_size = 0;
Elf32_Dyn *dpnt;
struct elf_resolve *tpnt;
elf_phdr *ppnt;
@@ -323,10 +323,10 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
char *status;
int flags;
char header[4096];
- int dynamic_info[24];
+ unsigned long dynamic_info[24];
int *lpnt;
- unsigned int libaddr;
- unsigned int minvma = 0xffffffff, maxvma = 0;
+ unsigned long libaddr;
+ unsigned long minvma = 0xffffffff, maxvma = 0;
int i;
int infile;
@@ -410,7 +410,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (piclib && ppnt->p_vaddr < minvma) {
minvma = ppnt->p_vaddr;
}
- if (((unsigned int) ppnt->p_vaddr + ppnt->p_memsz) > maxvma) {
+ if (((unsigned long) ppnt->p_vaddr + ppnt->p_memsz) > maxvma) {
maxvma = ppnt->p_vaddr + ppnt->p_memsz;
}
}
@@ -432,7 +432,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
_dl_close(infile);
return NULL;
};
- libaddr = (unsigned int) status;
+ libaddr = (unsigned long) status;
flags |= MAP_FIXED;
/* Get the memory to store the library */
@@ -450,7 +450,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (ppnt->p_flags & PF_W) {
- unsigned int map_size;
+ unsigned long map_size;
char *cpnt;
status = (char *) _dl_mmap((char *) ((piclib ? libaddr : 0) +
@@ -470,7 +470,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
/* Pad the last page with zeroes. */
cpnt = (char *) (status + (ppnt->p_vaddr & 0xfff) +
ppnt->p_filesz);
- while (((unsigned int) cpnt) & 0xfff)
+ while (((unsigned long) cpnt) & 0xfff)
*cpnt++ = 0;
/* I am not quite sure if this is completely
@@ -499,7 +499,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
};
/* if(libaddr == 0 && piclib) {
- libaddr = (unsigned int) status;
+ libaddr = (unsigned long) status;
flags |= MAP_FIXED;
}; */
};
@@ -509,7 +509,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
/* For a non-PIC library, the addresses are all absolute */
if (piclib) {
- dynamic_addr += (unsigned int) libaddr;
+ dynamic_addr += (unsigned long) libaddr;
}
/*
@@ -551,7 +551,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) ((piclib ? libaddr : 0) +
(ppnt->p_vaddr & 0xfffff000)),
- (ppnt->p_vaddr & 0xfff) + (unsigned int) ppnt->p_filesz,
+ (ppnt->p_vaddr & 0xfff) + (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c
index fa610e012..5639a9a69 100644
--- a/ldso/ldso/dl-hash.c
+++ b/ldso/ldso/dl-hash.c
@@ -94,10 +94,10 @@ struct elf_resolve *_dl_check_hashed_files(char *libname)
*/
struct elf_resolve *_dl_add_elf_hash_table(char *libname,
- char *loadaddr, unsigned int *dynamic_info, unsigned int dynamic_addr,
- unsigned int dynamic_size)
+ char *loadaddr, unsigned long *dynamic_info, unsigned long dynamic_addr,
+ unsigned long dynamic_size)
{
- unsigned int *hash_addr;
+ unsigned long *hash_addr;
struct elf_resolve *tpnt;
int i;
@@ -123,7 +123,7 @@ struct elf_resolve *_dl_add_elf_hash_table(char *libname,
tpnt->libtype = loaded_file;
if (dynamic_info[DT_HASH] != 0) {
- hash_addr = (unsigned int *) (dynamic_info[DT_HASH] + loadaddr);
+ hash_addr = (unsigned long *) (dynamic_info[DT_HASH] + loadaddr);
tpnt->nbucket = *hash_addr++;
tpnt->nchain = *hash_addr++;
tpnt->elf_buckets = hash_addr;
@@ -143,7 +143,7 @@ struct elf_resolve *_dl_add_elf_hash_table(char *libname,
*/
char *_dl_find_hash(char *name, struct dyn_elf *rpnt1,
- unsigned int instr_addr, struct elf_resolve *f_tpnt, int copyrel)
+ unsigned long instr_addr, struct elf_resolve *f_tpnt, int copyrel)
{
struct elf_resolve *tpnt;
int si;
@@ -151,7 +151,7 @@ char *_dl_find_hash(char *name, struct dyn_elf *rpnt1,
int pass;
char *strtab;
Elf32_Sym *symtab;
- unsigned int elf_hash_number, hn;
+ unsigned long elf_hash_number, hn;
char *weak_result;
struct elf_resolve *first_def;
struct dyn_elf *rpnt, first;
diff --git a/ldso/ldso/hash.c b/ldso/ldso/hash.c
index fa610e012..5639a9a69 100644
--- a/ldso/ldso/hash.c
+++ b/ldso/ldso/hash.c
@@ -94,10 +94,10 @@ struct elf_resolve *_dl_check_hashed_files(char *libname)
*/
struct elf_resolve *_dl_add_elf_hash_table(char *libname,
- char *loadaddr, unsigned int *dynamic_info, unsigned int dynamic_addr,
- unsigned int dynamic_size)
+ char *loadaddr, unsigned long *dynamic_info, unsigned long dynamic_addr,
+ unsigned long dynamic_size)
{
- unsigned int *hash_addr;
+ unsigned long *hash_addr;
struct elf_resolve *tpnt;
int i;
@@ -123,7 +123,7 @@ struct elf_resolve *_dl_add_elf_hash_table(char *libname,
tpnt->libtype = loaded_file;
if (dynamic_info[DT_HASH] != 0) {
- hash_addr = (unsigned int *) (dynamic_info[DT_HASH] + loadaddr);
+ hash_addr = (unsigned long *) (dynamic_info[DT_HASH] + loadaddr);
tpnt->nbucket = *hash_addr++;
tpnt->nchain = *hash_addr++;
tpnt->elf_buckets = hash_addr;
@@ -143,7 +143,7 @@ struct elf_resolve *_dl_add_elf_hash_table(char *libname,
*/
char *_dl_find_hash(char *name, struct dyn_elf *rpnt1,
- unsigned int instr_addr, struct elf_resolve *f_tpnt, int copyrel)
+ unsigned long instr_addr, struct elf_resolve *f_tpnt, int copyrel)
{
struct elf_resolve *tpnt;
int si;
@@ -151,7 +151,7 @@ char *_dl_find_hash(char *name, struct dyn_elf *rpnt1,
int pass;
char *strtab;
Elf32_Sym *symtab;
- unsigned int elf_hash_number, hn;
+ unsigned long elf_hash_number, hn;
char *weak_result;
struct elf_resolve *first_def;
struct dyn_elf *rpnt, first;
diff --git a/ldso/ldso/hash.h b/ldso/ldso/hash.h
index f7c6eebd5..74bac2f7d 100644
--- a/ldso/ldso/hash.h
+++ b/ldso/ldso/hash.h
@@ -5,7 +5,7 @@
#endif
struct dyn_elf{
- unsigned int flags;
+ unsigned long flags;
struct elf_resolve * dyn;
struct dyn_elf * next_handle; /* Used by dlopen et al. */
struct dyn_elf * next;
@@ -16,7 +16,7 @@ struct elf_resolve{
by gdb to obtain the list of symbols. */
char * loadaddr;
char * libname;
- unsigned int dynamic_addr;
+ unsigned long dynamic_addr;
struct elf_resolve * next;
struct elf_resolve * prev;
/* Nothing after this address is used by gdb. */
@@ -25,16 +25,16 @@ struct elf_resolve{
unsigned short usage_count;
unsigned short int init_flag;
unsigned int nbucket;
- unsigned int * elf_buckets;
+ unsigned long * elf_buckets;
/*
* These are only used with ELF style shared libraries
*/
- unsigned int nchain;
- unsigned int * chains;
- unsigned int dynamic_info[24];
+ unsigned long nchain;
+ unsigned long * chains;
+ unsigned long dynamic_info[24];
- unsigned int dynamic_size;
- unsigned int n_phent;
+ unsigned long dynamic_size;
+ unsigned long n_phent;
Elf32_Phdr * ppnt;
};
@@ -64,15 +64,11 @@ extern struct dyn_elf * _dl_handles;
extern struct elf_resolve * _dl_check_hashed_files(char * libname);
extern struct elf_resolve * _dl_add_elf_hash_table(char * libname,
- char * loadaddr,
- unsigned int * dynamic_info,
- unsigned int dynamic_addr,
- unsigned int dynamic_size);
+ char * loadaddr, unsigned long * dynamic_info,
+ unsigned long dynamic_addr, unsigned long dynamic_size);
extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1,
- unsigned int instr_addr,
- struct elf_resolve * f_tpnt,
- int copyrel);
-
+ unsigned long instr_addr, struct elf_resolve * f_tpnt,
+ int copyrel);
extern int _dl_linux_dynamic_link(void);
#ifdef __mc68000__
diff --git a/ldso/ldso/i386/dl-sysdep.h b/ldso/ldso/i386/dl-sysdep.h
index 64d4b7a46..d8e57a66c 100644
--- a/ldso/ldso/i386/dl-sysdep.h
+++ b/ldso/ldso/i386/dl-sysdep.h
@@ -13,7 +13,7 @@
* the address if the first argument, on other platforms we need to
* do something a little more subtle here.
*/
-#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned int*) & ARGS)
+#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) & ARGS)
/*
* Get the address of the Global offset table. This must be absolute, not
* relative.
@@ -42,14 +42,14 @@
*REL += SYMBOL; \
break; \
case R_386_PC32: \
- *REL += SYMBOL - (unsigned int) REL; \
+ *REL += SYMBOL - (unsigned long) REL; \
break; \
case R_386_GLOB_DAT: \
case R_386_JMP_SLOT: \
*REL = SYMBOL; \
break; \
case R_386_RELATIVE: \
- *REL += (unsigned int) LOAD; \
+ *REL += (unsigned long) LOAD; \
break; \
default: \
_dl_exit(1); \
@@ -76,6 +76,6 @@
#define ELF_TARGET "386"
struct elf_resolve;
-extern unsigned int _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
+extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
#define do_rem(result, n, base) result = (n % base)
diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c
index e0d3505f9..aa795d803 100644
--- a/ldso/ldso/i386/elfinterp.c
+++ b/ldso/ldso/i386/elfinterp.c
@@ -51,7 +51,7 @@ extern char *_dl_progname;
extern int _dl_linux_resolve(void);
-unsigned int _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
+unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
int reloc_type;
Elf32_Rel *this_reloc;
@@ -61,7 +61,7 @@ unsigned int _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
int symtab_index;
char *new_addr;
char **got_addr;
- unsigned int instr_addr;
+ unsigned long instr_addr;
rel_addr = (Elf32_Rel *) (tpnt->dynamic_info[DT_JMPREL] + tpnt->loadaddr);
@@ -98,7 +98,7 @@ unsigned int _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
};
/* #define DEBUG_LIBRARY */
#ifdef DEBUG_LIBRARY
- if ((unsigned int) got_addr < 0x40000000) {
+ if ((unsigned long) got_addr < 0x40000000) {
_dl_fdprintf(2, "Calling library function: %s\n",
strtab + symtab[symtab_index].st_name);
} else {
@@ -107,11 +107,11 @@ unsigned int _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
#else
*got_addr = new_addr;
#endif
- return (unsigned int) new_addr;
+ return (unsigned long) new_addr;
}
void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
- int rel_addr, int rel_size, int type)
+ unsigned long rel_addr, unsigned long rel_size, int type)
{
int i;
char *strtab;
@@ -119,7 +119,7 @@ void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
int symtab_index;
Elf32_Sym *symtab;
Elf32_Rel *rpnt;
- unsigned int *reloc_addr;
+ unsigned long *reloc_addr;
/* Now parse the relocation information */
rpnt = (Elf32_Rel *) (rel_addr + tpnt->loadaddr);
@@ -130,7 +130,7 @@ void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
for (i = 0; i < rel_size; i++, rpnt++) {
- reloc_addr = (int *) (tpnt->loadaddr + (int) rpnt->r_offset);
+ reloc_addr = (unsigned long *) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
reloc_type = ELF32_R_TYPE(rpnt->r_info);
symtab_index = ELF32_R_SYM(rpnt->r_info);
@@ -146,7 +146,7 @@ void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
case R_386_NONE:
break;
case R_386_JMP_SLOT:
- *reloc_addr += (unsigned int) tpnt->loadaddr;
+ *reloc_addr += (unsigned long) tpnt->loadaddr;
break;
default:
_dl_fdprintf(2, "%s: (LAZY) can't handle reloc type ",
@@ -162,7 +162,7 @@ void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
}
int _dl_parse_relocation_information(struct elf_resolve *tpnt,
- int rel_addr, int rel_size, int type)
+ unsigned long rel_addr, unsigned long rel_size, int type)
{
int i;
char *strtab;
@@ -170,8 +170,8 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
int goof = 0;
Elf32_Sym *symtab;
Elf32_Rel *rpnt;
- unsigned int *reloc_addr;
- unsigned int symbol_addr;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr;
int symtab_index;
/* Now parse the relocation information */
@@ -184,7 +184,7 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
for (i = 0; i < rel_size; i++, rpnt++) {
- reloc_addr = (int *) (tpnt->loadaddr + (int) rpnt->r_offset);
+ reloc_addr = (unsigned long *) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
reloc_type = ELF32_R_TYPE(rpnt->r_info);
symtab_index = ELF32_R_SYM(rpnt->r_info);
symbol_addr = 0;
@@ -198,9 +198,9 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
_dl_symbol(strtab + symtab[symtab_index].st_name))
continue;
- symbol_addr = (unsigned int)
+ symbol_addr = (unsigned long)
_dl_find_hash(strtab + symtab[symtab_index].st_name,
- tpnt->symbol_scope, (int) reloc_addr,
+ tpnt->symbol_scope, (unsigned long) reloc_addr,
(reloc_type == R_386_JMP_SLOT ? tpnt : NULL), 0);
/*
@@ -223,14 +223,14 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
*reloc_addr += symbol_addr;
break;
case R_386_PC32:
- *reloc_addr += symbol_addr - (unsigned int) reloc_addr;
+ *reloc_addr += symbol_addr - (unsigned long) reloc_addr;
break;
case R_386_GLOB_DAT:
case R_386_JMP_SLOT:
*reloc_addr = symbol_addr;
break;
case R_386_RELATIVE:
- *reloc_addr += (unsigned int) tpnt->loadaddr;
+ *reloc_addr += (unsigned long) tpnt->loadaddr;
break;
case R_386_COPY:
#if 0
@@ -266,8 +266,8 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
/* No, there are cases where the SVr4 linker fails to emit COPY relocs
at all */
-int _dl_parse_copy_information(struct dyn_elf *xpnt, int rel_addr,
- int rel_size, int type)
+int _dl_parse_copy_information(struct dyn_elf *xpnt, unsigned long rel_addr,
+ unsigned long rel_size, int type)
{
int i;
char *strtab;
@@ -275,8 +275,8 @@ int _dl_parse_copy_information(struct dyn_elf *xpnt, int rel_addr,
int goof = 0;
Elf32_Sym *symtab;
Elf32_Rel *rpnt;
- unsigned int *reloc_addr;
- unsigned int symbol_addr;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr;
struct elf_resolve *tpnt;
int symtab_index;
@@ -291,7 +291,7 @@ int _dl_parse_copy_information(struct dyn_elf *xpnt, int rel_addr,
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
for (i = 0; i < rel_size; i++, rpnt++) {
- reloc_addr = (int *) (tpnt->loadaddr + (int) rpnt->r_offset);
+ reloc_addr = (unsigned long *) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
reloc_type = ELF32_R_TYPE(rpnt->r_info);
if (reloc_type != R_386_COPY)
continue;
@@ -305,7 +305,7 @@ int _dl_parse_copy_information(struct dyn_elf *xpnt, int rel_addr,
_dl_symbol(strtab + symtab[symtab_index].st_name))
continue;
- symbol_addr = (unsigned int) _dl_find_hash(strtab + symtab[symtab_index].st_name,
+ symbol_addr = (unsigned long) _dl_find_hash(strtab + symtab[symtab_index].st_name,
xpnt->next, (int) reloc_addr, NULL, 1);
if (!symbol_addr) {
_dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
diff --git a/ldso/ldso/i386/ld_sysdep.h b/ldso/ldso/i386/ld_sysdep.h
index 64d4b7a46..d8e57a66c 100644
--- a/ldso/ldso/i386/ld_sysdep.h
+++ b/ldso/ldso/i386/ld_sysdep.h
@@ -13,7 +13,7 @@
* the address if the first argument, on other platforms we need to
* do something a little more subtle here.
*/
-#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned int*) & ARGS)
+#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) & ARGS)
/*
* Get the address of the Global offset table. This must be absolute, not
* relative.
@@ -42,14 +42,14 @@
*REL += SYMBOL; \
break; \
case R_386_PC32: \
- *REL += SYMBOL - (unsigned int) REL; \
+ *REL += SYMBOL - (unsigned long) REL; \
break; \
case R_386_GLOB_DAT: \
case R_386_JMP_SLOT: \
*REL = SYMBOL; \
break; \
case R_386_RELATIVE: \
- *REL += (unsigned int) LOAD; \
+ *REL += (unsigned long) LOAD; \
break; \
default: \
_dl_exit(1); \
@@ -76,6 +76,6 @@
#define ELF_TARGET "386"
struct elf_resolve;
-extern unsigned int _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
+extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
#define do_rem(result, n, base) result = (n % base)
diff --git a/ldso/ldso/i386/sysdep.h b/ldso/ldso/i386/sysdep.h
index 64d4b7a46..d8e57a66c 100644
--- a/ldso/ldso/i386/sysdep.h
+++ b/ldso/ldso/i386/sysdep.h
@@ -13,7 +13,7 @@
* the address if the first argument, on other platforms we need to
* do something a little more subtle here.
*/
-#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned int*) & ARGS)
+#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) & ARGS)
/*
* Get the address of the Global offset table. This must be absolute, not
* relative.
@@ -42,14 +42,14 @@
*REL += SYMBOL; \
break; \
case R_386_PC32: \
- *REL += SYMBOL - (unsigned int) REL; \
+ *REL += SYMBOL - (unsigned long) REL; \
break; \
case R_386_GLOB_DAT: \
case R_386_JMP_SLOT: \
*REL = SYMBOL; \
break; \
case R_386_RELATIVE: \
- *REL += (unsigned int) LOAD; \
+ *REL += (unsigned long) LOAD; \
break; \
default: \
_dl_exit(1); \
@@ -76,6 +76,6 @@
#define ELF_TARGET "386"
struct elf_resolve;
-extern unsigned int _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
+extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
#define do_rem(result, n, base) result = (n % base)
diff --git a/ldso/ldso/ld-uClibc.c b/ldso/ldso/ld-uClibc.c
index 948a6e159..ca8bdbab4 100644
--- a/ldso/ldso/ld-uClibc.c
+++ b/ldso/ldso/ld-uClibc.c
@@ -120,9 +120,9 @@ void *(*_dl_malloc_function) (int size) = NULL;
struct r_debug *_dl_debug_addr = NULL;
-unsigned int *_dl_brkp;
+unsigned long *_dl_brkp;
-unsigned int *_dl_envp;
+unsigned long *_dl_envp;
#define DL_MALLOC(SIZE) ((void *) (malloc_buffer += SIZE, malloc_buffer - SIZE))
/*
@@ -130,7 +130,7 @@ unsigned int *_dl_envp;
* platforms we may need to increase this to 8, but this is good enough for
* now. This is typically called after DL_MALLOC.
*/
-#define REALIGN() malloc_buffer = (char *) (((unsigned int) malloc_buffer + 3) & ~(3))
+#define REALIGN() malloc_buffer = (char *) (((unsigned long) malloc_buffer + 3) & ~(3))
@@ -161,31 +161,29 @@ void _dl_debug_state()
return;
}
-void _dl_boot(int args);
-
-void _dl_boot(int args)
+void _dl_boot(unsigned long args)
{
- unsigned int argc;
+ unsigned long argc;
char **argv, **envp;
int status;
- unsigned int load_addr;
- unsigned int *got;
- unsigned int *aux_dat;
+ unsigned long load_addr;
+ unsigned long *got;
+ unsigned long *aux_dat;
int goof = 0;
elfhdr *header;
struct elf_resolve *tpnt;
struct dyn_elf *rpnt;
struct elf_resolve *app_tpnt;
- unsigned int brk_addr;
- unsigned int dl_data[AT_EGID + 1];
+ unsigned long brk_addr;
+ unsigned long dl_data[AT_EGID + 1];
unsigned char *malloc_buffer, *mmap_zero;
int (*_dl_atexit) (void *);
- int *lpnt;
+ unsigned long *lpnt;
Elf32_Dyn *dpnt;
- unsigned int *hash_addr;
+ unsigned long *hash_addr;
struct r_debug *debug_addr;
- unsigned int *chains;
+ unsigned long *chains;
int indx;
int _dl_secure;
@@ -204,7 +202,7 @@ void _dl_boot(int args)
dl_data[AT_UID] = -1; /* check later to see if it is changed */
while (*aux_dat)
{
- unsigned int *ad1;
+ unsigned long *ad1;
ad1 = aux_dat + 1;
if (*aux_dat <= AT_EGID)
@@ -282,7 +280,7 @@ void _dl_boot(int args)
}
app_tpnt->dynamic_info[dpnt->d_tag] = dpnt->d_un.d_val;
if (dpnt->d_tag == DT_DEBUG)
- dpnt->d_un.d_val = (int) debug_addr;
+ dpnt->d_un.d_val = (unsigned long) debug_addr;
if (dpnt->d_tag == DT_TEXTREL || SVR4_BUGCOMPAT)
app_tpnt->dynamic_info[DT_TEXTREL] = 1;
dpnt++;
@@ -293,7 +291,7 @@ void _dl_boot(int args)
/* Get some more of the information that we will need to dynamicly link
this module to itself */
- hash_addr = (unsigned int *) (tpnt->dynamic_info[DT_HASH] + load_addr);
+ hash_addr = (unsigned long *) (tpnt->dynamic_info[DT_HASH] + load_addr);
tpnt->nbucket = *hash_addr++;
tpnt->nchain = *hash_addr++;
tpnt->elf_buckets = hash_addr;
@@ -317,7 +315,7 @@ void _dl_boot(int args)
_dl_mprotect((void *) (load_addr +
(ppnt->p_vaddr & 0xfffff000)),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
@@ -329,7 +327,7 @@ void _dl_boot(int args)
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) (ppnt->p_vaddr & 0xfffff000),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
@@ -342,10 +340,10 @@ void _dl_boot(int args)
for (indx = 0; indx < 2; indx++) {
int i;
ELF_RELOC *rpnt;
- unsigned int *reloc_addr;
- unsigned int symbol_addr;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr;
int symtab_index;
- unsigned int rel_addr, rel_size;
+ unsigned long rel_addr, rel_size;
#ifdef ELF_USES_RELOCA
@@ -371,7 +369,7 @@ void _dl_boot(int args)
/* Now parse the relocation information */
rpnt = (ELF_RELOC *) (rel_addr + load_addr);
for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
- reloc_addr = (int *) (load_addr + (int) rpnt->r_offset);
+ reloc_addr = (unsigned long *) (load_addr + (unsigned long) rpnt->r_offset);
symtab_index = ELF32_R_SYM(rpnt->r_info);
symbol_addr = 0;
if (symtab_index) {
@@ -430,7 +428,7 @@ void _dl_boot(int args)
fixed up by now. Still no function calls outside of this library ,
since the dynamic resolver is not yet ready. */
- lpnt = (int *) (tpnt->dynamic_info[DT_PLTGOT] + load_addr);
+ lpnt = (unsigned long *) (tpnt->dynamic_info[DT_PLTGOT] + load_addr);
INIT_GOT(lpnt, tpnt);
/* OK, this was a big step, now we need to scan all of the user images
@@ -494,7 +492,7 @@ void _dl_boot(int args)
rpnt->dyn = _dl_loaded_modules;
app_tpnt->usage_count++;
app_tpnt->symbol_scope = _dl_symbol_tables;
- lpnt = (int *) (app_tpnt->dynamic_info[DT_PLTGOT]);
+ lpnt = (unsigned long *) (app_tpnt->dynamic_info[DT_PLTGOT]);
#ifdef ALLOW_ZERO_PLTGOT
if (lpnt)
#endif
@@ -812,14 +810,14 @@ void _dl_boot(int args)
up each symbol individually. */
- _dl_brkp = (unsigned int *) _dl_find_hash("___brk_addr", NULL, 1, NULL, 0);
+ _dl_brkp = (unsigned long *) _dl_find_hash("___brk_addr", NULL, 1, NULL, 0);
if (_dl_brkp)
*_dl_brkp = brk_addr;
_dl_envp =
- (unsigned int *) _dl_find_hash("__environ", NULL, 1, NULL, 0);
+ (unsigned long *) _dl_find_hash("__environ", NULL, 1, NULL, 0);
if (_dl_envp)
- *_dl_envp = (unsigned int) envp;
+ *_dl_envp = (unsigned long) envp;
{
int i;
@@ -834,7 +832,7 @@ void _dl_boot(int args)
_dl_mprotect((void *) (tpnt->loadaddr +
(ppnt->p_vaddr & 0xfffff000)),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
LXFLAGS(ppnt->p_flags));
}
@@ -974,7 +972,7 @@ void *_dl_malloc(int size)
* Align memory to 4 byte boundary. Some platforms require this, others
* simply get better performance.
*/
- _dl_malloc_addr = (char *) (((unsigned int) _dl_malloc_addr + 3) & ~(3));
+ _dl_malloc_addr = (char *) (((unsigned long) _dl_malloc_addr + 3) & ~(3));
return retval;
}
diff --git a/ldso/ldso/ld_hash.h b/ldso/ldso/ld_hash.h
index f7c6eebd5..74bac2f7d 100644
--- a/ldso/ldso/ld_hash.h
+++ b/ldso/ldso/ld_hash.h
@@ -5,7 +5,7 @@
#endif
struct dyn_elf{
- unsigned int flags;
+ unsigned long flags;
struct elf_resolve * dyn;
struct dyn_elf * next_handle; /* Used by dlopen et al. */
struct dyn_elf * next;
@@ -16,7 +16,7 @@ struct elf_resolve{
by gdb to obtain the list of symbols. */
char * loadaddr;
char * libname;
- unsigned int dynamic_addr;
+ unsigned long dynamic_addr;
struct elf_resolve * next;
struct elf_resolve * prev;
/* Nothing after this address is used by gdb. */
@@ -25,16 +25,16 @@ struct elf_resolve{
unsigned short usage_count;
unsigned short int init_flag;
unsigned int nbucket;
- unsigned int * elf_buckets;
+ unsigned long * elf_buckets;
/*
* These are only used with ELF style shared libraries
*/
- unsigned int nchain;
- unsigned int * chains;
- unsigned int dynamic_info[24];
+ unsigned long nchain;
+ unsigned long * chains;
+ unsigned long dynamic_info[24];
- unsigned int dynamic_size;
- unsigned int n_phent;
+ unsigned long dynamic_size;
+ unsigned long n_phent;
Elf32_Phdr * ppnt;
};
@@ -64,15 +64,11 @@ extern struct dyn_elf * _dl_handles;
extern struct elf_resolve * _dl_check_hashed_files(char * libname);
extern struct elf_resolve * _dl_add_elf_hash_table(char * libname,
- char * loadaddr,
- unsigned int * dynamic_info,
- unsigned int dynamic_addr,
- unsigned int dynamic_size);
+ char * loadaddr, unsigned long * dynamic_info,
+ unsigned long dynamic_addr, unsigned long dynamic_size);
extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1,
- unsigned int instr_addr,
- struct elf_resolve * f_tpnt,
- int copyrel);
-
+ unsigned long instr_addr, struct elf_resolve * f_tpnt,
+ int copyrel);
extern int _dl_linux_dynamic_link(void);
#ifdef __mc68000__
diff --git a/ldso/ldso/ld_syscall.h b/ldso/ldso/ld_syscall.h
index 6678e2c74..167e2ed15 100644
--- a/ldso/ldso/ld_syscall.h
+++ b/ldso/ldso/ld_syscall.h
@@ -37,7 +37,14 @@ static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
#endif
#define _dl_mmap_check_error(__res) \
(((int)__res) < 0 && ((int)__res) >= -_dl_MAX_ERRNO)
-
+#include <sys/mman.h> // For MAP_ANONYMOUS -- differs between platforms
+#ifndef MAP_ANONYMOUS
+#ifdef __sparc__
+#define MAP_ANONYMOUS 0x20
+#else
+#error MAP_ANONYMOUS not defined and suplementary value not known
+#endif
+#endif
#define __NR__dl_open __NR_open
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 948a6e159..ca8bdbab4 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -120,9 +120,9 @@ void *(*_dl_malloc_function) (int size) = NULL;
struct r_debug *_dl_debug_addr = NULL;
-unsigned int *_dl_brkp;
+unsigned long *_dl_brkp;
-unsigned int *_dl_envp;
+unsigned long *_dl_envp;
#define DL_MALLOC(SIZE) ((void *) (malloc_buffer += SIZE, malloc_buffer - SIZE))
/*
@@ -130,7 +130,7 @@ unsigned int *_dl_envp;
* platforms we may need to increase this to 8, but this is good enough for
* now. This is typically called after DL_MALLOC.
*/
-#define REALIGN() malloc_buffer = (char *) (((unsigned int) malloc_buffer + 3) & ~(3))
+#define REALIGN() malloc_buffer = (char *) (((unsigned long) malloc_buffer + 3) & ~(3))
@@ -161,31 +161,29 @@ void _dl_debug_state()
return;
}
-void _dl_boot(int args);
-
-void _dl_boot(int args)
+void _dl_boot(unsigned long args)
{
- unsigned int argc;
+ unsigned long argc;
char **argv, **envp;
int status;
- unsigned int load_addr;
- unsigned int *got;
- unsigned int *aux_dat;
+ unsigned long load_addr;
+ unsigned long *got;
+ unsigned long *aux_dat;
int goof = 0;
elfhdr *header;
struct elf_resolve *tpnt;
struct dyn_elf *rpnt;
struct elf_resolve *app_tpnt;
- unsigned int brk_addr;
- unsigned int dl_data[AT_EGID + 1];
+ unsigned long brk_addr;
+ unsigned long dl_data[AT_EGID + 1];
unsigned char *malloc_buffer, *mmap_zero;
int (*_dl_atexit) (void *);
- int *lpnt;
+ unsigned long *lpnt;
Elf32_Dyn *dpnt;
- unsigned int *hash_addr;
+ unsigned long *hash_addr;
struct r_debug *debug_addr;
- unsigned int *chains;
+ unsigned long *chains;
int indx;
int _dl_secure;
@@ -204,7 +202,7 @@ void _dl_boot(int args)
dl_data[AT_UID] = -1; /* check later to see if it is changed */
while (*aux_dat)
{
- unsigned int *ad1;
+ unsigned long *ad1;
ad1 = aux_dat + 1;
if (*aux_dat <= AT_EGID)
@@ -282,7 +280,7 @@ void _dl_boot(int args)
}
app_tpnt->dynamic_info[dpnt->d_tag] = dpnt->d_un.d_val;
if (dpnt->d_tag == DT_DEBUG)
- dpnt->d_un.d_val = (int) debug_addr;
+ dpnt->d_un.d_val = (unsigned long) debug_addr;
if (dpnt->d_tag == DT_TEXTREL || SVR4_BUGCOMPAT)
app_tpnt->dynamic_info[DT_TEXTREL] = 1;
dpnt++;
@@ -293,7 +291,7 @@ void _dl_boot(int args)
/* Get some more of the information that we will need to dynamicly link
this module to itself */
- hash_addr = (unsigned int *) (tpnt->dynamic_info[DT_HASH] + load_addr);
+ hash_addr = (unsigned long *) (tpnt->dynamic_info[DT_HASH] + load_addr);
tpnt->nbucket = *hash_addr++;
tpnt->nchain = *hash_addr++;
tpnt->elf_buckets = hash_addr;
@@ -317,7 +315,7 @@ void _dl_boot(int args)
_dl_mprotect((void *) (load_addr +
(ppnt->p_vaddr & 0xfffff000)),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
@@ -329,7 +327,7 @@ void _dl_boot(int args)
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) (ppnt->p_vaddr & 0xfffff000),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
@@ -342,10 +340,10 @@ void _dl_boot(int args)
for (indx = 0; indx < 2; indx++) {
int i;
ELF_RELOC *rpnt;
- unsigned int *reloc_addr;
- unsigned int symbol_addr;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr;
int symtab_index;
- unsigned int rel_addr, rel_size;
+ unsigned long rel_addr, rel_size;
#ifdef ELF_USES_RELOCA
@@ -371,7 +369,7 @@ void _dl_boot(int args)
/* Now parse the relocation information */
rpnt = (ELF_RELOC *) (rel_addr + load_addr);
for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
- reloc_addr = (int *) (load_addr + (int) rpnt->r_offset);
+ reloc_addr = (unsigned long *) (load_addr + (unsigned long) rpnt->r_offset);
symtab_index = ELF32_R_SYM(rpnt->r_info);
symbol_addr = 0;
if (symtab_index) {
@@ -430,7 +428,7 @@ void _dl_boot(int args)
fixed up by now. Still no function calls outside of this library ,
since the dynamic resolver is not yet ready. */
- lpnt = (int *) (tpnt->dynamic_info[DT_PLTGOT] + load_addr);
+ lpnt = (unsigned long *) (tpnt->dynamic_info[DT_PLTGOT] + load_addr);
INIT_GOT(lpnt, tpnt);
/* OK, this was a big step, now we need to scan all of the user images
@@ -494,7 +492,7 @@ void _dl_boot(int args)
rpnt->dyn = _dl_loaded_modules;
app_tpnt->usage_count++;
app_tpnt->symbol_scope = _dl_symbol_tables;
- lpnt = (int *) (app_tpnt->dynamic_info[DT_PLTGOT]);
+ lpnt = (unsigned long *) (app_tpnt->dynamic_info[DT_PLTGOT]);
#ifdef ALLOW_ZERO_PLTGOT
if (lpnt)
#endif
@@ -812,14 +810,14 @@ void _dl_boot(int args)
up each symbol individually. */
- _dl_brkp = (unsigned int *) _dl_find_hash("___brk_addr", NULL, 1, NULL, 0);
+ _dl_brkp = (unsigned long *) _dl_find_hash("___brk_addr", NULL, 1, NULL, 0);
if (_dl_brkp)
*_dl_brkp = brk_addr;
_dl_envp =
- (unsigned int *) _dl_find_hash("__environ", NULL, 1, NULL, 0);
+ (unsigned long *) _dl_find_hash("__environ", NULL, 1, NULL, 0);
if (_dl_envp)
- *_dl_envp = (unsigned int) envp;
+ *_dl_envp = (unsigned long) envp;
{
int i;
@@ -834,7 +832,7 @@ void _dl_boot(int args)
_dl_mprotect((void *) (tpnt->loadaddr +
(ppnt->p_vaddr & 0xfffff000)),
(ppnt->p_vaddr & 0xfff) +
- (unsigned int) ppnt->p_filesz,
+ (unsigned long) ppnt->p_filesz,
LXFLAGS(ppnt->p_flags));
}
@@ -974,7 +972,7 @@ void *_dl_malloc(int size)
* Align memory to 4 byte boundary. Some platforms require this, others
* simply get better performance.
*/
- _dl_malloc_addr = (char *) (((unsigned int) _dl_malloc_addr + 3) & ~(3));
+ _dl_malloc_addr = (char *) (((unsigned long) _dl_malloc_addr + 3) & ~(3));
return retval;
}
diff --git a/ldso/ldso/linuxelf.h b/ldso/ldso/linuxelf.h
index bab9cd47a..3bbcfa7c9 100644
--- a/ldso/ldso/linuxelf.h
+++ b/ldso/ldso/linuxelf.h
@@ -11,16 +11,16 @@ extern void * _dl_malloc(int size);
extern int _dl_map_cache(void);
extern int _dl_unmap_cache(void);
int _dl_copy_fixups(struct dyn_elf * tpnt);
-extern int _dl_parse_relocation_information(struct elf_resolve * tpnt, int rel_addr,
- int rel_size, int type);
-extern void _dl_parse_lazy_relocation_information(struct elf_resolve * tpnt, int rel_addr,
- int rel_size, int type);
+extern int _dl_parse_relocation_information(struct elf_resolve * tpnt, unsigned long rel_addr,
+ unsigned long rel_size, int type);
+extern void _dl_parse_lazy_relocation_information(struct elf_resolve * tpnt, unsigned long rel_addr,
+ unsigned long rel_size, int type);
extern struct elf_resolve * _dl_load_shared_library(int secure,
struct elf_resolve *, char * libname);
extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
- char * libname, int);
-extern int _dl_parse_copy_information(struct dyn_elf * rpnt, int rel_addr,
- int rel_size, int type);
+ char * libname, int flag);
+extern int _dl_parse_copy_information(struct dyn_elf * rpnt, unsigned long rel_addr,
+ unsigned long rel_size, int type);
extern int _dl_linux_resolve(void);
#define ELF_CLASS ELFCLASS32
diff --git a/ldso/ldso/readelflib1.c b/ldso/ldso/readelflib1.c
index d9b900809..4689e51f2 100644
--- a/ldso/ldso/readelflib1.c
+++ b/ldso/ldso/readelflib1.c
@@ -121,8 +121,8 @@ int _dl_unmap_cache(void)
* Used to return error codes back to dlopen et. al.
*/
-unsigned int _dl_error_number;
-unsigned int _dl_internal_error_number;
+unsigned long _dl_error_number;
+unsigned long _dl_internal_error_number;
struct elf_resolve *_dl_load_shared_library(int secure,
struct elf_resolve *tpnt, char *full_libname)
@@ -166,7 +166,7 @@ struct elf_resolve *_dl_load_shared_library(int secure,
if (tpnt->libtype == elf_executable) {
pnt1 = (char *) tpnt->dynamic_info[DT_RPATH];
if (pnt1) {
- pnt1 += (unsigned int) tpnt->loadaddr +
+ pnt1 += (unsigned long) tpnt->loadaddr +
tpnt->dynamic_info[DT_STRTAB];
while (*pnt1) {
pnt2 = mylibname;
@@ -314,8 +314,8 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
char *libname, int flag)
{
elfhdr *epnt;
- unsigned int dynamic_addr = 0;
- unsigned int dynamic_size = 0;
+ unsigned long dynamic_addr = 0;
+ unsigned long dynamic_size = 0;
Elf32_Dyn *dpnt;
struct elf_resolve *tpnt;
elf_phdr *ppnt;
@@ -323,10 +323,10 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
char *status;
int flags;
char header[4096];
- int dynamic_info[24];
+ unsigned long dynamic_info[24];
int *lpnt;
- unsigned int libaddr;
- unsigned int minvma = 0xffffffff, maxvma = 0;
+ unsigned long libaddr;
+ unsigned long minvma = 0xffffffff, maxvma = 0;
int i;
int infile;
@@ -410,7 +410,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (piclib && ppnt->p_vaddr < minvma) {
minvma = ppnt->p_vaddr;
}
- if (((unsigned int) ppnt->p_vaddr + ppnt->p_memsz) > maxvma) {
+ if (((unsigned long) ppnt->p_vaddr + ppnt->p_memsz) > maxvma) {
maxvma = ppnt->p_vaddr + ppnt->p_memsz;
}
}
@@ -432,7 +432,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
_dl_close(infile);
return NULL;
};
- libaddr = (unsigned int) status;
+ libaddr = (unsigned long) status;
flags |= MAP_FIXED;
/* Get the memory to store the library */
@@ -450,7 +450,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (ppnt->p_flags & PF_W) {
- unsigned int map_size;
+ unsigned long map_size;
char *cpnt;
status = (char *) _dl_mmap((char *) ((piclib ? libaddr : 0) +
@@ -470,7 +470,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
/* Pad the last page with zeroes. */
cpnt = (char *) (status + (ppnt->p_vaddr & 0xfff) +
ppnt->p_filesz);
- while (((unsigned int) cpnt) & 0xfff)
+ while (((unsigned long) cpnt) & 0xfff)
*cpnt++ = 0;
/* I am not quite sure if this is completely
@@ -499,7 +499,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
};
/* if(libaddr == 0 && piclib) {
- libaddr = (unsigned int) status;
+ libaddr = (unsigned long) status;
flags |= MAP_FIXED;
}; */
};
@@ -509,7 +509,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
/* For a non-PIC library, the addresses are all absolute */
if (piclib) {
- dynamic_addr += (unsigned int) libaddr;
+ dynamic_addr += (unsigned long) libaddr;
}
/*
@@ -551,7 +551,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) ((piclib ? libaddr : 0) +
(ppnt->p_vaddr & 0xfffff000)),
- (ppnt->p_vaddr & 0xfff) + (unsigned int) ppnt->p_filesz,
+ (ppnt->p_vaddr & 0xfff) + (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
diff --git a/ldso/ldso/syscall.h b/ldso/ldso/syscall.h
index 6678e2c74..167e2ed15 100644
--- a/ldso/ldso/syscall.h
+++ b/ldso/ldso/syscall.h
@@ -37,7 +37,14 @@ static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
#endif
#define _dl_mmap_check_error(__res) \
(((int)__res) < 0 && ((int)__res) >= -_dl_MAX_ERRNO)
-
+#include <sys/mman.h> // For MAP_ANONYMOUS -- differs between platforms
+#ifndef MAP_ANONYMOUS
+#ifdef __sparc__
+#define MAP_ANONYMOUS 0x20
+#else
+#error MAP_ANONYMOUS not defined and suplementary value not known
+#endif
+#endif
#define __NR__dl_open __NR_open
diff --git a/ldso/libdl/dlib.c b/ldso/libdl/dlib.c
index 317ab2253..508299451 100644
--- a/ldso/libdl/dlib.c
+++ b/ldso/libdl/dlib.c
@@ -4,11 +4,8 @@
* Functions required for dlopen et. al.
*/
-#include "dlfcn.h"
-/* #include "link.h" */
#include <stdlib.h>
-#include <linux/mman.h>
-#include <linux/unistd.h>
+#include "dlfcn.h"
#include "sysdep.h"
#include "syscall.h"
#include "hash.h"
@@ -16,26 +13,26 @@
#include "linuxelf.h"
extern int _dl_error_number;
-extern struct r_debug * _dl_debug_addr;
+extern struct r_debug *_dl_debug_addr;
-extern void * (*_dl_malloc_function)(size_t size);
+extern void *(*_dl_malloc_function) (size_t size);
-static int do_fixup(struct elf_resolve * tpnt, int flag);
+static int do_fixup(struct elf_resolve *tpnt, int flag);
static int do_dlclose(void *, int need_fini);
-void * _dlopen(char * filename, int flag);
-const char * _dlerror(void);
-void * _dlsym(void *, char *);
+void *_dlopen(char *filename, int flag);
+const char *_dlerror(void);
+void *_dlsym(void *, char *);
int _dlclose(void *);
-int _dladdr(void * __address, Dl_info * __dlip );
+int _dladdr(void *__address, Dl_info * __dlip);
-static const char * dl_error_names[] = {
+static const char *dl_error_names[] = {
"",
"File not found",
"Unable to open /dev/zero",
"Not an ELF file",
#if defined (__i386__)
- "Not i386 binary",
+ "Not i386 binary",
#elif defined (__sparc__)
"Not sparc binary",
#elif defined (__mc68000__)
@@ -54,31 +51,30 @@ static const char * dl_error_names[] = {
"Bad handle",
"Unable to resolve symbol"
};
-
+
static void dl_cleanup(void) __attribute__ ((destructor));
static void dl_cleanup(void)
{
- struct dyn_elf* d;
-
+ struct dyn_elf *d;
+
for (d = _dl_handles; d; d = d->next_handle)
- if (d->dyn->libtype == loaded_file && d->dyn->dynamic_info[DT_FINI])
- {
- (*((int(*)(void))(d->dyn->loadaddr + d->dyn->dynamic_info[DT_FINI])))();
+ if (d->dyn->libtype == loaded_file && d->dyn->dynamic_info[DT_FINI]) {
+ (* ((int (*)(void)) (d->dyn->loadaddr + d->dyn->dynamic_info[DT_FINI]))) ();
d->dyn->dynamic_info[DT_FINI] = 0;
}
}
-void * _dlopen(char * libname, int flag)
+void *_dlopen(char *libname, int flag)
{
- struct elf_resolve * tpnt, *tfrom;
- struct dyn_elf * rpnt;
- struct dyn_elf * dyn_chain;
- struct dyn_elf * dpnt;
+ struct elf_resolve *tpnt, *tfrom;
+ struct dyn_elf *rpnt;
+ struct dyn_elf *dyn_chain;
+ struct dyn_elf *dpnt;
static int dl_init = 0;
- char * from;
- void (*dl_brk)(void);
- int (*dl_elf_init)(void);
+ char *from;
+ void (*dl_brk) (void);
+ int (*dl_elf_init) (void);
from = __builtin_return_address(0);
@@ -89,7 +85,8 @@ void * _dlopen(char * libname, int flag)
}
/* Cover the trivial case first */
- if (!libname) return _dl_symbol_tables;
+ if (!libname)
+ return _dl_symbol_tables;
#ifdef USE_CACHE
_dl_map_cache();
@@ -104,31 +101,28 @@ void * _dlopen(char * libname, int flag)
* in the future.
*/
tfrom = NULL;
- for(dpnt = _dl_symbol_tables; dpnt; dpnt = dpnt->next)
- {
- tpnt = dpnt->dyn;
- if( tpnt->loadaddr < from
- && ( tfrom == NULL
- || tfrom->loadaddr < tpnt->loadaddr))
- tfrom = tpnt;
- }
+ for (dpnt = _dl_symbol_tables; dpnt; dpnt = dpnt->next) {
+ tpnt = dpnt->dyn;
+ if (tpnt->loadaddr < from
+ && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr))
+ tfrom = tpnt;
+ }
- if(!(tpnt = _dl_load_shared_library(0, tfrom, libname)))
- {
+ if (!(tpnt = _dl_load_shared_library(0, tfrom, libname))) {
#ifdef USE_CACHE
- _dl_unmap_cache();
+ _dl_unmap_cache();
#endif
- return NULL;
+ return NULL;
}
tpnt->usage_count++;
- dyn_chain = rpnt =
- (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
- _dl_memset (rpnt, 0, sizeof(*rpnt));
+ dyn_chain = rpnt = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
+ _dl_memset(rpnt, 0, sizeof(*rpnt));
rpnt->dyn = tpnt;
rpnt->flags = flag;
- if (!tpnt->symbol_scope) tpnt->symbol_scope = dyn_chain;
-
+ if (!tpnt->symbol_scope)
+ tpnt->symbol_scope = dyn_chain;
+
rpnt->next_handle = _dl_handles;
_dl_handles = rpnt;
@@ -154,8 +148,7 @@ void * _dlopen(char * libname, int flag)
if(!(tpnt1 = _dl_load_shared_library(0, tcurr, lpnt)))
goto oops;
- rpnt->next =
- (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
+ rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
_dl_memset (rpnt->next, 0, sizeof (*(rpnt->next)));
rpnt = rpnt->next;
tpnt1->usage_count++;
@@ -175,179 +168,178 @@ void * _dlopen(char * libname, int flag)
rpnt->next = _dl_symbol_tables;
if (do_fixup(tpnt, flag)) {
- _dl_error_number = DL_NO_SYMBOL;
- goto oops;
+ _dl_error_number = DL_NO_SYMBOL;
+ goto oops;
}
dl_brk = (void (*)()) _dl_debug_addr->r_brk;
- if( dl_brk != NULL )
- {
- _dl_debug_addr->r_state = RT_ADD;
- (*dl_brk)();
-
- _dl_debug_addr->r_state = RT_CONSISTENT;
- (*dl_brk)();
- }
+ if (dl_brk != NULL) {
+ _dl_debug_addr->r_state = RT_ADD;
+ (*dl_brk) ();
- for(rpnt = dyn_chain; rpnt; rpnt = rpnt->next)
- {
+ _dl_debug_addr->r_state = RT_CONSISTENT;
+ (*dl_brk) ();
+ }
+
+ for (rpnt = dyn_chain; rpnt; rpnt = rpnt->next) {
tpnt = rpnt->dyn;
- /* Apparently crt1 for the application is responsible for handling this.
- * We only need to run the init/fini for shared libraries
- */
- if (tpnt->libtype == elf_executable) continue;
- if (tpnt->init_flag & INIT_FUNCS_CALLED) continue;
- tpnt->init_flag |= INIT_FUNCS_CALLED;
-
- if(tpnt->dynamic_info[DT_INIT]) {
- dl_elf_init = (int (*)(void)) (tpnt->loadaddr +
- tpnt->dynamic_info[DT_INIT]);
- (*dl_elf_init)();
- }
- }
+ /* Apparently crt1 for the application is responsible for handling this.
+ * We only need to run the init/fini for shared libraries
+ */
+ if (tpnt->libtype == elf_executable)
+ continue;
+ if (tpnt->init_flag & INIT_FUNCS_CALLED)
+ continue;
+ tpnt->init_flag |= INIT_FUNCS_CALLED;
+
+ if (tpnt->dynamic_info[DT_INIT]) {
+ dl_elf_init = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_INIT]);
+ (*dl_elf_init) ();
+ }
+ }
#ifdef USE_CACHE
_dl_unmap_cache();
#endif
return (void *) dyn_chain;
-oops:
+ oops:
/* Something went wrong. Clean up and return NULL. */
#ifdef USE_CACHE
_dl_unmap_cache();
#endif
- do_dlclose (dyn_chain, 0);
+ do_dlclose(dyn_chain, 0);
return NULL;
}
-static int do_fixup(struct elf_resolve * tpnt, int flag)
+static int do_fixup(struct elf_resolve *tpnt, int flag)
{
- int goof = 0;
- if(tpnt->next) goof += do_fixup(tpnt->next, flag);
+ int goof = 0;
+
+ if (tpnt->next)
+ goof += do_fixup(tpnt->next, flag);
- if(tpnt->dynamic_info[DT_REL]) {
+ if (tpnt->dynamic_info[DT_REL]) {
#ifdef ELF_USES_RELOCA
- goof++;
+ goof++;
#else
- if (tpnt->init_flag & RELOCS_DONE) return goof;
- tpnt->init_flag |= RELOCS_DONE;
-
- goof += _dl_parse_relocation_information(tpnt, tpnt->dynamic_info[DT_REL],
- tpnt->dynamic_info[DT_RELSZ], 0);
+ if (tpnt->init_flag & RELOCS_DONE)
+ return goof;
+ tpnt->init_flag |= RELOCS_DONE;
+
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_REL], tpnt->dynamic_info[DT_RELSZ], 0);
#endif
- }
- if(tpnt->dynamic_info[DT_RELA]) {
+ }
+ if (tpnt->dynamic_info[DT_RELA]) {
#ifdef ELF_USES_RELOCA
- if (tpnt->init_flag & RELOCS_DONE) return goof;
- tpnt->init_flag |= RELOCS_DONE;
-
- goof += _dl_parse_relocation_information(tpnt, tpnt->dynamic_info[DT_RELA],
- tpnt->dynamic_info[DT_RELASZ], 0);
+ if (tpnt->init_flag & RELOCS_DONE)
+ return goof;
+ tpnt->init_flag |= RELOCS_DONE;
+
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
#else
- goof++;
+ goof++;
#endif
- }
- if(tpnt->dynamic_info[DT_JMPREL])
- {
- if (tpnt->init_flag & JMP_RELOCS_DONE) return goof;
- tpnt->init_flag |= JMP_RELOCS_DONE;
-
- if(flag == RTLD_LAZY)
- _dl_parse_lazy_relocation_information(tpnt, tpnt->dynamic_info[DT_JMPREL],
- tpnt->dynamic_info[DT_PLTRELSZ], 0);
- else
- goof += _dl_parse_relocation_information(tpnt,
- tpnt->dynamic_info[DT_JMPREL],
- tpnt->dynamic_info[DT_PLTRELSZ], 0);
- };
- return goof;
+ }
+ if (tpnt->dynamic_info[DT_JMPREL]) {
+ if (tpnt->init_flag & JMP_RELOCS_DONE)
+ return goof;
+ tpnt->init_flag |= JMP_RELOCS_DONE;
+
+ if (flag == RTLD_LAZY)
+ _dl_parse_lazy_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_JMPREL],
+ tpnt->dynamic_info[DT_PLTRELSZ], 0);
+ else
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_JMPREL],
+ tpnt->dynamic_info[DT_PLTRELSZ], 0);
+ };
+ return goof;
}
-void * _dlsym(void * vhandle, char * name)
-{
- struct elf_resolve * tpnt, *tfrom;
- struct dyn_elf * handle;
- char * from;
- struct dyn_elf * rpnt;
+void *_dlsym(void *vhandle, char *name)
+{
+ struct elf_resolve *tpnt, *tfrom;
+ struct dyn_elf *handle;
+ char *from;
+ struct dyn_elf *rpnt;
void *ret;
handle = (struct dyn_elf *) vhandle;
/* First of all verify that we have a real handle
- of some kind. Return NULL if not a valid handle. */
+ of some kind. Return NULL if not a valid handle. */
if (handle == NULL)
handle = _dl_symbol_tables;
else if (handle != RTLD_NEXT && handle != _dl_symbol_tables) {
- for(rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle)
- if (rpnt == handle) break;
+ for (rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle)
+ if (rpnt == handle)
+ break;
if (!rpnt) {
_dl_error_number = DL_BAD_HANDLE;
return NULL;
}
+ } else if (handle == RTLD_NEXT) {
+ /*
+ * Try and locate the module we were called from - we
+ * need this so that we know where to start searching
+ * from. We never pass RTLD_NEXT down into the actual
+ * dynamic loader itself, as it doesn't know
+ * how to properly treat it.
+ */
+ from = __builtin_return_address(0);
+
+ tfrom = NULL;
+ for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next) {
+ tpnt = rpnt->dyn;
+ if (tpnt->loadaddr < from
+ && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr)) {
+ tfrom = tpnt;
+ handle = rpnt->next;
+ }
+ }
}
- else if (handle == RTLD_NEXT )
- {
- /*
- * Try and locate the module we were called from - we
- * need this so that we know where to start searching
- * from. We never pass RTLD_NEXT down into the actual
- * dynamic loader itself, as it doesn't know
- * how to properly treat it.
- */
- from = __builtin_return_address(0);
-
- tfrom = NULL;
- for(rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next)
- {
- tpnt = rpnt->dyn;
- if( tpnt->loadaddr < from
- && ( tfrom == NULL
- || tfrom->loadaddr < tpnt->loadaddr))
- {
- tfrom = tpnt;
- handle = rpnt->next;
- }
- }
- }
ret = _dl_find_hash(name, handle, 1, NULL, 1);
- /*
- * Nothing found.
- */
+ /*
+ * Nothing found.
+ */
if (!ret)
_dl_error_number = DL_NO_SYMBOL;
return ret;
}
-int _dlclose(void * vhandle)
+int _dlclose(void *vhandle)
{
- return do_dlclose(vhandle, 1);
+ return do_dlclose(vhandle, 1);
}
-static int do_dlclose(void * vhandle, int need_fini)
+static int do_dlclose(void *vhandle, int need_fini)
{
- struct dyn_elf * rpnt, *rpnt1;
+ struct dyn_elf *rpnt, *rpnt1;
struct dyn_elf *spnt, *spnt1;
- elf_phdr * ppnt;
- struct elf_resolve * tpnt;
- int (*dl_elf_fini)(void);
- void (*dl_brk)(void);
- struct dyn_elf * handle;
+ elf_phdr *ppnt;
+ struct elf_resolve *tpnt;
+ int (*dl_elf_fini) (void);
+ void (*dl_brk) (void);
+ struct dyn_elf *handle;
unsigned int end;
int i = 0;
handle = (struct dyn_elf *) vhandle;
rpnt1 = NULL;
- for(rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle)
- {
- if(rpnt == handle) {
+ for (rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle) {
+ if (rpnt == handle) {
break;
}
rpnt1 = rpnt;
}
-
+
if (!rpnt) {
_dl_error_number = DL_BAD_HANDLE;
return 1;
@@ -356,104 +348,105 @@ static int do_dlclose(void * vhandle, int need_fini)
/* OK, this is a valid handle - now close out the file.
* We check if we need to call fini () on the handle. */
spnt = need_fini ? handle : handle->next;
- for(; spnt; spnt = spnt1)
- {
- spnt1 = spnt->next;
+ for (; spnt; spnt = spnt1) {
+ spnt1 = spnt->next;
- /* We appended the module list to the end - when we get back here,
- quit. The access counts were not adjusted to account for being here. */
- if (spnt == _dl_symbol_tables) break;
- if(spnt->dyn->usage_count==1 && spnt->dyn->libtype == loaded_file) {
- tpnt = spnt->dyn;
- /* Apparently crt1 for the application is responsible for handling this.
- * We only need to run the init/fini for shared libraries
- */
-
- if(tpnt->dynamic_info[DT_FINI]) {
- dl_elf_fini = (int (*)(void)) (tpnt->loadaddr +
- tpnt->dynamic_info[DT_FINI]);
- (*dl_elf_fini)();
- }
- }
+ /* We appended the module list to the end - when we get back here,
+ quit. The access counts were not adjusted to account for being here. */
+ if (spnt == _dl_symbol_tables)
+ break;
+ if (spnt->dyn->usage_count == 1
+ && spnt->dyn->libtype == loaded_file) {
+ tpnt = spnt->dyn;
+ /* Apparently crt1 for the application is responsible for handling this.
+ * We only need to run the init/fini for shared libraries
+ */
+
+ if (tpnt->dynamic_info[DT_FINI]) {
+ dl_elf_fini = (int (*)(void)) (tpnt->loadaddr +
+ tpnt->dynamic_info[DT_FINI]);
+ (*dl_elf_fini) ();
+ }
+ }
}
- if(rpnt1)
- rpnt1->next_handle = rpnt->next_handle;
+ if (rpnt1)
+ rpnt1->next_handle = rpnt->next_handle;
else
- _dl_handles = rpnt->next_handle;
-
+ _dl_handles = rpnt->next_handle;
+
/* OK, this is a valid handle - now close out the file */
- for(rpnt = handle; rpnt; rpnt = rpnt1)
- {
+ for (rpnt = handle; rpnt; rpnt = rpnt1) {
rpnt1 = rpnt->next;
/* We appended the module list to the end - when we get back here,
quit. The access counts were not adjusted to account for being here. */
- if (rpnt == _dl_symbol_tables) break;
+ if (rpnt == _dl_symbol_tables)
+ break;
rpnt->dyn->usage_count--;
- if(rpnt->dyn->usage_count == 0 && rpnt->dyn->libtype == loaded_file)
- {
+ if (rpnt->dyn->usage_count == 0
+ && rpnt->dyn->libtype == loaded_file) {
tpnt = rpnt->dyn;
- /* Apparently crt1 for the application is responsible for handling this.
- * We only need to run the init/fini for shared libraries
- */
+ /* Apparently crt1 for the application is responsible for handling this.
+ * We only need to run the init/fini for shared libraries
+ */
#if 0
-/* We have to do this above, before we start closing objects.
-Otherwise when the needed symbols for _fini handling are
-resolved a coredump would occur. Rob Ryan (robr@cmu.edu)*/
- if(tpnt->dynamic_info[DT_FINI]) {
- dl_elf_fini = (int (*)(void)) (tpnt->loadaddr +
- tpnt->dynamic_info[DT_FINI]);
- (*dl_elf_fini)();
- }
+
+ /* We have to do this above, before we start closing objects.
+ * Otherwise when the needed symbols for _fini handling are
+ * resolved a coredump would occur. Rob Ryan (robr@cmu.edu)*/
+ if (tpnt->dynamic_info[DT_FINI]) {
+ dl_elf_fini = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]);
+ (*dl_elf_fini) ();
+ }
#endif
- end = 0;
- for(i = 0, ppnt = rpnt->dyn->ppnt;
- i < rpnt->dyn->n_phent; ppnt++, i++) {
- if (ppnt->p_type != PT_LOAD) continue;
+ end = 0;
+ for (i = 0, ppnt = rpnt->dyn->ppnt;
+ i < rpnt->dyn->n_phent; ppnt++, i++) {
+ if (ppnt->p_type != PT_LOAD)
+ continue;
if (end < ppnt->p_vaddr + ppnt->p_memsz)
end = ppnt->p_vaddr + ppnt->p_memsz;
}
- _dl_munmap (rpnt->dyn->loadaddr, end);
+ _dl_munmap(rpnt->dyn->loadaddr, end);
/* Next, remove rpnt->dyn from the loaded_module list */
- if (_dl_loaded_modules == rpnt->dyn)
- {
- _dl_loaded_modules = rpnt->dyn->next;
- if (_dl_loaded_modules)
- _dl_loaded_modules->prev = 0;
- }
- else
- for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next)
- if (tpnt->next == rpnt->dyn) {
- tpnt->next = tpnt->next->next;
- if (tpnt->next)
- tpnt->next->prev = tpnt;
- break;
- }
+ if (_dl_loaded_modules == rpnt->dyn) {
+ _dl_loaded_modules = rpnt->dyn->next;
+ if (_dl_loaded_modules)
+ _dl_loaded_modules->prev = 0;
+ } else
+ for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next)
+ if (tpnt->next == rpnt->dyn) {
+ tpnt->next = tpnt->next->next;
+ if (tpnt->next)
+ tpnt->next->prev = tpnt;
+ break;
+ }
free(rpnt->dyn->libname);
free(rpnt->dyn);
- }
+ }
free(rpnt);
- }
+ }
dl_brk = (void (*)()) _dl_debug_addr->r_brk;
- if( dl_brk != NULL )
- {
- _dl_debug_addr->r_state = RT_DELETE;
- (*dl_brk)();
-
- _dl_debug_addr->r_state = RT_CONSISTENT;
- (*dl_brk)();
- }
+ if (dl_brk != NULL) {
+ _dl_debug_addr->r_state = RT_DELETE;
+ (*dl_brk) ();
+
+ _dl_debug_addr->r_state = RT_CONSISTENT;
+ (*dl_brk) ();
+ }
return 0;
}
-const char * _dlerror()
+const char *_dlerror()
{
- const char * retval;
- if(!_dl_error_number) return NULL;
+ const char *retval;
+
+ if (!_dl_error_number)
+ return NULL;
retval = dl_error_names[_dl_error_number];
_dl_error_number = 0;
return retval;
@@ -481,11 +474,11 @@ possible, but at run time the normal symbols are accessed. */
static void foobar()
{
- _dl_fdprintf(2,"libdl library not correctly linked\n");
+ _dl_fdprintf(2, "libdl library not correctly linked\n");
_dl_exit(1);
}
-static int __attribute__((unused)) foobar1 = (int)foobar; /* Use as pointer */
+static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
#if 1
#pragma weak _dl_find_hash = foobar
@@ -516,50 +509,51 @@ __asm__(".weak _dl_map_cache; _dl_map_cache = foobar");
__asm__(".weak _dl_unmap_cache; _dl_unmap_cache = foobar");
#endif
__asm__(".weak _dl_malloc_function; _dl_malloc_function = foobar1");
-__asm__(".weak _dl_parse_relocation_information; _dl_parse_relocation_information = foobar");
-__asm__(".weak _dl_parse_lazy_relocation_information; _dl_parse_lazy_relocation_information = foobar");
+__asm__
+ (".weak _dl_parse_relocation_information; _dl_parse_relocation_information = foobar");
+__asm__
+ (".weak _dl_parse_lazy_relocation_information; _dl_parse_lazy_relocation_information = foobar");
__asm__(".weak _dl_fdprintf; _dl_fdprintf = foobar");
#endif
/*
* Dump information to stderrr about the current loaded modules
*/
-static char * type[] = {"Lib","Exe","Int","Mod"};
+static char *type[] = { "Lib", "Exe", "Int", "Mod" };
void _dlinfo()
{
- struct elf_resolve * tpnt;
- struct dyn_elf * rpnt, *hpnt;
+ struct elf_resolve *tpnt;
+ struct dyn_elf *rpnt, *hpnt;
+
_dl_fdprintf(2, "List of loaded modules\n");
/* First start with a complete list of all of the loaded files. */
- for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next)
- _dl_fdprintf(2, "\t%8.8x %8.8x %8.8x %s %d %s\n",
- (unsigned)tpnt->loadaddr, (unsigned)tpnt,
- (unsigned)tpnt->symbol_scope,
+ for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
+ _dl_fdprintf(2, "\t%8.8x %8.8x %8.8x %s %d %s\n",
+ (unsigned) tpnt->loadaddr, (unsigned) tpnt,
+ (unsigned) tpnt->symbol_scope,
type[tpnt->libtype],
- tpnt->usage_count,
- tpnt->libname);
+ tpnt->usage_count, tpnt->libname);
+ }
/* Next dump the module list for the application itself */
_dl_fdprintf(2, "\nModules for application (%x):\n",
- (unsigned)_dl_symbol_tables);
+ (unsigned) _dl_symbol_tables);
for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next)
- _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned)rpnt->dyn,
- rpnt->dyn->libname);
+ _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned) rpnt->dyn, rpnt->dyn->libname);
- for (hpnt = _dl_handles; hpnt; hpnt = hpnt->next_handle)
- {
- _dl_fdprintf(2, "Modules for handle %x\n", (unsigned)hpnt);
- for(rpnt = hpnt; rpnt; rpnt = rpnt->next)
- _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned)rpnt->dyn,
+ for (hpnt = _dl_handles; hpnt; hpnt = hpnt->next_handle) {
+ _dl_fdprintf(2, "Modules for handle %x\n", (unsigned) hpnt);
+ for (rpnt = hpnt; rpnt; rpnt = rpnt->next)
+ _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned) rpnt->dyn,
rpnt->dyn->libname);
}
}
-int _dladdr(void * __address, Dl_info * __dlip )
+int _dladdr(void *__address, Dl_info * __dlip)
{
- struct elf_resolve * pelf;
- struct elf_resolve * rpnt;
+ struct elf_resolve *pelf;
+ struct elf_resolve *rpnt;
#ifdef USE_CACHE
_dl_map_cache();
@@ -571,78 +565,66 @@ int _dladdr(void * __address, Dl_info * __dlip )
pelf = NULL;
#if 0
- _dl_fdprintf( 2,
- "dladdr( 0x%p, 0x%p )\n",
- __address, __dlip );
+ _dl_fdprintf(2, "dladdr( 0x%p, 0x%p )\n", __address, __dlip);
#endif
- for(rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next)
- {
- struct elf_resolve * tpnt;
- tpnt = rpnt;
+ for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next) {
+ struct elf_resolve *tpnt;
+
+ tpnt = rpnt;
#if 0
- _dl_fdprintf( 2,
- "Module \"%s\" at 0x%p\n",
- tpnt->libname,
- tpnt->loadaddr );
+ _dl_fdprintf(2, "Module \"%s\" at 0x%p\n",
+ tpnt->libname, tpnt->loadaddr);
#endif
- if( tpnt->loadaddr < (char*)__address
- && ( pelf == NULL
- || pelf->loadaddr < tpnt->loadaddr))
- pelf = tpnt;
- }
+ if (tpnt->loadaddr < (char *) __address
+ && (pelf == NULL || pelf->loadaddr < tpnt->loadaddr)) {
+ pelf = tpnt;
+ }
+ }
- if ( ! pelf )
- {
- return 0;
+ if (!pelf) {
+ return 0;
}
-
+
/*
* Try and locate the symbol of address
*/
{
- char * strtab;
- Elf32_Sym * symtab;
- int hn, si;
- int sf;
- int sn = 0;
- void* sa = 0;
-
- symtab = (Elf32_Sym *) (pelf->dynamic_info[DT_SYMTAB] +
- pelf->loadaddr);
- strtab = (char *) (pelf->dynamic_info[DT_STRTAB] + pelf->loadaddr);
-
- sf = 0;
- for(hn = 0; hn < pelf->nbucket; hn++)
- {
- for(si = pelf->elf_buckets[hn]; si; si = pelf->chains[si])
- {
- void* symbol_addr;
- symbol_addr = pelf->loadaddr + symtab[si].st_value;
- if ( symbol_addr <= __address &&
- ( !sf || sa < symbol_addr ) )
- {
- sa = symbol_addr;
- sn = si;
- sf = 1;
- }
+ char *strtab;
+ Elf32_Sym *symtab;
+ int hn, si;
+ int sf;
+ int sn = 0;
+ void *sa = 0;
+
+ symtab = (Elf32_Sym *) (pelf->dynamic_info[DT_SYMTAB] + pelf->loadaddr);
+ strtab = (char *) (pelf->dynamic_info[DT_STRTAB] + pelf->loadaddr);
+
+ sf = 0;
+ for (hn = 0; hn < pelf->nbucket; hn++) {
+ for (si = pelf->elf_buckets[hn]; si; si = pelf->chains[si]) {
+ void *symbol_addr;
+
+ symbol_addr = pelf->loadaddr + symtab[si].st_value;
+ if (symbol_addr <= __address && (!sf || sa < symbol_addr)) {
+ sa = symbol_addr;
+ sn = si;
+ sf = 1;
+ }
#if 0
- _dl_fdprintf( 2,
- "Symbol \"%s\" at 0x%p\n",
- strtab + symtab[si].st_name,
- symbol_addr );
+ _dl_fdprintf(2, "Symbol \"%s\" at 0x%p\n",
+ strtab + symtab[si].st_name, symbol_addr);
#endif
- }
- }
+ }
+ }
- if ( sf )
- {
- __dlip->dli_fname = pelf->libname;
- __dlip->dli_fbase = pelf->loadaddr;
- __dlip->dli_sname = strtab + symtab[sn].st_name;
- __dlip->dli_saddr = sa;
- }
- return 1;
+ if (sf) {
+ __dlip->dli_fname = pelf->libname;
+ __dlip->dli_fbase = pelf->loadaddr;
+ __dlip->dli_sname = strtab + symtab[sn].st_name;
+ __dlip->dli_saddr = sa;
+ }
+ return 1;
}
}
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 317ab2253..508299451 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -4,11 +4,8 @@
* Functions required for dlopen et. al.
*/
-#include "dlfcn.h"
-/* #include "link.h" */
#include <stdlib.h>
-#include <linux/mman.h>
-#include <linux/unistd.h>
+#include "dlfcn.h"
#include "sysdep.h"
#include "syscall.h"
#include "hash.h"
@@ -16,26 +13,26 @@
#include "linuxelf.h"
extern int _dl_error_number;
-extern struct r_debug * _dl_debug_addr;
+extern struct r_debug *_dl_debug_addr;
-extern void * (*_dl_malloc_function)(size_t size);
+extern void *(*_dl_malloc_function) (size_t size);
-static int do_fixup(struct elf_resolve * tpnt, int flag);
+static int do_fixup(struct elf_resolve *tpnt, int flag);
static int do_dlclose(void *, int need_fini);
-void * _dlopen(char * filename, int flag);
-const char * _dlerror(void);
-void * _dlsym(void *, char *);
+void *_dlopen(char *filename, int flag);
+const char *_dlerror(void);
+void *_dlsym(void *, char *);
int _dlclose(void *);
-int _dladdr(void * __address, Dl_info * __dlip );
+int _dladdr(void *__address, Dl_info * __dlip);
-static const char * dl_error_names[] = {
+static const char *dl_error_names[] = {
"",
"File not found",
"Unable to open /dev/zero",
"Not an ELF file",
#if defined (__i386__)
- "Not i386 binary",
+ "Not i386 binary",
#elif defined (__sparc__)
"Not sparc binary",
#elif defined (__mc68000__)
@@ -54,31 +51,30 @@ static const char * dl_error_names[] = {
"Bad handle",
"Unable to resolve symbol"
};
-
+
static void dl_cleanup(void) __attribute__ ((destructor));
static void dl_cleanup(void)
{
- struct dyn_elf* d;
-
+ struct dyn_elf *d;
+
for (d = _dl_handles; d; d = d->next_handle)
- if (d->dyn->libtype == loaded_file && d->dyn->dynamic_info[DT_FINI])
- {
- (*((int(*)(void))(d->dyn->loadaddr + d->dyn->dynamic_info[DT_FINI])))();
+ if (d->dyn->libtype == loaded_file && d->dyn->dynamic_info[DT_FINI]) {
+ (* ((int (*)(void)) (d->dyn->loadaddr + d->dyn->dynamic_info[DT_FINI]))) ();
d->dyn->dynamic_info[DT_FINI] = 0;
}
}
-void * _dlopen(char * libname, int flag)
+void *_dlopen(char *libname, int flag)
{
- struct elf_resolve * tpnt, *tfrom;
- struct dyn_elf * rpnt;
- struct dyn_elf * dyn_chain;
- struct dyn_elf * dpnt;
+ struct elf_resolve *tpnt, *tfrom;
+ struct dyn_elf *rpnt;
+ struct dyn_elf *dyn_chain;
+ struct dyn_elf *dpnt;
static int dl_init = 0;
- char * from;
- void (*dl_brk)(void);
- int (*dl_elf_init)(void);
+ char *from;
+ void (*dl_brk) (void);
+ int (*dl_elf_init) (void);
from = __builtin_return_address(0);
@@ -89,7 +85,8 @@ void * _dlopen(char * libname, int flag)
}
/* Cover the trivial case first */
- if (!libname) return _dl_symbol_tables;
+ if (!libname)
+ return _dl_symbol_tables;
#ifdef USE_CACHE
_dl_map_cache();
@@ -104,31 +101,28 @@ void * _dlopen(char * libname, int flag)
* in the future.
*/
tfrom = NULL;
- for(dpnt = _dl_symbol_tables; dpnt; dpnt = dpnt->next)
- {
- tpnt = dpnt->dyn;
- if( tpnt->loadaddr < from
- && ( tfrom == NULL
- || tfrom->loadaddr < tpnt->loadaddr))
- tfrom = tpnt;
- }
+ for (dpnt = _dl_symbol_tables; dpnt; dpnt = dpnt->next) {
+ tpnt = dpnt->dyn;
+ if (tpnt->loadaddr < from
+ && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr))
+ tfrom = tpnt;
+ }
- if(!(tpnt = _dl_load_shared_library(0, tfrom, libname)))
- {
+ if (!(tpnt = _dl_load_shared_library(0, tfrom, libname))) {
#ifdef USE_CACHE
- _dl_unmap_cache();
+ _dl_unmap_cache();
#endif
- return NULL;
+ return NULL;
}
tpnt->usage_count++;
- dyn_chain = rpnt =
- (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
- _dl_memset (rpnt, 0, sizeof(*rpnt));
+ dyn_chain = rpnt = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
+ _dl_memset(rpnt, 0, sizeof(*rpnt));
rpnt->dyn = tpnt;
rpnt->flags = flag;
- if (!tpnt->symbol_scope) tpnt->symbol_scope = dyn_chain;
-
+ if (!tpnt->symbol_scope)
+ tpnt->symbol_scope = dyn_chain;
+
rpnt->next_handle = _dl_handles;
_dl_handles = rpnt;
@@ -154,8 +148,7 @@ void * _dlopen(char * libname, int flag)
if(!(tpnt1 = _dl_load_shared_library(0, tcurr, lpnt)))
goto oops;
- rpnt->next =
- (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
+ rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
_dl_memset (rpnt->next, 0, sizeof (*(rpnt->next)));
rpnt = rpnt->next;
tpnt1->usage_count++;
@@ -175,179 +168,178 @@ void * _dlopen(char * libname, int flag)
rpnt->next = _dl_symbol_tables;
if (do_fixup(tpnt, flag)) {
- _dl_error_number = DL_NO_SYMBOL;
- goto oops;
+ _dl_error_number = DL_NO_SYMBOL;
+ goto oops;
}
dl_brk = (void (*)()) _dl_debug_addr->r_brk;
- if( dl_brk != NULL )
- {
- _dl_debug_addr->r_state = RT_ADD;
- (*dl_brk)();
-
- _dl_debug_addr->r_state = RT_CONSISTENT;
- (*dl_brk)();
- }
+ if (dl_brk != NULL) {
+ _dl_debug_addr->r_state = RT_ADD;
+ (*dl_brk) ();
- for(rpnt = dyn_chain; rpnt; rpnt = rpnt->next)
- {
+ _dl_debug_addr->r_state = RT_CONSISTENT;
+ (*dl_brk) ();
+ }
+
+ for (rpnt = dyn_chain; rpnt; rpnt = rpnt->next) {
tpnt = rpnt->dyn;
- /* Apparently crt1 for the application is responsible for handling this.
- * We only need to run the init/fini for shared libraries
- */
- if (tpnt->libtype == elf_executable) continue;
- if (tpnt->init_flag & INIT_FUNCS_CALLED) continue;
- tpnt->init_flag |= INIT_FUNCS_CALLED;
-
- if(tpnt->dynamic_info[DT_INIT]) {
- dl_elf_init = (int (*)(void)) (tpnt->loadaddr +
- tpnt->dynamic_info[DT_INIT]);
- (*dl_elf_init)();
- }
- }
+ /* Apparently crt1 for the application is responsible for handling this.
+ * We only need to run the init/fini for shared libraries
+ */
+ if (tpnt->libtype == elf_executable)
+ continue;
+ if (tpnt->init_flag & INIT_FUNCS_CALLED)
+ continue;
+ tpnt->init_flag |= INIT_FUNCS_CALLED;
+
+ if (tpnt->dynamic_info[DT_INIT]) {
+ dl_elf_init = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_INIT]);
+ (*dl_elf_init) ();
+ }
+ }
#ifdef USE_CACHE
_dl_unmap_cache();
#endif
return (void *) dyn_chain;
-oops:
+ oops:
/* Something went wrong. Clean up and return NULL. */
#ifdef USE_CACHE
_dl_unmap_cache();
#endif
- do_dlclose (dyn_chain, 0);
+ do_dlclose(dyn_chain, 0);
return NULL;
}
-static int do_fixup(struct elf_resolve * tpnt, int flag)
+static int do_fixup(struct elf_resolve *tpnt, int flag)
{
- int goof = 0;
- if(tpnt->next) goof += do_fixup(tpnt->next, flag);
+ int goof = 0;
+
+ if (tpnt->next)
+ goof += do_fixup(tpnt->next, flag);
- if(tpnt->dynamic_info[DT_REL]) {
+ if (tpnt->dynamic_info[DT_REL]) {
#ifdef ELF_USES_RELOCA
- goof++;
+ goof++;
#else
- if (tpnt->init_flag & RELOCS_DONE) return goof;
- tpnt->init_flag |= RELOCS_DONE;
-
- goof += _dl_parse_relocation_information(tpnt, tpnt->dynamic_info[DT_REL],
- tpnt->dynamic_info[DT_RELSZ], 0);
+ if (tpnt->init_flag & RELOCS_DONE)
+ return goof;
+ tpnt->init_flag |= RELOCS_DONE;
+
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_REL], tpnt->dynamic_info[DT_RELSZ], 0);
#endif
- }
- if(tpnt->dynamic_info[DT_RELA]) {
+ }
+ if (tpnt->dynamic_info[DT_RELA]) {
#ifdef ELF_USES_RELOCA
- if (tpnt->init_flag & RELOCS_DONE) return goof;
- tpnt->init_flag |= RELOCS_DONE;
-
- goof += _dl_parse_relocation_information(tpnt, tpnt->dynamic_info[DT_RELA],
- tpnt->dynamic_info[DT_RELASZ], 0);
+ if (tpnt->init_flag & RELOCS_DONE)
+ return goof;
+ tpnt->init_flag |= RELOCS_DONE;
+
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
#else
- goof++;
+ goof++;
#endif
- }
- if(tpnt->dynamic_info[DT_JMPREL])
- {
- if (tpnt->init_flag & JMP_RELOCS_DONE) return goof;
- tpnt->init_flag |= JMP_RELOCS_DONE;
-
- if(flag == RTLD_LAZY)
- _dl_parse_lazy_relocation_information(tpnt, tpnt->dynamic_info[DT_JMPREL],
- tpnt->dynamic_info[DT_PLTRELSZ], 0);
- else
- goof += _dl_parse_relocation_information(tpnt,
- tpnt->dynamic_info[DT_JMPREL],
- tpnt->dynamic_info[DT_PLTRELSZ], 0);
- };
- return goof;
+ }
+ if (tpnt->dynamic_info[DT_JMPREL]) {
+ if (tpnt->init_flag & JMP_RELOCS_DONE)
+ return goof;
+ tpnt->init_flag |= JMP_RELOCS_DONE;
+
+ if (flag == RTLD_LAZY)
+ _dl_parse_lazy_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_JMPREL],
+ tpnt->dynamic_info[DT_PLTRELSZ], 0);
+ else
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_JMPREL],
+ tpnt->dynamic_info[DT_PLTRELSZ], 0);
+ };
+ return goof;
}
-void * _dlsym(void * vhandle, char * name)
-{
- struct elf_resolve * tpnt, *tfrom;
- struct dyn_elf * handle;
- char * from;
- struct dyn_elf * rpnt;
+void *_dlsym(void *vhandle, char *name)
+{
+ struct elf_resolve *tpnt, *tfrom;
+ struct dyn_elf *handle;
+ char *from;
+ struct dyn_elf *rpnt;
void *ret;
handle = (struct dyn_elf *) vhandle;
/* First of all verify that we have a real handle
- of some kind. Return NULL if not a valid handle. */
+ of some kind. Return NULL if not a valid handle. */
if (handle == NULL)
handle = _dl_symbol_tables;
else if (handle != RTLD_NEXT && handle != _dl_symbol_tables) {
- for(rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle)
- if (rpnt == handle) break;
+ for (rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle)
+ if (rpnt == handle)
+ break;
if (!rpnt) {
_dl_error_number = DL_BAD_HANDLE;
return NULL;
}
+ } else if (handle == RTLD_NEXT) {
+ /*
+ * Try and locate the module we were called from - we
+ * need this so that we know where to start searching
+ * from. We never pass RTLD_NEXT down into the actual
+ * dynamic loader itself, as it doesn't know
+ * how to properly treat it.
+ */
+ from = __builtin_return_address(0);
+
+ tfrom = NULL;
+ for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next) {
+ tpnt = rpnt->dyn;
+ if (tpnt->loadaddr < from
+ && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr)) {
+ tfrom = tpnt;
+ handle = rpnt->next;
+ }
+ }
}
- else if (handle == RTLD_NEXT )
- {
- /*
- * Try and locate the module we were called from - we
- * need this so that we know where to start searching
- * from. We never pass RTLD_NEXT down into the actual
- * dynamic loader itself, as it doesn't know
- * how to properly treat it.
- */
- from = __builtin_return_address(0);
-
- tfrom = NULL;
- for(rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next)
- {
- tpnt = rpnt->dyn;
- if( tpnt->loadaddr < from
- && ( tfrom == NULL
- || tfrom->loadaddr < tpnt->loadaddr))
- {
- tfrom = tpnt;
- handle = rpnt->next;
- }
- }
- }
ret = _dl_find_hash(name, handle, 1, NULL, 1);
- /*
- * Nothing found.
- */
+ /*
+ * Nothing found.
+ */
if (!ret)
_dl_error_number = DL_NO_SYMBOL;
return ret;
}
-int _dlclose(void * vhandle)
+int _dlclose(void *vhandle)
{
- return do_dlclose(vhandle, 1);
+ return do_dlclose(vhandle, 1);
}
-static int do_dlclose(void * vhandle, int need_fini)
+static int do_dlclose(void *vhandle, int need_fini)
{
- struct dyn_elf * rpnt, *rpnt1;
+ struct dyn_elf *rpnt, *rpnt1;
struct dyn_elf *spnt, *spnt1;
- elf_phdr * ppnt;
- struct elf_resolve * tpnt;
- int (*dl_elf_fini)(void);
- void (*dl_brk)(void);
- struct dyn_elf * handle;
+ elf_phdr *ppnt;
+ struct elf_resolve *tpnt;
+ int (*dl_elf_fini) (void);
+ void (*dl_brk) (void);
+ struct dyn_elf *handle;
unsigned int end;
int i = 0;
handle = (struct dyn_elf *) vhandle;
rpnt1 = NULL;
- for(rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle)
- {
- if(rpnt == handle) {
+ for (rpnt = _dl_handles; rpnt; rpnt = rpnt->next_handle) {
+ if (rpnt == handle) {
break;
}
rpnt1 = rpnt;
}
-
+
if (!rpnt) {
_dl_error_number = DL_BAD_HANDLE;
return 1;
@@ -356,104 +348,105 @@ static int do_dlclose(void * vhandle, int need_fini)
/* OK, this is a valid handle - now close out the file.
* We check if we need to call fini () on the handle. */
spnt = need_fini ? handle : handle->next;
- for(; spnt; spnt = spnt1)
- {
- spnt1 = spnt->next;
+ for (; spnt; spnt = spnt1) {
+ spnt1 = spnt->next;
- /* We appended the module list to the end - when we get back here,
- quit. The access counts were not adjusted to account for being here. */
- if (spnt == _dl_symbol_tables) break;
- if(spnt->dyn->usage_count==1 && spnt->dyn->libtype == loaded_file) {
- tpnt = spnt->dyn;
- /* Apparently crt1 for the application is responsible for handling this.
- * We only need to run the init/fini for shared libraries
- */
-
- if(tpnt->dynamic_info[DT_FINI]) {
- dl_elf_fini = (int (*)(void)) (tpnt->loadaddr +
- tpnt->dynamic_info[DT_FINI]);
- (*dl_elf_fini)();
- }
- }
+ /* We appended the module list to the end - when we get back here,
+ quit. The access counts were not adjusted to account for being here. */
+ if (spnt == _dl_symbol_tables)
+ break;
+ if (spnt->dyn->usage_count == 1
+ && spnt->dyn->libtype == loaded_file) {
+ tpnt = spnt->dyn;
+ /* Apparently crt1 for the application is responsible for handling this.
+ * We only need to run the init/fini for shared libraries
+ */
+
+ if (tpnt->dynamic_info[DT_FINI]) {
+ dl_elf_fini = (int (*)(void)) (tpnt->loadaddr +
+ tpnt->dynamic_info[DT_FINI]);
+ (*dl_elf_fini) ();
+ }
+ }
}
- if(rpnt1)
- rpnt1->next_handle = rpnt->next_handle;
+ if (rpnt1)
+ rpnt1->next_handle = rpnt->next_handle;
else
- _dl_handles = rpnt->next_handle;
-
+ _dl_handles = rpnt->next_handle;
+
/* OK, this is a valid handle - now close out the file */
- for(rpnt = handle; rpnt; rpnt = rpnt1)
- {
+ for (rpnt = handle; rpnt; rpnt = rpnt1) {
rpnt1 = rpnt->next;
/* We appended the module list to the end - when we get back here,
quit. The access counts were not adjusted to account for being here. */
- if (rpnt == _dl_symbol_tables) break;
+ if (rpnt == _dl_symbol_tables)
+ break;
rpnt->dyn->usage_count--;
- if(rpnt->dyn->usage_count == 0 && rpnt->dyn->libtype == loaded_file)
- {
+ if (rpnt->dyn->usage_count == 0
+ && rpnt->dyn->libtype == loaded_file) {
tpnt = rpnt->dyn;
- /* Apparently crt1 for the application is responsible for handling this.
- * We only need to run the init/fini for shared libraries
- */
+ /* Apparently crt1 for the application is responsible for handling this.
+ * We only need to run the init/fini for shared libraries
+ */
#if 0
-/* We have to do this above, before we start closing objects.
-Otherwise when the needed symbols for _fini handling are
-resolved a coredump would occur. Rob Ryan (robr@cmu.edu)*/
- if(tpnt->dynamic_info[DT_FINI]) {
- dl_elf_fini = (int (*)(void)) (tpnt->loadaddr +
- tpnt->dynamic_info[DT_FINI]);
- (*dl_elf_fini)();
- }
+
+ /* We have to do this above, before we start closing objects.
+ * Otherwise when the needed symbols for _fini handling are
+ * resolved a coredump would occur. Rob Ryan (robr@cmu.edu)*/
+ if (tpnt->dynamic_info[DT_FINI]) {
+ dl_elf_fini = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]);
+ (*dl_elf_fini) ();
+ }
#endif
- end = 0;
- for(i = 0, ppnt = rpnt->dyn->ppnt;
- i < rpnt->dyn->n_phent; ppnt++, i++) {
- if (ppnt->p_type != PT_LOAD) continue;
+ end = 0;
+ for (i = 0, ppnt = rpnt->dyn->ppnt;
+ i < rpnt->dyn->n_phent; ppnt++, i++) {
+ if (ppnt->p_type != PT_LOAD)
+ continue;
if (end < ppnt->p_vaddr + ppnt->p_memsz)
end = ppnt->p_vaddr + ppnt->p_memsz;
}
- _dl_munmap (rpnt->dyn->loadaddr, end);
+ _dl_munmap(rpnt->dyn->loadaddr, end);
/* Next, remove rpnt->dyn from the loaded_module list */
- if (_dl_loaded_modules == rpnt->dyn)
- {
- _dl_loaded_modules = rpnt->dyn->next;
- if (_dl_loaded_modules)
- _dl_loaded_modules->prev = 0;
- }
- else
- for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next)
- if (tpnt->next == rpnt->dyn) {
- tpnt->next = tpnt->next->next;
- if (tpnt->next)
- tpnt->next->prev = tpnt;
- break;
- }
+ if (_dl_loaded_modules == rpnt->dyn) {
+ _dl_loaded_modules = rpnt->dyn->next;
+ if (_dl_loaded_modules)
+ _dl_loaded_modules->prev = 0;
+ } else
+ for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next)
+ if (tpnt->next == rpnt->dyn) {
+ tpnt->next = tpnt->next->next;
+ if (tpnt->next)
+ tpnt->next->prev = tpnt;
+ break;
+ }
free(rpnt->dyn->libname);
free(rpnt->dyn);
- }
+ }
free(rpnt);
- }
+ }
dl_brk = (void (*)()) _dl_debug_addr->r_brk;
- if( dl_brk != NULL )
- {
- _dl_debug_addr->r_state = RT_DELETE;
- (*dl_brk)();
-
- _dl_debug_addr->r_state = RT_CONSISTENT;
- (*dl_brk)();
- }
+ if (dl_brk != NULL) {
+ _dl_debug_addr->r_state = RT_DELETE;
+ (*dl_brk) ();
+
+ _dl_debug_addr->r_state = RT_CONSISTENT;
+ (*dl_brk) ();
+ }
return 0;
}
-const char * _dlerror()
+const char *_dlerror()
{
- const char * retval;
- if(!_dl_error_number) return NULL;
+ const char *retval;
+
+ if (!_dl_error_number)
+ return NULL;
retval = dl_error_names[_dl_error_number];
_dl_error_number = 0;
return retval;
@@ -481,11 +474,11 @@ possible, but at run time the normal symbols are accessed. */
static void foobar()
{
- _dl_fdprintf(2,"libdl library not correctly linked\n");
+ _dl_fdprintf(2, "libdl library not correctly linked\n");
_dl_exit(1);
}
-static int __attribute__((unused)) foobar1 = (int)foobar; /* Use as pointer */
+static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
#if 1
#pragma weak _dl_find_hash = foobar
@@ -516,50 +509,51 @@ __asm__(".weak _dl_map_cache; _dl_map_cache = foobar");
__asm__(".weak _dl_unmap_cache; _dl_unmap_cache = foobar");
#endif
__asm__(".weak _dl_malloc_function; _dl_malloc_function = foobar1");
-__asm__(".weak _dl_parse_relocation_information; _dl_parse_relocation_information = foobar");
-__asm__(".weak _dl_parse_lazy_relocation_information; _dl_parse_lazy_relocation_information = foobar");
+__asm__
+ (".weak _dl_parse_relocation_information; _dl_parse_relocation_information = foobar");
+__asm__
+ (".weak _dl_parse_lazy_relocation_information; _dl_parse_lazy_relocation_information = foobar");
__asm__(".weak _dl_fdprintf; _dl_fdprintf = foobar");
#endif
/*
* Dump information to stderrr about the current loaded modules
*/
-static char * type[] = {"Lib","Exe","Int","Mod"};
+static char *type[] = { "Lib", "Exe", "Int", "Mod" };
void _dlinfo()
{
- struct elf_resolve * tpnt;
- struct dyn_elf * rpnt, *hpnt;
+ struct elf_resolve *tpnt;
+ struct dyn_elf *rpnt, *hpnt;
+
_dl_fdprintf(2, "List of loaded modules\n");
/* First start with a complete list of all of the loaded files. */
- for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next)
- _dl_fdprintf(2, "\t%8.8x %8.8x %8.8x %s %d %s\n",
- (unsigned)tpnt->loadaddr, (unsigned)tpnt,
- (unsigned)tpnt->symbol_scope,
+ for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
+ _dl_fdprintf(2, "\t%8.8x %8.8x %8.8x %s %d %s\n",
+ (unsigned) tpnt->loadaddr, (unsigned) tpnt,
+ (unsigned) tpnt->symbol_scope,
type[tpnt->libtype],
- tpnt->usage_count,
- tpnt->libname);
+ tpnt->usage_count, tpnt->libname);
+ }
/* Next dump the module list for the application itself */
_dl_fdprintf(2, "\nModules for application (%x):\n",
- (unsigned)_dl_symbol_tables);
+ (unsigned) _dl_symbol_tables);
for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next)
- _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned)rpnt->dyn,
- rpnt->dyn->libname);
+ _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned) rpnt->dyn, rpnt->dyn->libname);
- for (hpnt = _dl_handles; hpnt; hpnt = hpnt->next_handle)
- {
- _dl_fdprintf(2, "Modules for handle %x\n", (unsigned)hpnt);
- for(rpnt = hpnt; rpnt; rpnt = rpnt->next)
- _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned)rpnt->dyn,
+ for (hpnt = _dl_handles; hpnt; hpnt = hpnt->next_handle) {
+ _dl_fdprintf(2, "Modules for handle %x\n", (unsigned) hpnt);
+ for (rpnt = hpnt; rpnt; rpnt = rpnt->next)
+ _dl_fdprintf(2, "\t%8.8x %s\n", (unsigned) rpnt->dyn,
rpnt->dyn->libname);
}
}
-int _dladdr(void * __address, Dl_info * __dlip )
+int _dladdr(void *__address, Dl_info * __dlip)
{
- struct elf_resolve * pelf;
- struct elf_resolve * rpnt;
+ struct elf_resolve *pelf;
+ struct elf_resolve *rpnt;
#ifdef USE_CACHE
_dl_map_cache();
@@ -571,78 +565,66 @@ int _dladdr(void * __address, Dl_info * __dlip )
pelf = NULL;
#if 0
- _dl_fdprintf( 2,
- "dladdr( 0x%p, 0x%p )\n",
- __address, __dlip );
+ _dl_fdprintf(2, "dladdr( 0x%p, 0x%p )\n", __address, __dlip);
#endif
- for(rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next)
- {
- struct elf_resolve * tpnt;
- tpnt = rpnt;
+ for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next) {
+ struct elf_resolve *tpnt;
+
+ tpnt = rpnt;
#if 0
- _dl_fdprintf( 2,
- "Module \"%s\" at 0x%p\n",
- tpnt->libname,
- tpnt->loadaddr );
+ _dl_fdprintf(2, "Module \"%s\" at 0x%p\n",
+ tpnt->libname, tpnt->loadaddr);
#endif
- if( tpnt->loadaddr < (char*)__address
- && ( pelf == NULL
- || pelf->loadaddr < tpnt->loadaddr))
- pelf = tpnt;
- }
+ if (tpnt->loadaddr < (char *) __address
+ && (pelf == NULL || pelf->loadaddr < tpnt->loadaddr)) {
+ pelf = tpnt;
+ }
+ }
- if ( ! pelf )
- {
- return 0;
+ if (!pelf) {
+ return 0;
}
-
+
/*
* Try and locate the symbol of address
*/
{
- char * strtab;
- Elf32_Sym * symtab;
- int hn, si;
- int sf;
- int sn = 0;
- void* sa = 0;
-
- symtab = (Elf32_Sym *) (pelf->dynamic_info[DT_SYMTAB] +
- pelf->loadaddr);
- strtab = (char *) (pelf->dynamic_info[DT_STRTAB] + pelf->loadaddr);
-
- sf = 0;
- for(hn = 0; hn < pelf->nbucket; hn++)
- {
- for(si = pelf->elf_buckets[hn]; si; si = pelf->chains[si])
- {
- void* symbol_addr;
- symbol_addr = pelf->loadaddr + symtab[si].st_value;
- if ( symbol_addr <= __address &&
- ( !sf || sa < symbol_addr ) )
- {
- sa = symbol_addr;
- sn = si;
- sf = 1;
- }
+ char *strtab;
+ Elf32_Sym *symtab;
+ int hn, si;
+ int sf;
+ int sn = 0;
+ void *sa = 0;
+
+ symtab = (Elf32_Sym *) (pelf->dynamic_info[DT_SYMTAB] + pelf->loadaddr);
+ strtab = (char *) (pelf->dynamic_info[DT_STRTAB] + pelf->loadaddr);
+
+ sf = 0;
+ for (hn = 0; hn < pelf->nbucket; hn++) {
+ for (si = pelf->elf_buckets[hn]; si; si = pelf->chains[si]) {
+ void *symbol_addr;
+
+ symbol_addr = pelf->loadaddr + symtab[si].st_value;
+ if (symbol_addr <= __address && (!sf || sa < symbol_addr)) {
+ sa = symbol_addr;
+ sn = si;
+ sf = 1;
+ }
#if 0
- _dl_fdprintf( 2,
- "Symbol \"%s\" at 0x%p\n",
- strtab + symtab[si].st_name,
- symbol_addr );
+ _dl_fdprintf(2, "Symbol \"%s\" at 0x%p\n",
+ strtab + symtab[si].st_name, symbol_addr);
#endif
- }
- }
+ }
+ }
- if ( sf )
- {
- __dlip->dli_fname = pelf->libname;
- __dlip->dli_fbase = pelf->loadaddr;
- __dlip->dli_sname = strtab + symtab[sn].st_name;
- __dlip->dli_saddr = sa;
- }
- return 1;
+ if (sf) {
+ __dlip->dli_fname = pelf->libname;
+ __dlip->dli_fbase = pelf->loadaddr;
+ __dlip->dli_sname = strtab + symtab[sn].st_name;
+ __dlip->dli_saddr = sa;
+ }
+ return 1;
}
}
diff --git a/ldso/util/ldd.c b/ldso/util/ldd.c
index a0b0338eb..ea4f1f5ef 100644
--- a/ldso/util/ldd.c
+++ b/ldso/util/ldd.c
@@ -23,7 +23,7 @@
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
-#include <linux/elf.h>
+#include "../d-link/elf.h"
#include "../config.h"
#include "readelf.h"
@@ -134,7 +134,7 @@ int is_bin(char *argv0, char *prog)
else if (N_MAGIC(exec) != ZMAGIC && N_MAGIC(exec) != QMAGIC &&
N_MAGIC(exec) != OMAGIC)
{
- struct elfhdr elf_hdr;
+ elfhdr elf_hdr;
rewind(file);
fread(&elf_hdr, sizeof elf_hdr, 1, file);
@@ -143,7 +143,7 @@ int is_bin(char *argv0, char *prog)
fprintf(stderr, "%s: %s is not a.out or ELF\n", argv0, prog);
else
{
- struct elf_phdr phdr;
+ elf_phdr phdr;
int i;
/* Check its an exectuable, library or other */