[PATCH] ldso - adding ARCH_NEEDS_BOOTSTRAP_RELOCS define
Carmelo AMOROSO
carmelo.amoroso at st.com
Thu Jan 8 11:16:13 UTC 2009
olsajiri at gmail.com wrote:
> Hi,
>
> updated with Peter's comment.
>
> jirka
>
Applied, except for ldso/ldso/sh/dl-sysdep.h that doesn't need to
perform bootstrap relocation.
Thanks,
Carmelo
> ---
> Index: include/tls.h
> ===================================================================
> --- include/tls.h (revision 24716)
> +++ include/tls.h (working copy)
> @@ -5,7 +5,7 @@
>
> #include_next <tls.h>
>
> -#if USE_TLS && HAVE___THREAD \
> +#if defined USE_TLS && USE_TLS && HAVE___THREAD \
> && (!defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt)
>
> # define USE___THREAD 1
> Index: ldso/ldso/dl-startup.c
> ===================================================================
> --- ldso/ldso/dl-startup.c (revision 24716)
> +++ 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,56 @@
> 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 should be RELATIVE. All archs
> + that need bootstrap relocations need to define ARCH_NEEDS_BOOTSTRAP_RELOCS. */
> +#ifdef ARCH_NEEDS_BOOTSTRAP_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);
> }
> +#else /* ARCH_NEEDS_BOOTSTRAP_RELOCS */
> + if (rel_size) {
> + SEND_EARLY_STDERR("Cannot continue, found non relative relocs during the bootstrap.\n");
> + _dl_exit(14);
> + }
> +#endif
> }
> }
> #endif
> Index: ldso/ldso/sh64/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/sh64/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/sh64/dl-sysdep.h (working copy)
> @@ -19,9 +19,13 @@
> /* Here we define the magic numbers that this dynamic loader should accept */
> #define MAGIC1 EM_SH
> #undef MAGIC2
> +
> /* Used for error messages */
> #define ELF_TARGET "sh64"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> struct elf_resolve;
> extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
>
> Index: ldso/ldso/m68k/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/m68k/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/m68k/dl-sysdep.h (working copy)
> @@ -22,6 +22,9 @@
> /* Used for error messages */
> #define ELF_TARGET "m68k"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> struct elf_resolve;
> extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
>
> Index: ldso/ldso/avr32/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/avr32/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/avr32/dl-sysdep.h (working copy)
> @@ -44,6 +44,9 @@
> /* Used for error messages */
> #define ELF_TARGET "AVR32"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
>
> #define elf_machine_type_class(type) \
> Index: ldso/ldso/frv/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/frv/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/frv/dl-sysdep.h (working copy)
> @@ -40,6 +40,9 @@
> /* Used for error messages */
> #define ELF_TARGET "FR-V"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> struct elf_resolve;
>
> struct funcdesc_value
> Index: ldso/ldso/cris/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/cris/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/cris/dl-sysdep.h (working copy)
> @@ -15,6 +15,9 @@
> #undef MAGIC2
> #define ELF_TARGET "CRIS"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> struct elf_resolve;
> extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
>
> Index: ldso/ldso/xtensa/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/xtensa/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/xtensa/dl-sysdep.h (working copy)
> @@ -73,6 +73,9 @@
> /* Used for error messages. */
> #define ELF_TARGET "Xtensa"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> struct elf_resolve;
> extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
>
> Index: ldso/ldso/sparc/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/sparc/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/sparc/dl-sysdep.h (working copy)
> @@ -40,6 +40,9 @@
> /* Used for error messages */
> #define ELF_TARGET "sparc"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> struct elf_resolve;
> unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
>
> Index: ldso/ldso/mips/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/mips/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/mips/dl-sysdep.h (working copy)
> @@ -149,6 +149,8 @@
> /* Used for error messages */
> #define ELF_TARGET "MIPS"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
>
> unsigned long __dl_runtime_resolve(unsigned long sym_index,
> unsigned long old_gpreg);
> Index: ldso/ldso/sh/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/sh/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/sh/dl-sysdep.h (working copy)
> @@ -22,6 +22,9 @@
> /* Used for error messages */
> #define ELF_TARGET "sh"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> struct elf_resolve;
> extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
>
> Index: ldso/ldso/bfin/dl-sysdep.h
> ===================================================================
> --- ldso/ldso/bfin/dl-sysdep.h (revision 24716)
> +++ ldso/ldso/bfin/dl-sysdep.h (working copy)
> @@ -56,6 +56,9 @@
> /* Used for error messages */
> #define ELF_TARGET "BFIN"
>
> +/* Need bootstrap relocations */
> +#define ARCH_NEEDS_BOOTSTRAP_RELOCS
> +
> struct elf_resolve;
>
> struct funcdesc_value
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc
>
More information about the uClibc
mailing list