diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2022-01-13 17:58:00 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2022-02-10 09:16:12 -0300 |
commit | 6628c742b2c16e785d3c884d9deeda5adb30ca12 (patch) | |
tree | 493580e40aef171896584e1d3d32bbe14c15140b /sysdeps | |
parent | 8c8510ab2790039e58995ef3a22309582413d3ff (diff) | |
download | glibc-6628c742b2c16e785d3c884d9deeda5adb30ca12.tar.gz glibc-6628c742b2c16e785d3c884d9deeda5adb30ca12.tar.xz glibc-6628c742b2c16e785d3c884d9deeda5adb30ca12.zip |
elf: Remove prelink support
Prelinked binaries and libraries still work, the dynamic tags DT_GNU_PRELINKED, DT_GNU_LIBLIST, DT_GNU_CONFLICT just ignored (meaning the process is reallocated as default). The loader environment variable TRACE_PRELINKING is also removed, since it used solely on prelink. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/alpha/dl-machine.h | 15 | ||||
-rw-r--r-- | sysdeps/arm/dl-machine.h | 4 | ||||
-rw-r--r-- | sysdeps/generic/ldsodefs.h | 11 | ||||
-rw-r--r-- | sysdeps/i386/dl-machine.h | 16 | ||||
-rw-r--r-- | sysdeps/or1k/dl-machine.h | 4 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/dl-machine.h | 31 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/dl-machine.h | 37 | ||||
-rw-r--r-- | sysdeps/s390/s390-32/dl-machine.h | 22 | ||||
-rw-r--r-- | sysdeps/s390/s390-64/dl-machine.h | 22 | ||||
-rw-r--r-- | sysdeps/sh/dl-machine.h | 2 | ||||
-rw-r--r-- | sysdeps/sparc/sparc32/dl-machine.h | 52 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/dl-machine.h | 72 | ||||
-rw-r--r-- | sysdeps/x86_64/dl-machine.h | 48 |
13 files changed, 61 insertions, 275 deletions
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h index 47cfefdc31..30fc790e88 100644 --- a/sysdeps/alpha/dl-machine.h +++ b/sysdeps/alpha/dl-machine.h @@ -423,23 +423,8 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], if (r_type == R_ALPHA_GLOB_DAT) *reloc_addr = sym_value; -#ifdef RESOLVE_CONFLICT_FIND_MAP - /* In .gnu.conflict section, R_ALPHA_JMP_SLOT relocations have - R_ALPHA_JMP_SLOT in lower 8 bits and the remaining 24 bits - are .rela.plt index. */ - else if ((r_type & 0xff) == R_ALPHA_JMP_SLOT) - { - /* elf_machine_fixup_plt needs the map reloc_addr points into, - while in _dl_resolve_conflicts map is _dl_loaded. */ - RESOLVE_CONFLICT_FIND_MAP (map, reloc_addr); - reloc = ((const Elf64_Rela *) D_PTR (map, l_info[DT_JMPREL])) - + (r_type >> 8); - elf_machine_fixup_plt (map, 0, 0, 0, reloc, reloc_addr, sym_value); - } -#else else if (r_type == R_ALPHA_JMP_SLOT) elf_machine_fixup_plt (map, 0, 0, 0, reloc, reloc_addr, sym_value); -#endif #ifndef RTLD_BOOTSTRAP else if (r_type == R_ALPHA_REFQUAD) { diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h index 68dcb96d9d..94f41c65cb 100644 --- a/sysdeps/arm/dl-machine.h +++ b/sysdeps/arm/dl-machine.h @@ -521,9 +521,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], return; else { -# ifndef RESOLVE_CONFLICT_FIND_MAP const Elf32_Sym *const refsym = sym; -# endif struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type); Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true); @@ -535,7 +533,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], switch (r_type) { -# ifndef RESOLVE_CONFLICT_FIND_MAP /* Not needed for dl-conflict.c. */ case R_ARM_COPY: if (sym == NULL) @@ -555,7 +552,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], memcpy (reloc_addr_arg, (void *) value, MIN (sym->st_size, refsym->st_size)); break; -# endif /* !RESOLVE_CONFLICT_FIND_MAP */ case R_ARM_GLOB_DAT: case R_ARM_JUMP_SLOT: case R_ARM_ABS32: diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 2ebe7901c0..d1c6cd902b 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -562,7 +562,6 @@ struct rtld_global_ro #define DL_DEBUG_SCOPES (1 << 9) /* These two are used only internally. */ #define DL_DEBUG_HELP (1 << 10) -#define DL_DEBUG_PRELINK (1 << 11) /* OS version. */ EXTERN unsigned int _dl_osversion; @@ -649,10 +648,6 @@ struct rtld_global_ro EXTERN const char *_dl_profile; /* Filename of the output file. */ EXTERN const char *_dl_profile_output; - /* Name of the object we want to trace the prelinking. */ - EXTERN const char *_dl_trace_prelink; - /* Map of shared object to be prelink traced. */ - EXTERN struct link_map *_dl_trace_prelink_map; /* All search directories defined at startup. This is assigned a non-NULL pointer by the ld.so startup code (after initialization @@ -1096,12 +1091,6 @@ extern void _dl_reloc_bad_type (struct link_map *map, unsigned int type, int plt) attribute_hidden __attribute__ ((__noreturn__)); -/* Resolve conflicts if prelinking. */ -extern void _dl_resolve_conflicts (struct link_map *l, - ElfW(Rela) *conflict, - ElfW(Rela) *conflictend) - attribute_hidden; - /* Check the version dependencies of all objects available through MAP. If VERBOSE print some more diagnostics. */ extern int _dl_check_all_versions (struct link_map *map, int verbose, diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 6182b45ed3..3ffd0b4e31 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -479,9 +479,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], *reloc_addr = map->l_addr + reloc->r_addend; else if (r_type != R_386_NONE) { -# ifndef RESOLVE_CONFLICT_FIND_MAP const Elf32_Sym *const refsym = sym; -# endif struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type); Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true); @@ -503,7 +501,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_386_32: *reloc_addr = value + reloc->r_addend; break; -# ifndef RESOLVE_CONFLICT_FIND_MAP /* Not needed for dl-conflict.c. */ case R_386_PC32: *reloc_addr = (value + reloc->r_addend - (Elf32_Addr) reloc_addr); @@ -525,19 +522,19 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], struct tlsdesc volatile *td = (struct tlsdesc volatile *)reloc_addr; -# ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP if (!sym) { td->arg = (void*)reloc->r_addend; td->entry = _dl_tlsdesc_undefweak; } else -# endif +# endif { -# ifndef RTLD_BOOTSTRAP -# ifndef SHARED +# ifndef RTLD_BOOTSTRAP +# ifndef SHARED CHECK_STATIC_TLS (map, sym_map); -# else +# else if (!TRY_STATIC_TLS (map, sym_map)) { td->arg = _dl_make_tlsdesc_dynamic @@ -545,8 +542,8 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], td->entry = _dl_tlsdesc_dynamic; } else -# endif # endif +# endif { td->arg = (void*)(sym->st_value - sym_map->l_tls_offset + reloc->r_addend); @@ -599,7 +596,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], memcpy (reloc_addr_arg, (void *) value, MIN (sym->st_size, refsym->st_size)); break; -# endif /* !RESOLVE_CONFLICT_FIND_MAP */ case R_386_IRELATIVE: value = map->l_addr + reloc->r_addend; if (__glibc_likely (!skip_ifunc)) diff --git a/sysdeps/or1k/dl-machine.h b/sysdeps/or1k/dl-machine.h index 35329a60f6..849763a36e 100644 --- a/sysdeps/or1k/dl-machine.h +++ b/sysdeps/or1k/dl-machine.h @@ -189,9 +189,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], return; else { -# ifndef RESOLVE_CONFLICT_FIND_MAP const Elf32_Sym *const refsym = sym; -# endif struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type); Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true); @@ -204,7 +202,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], switch (r_type) { -# ifndef RESOLVE_CONFLICT_FIND_MAP case R_OR1K_COPY: if (sym == NULL) /* This can happen in trace mode if an object could not be @@ -225,7 +222,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], memcpy (reloc_addr_arg, (void *) value, MIN (sym->st_size, refsym->st_size)); break; -# endif /* !RESOLVE_CONFLICT_FIND_MAP */ case R_OR1K_32: /* Support relocations on mis-aligned offsets. */ value += reloc->r_addend; diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h index 70961b4b78..7583b491f9 100644 --- a/sysdeps/powerpc/powerpc32/dl-machine.h +++ b/sysdeps/powerpc/powerpc32/dl-machine.h @@ -294,7 +294,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], const int r_type = ELF32_R_TYPE (reloc->r_info); struct link_map *sym_map = NULL; -#ifndef RESOLVE_CONFLICT_FIND_MAP if (r_type == R_PPC_RELATIVE) { *reloc_addr = map->l_addr + reloc->r_addend; @@ -318,9 +317,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], value = SYMBOL_ADDRESS (sym_map, sym, true); } value += reloc->r_addend; -#else - value = reloc->r_addend; -#endif if (sym != NULL && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0) @@ -341,12 +337,11 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], *reloc_addr = value; break; -#ifndef RESOLVE_CONFLICT_FIND_MAP -# ifdef RTLD_BOOTSTRAP -# define NOT_BOOTSTRAP 0 -# else -# define NOT_BOOTSTRAP 1 -# endif +#ifdef RTLD_BOOTSTRAP +# define NOT_BOOTSTRAP 0 +#else +# define NOT_BOOTSTRAP 1 +#endif case R_PPC_DTPMOD32: if (map->l_info[DT_PPC(OPT)] @@ -361,11 +356,11 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], } else if (sym_map != NULL) { -# ifndef SHARED +#ifndef SHARED CHECK_STATIC_TLS (map, sym_map); -# else +#else if (TRY_STATIC_TLS (map, sym_map)) -# endif +#endif { reloc_addr[0] = 0; /* Set up for local dynamic. */ @@ -395,11 +390,11 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], else if (sym_map != NULL) { /* This reloc is always preceded by R_PPC_DTPMOD32. */ -# ifndef SHARED +#ifndef SHARED assert (HAVE_STATIC_TLS (map, sym_map)); -# else +#else if (HAVE_STATIC_TLS (map, sym_map)) -# endif +#endif { *reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc); break; @@ -419,12 +414,8 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], *reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc); } break; -#endif case R_PPC_JMP_SLOT: -#ifdef RESOLVE_CONFLICT_FIND_MAP - RESOLVE_CONFLICT_FIND_MAP (map, reloc_addr); -#endif if (map->l_info[DT_PPC(GOT)] != 0) { *reloc_addr = value; diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index a505998351..5da5de7a0a 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -537,36 +537,6 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t sym_map, return finaladdr; } -static inline void __attribute__ ((always_inline)) -elf_machine_plt_conflict (struct link_map *map, lookup_t sym_map, - const ElfW(Sym) *refsym, const ElfW(Sym) *sym, - const Elf64_Rela *reloc, - Elf64_Addr *reloc_addr, Elf64_Addr finaladdr) -{ -#if _CALL_ELF != 2 - Elf64_FuncDesc *plt = (Elf64_FuncDesc *) reloc_addr; - Elf64_FuncDesc *rel = (Elf64_FuncDesc *) finaladdr; - Elf64_FuncDesc zero_fd = {0, 0, 0}; - - if (sym_map == NULL) - finaladdr = 0; - - if (finaladdr == 0) - rel = &zero_fd; - - plt->fd_func = rel->fd_func; - plt->fd_aux = rel->fd_aux; - plt->fd_toc = rel->fd_toc; - PPC_DCBST (&plt->fd_func); - PPC_DCBST (&plt->fd_aux); - PPC_DCBST (&plt->fd_toc); - PPC_SYNC; -#else - finaladdr += ppc64_local_entry_offset (map, sym_map, refsym, sym); - *reloc_addr = finaladdr; -#endif -} - /* Return the final value of a plt relocation. */ static inline Elf64_Addr elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc, @@ -639,7 +609,6 @@ resolve_ifunc (Elf64_Addr value, const struct link_map *map, const struct link_map *sym_map) { #if _CALL_ELF != 2 -#ifndef RESOLVE_CONFLICT_FIND_MAP /* The function we are calling may not yet have its opd entry relocated. */ Elf64_FuncDesc opd; if (map != sym_map @@ -658,7 +627,6 @@ resolve_ifunc (Elf64_Addr value, asm ("" : "=r" (value) : "0" (&opd), "X" (opd)); } #endif -#endif return ((Elf64_Addr (*) (unsigned long int)) value) (GLRO(dl_hwcap)); } @@ -722,13 +690,8 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], value = resolve_ifunc (value, map, sym_map); /* Fall thru */ case R_PPC64_JMP_SLOT: -#ifdef RESOLVE_CONFLICT_FIND_MAP - elf_machine_plt_conflict (map, sym_map, refsym, sym, - reloc, reloc_addr, value); -#else elf_machine_fixup_plt (map, sym_map, refsym, sym, reloc, reloc_addr, value); -#endif return; case R_PPC64_DTPMOD64: diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h index 5178d8c68c..4e6229e945 100644 --- a/sysdeps/s390/s390-32/dl-machine.h +++ b/sysdeps/s390/s390-32/dl-machine.h @@ -352,7 +352,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], return; else { -#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP +#if !defined RTLD_BOOTSTRAP /* Only needed for R_390_COPY below. */ const Elf32_Sym *const refsym = sym; #endif @@ -380,34 +380,33 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], *reloc_addr = value + reloc->r_addend; break; -#ifndef RESOLVE_CONFLICT_FIND_MAP case R_390_TLS_DTPMOD: -# ifdef RTLD_BOOTSTRAP +#ifdef RTLD_BOOTSTRAP /* During startup the dynamic linker is always the module with index 1. XXX If this relocation is necessary move before RESOLVE call. */ *reloc_addr = 1; -# else +#else /* Get the information from the link map returned by the resolv function. */ if (sym_map != NULL) *reloc_addr = sym_map->l_tls_modid; -# endif +#endif break; case R_390_TLS_DTPOFF: -# ifndef RTLD_BOOTSTRAP +#ifndef RTLD_BOOTSTRAP /* During relocation all TLS symbols are defined and used. Therefore the offset is already correct. */ if (sym != NULL) *reloc_addr = sym->st_value + reloc->r_addend; -# endif +#endif break; case R_390_TLS_TPOFF: /* The offset is negative, forward from the thread pointer. */ -# ifdef RTLD_BOOTSTRAP +#ifdef RTLD_BOOTSTRAP *reloc_addr = sym->st_value + reloc->r_addend - map->l_tls_offset; -# else +#else /* We know the offset of the object the symbol is contained in. It is a negative value which will be added to the thread pointer. */ @@ -419,10 +418,8 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], } #endif break; -#endif /* use TLS */ #ifndef RTLD_BOOTSTRAP -# ifndef RESOLVE_CONFLICT_FIND_MAP /* Not needed in dl-conflict.c. */ case R_390_COPY: if (sym == NULL) @@ -443,7 +440,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], memcpy (reloc_addr_arg, (void *) value, MIN (sym->st_size, refsym->st_size)); break; -# endif case R_390_32: *reloc_addr = value + reloc->r_addend; break; @@ -453,7 +449,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_390_8: *(char *) reloc_addr = value + reloc->r_addend; break; -# ifndef RESOLVE_CONFLICT_FIND_MAP case R_390_PC32: *reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr; break; @@ -471,7 +466,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], break; case R_390_NONE: break; -# endif #endif #if !defined(RTLD_BOOTSTRAP) || defined(_NDEBUG) default: diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h index 9c0d247e60..4bd97f5645 100644 --- a/sysdeps/s390/s390-64/dl-machine.h +++ b/sysdeps/s390/s390-64/dl-machine.h @@ -299,7 +299,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], return; else { -#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP +#if !defined RTLD_BOOTSTRAP /* Only needed for R_390_COPY below. */ const Elf64_Sym *const refsym = sym; #endif @@ -327,34 +327,33 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], *reloc_addr = value + reloc->r_addend; break; -#ifndef RESOLVE_CONFLICT_FIND_MAP case R_390_TLS_DTPMOD: -# ifdef RTLD_BOOTSTRAP +#ifdef RTLD_BOOTSTRAP /* During startup the dynamic linker is always the module with index 1. XXX If this relocation is necessary move before RESOLVE call. */ *reloc_addr = 1; -# else +#else /* Get the information from the link map returned by the resolv function. */ if (sym_map != NULL) *reloc_addr = sym_map->l_tls_modid; -# endif +#endif break; case R_390_TLS_DTPOFF: -# ifndef RTLD_BOOTSTRAP +#ifndef RTLD_BOOTSTRAP /* During relocation all TLS symbols are defined and used. Therefore the offset is already correct. */ if (sym != NULL) *reloc_addr = sym->st_value + reloc->r_addend; -# endif +#endif break; case R_390_TLS_TPOFF: /* The offset is negative, forward from the thread pointer. */ -# ifdef RTLD_BOOTSTRAP +#ifdef RTLD_BOOTSTRAP *reloc_addr = sym->st_value + reloc->r_addend - map->l_tls_offset; -# else +#else /* We know the offset of the object the symbol is contained in. It is a negative value which will be added to the thread pointer. */ @@ -366,10 +365,8 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], } #endif break; -#endif /* use TLS */ #ifndef RTLD_BOOTSTRAP -# ifndef RESOLVE_CONFLICT_FIND_MAP /* Not needed for dl-conflict.c. */ case R_390_COPY: if (sym == NULL) @@ -390,7 +387,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], memcpy (reloc_addr_arg, (void *) value, MIN (sym->st_size, refsym->st_size)); break; -# endif case R_390_64: *reloc_addr = value + reloc->r_addend; break; @@ -403,7 +399,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], case R_390_8: *(char *) reloc_addr = value + reloc->r_addend; break; -# ifndef RESOLVE_CONFLICT_FIND_MAP case R_390_PC64: *reloc_addr = value +reloc->r_addend - (Elf64_Addr) reloc_addr; break; @@ -425,7 +420,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], break; case R_390_NONE: break; -# endif #endif #if !defined(RTLD_BOOTSTRAP) || defined(_NDEBUG) default: diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index c99ad2054d..8b08a1fc47 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -391,7 +391,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], break; case R_SH_DIR32: { -#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP +#if !defined RTLD_BOOTSTRAP /* This is defined in rtld.c, but nowhere in the static libc.a; make the reference weak so static programs can still link. This declaration cannot be done when diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h index 35e680c255..e8d208a080 100644 --- a/sysdeps/sparc/sparc32/dl-machine.h +++ b/sysdeps/sparc/sparc32/dl-machine.h @@ -142,44 +142,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], plt[1] = 0x85c0a000 | (rfunc & 0x3ff); plt[2] = OPCODE_NOP; /* Fill call delay slot. */ plt[3] = (Elf32_Addr) l; - if (__builtin_expect (l->l_info[VALIDX(DT_GNU_PRELINKED)] != NULL, 0) - || __builtin_expect (l->l_info [VALIDX (DT_GNU_LIBLISTSZ)] != NULL, 0)) - { - /* Need to reinitialize .plt to undo prelinking. */ - Elf32_Rela *rela = (Elf32_Rela *) D_PTR (l, l_info[DT_JMPREL]); - Elf32_Rela *relaend - = (Elf32_Rela *) ((char *) rela - + l->l_info[DT_PLTRELSZ]->d_un.d_val); -#if !defined RTLD_BOOTSTRAP && !defined __sparc_v9__ - /* Note that we don't mask the hwcap here, as the flush is - essential to functionality on those cpu's that implement it. - For sparcv9 we can assume flush is present. */ - const int do_flush = GLRO(dl_hwcap) & HWCAP_SPARC_FLUSH; -#else - const int do_flush = 1; -#endif - - /* prelink must ensure there are no R_SPARC_NONE relocs left - in .rela.plt. */ - while (rela < relaend) - { - *(unsigned int *) (rela->r_offset + l->l_addr) - = OPCODE_SETHI_G1 | (rela->r_offset + l->l_addr - - (Elf32_Addr) plt); - *(unsigned int *) (rela->r_offset + l->l_addr + 4) - = OPCODE_BA | ((((Elf32_Addr) plt - - rela->r_offset - l->l_addr - 4) >> 2) - & 0x3fffff); - if (do_flush) - { - __asm __volatile ("flush %0" : : "r" (rela->r_offset - + l->l_addr)); - __asm __volatile ("flush %0+4" : : "r" (rela->r_offset - + l->l_addr)); - } - ++rela; - } - } } return lazy; @@ -334,14 +296,12 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], void *const reloc_addr_arg, int skip_ifunc) { Elf32_Addr *const reloc_addr = reloc_addr_arg; -#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP +#if !defined RTLD_BOOTSTRAP const Elf32_Sym *const refsym = sym; #endif Elf32_Addr value; const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); -#if !defined RESOLVE_CONFLICT_FIND_MAP struct link_map *sym_map = NULL; -#endif #if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC /* This is defined in rtld.c, but nowhere in the static libc.a; make the @@ -372,7 +332,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], } #endif -#ifndef RESOLVE_CONFLICT_FIND_MAP if (__builtin_expect (ELF32_ST_BIND (sym->st_info) == STB_LOCAL, 0) && sym->st_shndx != SHN_UNDEF) { @@ -384,9 +343,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type); value = SYMBOL_ADDRESS (sym_map, sym, true); } -#else - value = 0; -#endif value += reloc->r_addend; /* Assume copy relocs have zero addend. */ @@ -400,7 +356,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], switch (r_type) { -#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP +#if !defined RTLD_BOOTSTRAP case R_SPARC_COPY: if (sym == NULL) /* This can happen in trace mode if an object could not be @@ -450,7 +406,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], sparc_fixup_plt (reloc, reloc_addr, value, 0, do_flush); } break; -#ifndef RESOLVE_CONFLICT_FIND_MAP case R_SPARC_TLS_DTPMOD32: /* Get the information from the link map returned by the resolv function. */ @@ -474,7 +429,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], + reloc->r_addend; } break; -# ifndef RTLD_BOOTSTRAP +#ifndef RTLD_BOOTSTRAP case R_SPARC_TLS_LE_HIX22: case R_SPARC_TLS_LE_LOX10: if (sym != NULL) @@ -489,7 +444,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], | 0x1c00; } break; -# endif #endif #ifndef RTLD_BOOTSTRAP case R_SPARC_8: diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h index b6b36db240..dc24dbc305 100644 --- a/sysdeps/sparc/sparc64/dl-machine.h +++ b/sysdeps/sparc/sparc64/dl-machine.h @@ -196,50 +196,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], /* Now put the magic cookie at the beginning of .PLT2 Entry .PLT3 is unused by this implementation. */ *((struct link_map **)(&plt[16])) = l; - - if (__builtin_expect (l->l_info[VALIDX(DT_GNU_PRELINKED)] != NULL, 0) - || __builtin_expect (l->l_info [VALIDX (DT_GNU_LIBLISTSZ)] != NULL, 0)) - { - /* Need to reinitialize .plt to undo prelinking. */ - Elf64_Rela *rela = (Elf64_Rela *) D_PTR (l, l_info[DT_JMPREL]); - Elf64_Rela *relaend - = (Elf64_Rela *) ((char *) rela - + l->l_info[DT_PLTRELSZ]->d_un.d_val); - - /* prelink must ensure there are no R_SPARC_NONE relocs left - in .rela.plt. */ - while (rela < relaend) - { - if (__builtin_expect (rela->r_addend, 0) != 0) - { - Elf64_Addr slot = ((rela->r_offset + l->l_addr + 0x400 - - (Elf64_Addr) plt) - / 0x1400) * 0x1400 - + (Elf64_Addr) plt - 0x400; - /* ldx [%o7 + X], %g1 */ - unsigned int first_ldx = *(unsigned int *)(slot + 12); - Elf64_Addr ptr = slot + (first_ldx & 0xfff) + 4; - - *(Elf64_Addr *) (rela->r_offset + l->l_addr) - = (Elf64_Addr) plt - - (slot + ((rela->r_offset + l->l_addr - ptr) / 8) * 24 - + 4); - ++rela; - continue; - } - - *(unsigned int *) (rela->r_offset + l->l_addr) - = 0x03000000 | (rela->r_offset + l->l_addr - (Elf64_Addr) plt); - *(unsigned int *) (rela->r_offset + l->l_addr + 4) - = 0x30680000 | ((((Elf64_Addr) plt + 32 - rela->r_offset - - l->l_addr - 4) >> 2) & 0x7ffff); - __asm __volatile ("flush %0" : : "r" (rela->r_offset - + l->l_addr)); - __asm __volatile ("flush %0+4" : : "r" (rela->r_offset - + l->l_addr)); - ++rela; - } - } } return lazy; @@ -361,14 +317,12 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], void *const reloc_addr_arg, int skip_ifunc) { Elf64_Addr *const reloc_addr = reloc_addr_arg; -#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP +#if !defined RTLD_BOOTSTRAP const Elf64_Sym *const refsym = sym; #endif Elf64_Addr value; const unsigned long int r_type = ELF64_R_TYPE_ID (reloc->r_info); -#if !defined RESOLVE_CONFLICT_FIND_MAP struct link_map *sym_map = NULL; -#endif #if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC /* This is defined in rtld.c, but nowhere in the static libc.a; make the @@ -399,7 +353,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], } #endif -#ifndef RESOLVE_CONFLICT_FIND_MAP if (__builtin_expect (ELF64_ST_BIND (sym->st_info) == STB_LOCAL, 0) && sym->st_shndx != SHN_UNDEF) { @@ -411,9 +364,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], sym_map = RESOLVE_MAP (map, scope, &sym, version, r_type); value = SYMBOL_ADDRESS (sym_map, sym, true); } -#else - value = 0; -#endif value += reloc->r_addend; /* Assume copy relocs have zero addend. */ @@ -425,7 +375,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], switch (r_type) { -#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP +#if !defined RTLD_BOOTSTRAP case R_SPARC_COPY: if (sym == NULL) /* This can happen in trace mode if an object could not be @@ -459,26 +409,11 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], value = ((Elf64_Addr (*) (int)) value) (GLRO(dl_hwcap)); /* 'high' is always zero, for large PLT entries the linker emits an R_SPARC_IRELATIVE. */ -#ifdef RESOLVE_CONFLICT_FIND_MAP - sparc64_fixup_plt (NULL, reloc, reloc_addr, value, 0, 0); -#else sparc64_fixup_plt (map, reloc, reloc_addr, value, 0, 0); -#endif break; case R_SPARC_JMP_SLOT: -#ifdef RESOLVE_CONFLICT_FIND_MAP - /* R_SPARC_JMP_SLOT conflicts against .plt[32768+] - relocs should be turned into R_SPARC_64 relocs - in .gnu.conflict section. - r_addend non-zero does not mean it is a .plt[32768+] - reloc, instead it is the actual address of the function - to call. */ - sparc64_fixup_plt (NULL, reloc, reloc_addr, value, 0, 0); -#else sparc64_fixup_plt (map, reloc, reloc_addr, value, reloc->r_addend, 0); -#endif break; -#ifndef RESOLVE_CONFLICT_FIND_MAP case R_SPARC_TLS_DTPMOD64: /* Get the information from the link map returned by the resolv function. */ @@ -502,7 +437,7 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], + reloc->r_addend; } break; -# ifndef RTLD_BOOTSTRAP +#ifndef RTLD_BOOTSTRAP case R_SPARC_TLS_LE_HIX22: case R_SPARC_TLS_LE_LOX10: if (sym != NULL) @@ -520,7 +455,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], | 0x1c00); } break; -# endif #endif #ifndef RTLD_BOOTSTRAP case R_SPARC_8: diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index 155ca36bd5..6a6187490b 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -346,59 +346,58 @@ and creates an unsatisfiable circular dependency.\n", *reloc_addr = value + reloc->r_addend; break; -# ifndef RESOLVE_CONFLICT_FIND_MAP case R_X86_64_DTPMOD64: -# ifdef RTLD_BOOTSTRAP +# ifdef RTLD_BOOTSTRAP /* During startup the dynamic linker is always the module with index 1. XXX If this relocation is necessary move before RESOLVE call. */ *reloc_addr = 1; -# else +# else /* Get the information from the link map returned by the resolve function. */ if (sym_map != NULL) *reloc_addr = sym_map->l_tls_modid; -# endif +# endif break; case R_X86_64_DTPOFF64: -# ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP /* During relocation all TLS symbols are defined and used. Therefore the offset is already correct. */ if (sym != NULL) { value = sym->st_value + reloc->r_addend; -# ifdef __ILP32__ +# ifdef __ILP32__ /* This relocation type computes a signed offset that is usually negative. The symbol and addend values are 32 bits but the GOT entry is 64 bits wide and the whole 64-bit entry is used as a signed quantity, so we need to sign-extend the computed value to 64 bits. */ *(Elf64_Sxword *) reloc_addr = (Elf64_Sxword) (Elf32_Sword) value; -# else +# else *reloc_addr = value; -# endif - } # endif + } +# endif break; case R_X86_64_TLSDESC: { struct tlsdesc volatile *td = (struct tlsdesc volatile *)reloc_addr; -# ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP if (! sym) { td->arg = (void*)reloc->r_addend; td->entry = _dl_tlsdesc_undefweak; } else -# endif +# endif { -# ifndef RTLD_BOOTSTRAP -# ifndef SHARED +# ifndef RTLD_BOOTSTRAP +# ifndef SHARED CHECK_STATIC_TLS (map, sym_map); -# else +# else if (!TRY_STATIC_TLS (map, sym_map)) { td->arg = _dl_make_tlsdesc_dynamic @@ -406,8 +405,8 @@ and creates an unsatisfiable circular dependency.\n", td->entry = _dl_tlsdesc_dynamic; } else -# endif # endif +# endif { td->arg = (void*)(sym->st_value - sym_map->l_tls_offset + reloc->r_addend); @@ -418,30 +417,29 @@ and creates an unsatisfiable circular dependency.\n", } case R_X86_64_TPOFF64: /* The offset is negative, forward from the thread pointer. */ -# ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP if (sym != NULL) -# endif +# endif { -# ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP CHECK_STATIC_TLS (map, sym_map); -# endif +# endif /* We know the offset of the object the symbol is contained in. It is a negative value which will be added to the thread pointer. */ value = (sym->st_value + reloc->r_addend - sym_map->l_tls_offset); -# ifdef __ILP32__ +# ifdef __ILP32__ /* The symbol and addend values are 32 bits but the GOT entry is 64 bits wide and the whole 64-bit entry is used as a signed quantity, so we need to sign-extend the computed value to 64 bits. */ *(Elf64_Sxword *) reloc_addr = (Elf64_Sxword) (Elf32_Sword) value; -# else +# else *reloc_addr = value; -# endif +# endif } break; -# endif # ifndef RTLD_BOOTSTRAP case R_X86_64_64: @@ -466,15 +464,12 @@ and creates an unsatisfiable circular dependency.\n", fmt = "\ %s: Symbol `%s' causes overflow in R_X86_64_32 relocation\n"; -# ifndef RESOLVE_CONFLICT_FIND_MAP print_err: -# endif strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf (fmt, RTLD_PROGNAME, strtab + refsym->st_name); } break; -# ifndef RESOLVE_CONFLICT_FIND_MAP /* Not needed for dl-conflict.c. */ case R_X86_64_PC32: value += reloc->r_addend - (ElfW(Addr)) reloc_addr; @@ -502,7 +497,6 @@ and creates an unsatisfiable circular dependency.\n", goto print_err; } break; -# endif case R_X86_64_IRELATIVE: value = map->l_addr + reloc->r_addend; if (__glibc_likely (!skip_ifunc)) |