[PATCH] ldso - adding HAVE_RELATIVE_RELOCS define - updated
olsajiri at gmail.com
olsajiri at gmail.com
Tue Jan 6 09:40:39 UTC 2009
Hi,
I moved the HAVE_RELATIVE_RELOCS to the dl-sysdep.h.
Also found there were warnings of non used variables due to the
ifdef'ed block. The rest is the same.
As the former comment suggested, I added the HAVE_RELATIVE_RELOCS and
and reduced the linker code size.
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
-[ 6] .text PROGBITS 00000a2c 000a2c 00323e 00 AX 0 0 4
+[ 6] .text PROGBITS 00000a2c 000a2c 003133 00 AX 0 0 4
I suppose most of the linkers support -Bsymbolic,
but I could verify only i386 and arm.
Signed-off-by: Jiri Olsa <olsajiri at gmail.com>
---
Index: ldso/ldso/arm/dl-sysdep.h
===================================================================
--- ldso/ldso/arm/dl-sysdep.h (revision 24692)
+++ ldso/ldso/arm/dl-sysdep.h (working copy)
@@ -52,6 +52,9 @@
/* Used for error messages */
#define ELF_TARGET "ARM"
+/* The linker supports relative relocations */
+#define HAVE_RELATIVE_RELOCS
+
struct elf_resolve;
unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
Index: ldso/ldso/dl-startup.c
===================================================================
--- ldso/ldso/dl-startup.c (revision 24692)
+++ ldso/ldso/dl-startup.c (working copy)
@@ -233,12 +233,6 @@
# define INDX_MAX 2
#endif
for (indx = 0; indx < INDX_MAX; indx++) {
- unsigned int i;
- unsigned long *reloc_addr;
- unsigned long symbol_addr;
- int symtab_index;
- ElfW(Sym) *sym;
- ELF_RELOC *rpnt;
unsigned long rel_addr, rel_size;
ElfW(Word) relative_count = tpnt->dynamic_info[DT_RELCONT_IDX];
@@ -250,41 +244,52 @@
if (!rel_addr)
continue;
- /* Now parse the relocation information */
- /* Since ldso is linked with -Bsymbolic, all relocs will be RELATIVE(for those archs that have
- RELATIVE relocs) which means that the for(..) loop below has nothing to do and can be deleted.
- Possibly one should add a HAVE_RELATIVE_RELOCS directive and #ifdef away some code. */
if (!indx && relative_count) {
rel_size -= relative_count * sizeof(ELF_RELOC);
elf_machine_relative(load_addr, rel_addr, relative_count);
rel_addr += relative_count * sizeof(ELF_RELOC);
}
- rpnt = (ELF_RELOC *) rel_addr;
- for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
- reloc_addr = (unsigned long *) DL_RELOC_ADDR(load_addr, (unsigned long)rpnt->r_offset);
- symtab_index = ELF_R_SYM(rpnt->r_info);
- symbol_addr = 0;
- sym = NULL;
- if (symtab_index) {
- char *strtab;
- ElfW(Sym) *symtab;
+ /* Since ldso is linked with -Bsymbolic, all relocs will be RELATIVE (for those archs that have
+ RELATIVE relocs - HAVE_RELATIVE_RELOCS define). Which means that the for(..) loop below has
+ nothing to do and can omited. */
+#if !defined(HAVE_RELATIVE_RELOCS)
+ {
+ ELF_RELOC *rpnt;
+ unsigned int i;
+ ElfW(Sym) *sym;
+ unsigned long symbol_addr;
+ int symtab_index;
+ unsigned long *reloc_addr;
+
+ /* Now parse the relocation information */
+ rpnt = (ELF_RELOC *) rel_addr;
+ for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
+ reloc_addr = (unsigned long *) DL_RELOC_ADDR(load_addr, (unsigned long)rpnt->r_offset);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ symbol_addr = 0;
+ sym = NULL;
+ if (symtab_index) {
+ char *strtab;
+ ElfW(Sym) *symtab;
- symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
- strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
- sym = &symtab[symtab_index];
- symbol_addr = (unsigned long) DL_RELOC_ADDR(load_addr, sym->st_value);
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+ sym = &symtab[symtab_index];
+ symbol_addr = (unsigned long) DL_RELOC_ADDR(load_addr, sym->st_value);
#if !defined(EARLY_STDERR_SPECIAL)
- SEND_STDERR_DEBUG("relocating symbol: ");
- SEND_STDERR_DEBUG(strtab + sym->st_name);
- SEND_STDERR_DEBUG("\n");
+ SEND_STDERR_DEBUG("relocating symbol: ");
+ SEND_STDERR_DEBUG(strtab + sym->st_name);
+ SEND_STDERR_DEBUG("\n");
#endif
- } else {
- SEND_STDERR_DEBUG("relocating unknown symbol\n");
+ } else {
+ SEND_STDERR_DEBUG("relocating unknown symbol\n");
+ }
+ /* Use this machine-specific macro to perform the actual relocation. */
+ PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
}
- /* Use this machine-specific macro to perform the actual relocation. */
- PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
}
+#endif // !defined(HAVE_RELATIVE_RELOCS)
}
}
#endif
Index: ldso/ldso/i386/dl-sysdep.h
===================================================================
--- ldso/ldso/i386/dl-sysdep.h (revision 24692)
+++ ldso/ldso/i386/dl-sysdep.h (working copy)
@@ -22,6 +22,9 @@
/* Used for error messages */
#define ELF_TARGET "386"
+/* The linker supports relative relocations */
+#define HAVE_RELATIVE_RELOCS
+
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
More information about the uClibc
mailing list