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/sparc | |
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/sparc')
-rw-r--r-- | sysdeps/sparc/sparc32/dl-machine.h | 52 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/dl-machine.h | 72 |
2 files changed, 6 insertions, 118 deletions
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: |