[uClibc-cvs] CVS uClibc/ldso/ldso/mips
CVS User jocke
jocke at codepoet.org
Tue Nov 2 08:14:49 UTC 2004
Update of /var/cvs/uClibc/ldso/ldso/mips
In directory nail:/tmp/cvs-serv19564/ldso/mips
Modified Files:
dl-startup.h dl-sysdep.h elfinterp.c
Log Message:
- Remove dynamic_size from struct elf_resolve.
- Replace all open coded dynamic handling with a function. Reduces size.
- Fold special MIPS dynamic code into the dynamic_info item.
- Add RELRO support.
- Support linking with "-z now".
- prepare for DT_RELACOUNT/DT_RELCOUNT optimization.
- Add -z now to ld.so linking, this is what ld.so does anyway so
let the linker know that.
--- /var/cvs/uClibc/ldso/ldso/mips/dl-startup.h 2004/04/20 06:33:01 1.10
+++ /var/cvs/uClibc/ldso/ldso/mips/dl-startup.h 2004/11/02 08:14:46 1.11
@@ -48,21 +48,21 @@
* Here is a macro to perform the GOT relocation. This is only
* used when bootstrapping the dynamic loader.
*/
-#define PERFORM_BOOTSTRAP_GOT(got) \
+#define PERFORM_BOOTSTRAP_GOT(got, tpnt) \
do { \
Elf32_Sym *sym; \
unsigned long i; \
\
/* Add load address displacement to all local GOT entries */ \
i = 2; \
- while (i < tpnt->mips_local_gotno) \
+ while (i < tpnt->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX]) \
got[i++] += load_addr; \
\
/* Handle global GOT entries */ \
- got += tpnt->mips_local_gotno; \
+ got += tpnt->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX]; \
sym = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + \
- load_addr) + tpnt->mips_gotsym; \
- i = tpnt->mips_symtabno - tpnt->mips_gotsym; \
+ load_addr) + tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX]; \
+ i = tpnt->dynamic_info[DT_MIPS_SYMTABNO_IDX] - tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX];\
\
while (i--) { \
if (sym->st_shndx == SHN_UNDEF || \
@@ -91,8 +91,8 @@
#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
switch(ELF32_R_TYPE((RELP)->r_info)) { \
case R_MIPS_REL32: \
- if (symtab_index) { \
- if (symtab_index < tpnt->mips_gotsym) \
+ if (SYMTAB) { \
+ if (symtab_index<tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX])\
*REL += SYMBOL; \
} \
else { \
--- /var/cvs/uClibc/ldso/ldso/mips/dl-sysdep.h 2004/09/23 07:05:36 1.12
+++ /var/cvs/uClibc/ldso/ldso/mips/dl-sysdep.h 2004/11/02 08:14:46 1.13
@@ -8,6 +8,22 @@
/* Define this if the system uses RELOCA. */
#undef ELF_USES_RELOCA
+#define ARCH_NUM 3
+#define DT_MIPS_GOTSYM_IDX (DT_NUM + OS_NUM)
+#define DT_MIPS_LOCAL_GOTNO_IDX (DT_NUM + OS_NUM +1)
+#define DT_MIPS_SYMTABNO_IDX (DT_NUM + OS_NUM +2)
+
+#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
+do { \
+if (dpnt->d_tag == DT_MIPS_GOTSYM) \
+ dynamic[DT_MIPS_GOTSYM_IDX] = dpnt->d_un.d_val; \
+else if(dpnt->d_tag == DT_MIPS_LOCAL_GOTNO) \
+ dynamic[DT_MIPS_LOCAL_GOTNO_IDX] = dpnt->d_un.d_val; \
+else if(dpnt->d_tag == DT_MIPS_SYMTABNO) \
+ dynamic[DT_MIPS_SYMTABNO_IDX] = dpnt->d_un.d_val; \
+else if (dpnt->d_tag == DT_MIPS_RLD_MAP) \
+ *(Elf32_Addr *)(dpnt->d_un.d_ptr) = (Elf32_Addr) debug_addr; \
+} while (0)
/* Initialization sequence for the application/library GOT. */
#define INIT_GOT(GOT_BASE,MODULE) \
@@ -24,7 +40,7 @@
\
/* Add load address displacement to all local GOT entries */ \
i = 2; \
- while (i < MODULE->mips_local_gotno) \
+ while (i < MODULE->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX]) \
GOT_BASE[i++] += (unsigned long) MODULE->loadaddr; \
\
} while (0)
--- /var/cvs/uClibc/ldso/ldso/mips/elfinterp.c 2004/08/26 20:43:25 1.22
+++ /var/cvs/uClibc/ldso/ldso/mips/elfinterp.c 2004/11/02 08:14:47 1.23
@@ -121,8 +121,8 @@
char **got_addr;
char *symname;
- gotsym = tpnt->mips_gotsym;
- local_gotno = tpnt->mips_local_gotno;
+ gotsym = tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX];
+ local_gotno = tpnt->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX];
sym = ((Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr)) + sym_index;
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
@@ -213,13 +213,13 @@
switch (reloc_type) {
case R_MIPS_REL32:
if (symtab_index) {
- if (symtab_index < tpnt->mips_gotsym)
+ if (symtab_index < tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX])
*reloc_addr +=
symtab[symtab_index].st_value +
(unsigned long) tpnt->loadaddr;
else {
- *reloc_addr += got[symtab_index + tpnt->mips_local_gotno -
- tpnt->mips_gotsym];
+ *reloc_addr += got[symtab_index + tpnt->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX] -
+ tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX]];
}
}
else {
@@ -270,12 +270,12 @@
/* Setup the loop variables */
got_entry = (unsigned long *) (tpnt->loadaddr +
- tpnt->dynamic_info[DT_PLTGOT]) + tpnt->mips_local_gotno;
+ tpnt->dynamic_info[DT_PLTGOT]) + tpnt->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX];
sym = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] +
- (unsigned long) tpnt->loadaddr) + tpnt->mips_gotsym;
+ (unsigned long) tpnt->loadaddr) + tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX];
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] +
(unsigned long) tpnt->loadaddr);
- i = tpnt->mips_symtabno - tpnt->mips_gotsym;
+ i = tpnt->dynamic_info[DT_MIPS_SYMTABNO_IDX] - tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX];
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug_reloc)
More information about the uClibc-cvs
mailing list