Skip to content

Commit

Permalink
Revert "Do not create a PLT for an IFUNC unless necessary"
Browse files Browse the repository at this point in the history
This reverts commit 651ae8a because
it broke CI.
  • Loading branch information
rui314 committed Oct 22, 2023
1 parent 651ae8a commit f7dea3a
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 23 deletions.
3 changes: 3 additions & 0 deletions elf/arch-alpha.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {

Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
Error(ctx) << sym << ": GNU ifunc symbol is not supported on Alpha";

switch (rel.r_type) {
case R_ALPHA_REFQUAD:
scan_dyn_absrel(ctx, sym, rel);
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-arm32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

switch (rel.r_type) {
case R_ARM_ABS32:
Expand All @@ -598,7 +598,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_ARM_JUMP24:
case R_ARM_PLT32:
case R_ARM_THM_JUMP24:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_ARM_GOT_PREL:
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
u8 *loc = (u8 *)(contents.data() + rel.r_offset);

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

switch (rel.r_type) {
case R_AARCH64_ABS64:
Expand Down Expand Up @@ -545,7 +545,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
case R_AARCH64_PLT32:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-i386.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
u8 *loc = (u8 *)(contents.data() + rel.r_offset);

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

if (rel.r_type == R_386_TLS_GD || rel.r_type == R_386_TLS_LDM) {
if (i + 1 == rels.size())
Expand Down Expand Up @@ -528,7 +528,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
}
break;
case R_386_PLT32:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_386_TLS_GOTIE:
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-loongarch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
}

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

switch (rel.r_type) {
case R_LARCH_32:
Expand All @@ -583,7 +583,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
break;
case R_LARCH_B26:
case R_LARCH_PCALA_HI20:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_LARCH_GOT_HI20:
Expand Down
3 changes: 3 additions & 0 deletions elf/arch-m68k.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {

Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
Error(ctx) << sym << ": GNU ifunc symbol is not supported on m68k";

switch (rel.r_type) {
case R_68K_32:
scan_dyn_absrel(ctx, sym, rel);
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-ppc32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

switch (rel.r_type) {
case R_PPC_ADDR32:
Expand Down Expand Up @@ -374,7 +374,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_PPC_REL24:
case R_PPC_PLTREL24:
case R_PPC_PLTREL32:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_PPC_GOT_TLSGD16:
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-ppc64v1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT | NEEDS_PPC_OPD;
sym.flags |= NEEDS_GOT | NEEDS_PLT | NEEDS_PPC_OPD;

// Any relocation except R_PPC64_REL24 is considered as an
// address-taking relocation.
Expand All @@ -364,7 +364,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
sym.flags |= NEEDS_GOTTP;
break;
case R_PPC64_REL24:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_PPC64_PLT16_HA:
Expand Down
6 changes: 3 additions & 3 deletions elf/arch-ppc64v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

switch (rel.r_type) {
case R_PPC64_ADDR64:
Expand All @@ -424,11 +424,11 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
sym.flags |= NEEDS_GOTTP;
break;
case R_PPC64_REL24:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_PPC64_REL24_NOTOC:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
ctx.extra.is_power10 = true;
break;
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-riscv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

switch (rel.r_type) {
case R_RISCV_32:
Expand All @@ -747,7 +747,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_RISCV_CALL:
case R_RISCV_CALL_PLT:
case R_RISCV_PLT32:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_RISCV_GOT_HI20:
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-s390x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

switch (rel.r_type) {
case R_390_64:
Expand Down Expand Up @@ -445,7 +445,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_390_PLTOFF16:
case R_390_PLTOFF32:
case R_390_PLTOFF64:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_390_TLS_GOTIE20:
Expand Down
3 changes: 3 additions & 0 deletions elf/arch-sh4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {

Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
Error(ctx) << sym << ": GNU ifunc symbol is not supported on sh4";

switch (rel.r_type) {
case R_SH_DIR32:
scan_dyn_absrel(ctx, sym, rel);
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-sparc64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
Symbol<E> &sym = *file.symbols[rel.r_sym];

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

switch (rel.r_type) {
case R_SPARC_64:
Expand Down Expand Up @@ -527,7 +527,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_SPARC_PCPLT22:
case R_SPARC_PCPLT10:
case R_SPARC_PLT64:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_SPARC_GOT13:
Expand Down
4 changes: 2 additions & 2 deletions elf/arch-x86-64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
u8 *loc = (u8 *)(contents.data() + rel.r_offset);

if (sym.is_ifunc())
sym.flags |= NEEDS_GOT;
sym.flags |= NEEDS_GOT | NEEDS_PLT;

if (rel.r_type == R_X86_64_TLSGD || rel.r_type == R_X86_64_TLSLD) {
if (i + 1 == rels.size())
Expand Down Expand Up @@ -707,7 +707,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
break;
case R_X86_64_PLT32:
case R_X86_64_PLTOFF64:
if (sym.is_imported || sym.is_ifunc())
if (sym.is_imported)
sym.flags |= NEEDS_PLT;
break;
case R_X86_64_TLSGD:
Expand Down

0 comments on commit f7dea3a

Please sign in to comment.