Index: lld/trunk/ELF/SyntheticSections.cpp =================================================================== --- lld/trunk/ELF/SyntheticSections.cpp +++ lld/trunk/ELF/SyntheticSections.cpp @@ -1218,6 +1218,25 @@ entries.push_back({tag, [=] { return sym->getVA(); }}); } +// The output section .rela.dyn may include these synthetic sections: +// +// - part.relaDyn +// - in.relaIplt: this is included if in.relaIplt is named .rela.dyn +// - in.relaPlt: this is included if a linker script places .rela.plt inside +// .rela.dyn +// +// DT_RELASZ is the total size of the included sections. +static std::function addRelaSz(RelocationBaseSection *relaDyn) { + return [=]() { + size_t size = relaDyn->getSize(); + if (in.relaIplt->getParent() == relaDyn->getParent()) + size += in.relaIplt->getSize(); + if (in.relaPlt->getParent() == relaDyn->getParent()) + size += in.relaPlt->getSize(); + return size; + }; +} + // A Linker script may assign the RELA relocation sections to the same // output section. When this occurs we cannot just use the OutputSection // Size. Moreover the [DT_JMPREL, DT_JMPREL + DT_PLTRELSZ) is permitted to @@ -1306,9 +1325,11 @@ if (OutputSection *sec = part.dynStrTab->getParent()) this->link = sec->sectionIndex; - if (part.relaDyn->isNeeded()) { + if (part.relaDyn->isNeeded() || + (in.relaIplt->isNeeded() && + part.relaDyn->getParent() == in.relaIplt->getParent())) { addInSec(part.relaDyn->dynamicTag, part.relaDyn); - addSize(part.relaDyn->sizeDynamicTag, part.relaDyn->getParent()); + entries.push_back({part.relaDyn->sizeDynamicTag, addRelaSz(part.relaDyn)}); bool isRela = config->isRela; addInt(isRela ? DT_RELAENT : DT_RELENT, Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -355,6 +355,8 @@ add(sec); } + StringRef relaDynName = config->isRela ? ".rela.dyn" : ".rel.dyn"; + for (Partition &part : partitions) { auto add = [&](InputSectionBase *sec) { sec->partition = part.getNumber(); @@ -378,13 +380,11 @@ part.dynStrTab = make(".dynstr", true); part.dynSymTab = make>(*part.dynStrTab); part.dynamic = make>(); - if (config->androidPackDynRelocs) { - part.relaDyn = make>( - config->isRela ? ".rela.dyn" : ".rel.dyn"); - } else { - part.relaDyn = make>( - config->isRela ? ".rela.dyn" : ".rel.dyn", config->zCombreloc); - } + if (config->androidPackDynRelocs) + part.relaDyn = make>(relaDynName); + else + part.relaDyn = + make>(relaDynName, config->zCombreloc); if (needsInterpSection()) add(createInterpSection()); @@ -504,16 +504,14 @@ config->isRela ? ".rela.plt" : ".rel.plt", /*sort=*/false); add(in.relaPlt); - // The relaIplt immediately follows .rel.plt (.rel.dyn for ARM) to ensure - // that the IRelative relocations are processed last by the dynamic loader. - // We cannot place the iplt section in .rel.dyn when Android relocation - // packing is enabled because that would cause a section type mismatch. - // However, because the Android dynamic loader reads .rel.plt after .rel.dyn, - // we can get the desired behaviour by placing the iplt section in .rel.plt. + // The relaIplt immediately follows .rel[a].dyn to ensure that the IRelative + // relocations are processed last by the dynamic loader. We cannot place the + // iplt section in .rel.dyn when Android relocation packing is enabled because + // that would cause a section type mismatch. However, because the Android + // dynamic loader reads .rel.plt after .rel.dyn, we can get the desired + // behaviour by placing the iplt section in .rel.plt. in.relaIplt = make>( - (config->emachine == EM_ARM && !config->androidPackDynRelocs) - ? ".rel.dyn" - : in.relaPlt->name, + config->androidPackDynRelocs ? in.relaPlt->name : relaDynName, /*sort=*/false); add(in.relaIplt); @@ -1070,7 +1068,7 @@ ElfSym::globalOffsetTable->section = gotSection; } - // .rela_iplt_{start,end} mark the start and the end of .rela.plt section. + // .rela_iplt_{start,end} mark the start and the end of in.relaIplt. if (ElfSym::relaIpltStart && in.relaIplt->isNeeded()) { ElfSym::relaIpltStart->section = in.relaIplt; ElfSym::relaIpltEnd->section = in.relaIplt; Index: lld/trunk/test/ELF/aarch64-gnu-ifunc-nonpreemptable.s =================================================================== --- lld/trunk/test/ELF/aarch64-gnu-ifunc-nonpreemptable.s +++ lld/trunk/test/ELF/aarch64-gnu-ifunc-nonpreemptable.s @@ -48,7 +48,7 @@ ## The adrp to myfunc should generate a PLT entry and a GOT entry with an ## irelative relocation. -# PDE-RELOC: .rela.plt { +# PDE-RELOC: .rela.dyn { # PDE-RELOC-NEXT: 0x220000 R_AARCH64_IRELATIVE - 0x210000 # PDE-RELOC-NEXT: } @@ -67,6 +67,6 @@ # PIE-NEXT: 10018: add x16, x16, #0 # PIE-NEXT: 1001c: br x17 -# PIE-RELOC: .rela.plt { +# PIE-RELOC: .rela.dyn { # PIE-RELOC-NEXT: 0x30000 R_AARCH64_IRELATIVE - 0x10000 # PIE-RELOC-NEXT: } Index: lld/trunk/test/ELF/aarch64-gnu-ifunc-plt.s =================================================================== --- lld/trunk/test/ELF/aarch64-gnu-ifunc-plt.s +++ lld/trunk/test/ELF/aarch64-gnu-ifunc-plt.s @@ -9,12 +9,14 @@ // Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt // CHECK: Relocations [ -// CHECK-NEXT: Section (4) .rela.plt { -// CHECK: 0x230018 R_AARCH64_JUMP_SLOT bar2 0x0 -// CHECK-NEXT: 0x230020 R_AARCH64_JUMP_SLOT zed2 0x0 +// CHECK-NEXT: Section (4) .rela.dyn { // CHECK-NEXT: 0x230028 R_AARCH64_IRELATIVE - 0x210000 // CHECK-NEXT: 0x230030 R_AARCH64_IRELATIVE - 0x210004 // CHECK-NEXT: } +// CHECK-NEXT: Section (5) .rela.plt { +// CHECK-NEXT: 0x230018 R_AARCH64_JUMP_SLOT bar2 0x0 +// CHECK-NEXT: 0x230020 R_AARCH64_JUMP_SLOT zed2 0x0 +// CHECK-NEXT: } // CHECK-NEXT: ] // Check that .got.plt entries point back to PLT header @@ -24,9 +26,10 @@ // GOTPLT-NEXT: 230020 20002100 00000000 20002100 00000000 // GOTPLT-NEXT: 230030 20002100 00000000 -// Check that the PLTRELSZ tag includes the IRELATIVE relocations +// Check that the PLTRELSZ tag does not include the IRELATIVE relocations // CHECK: DynamicSection [ -// CHECK: 0x0000000000000002 PLTRELSZ 96 (bytes) +// CHECK: 0x0000000000000008 RELASZ 48 (bytes) +// CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes) // Check that a PLT header is written and the ifunc entries appear last // DISASM: Disassembly of section .text: Index: lld/trunk/test/ELF/aarch64-gnu-ifunc.s =================================================================== --- lld/trunk/test/ELF/aarch64-gnu-ifunc.s +++ lld/trunk/test/ELF/aarch64-gnu-ifunc.s @@ -7,7 +7,7 @@ // CHECK: Sections [ // CHECK: Section { // CHECK: Index: 1 -// CHECK-NEXT: Name: .rela.plt +// CHECK-NEXT: Name: .rela.dyn // CHECK-NEXT: Type: SHT_RELA // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC @@ -21,7 +21,7 @@ // CHECK-NEXT: EntrySize: 24 // CHECK-NEXT: } // CHECK: Relocations [ -// CHECK-NEXT: Section ({{.*}}) .rela.plt { +// CHECK-NEXT: Section ({{.*}}) .rela.dyn { // CHECK-NEXT: 0x220000 R_AARCH64_IRELATIVE // CHECK-NEXT: 0x220008 R_AARCH64_IRELATIVE // CHECK-NEXT: } @@ -54,7 +54,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: .rela.plt +// CHECK-NEXT: Section: .rela.dyn // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: __rela_iplt_start @@ -65,7 +65,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: .rela.plt +// CHECK-NEXT: Section: .rela.dyn // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _start Index: lld/trunk/test/ELF/aarch64-gnu-ifunc2.s =================================================================== --- lld/trunk/test/ELF/aarch64-gnu-ifunc2.s +++ lld/trunk/test/ELF/aarch64-gnu-ifunc2.s @@ -28,7 +28,7 @@ # SEC: .got.plt PROGBITS 0000000000220000 020000 000008 00 WA 0 0 8 # RELOC: Relocations [ -# RELOC-NEXT: Section {{.*}} .rela.plt { +# RELOC-NEXT: Section {{.*}} .rela.dyn { # RELOC-NEXT: 0x220000 R_AARCH64_IRELATIVE - 0x210000 # RELOC-NEXT: } # RELOC-NEXT: ] Index: lld/trunk/test/ELF/gnu-ifunc-canon.s =================================================================== --- lld/trunk/test/ELF/gnu-ifunc-canon.s +++ lld/trunk/test/ELF/gnu-ifunc-canon.s @@ -34,14 +34,14 @@ // Two relocs, one for the GOT and the other for .data. // IREL2-NOT: R_X86_64_ -// IREL2: .rela.plt +// IREL2: .rela.dyn // IREL2-NEXT: R_X86_64_IRELATIVE // IREL2-NEXT: R_X86_64_IRELATIVE // IREL2-NOT: R_X86_64_ // One reloc for the canonical PLT. // IREL1-NOT: R_X86_64_ -// IREL1: .rela.plt +// IREL1: .rela.dyn // IREL1-NEXT: R_X86_64_IRELATIVE // IREL1-NOT: R_X86_64_ @@ -51,7 +51,6 @@ // IREL1-REL2: .rela.dyn // IREL1-REL2-NEXT: R_X86_64_RELATIVE // IREL1-REL2-NEXT: R_X86_64_RELATIVE -// IREL1-REL2: .rela.plt // IREL1-REL2-NEXT: R_X86_64_IRELATIVE // IREL1-REL2-NOT: R_X86_64_ @@ -62,7 +61,6 @@ // IREL1-REL3-NEXT: R_X86_64_RELATIVE // IREL1-REL3-NEXT: R_X86_64_RELATIVE // IREL1-REL3-NEXT: R_X86_64_RELATIVE -// IREL1-REL3: .rela.plt // IREL1-REL3-NEXT: R_X86_64_IRELATIVE // IREL1-REL3-NOT: R_X86_64_ Index: lld/trunk/test/ELF/gnu-ifunc-dyntags.s =================================================================== --- lld/trunk/test/ELF/gnu-ifunc-dyntags.s +++ lld/trunk/test/ELF/gnu-ifunc-dyntags.s @@ -8,19 +8,21 @@ ## when there are no other relocations except R_*_IRELATIVE. # CHECK: Name Size VMA -# CHECK: .rela.plt 00000030 0000000000000248 +# CHECK: .rela.dyn 00000030 0000000000000248 # CHECK: .got.plt 00000010 0000000000003000 # TAGS: Relocations [ -# TAGS-NEXT: Section {{.*}} .rela.plt { +# TAGS-NEXT: Section {{.*}} .rela.dyn { # TAGS-NEXT: R_X86_64_IRELATIVE # TAGS-NEXT: R_X86_64_IRELATIVE # TAGS-NEXT: } # TAGS-NEXT: ] # TAGS: Tag Type Name/Value -# TAGS: 0x0000000000000017 JMPREL 0x248 -# TAGS: 0x0000000000000002 PLTRELSZ 48 +# TAGS: 0x0000000000000007 RELA 0x248 +# TAGS: 0x0000000000000008 RELASZ 48 (bytes) +# TAGS: 0x0000000000000017 JMPREL 0x0 +# TAGS: 0x0000000000000002 PLTRELSZ 0 (bytes) # TAGS: 0x0000000000000003 PLTGOT 0x3000 # TAGS: 0x0000000000000014 PLTREL RELA Index: lld/trunk/test/ELF/gnu-ifunc-i386.s =================================================================== --- lld/trunk/test/ELF/gnu-ifunc-i386.s +++ lld/trunk/test/ELF/gnu-ifunc-i386.s @@ -7,7 +7,7 @@ // CHECK: Sections [ // CHECK: Section { // CHECK: Index: 1 -// CHECK-NEXT: Name: .rel.plt +// CHECK-NEXT: Name: .rel.dyn // CHECK-NEXT: Type: SHT_REL // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC @@ -21,7 +21,7 @@ // CHECK-NEXT: EntrySize: 8 // CHECK-NEXT: } // CHECK: Relocations [ -// CHECK-NEXT: Section ({{.*}}) .rel.plt { +// CHECK-NEXT: Section ({{.*}}) .rel.dyn { // CHECK-NEXT: 0x402000 R_386_IRELATIVE // CHECK-NEXT: 0x402004 R_386_IRELATIVE // CHECK-NEXT: } @@ -46,7 +46,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: .rel.plt +// CHECK-NEXT: Section: .rel.dyn // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: __rel_iplt_start @@ -57,7 +57,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: .rel.plt +// CHECK-NEXT: Section: .rel.dyn // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _start Index: lld/trunk/test/ELF/gnu-ifunc-plt-i386.s =================================================================== --- lld/trunk/test/ELF/gnu-ifunc-plt-i386.s +++ lld/trunk/test/ELF/gnu-ifunc-plt-i386.s @@ -9,11 +9,14 @@ // Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt // CHECK: Relocations [ -// CHECK-NEXT: Section (4) .rel.plt { -// CHECK-NEXT: 0x40300C R_386_JUMP_SLOT bar2 -// CHECK-NEXT: 0x403010 R_386_JUMP_SLOT zed2 +// CHECK-NEXT: Section (4) .rel.dyn { // CHECK-NEXT: 0x403014 R_386_IRELATIVE // CHECK-NEXT: 0x403018 R_386_IRELATIVE +// CHECK-NEXT: } +// CHECK-NEXT: Section (5) .rel.plt { +// CHECK-NEXT: 0x40300C R_386_JUMP_SLOT bar2 +// CHECK-NEXT: 0x403010 R_386_JUMP_SLOT zed2 +// CHECK-NEXT: } // Check that IRELATIVE .got.plt entries point to ifunc resolver and not // back to the plt entry + 6. @@ -21,9 +24,10 @@ // GOTPLT: 403000 00204000 00000000 00000000 36104000 // GOTPLT-NEXT: 403010 46104000 00104000 01104000 -// Check that the PLTRELSZ tag includes the IRELATIVE relocations +// Check that the PLTRELSZ tag does not include the IRELATIVE relocations // CHECK: DynamicSection [ -// CHECK: 0x00000002 PLTRELSZ 32 (bytes) +// CHECK: 0x00000012 RELSZ 16 (bytes) +// CHECK: 0x00000002 PLTRELSZ 16 (bytes) // Check that a PLT header is written and the ifunc entries appear last // DISASM: Disassembly of section .text: Index: lld/trunk/test/ELF/gnu-ifunc-plt.s =================================================================== --- lld/trunk/test/ELF/gnu-ifunc-plt.s +++ lld/trunk/test/ELF/gnu-ifunc-plt.s @@ -9,11 +9,14 @@ // Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt // CHECK: Relocations [ -// CHECK-NEXT: Section (4) .rela.plt { -// CHECK-NEXT: 0x203018 R_X86_64_JUMP_SLOT bar2 0x0 -// CHECK-NEXT: 0x203020 R_X86_64_JUMP_SLOT zed2 0x0 +// CHECK-NEXT: Section (4) .rela.dyn { // CHECK-NEXT: 0x203028 R_X86_64_IRELATIVE - 0x201000 // CHECK-NEXT: 0x203030 R_X86_64_IRELATIVE - 0x201001 +// CHECK-NEXT: } +// CHECK-NEXT: Section (5) .rela.plt { +// CHECK-NEXT: 0x203018 R_X86_64_JUMP_SLOT bar2 0x0 +// CHECK-NEXT: 0x203020 R_X86_64_JUMP_SLOT zed2 0x0 +// CHECK-NEXT: } // Check that .got.plt entries point back to PLT header // GOTPLT: Contents of section .got.plt: @@ -22,9 +25,10 @@ // GOTPLT-NEXT: 203020 46102000 00000000 56102000 00000000 // GOTPLT-NEXT: 203030 66102000 00000000 -// Check that the PLTRELSZ tag includes the IRELATIVE relocations +// Check that the PLTRELSZ tag does not include the IRELATIVE relocations // CHECK: DynamicSection [ -// CHECK: 0x0000000000000002 PLTRELSZ 96 (bytes) +// CHECK: 0x0000000000000008 RELASZ 48 (bytes) +// CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes) // Check that a PLT header is written and the ifunc entries appear last // DISASM: Disassembly of section .text: Index: lld/trunk/test/ELF/gnu-ifunc-relative.s =================================================================== --- lld/trunk/test/ELF/gnu-ifunc-relative.s +++ lld/trunk/test/ELF/gnu-ifunc-relative.s @@ -14,7 +14,7 @@ _start: call foo -// CHECK: Section ({{.*}}) .rela.plt { +// CHECK: Section ({{.*}}) .rela.dyn { // CHECK-NEXT: R_X86_64_IRELATIVE - 0x[[ADDR:.*]] // CHECK-NEXT: } Index: lld/trunk/test/ELF/gnu-ifunc-shared.s =================================================================== --- lld/trunk/test/ELF/gnu-ifunc-shared.s +++ lld/trunk/test/ELF/gnu-ifunc-shared.s @@ -41,10 +41,13 @@ // DISASM-NEXT: 105b: e9 e0 ff ff ff jmp -32 // CHECK: Relocations [ -// CHECK-NEXT: Section (4) .rela.plt { +// CHECK-NEXT: Section (4) .rela.dyn { +// CHECK-NEXT: 0x3028 R_X86_64_IRELATIVE - 0x1000 +// CHECK-NEXT: } +// CHECK-NEXT: Section (5) .rela.plt { // CHECK-NEXT: 0x3018 R_X86_64_JUMP_SLOT fct2 0x0 // CHECK-NEXT: 0x3020 R_X86_64_JUMP_SLOT f2 0x0 -// CHECK-NEXT: 0x3028 R_X86_64_IRELATIVE - 0x1000 +// CHECK-NEXT: } // Hidden expect IRELATIVE .globl fct Index: lld/trunk/test/ELF/gnu-ifunc.s =================================================================== --- lld/trunk/test/ELF/gnu-ifunc.s +++ lld/trunk/test/ELF/gnu-ifunc.s @@ -7,7 +7,7 @@ // CHECK: Sections [ // CHECK: Section { // CHECK: Index: 1 -// CHECK-NEXT: Name: .rela.plt +// CHECK-NEXT: Name: .rela.dyn // CHECK-NEXT: Type: SHT_RELA // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC @@ -23,7 +23,7 @@ // CHECK: Index: [[GOTPLT]] // CHECK-NEXT: Name: .got.plt // CHECK: Relocations [ -// CHECK-NEXT: Section ({{.*}}) .rela.plt { +// CHECK-NEXT: Section ({{.*}}) .rela.dyn { // CHECK-NEXT: 0x202000 R_X86_64_IRELATIVE // CHECK-NEXT: 0x202008 R_X86_64_IRELATIVE // CHECK-NEXT: } @@ -47,7 +47,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: .rela.plt +// CHECK-NEXT: Section: .rela.dyn // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: __rela_iplt_start @@ -58,7 +58,7 @@ // CHECK-NEXT: Other [ // CHECK-NEXT: STV_HIDDEN // CHECK-NEXT: ] -// CHECK-NEXT: Section: .rela.plt +// CHECK-NEXT: Section: .rela.dyn // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: _start Index: lld/trunk/test/ELF/linkerscript/orphan-report.s =================================================================== --- lld/trunk/test/ELF/linkerscript/orphan-report.s +++ lld/trunk/test/ELF/linkerscript/orphan-report.s @@ -32,7 +32,7 @@ # REPORT-NEXT: :(.got.plt) is being placed in '.got.plt' # REPORT-NEXT: :(.got.plt) is being placed in '.got.plt' # REPORT-NEXT: :(.rela.plt) is being placed in '.rela.plt' -# REPORT-NEXT: :(.rela.plt) is being placed in '.rela.plt' +# REPORT-NEXT: :(.rela.dyn) is being placed in '.rela.dyn' # REPORT-NEXT: :(.plt) is being placed in '.plt' # REPORT-NEXT: :(.plt) is being placed in '.plt' # REPORT-NEXT: :(.symtab) is being placed in '.symtab' Index: lld/trunk/test/ELF/ppc32-gnu-ifunc-nonpreemptable.s =================================================================== --- lld/trunk/test/ELF/ppc32-gnu-ifunc-nonpreemptable.s +++ lld/trunk/test/ELF/ppc32-gnu-ifunc-nonpreemptable.s @@ -6,7 +6,7 @@ # RUN: llvm-readelf -x .got2 %t | FileCheck --check-prefix=HEX %s # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s -# RELOC: .rela.plt { +# RELOC: .rela.dyn { # RELOC-NEXT: 0x10020004 R_PPC_IRELATIVE - 0x10010000 # RELOC-NEXT: } Index: lld/trunk/test/ELF/ppc32-gnu-ifunc.s =================================================================== --- lld/trunk/test/ELF/ppc32-gnu-ifunc.s +++ lld/trunk/test/ELF/ppc32-gnu-ifunc.s @@ -5,11 +5,11 @@ # RUN: llvm-readelf -S -s %t | FileCheck --check-prefixes=SEC,SYM %s # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s -# RELOC: .rela.plt { +# RELOC: .rela.dyn { # RELOC-NEXT: 0x10020000 R_PPC_IRELATIVE - 0x10010000 # RELOC-NEXT: } -# SEC: .rela.plt RELA 100000d4 0000d4 00000c +# SEC: .rela.dyn RELA 100000d4 0000d4 00000c # SYM: 10010000 0 FUNC GLOBAL DEFAULT {{.*}} func # CHECK: func_resolver: Index: lld/trunk/test/ELF/ppc64-ifunc.s =================================================================== --- lld/trunk/test/ELF/ppc64-ifunc.s +++ lld/trunk/test/ELF/ppc64-ifunc.s @@ -5,14 +5,14 @@ # RUN: llvm-nm %t | FileCheck --check-prefix=NM %s # RUN: llvm-readelf -S %t | FileCheck --check-prefix=SECTIONS %s # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s -# RUN: llvm-readelf -r %t | FileCheck --check-prefix=DYNREL %s +# RUN: llvm-readobj -r %t | FileCheck --check-prefix=REL %s # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o # RUN: ld.lld %t.o -o %t # RUN: llvm-nm %t | FileCheck --check-prefix=NM %s # RUN: llvm-readelf -S %t | FileCheck --check-prefix=SECTIONS %s # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s -# RUN: llvm-readelf -r %t | FileCheck --check-prefix=DYNREL %s +# RUN: llvm-readobj -r %t | FileCheck --check-prefix=REL %s # NM-DAG: 0000000010028000 d .TOC. # NM-DAG: 0000000010010000 T ifunc @@ -46,9 +46,12 @@ # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr -# Check that we emit 2 R_PPC64_IRELATIVE. -# DYNREL: R_PPC64_IRELATIVE 10010000 -# DYNREL: R_PPC64_IRELATIVE 10010004 +## Check that we emit 2 R_PPC64_IRELATIVE in .rela.dyn. +## glibc powerpc64 does not eagerly resolve R_PPC64_IRELATIVE if they are in .rela.plt. +# REL: .rela.dyn { +# REL-NEXT: 0x10030000 R_PPC64_IRELATIVE - 0x10010000 +# REL-NEXT: 0x10030008 R_PPC64_IRELATIVE - 0x10010004 +# REL-NEXT: } .type ifunc STT_GNU_IFUNC .globl ifunc