diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -3525,8 +3525,8 @@ } ThunkSection::ThunkSection(OutputSection *os, uint64_t off) - : SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 4, - ".text.thunk") { + : SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, + config->emachine == EM_PPC64 ? 16 : 4, ".text.thunk") { this->parent = os; this->outSecOff = off; } diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp --- a/lld/ELF/Thunks.cpp +++ b/lld/ELF/Thunks.cpp @@ -301,7 +301,7 @@ // callee's global entry point into r12 without a save of R2. class PPC64R12SetupStub final : public Thunk { public: - PPC64R12SetupStub(Symbol &dest) : Thunk(dest, 0) {} + PPC64R12SetupStub(Symbol &dest) : Thunk(dest, 0) { alignment = 16; } uint32_t size() override { return 16; } void writeTo(uint8_t *buf) override; void addSymbols(ThunkSection &isec) override; @@ -316,7 +316,7 @@ // 2) Transferring control to the target function through an indirect branch. class PPC64PCRelPLTStub final : public Thunk { public: - PPC64PCRelPLTStub(Symbol &dest) : Thunk(dest, 0) {} + PPC64PCRelPLTStub(Symbol &dest) : Thunk(dest, 0) { alignment = 16; } uint32_t size() override { return 16; } void writeTo(uint8_t *buf) override; void addSymbols(ThunkSection &isec) override; diff --git a/lld/test/ELF/ppc64-bsymbolic-toc-restore.s b/lld/test/ELF/ppc64-bsymbolic-toc-restore.s --- a/lld/test/ELF/ppc64-bsymbolic-toc-restore.s +++ b/lld/test/ELF/ppc64-bsymbolic-toc-restore.s @@ -63,8 +63,10 @@ # CHECK-EMPTY: # CHECK-NEXT: : # CHECK-NEXT: addis 2, 12, 2 -# CHECK-NEXT: addi 2, 2, -32456 +# CHECK-NEXT: addi 2, 2, -32448 # CHECK-NEXT: [[DEF]]: li 3, 55 # CHECK-NEXT: blr +# CHECK-NEXT: trap +# CHECK-NEXT: trap # CHECK-EMPTY: # CHECK-NEXT: 00000000000[[NOT_DEFINED]] <__plt_not_defined>: diff --git a/lld/test/ELF/ppc64-call-reach.s b/lld/test/ELF/ppc64-call-reach.s --- a/lld/test/ELF/ppc64-call-reach.s +++ b/lld/test/ELF/ppc64-call-reach.s @@ -66,19 +66,19 @@ # NEGOFFSET: 10010024: b 0xe010024 # THUNK-LABEL: : -# THUNK: 10010014: bl 0x10010028 -# THUNK: 10010024: b 0x10010038 +# THUNK: 10010014: bl 0x10010030 +# THUNK: 10010024: b 0x10010040 # .branch_lt[0] # THUNK-LABEL: <__long_branch_callee>: -# THUNK-NEXT: 10010028: addis 12, 2, 1 +# THUNK-NEXT: 10010030: addis 12, 2, 1 # THUNK-NEXT: ld 12, -32760(12) # THUNK-NEXT: mtctr 12 # THUNK-NEXT: bctr # .branch_lt[1] # THUNK-LABEL: <__long_branch_tail_callee>: -# THUNK-NEXT: 10010038: addis 12, 2, 1 +# THUNK-NEXT: 10010040: addis 12, 2, 1 # THUNK-NEXT: ld 12, -32752(12) # THUNK-NEXT: mtctr 12 # THUNK-NEXT: bctr diff --git a/lld/test/ELF/ppc64-dtprel.s b/lld/test/ELF/ppc64-dtprel.s --- a/lld/test/ELF/ppc64-dtprel.s +++ b/lld/test/ELF/ppc64-dtprel.s @@ -140,12 +140,12 @@ // The got entry for i is at .got+8*1 = 0x4209e0 // i@dtprel = 1024 - 0x8000 = -31744 = 0xffffffffffff8400 // HEX-LE: section '.got': -// HEX-LE-NEXT: 4209c8 c8894200 00000000 00000000 00000000 -// HEX-LE-NEXT: 4209d8 00000000 00000000 +// HEX-LE-NEXT: 4209d0 d0894200 00000000 00000000 00000000 +// HEX-LE-NEXT: 4209e0 00000000 00000000 // HEX-BE: section '.got': -// HEX-BE-NEXT: 4209c8 00000000 004289c8 00000000 00000000 -// HEX-BE-NEXT: 4209d8 00000000 00000000 +// HEX-BE-NEXT: 4209d0 00000000 004289d0 00000000 00000000 +// HEX-BE-NEXT: 4209e0 00000000 00000000 // Dis: : // Dis: addi 4, 3, -31744 diff --git a/lld/test/ELF/ppc64-ifunc.s b/lld/test/ELF/ppc64-ifunc.s --- a/lld/test/ELF/ppc64-ifunc.s +++ b/lld/test/ELF/ppc64-ifunc.s @@ -16,9 +16,9 @@ # SYM: Value Size Type Bind Vis Ndx # SYM: 0000000010028298 0 NOTYPE LOCAL HIDDEN 4 .TOC. -# SYM: 0000000010010284 0 FUNC GLOBAL DEFAULT 3 ifunc1 +# SYM: 0000000010010288 0 FUNC GLOBAL DEFAULT 3 ifunc1 # SYM: 0000000010010210 0 IFUNC GLOBAL DEFAULT 2 ifunc2 -# SYM: 0000000010010274 0 FUNC GLOBAL DEFAULT 3 ifunc3 +# SYM: 0000000010010278 0 FUNC GLOBAL DEFAULT 3 ifunc3 # SECTIONS: .plt NOBITS 00000000100302a0 0002a0 000018 00 WA 0 0 8 @@ -27,14 +27,14 @@ # CHECK: <_start>: # CHECK-NEXT: addis 2, 12, 2 # CHECK-NEXT: addi 2, 2, -32636 -# CHECK-NEXT: 1001021c: bl 0x1001023c +# CHECK-NEXT: 1001021c: bl 0x10010240 # CHECK-NEXT: ld 2, 24(1) -# CHECK-NEXT: 10010224: bl 0x10010250 +# CHECK-NEXT: 10010224: bl 0x10010254 # CHECK-NEXT: ld 2, 24(1) # CHECK-NEXT: addis 3, 2, -2 -# CHECK-NEXT: addi 3, 3, 32748 +# CHECK-NEXT: addi 3, 3, 32752 # CHECK-NEXT: addis 3, 2, -2 -# CHECK-NEXT: addi 3, 3, 32732 +# CHECK-NEXT: addi 3, 3, 32736 # .plt[0] - .TOC. = 0x100302a0 - 0x10028298 = (1<<16) - 32760 # CHECK: <__plt_ifunc2>: @@ -57,19 +57,19 @@ ## ifunc2 and ifunc3 have the same code sequence as their PLT call stubs. # CHECK: Disassembly of section .glink: # CHECK-EMPTY: -# CHECK-NEXT: 0000000010010264 <.glink>: +# CHECK-NEXT: 0000000010010268 <.glink>: # CHECK-NEXT: addis 12, 2, 1 # CHECK-NEXT: ld 12, -32760(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr # CHECK-EMPTY: -# CHECK-NEXT: 0000000010010274 : +# CHECK-NEXT: 0000000010010278 : # CHECK-NEXT: addis 12, 2, 1 # CHECK-NEXT: ld 12, -32752(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr # CHECK-EMPTY: -# CHECK-NEXT: 0000000010010284 : +# CHECK-NEXT: 0000000010010288 : # CHECK-NEXT: addis 12, 2, 1 # CHECK-NEXT: ld 12, -32744(12) # CHECK-NEXT: mtctr 12 diff --git a/lld/test/ELF/ppc64-local-dynamic.s b/lld/test/ELF/ppc64-local-dynamic.s --- a/lld/test/ELF/ppc64-local-dynamic.s +++ b/lld/test/ELF/ppc64-local-dynamic.s @@ -113,7 +113,7 @@ // Dis: : // Dis: addis 3, 2, 0 // Dis-NEXT: addi 3, 3, -32760 -// Dis-NEXT: bl 0x10058 +// Dis-NEXT: bl 0x10060 // Dis-NEXT: ld 2, 24(1) // Dis-NEXT: addis 3, 3, 0 // Dis-NEXT: lwa 3, -32768(3) diff --git a/lld/test/ELF/ppc64-long-branch-init.s b/lld/test/ELF/ppc64-long-branch-init.s --- a/lld/test/ELF/ppc64-long-branch-init.s +++ b/lld/test/ELF/ppc64-long-branch-init.s @@ -14,6 +14,8 @@ # CHECK-EMPTY: # CHECK-LABEL: <_init>: # CHECK: blr +# CHECK-NEXT: trap +# CHECK-NEXT: trap # CHECK-EMPTY: # CHECK-LABEL: <__long_branch_foo>: diff --git a/lld/test/ELF/ppc64-long-branch-rel14.s b/lld/test/ELF/ppc64-long-branch-rel14.s --- a/lld/test/ELF/ppc64-long-branch-rel14.s +++ b/lld/test/ELF/ppc64-long-branch-rel14.s @@ -17,21 +17,24 @@ # SEC: There are no relocations in this file. # CHECK-LABEL: <_start>: -# CHECK-NEXT: 2000: bt 2, 0x2014 -# CHECK-NEXT: bt+ 2, 0x2014 +# CHECK-NEXT: 2000: bt 2, 0x2020 +# CHECK-NEXT: bt+ 2, 0x2020 # CHECK-NEXT: bf 2, 0xa004 -# CHECK-NEXT: bt 2, 0x2024 +# CHECK-NEXT: bt 2, 0x2030 # CHECK-NEXT: blr +# CHECK-NEXT: trap +# CHECK-NEXT: trap +# CHECK-NEXT: trap # CHECK-EMPTY: # CHECK-NEXT: <__long_branch_high>: -# CHECK-NEXT: 2014: addis 12, 2, 0 +# CHECK-NEXT: 2020: addis 12, 2, 0 # CHECK-NEXT: ld 12, {{.*}}(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr # CHECK-EMPTY: # CHECK-NEXT: <__long_branch_>: -# CHECK-NEXT: 2024: addis 12, 2, 0 +# CHECK-NEXT: 2030: addis 12, 2, 0 # CHECK-NEXT: ld 12, {{.*}}(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr diff --git a/lld/test/ELF/ppc64-long-branch.s b/lld/test/ELF/ppc64-long-branch.s --- a/lld/test/ELF/ppc64-long-branch.s +++ b/lld/test/ELF/ppc64-long-branch.s @@ -19,33 +19,33 @@ # RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s # SEC: Name Type Address Off Size ES Flg Lk Inf Al -# SEC: .got PROGBITS 0000000002002028 2002028 000008 00 WA 0 0 8 -# SEC: .branch_lt PROGBITS 0000000002002030 2002030 000018 00 WA 0 0 8 +# SEC: .got PROGBITS 0000000002002030 2002030 000008 00 WA 0 0 8 +# SEC: .branch_lt PROGBITS 0000000002002038 2002038 000018 00 WA 0 0 8 # SEC: There are no relocations in this file. ## high@localentry (high+8), .text_high+16 and .text_low+8 -# BRANCH-LE: 0x02002030 08200002 00000000 10200002 00000000 -# BRANCH-LE-NEXT: 0x02002040 08200000 00000000 -# BRANCH-BE: 0x02002030 00000000 02002008 00000000 02002010 -# BRANCH-BE-NEXT: 0x02002040 00000000 00002008 +# BRANCH-LE: 0x02002038 08200002 00000000 10200002 00000000 +# BRANCH-LE-NEXT: 0x02002048 08200000 00000000 +# BRANCH-BE: 0x02002038 00000000 02002008 00000000 02002010 +# BRANCH-BE-NEXT: 0x02002048 00000000 00002008 # CHECK: <_start>: -# CHECK-NEXT: 2000: bl 0x2018 -# CHECK-NEXT: bl 0x2018 -# CHECK-NEXT: bl 0x2018 +# CHECK-NEXT: 2000: bl 0x2020 +# CHECK-NEXT: bl 0x2020 +# CHECK-NEXT: bl 0x2020 # CHECK-NEXT: bl 0x2002008 ## &.branch_lt[0] - .TOC. = .branch_lt - (.got+0x8000) = -32760 # CHECK: <__long_branch_high>: -# CHECK-NEXT: 2018: addis 12, 2, 0 +# CHECK-NEXT: 2020: addis 12, 2, 0 # CHECK-NEXT: ld 12, -32760(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr ## &.branch_lt[1] - .TOC. = .branch_lt - (.got+0x8000) = -32752 # CHECK: <__long_branch_>: -# CHECK-NEXT: 2028: addis 12, 2, 0 +# CHECK-NEXT: 2030: addis 12, 2, 0 # CHECK-NEXT: ld 12, -32752(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr @@ -64,11 +64,11 @@ # CHECK-EMPTY: # CHECK-NEXT: : # CHECK-NEXT: 2002000: addis 2, 12, 1 -# CHECK-NEXT: addi 2, 2, -32728 +# CHECK-NEXT: addi 2, 2, -32720 # CHECK-NEXT: bl 0x2008 -# CHECK-NEXT: bl 0x2002014 +# CHECK-NEXT: bl 0x2002020 # CHECK: <__long_branch_>: -# CHECK-NEXT: 2002014: addis 12, 2, 0 +# CHECK-NEXT: 2002020: addis 12, 2, 0 # CHECK-NEXT: ld 12, -32744(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr diff --git a/lld/test/ELF/ppc64-pcrel-call-to-extern.s b/lld/test/ELF/ppc64-pcrel-call-to-extern.s --- a/lld/test/ELF/ppc64-pcrel-call-to-extern.s +++ b/lld/test/ELF/ppc64-pcrel-call-to-extern.s @@ -35,55 +35,55 @@ # SYMBOL: 2: 0000000010010000 0 NOTYPE LOCAL DEFAULT [] 6 caller1 # SYMBOL-NEXT: 3: 0000000010020000 0 NOTYPE LOCAL DEFAULT [] 7 caller2 # SYMBOL-NEXT: 4: 0000000010030000 0 NOTYPE LOCAL DEFAULT [] 8 caller3 -# SYMBOL: 6: 0000000010010008 16 FUNC LOCAL DEFAULT 6 __plt_pcrel_callee_global_stother0 -# SYMBOL-NEXT: 7: 0000000010020008 16 FUNC LOCAL DEFAULT 7 __plt_pcrel_callee_global_stother1 -# SYMBOL-NEXT: 8: 0000000010030008 16 FUNC LOCAL DEFAULT 8 __plt_pcrel_callee_global_TOC +# SYMBOL: 6: 0000000010010010 16 FUNC LOCAL DEFAULT 6 __plt_pcrel_callee_global_stother0 +# SYMBOL-NEXT: 7: 0000000010020010 16 FUNC LOCAL DEFAULT 7 __plt_pcrel_callee_global_stother1 +# SYMBOL-NEXT: 8: 0000000010030010 16 FUNC LOCAL DEFAULT 8 __plt_pcrel_callee_global_TOC # SYMBOL-NEXT: 9: 0000000000000000 0 NOTYPE GLOBAL DEFAULT [] UND callee_global_TOC # SYMBOL-NEXT: 10: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND callee_global_stother0 # SYMBOL-NEXT: 11: 0000000000000000 0 NOTYPE GLOBAL DEFAULT [] UND callee_global_stother1 ## DT_PLTGOT points to .plt -# SEC: .plt NOBITS 0000000010030140 040140 000028 00 WA 0 0 8 -# SEC: 0x0000000000000003 (PLTGOT) 0x10030140 +# SEC: .plt NOBITS 0000000010030148 040148 000028 00 WA 0 0 8 +# SEC: 0x0000000000000003 (PLTGOT) 0x10030148 ## The first 2 entries in the .plt are reserved for the dynamic linkers ## usage. The JMP_SLOT relocations are stored at .plt[2], .plt[3], .plt[4]. ## Check that we emit 3 R_PPC64_JMP_SLOT in .rela.plt. # REL: .rela.plt { -# REL-NEXT: 0x10030150 R_PPC64_JMP_SLOT callee_global_stother0 0x0 -# REL-NEXT: 0x10030158 R_PPC64_JMP_SLOT callee_global_stother1 0x0 -# REL-NEXT: 0x10030160 R_PPC64_JMP_SLOT callee_global_TOC 0x0 +# REL-NEXT: 0x10030158 R_PPC64_JMP_SLOT callee_global_stother0 0x0 +# REL-NEXT: 0x10030160 R_PPC64_JMP_SLOT callee_global_stother1 0x0 +# REL-NEXT: 0x10030168 R_PPC64_JMP_SLOT callee_global_TOC 0x0 # REL-NEXT: } # CHECK-LABEL: : -# CHECK: 10010000: bl 0x10010008 +# CHECK: 10010000: bl 0x10010010 # CHECK-NEXT: 10010004: blr -## .plt[2] - 0x10010008 = 0x10030150 - 0x10010008 = 0x20148 = 131400 +## .plt[2] - 0x10010010 = 0x10030158 - 0x10010010 = 0x20148 = 131400 # CHECK-LABEL: <__plt_pcrel_callee_global_stother0>: -# CHECK: 10010008: pld 12, 131400(0), 1 -# CHECK-NEXT: 10010010: mtctr 12 -# CHECK-NEXT: 10010014: bctr +# CHECK: 10010010: pld 12, 131400(0), 1 +# CHECK-NEXT: 10010018: mtctr 12 +# CHECK-NEXT: 1001001c: bctr # CHECK-LABEL: : -# CHECK: 10020000: bl 0x10020008 +# CHECK: 10020000: bl 0x10020010 # CHECK-NEXT: 10020004: blr -## .plt[3] - 0x10020008 = 0x10030158 - 0x10020008 = 0x10150 = 65872 +## .plt[3] - 0x10020010 = 0x10030160 - 0x10020010 = 0x10150 = 65872 # CHECK-LABEL: <__plt_pcrel_callee_global_stother1>: -# CHECK: 10020008: pld 12, 65872(0), 1 -# CHECK-NEXT: 10020010: mtctr 12 -# CHECK-NEXT: 10020014: bctr +# CHECK: 10020010: pld 12, 65872(0), 1 +# CHECK-NEXT: 10020018: mtctr 12 +# CHECK-NEXT: 1002001c: bctr # CHECK-LABEL: : -# CHECK: 10030000: bl 0x10030008 +# CHECK: 10030000: bl 0x10030010 # CHECK-NEXT: 10030004: blr -## .plt[4] - 0x10030008 = 0x10030160 - 0x10030008 = 0x158 = 344 +## .plt[4] - 0x10030010 = 0x10030168 - 0x10030010 = 0x150 = 344 # CHECK-LABEL: <__plt_pcrel_callee_global_TOC>: -# CHECK: 10030008: pld 12, 344(0), 1 -# CHECK-NEXT: 10030010: mtctr 12 -# CHECK-NEXT: 10030014: bctr +# CHECK: 10030010: pld 12, 344(0), 1 +# CHECK-NEXT: 10030018: mtctr 12 +# CHECK-NEXT: 1003001c: bctr .ifdef AUX .section .text_caller1, "ax", %progbits diff --git a/lld/test/ELF/ppc64-pcrel-call-to-toc.s b/lld/test/ELF/ppc64-pcrel-call-to-toc.s --- a/lld/test/ELF/ppc64-pcrel-call-to-toc.s +++ b/lld/test/ELF/ppc64-pcrel-call-to-toc.s @@ -21,7 +21,7 @@ # SYMBOL: 1: 0000000010020000 0 NOTYPE LOCAL DEFAULT [] 2 callee # SYMBOL-NEXT: 2: 0000000010030000 0 NOTYPE LOCAL DEFAULT [] 3 caller # SYMBOL-NEXT: 3: 0000000010010000 0 NOTYPE LOCAL DEFAULT 1 func -# SYMBOL: 6: 000000001003000c 16 FUNC LOCAL DEFAULT 3 __gep_setup_callee +# SYMBOL: 6: 0000000010030010 16 FUNC LOCAL DEFAULT 3 __gep_setup_callee # CHECK-LABEL: : # CHECK-NEXT: blr @@ -33,11 +33,11 @@ # CHECK-NEXT: blr # CHECK-LABEL: : -# CHECK-NEXT: bl 0x1003000c +# CHECK-NEXT: bl 0x10030010 # CHECK-NEXT: blr # CHECK-LABEL: <__gep_setup_callee>: -# CHECK-NEXT: paddi 12, 0, -65548, 1 +# CHECK-NEXT: paddi 12, 0, -65552, 1 # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr diff --git a/lld/test/ELF/ppc64-plt-stub-compatible.s b/lld/test/ELF/ppc64-plt-stub-compatible.s --- a/lld/test/ELF/ppc64-plt-stub-compatible.s +++ b/lld/test/ELF/ppc64-plt-stub-compatible.s @@ -29,16 +29,16 @@ # T2-LABEL: : # T2-NEXT: 10010300: addis 2, 12, 1 -# T2-NEXT: 10010304: addi 2, 2, -32392 +# T2-NEXT: 10010304: addi 2, 2, -32384 # T2-NEXT: 10010308: addis 4, 2, -1 -# T2-NEXT: 1001030c: lwa 3, 32436(4) +# T2-NEXT: 1001030c: lwa 3, 32428(4) # T2-NEXT: 10010310: bl 0x10010330 # T2-NEXT: 10010314: ld 2, 24(1) # T2-NEXT: 10010318: blr # T2-LABEL: : # T2-NEXT: 1001031c: plwa 3, 16(0), 1 -# T2-NEXT: 10010324: bl 0x10010344 +# T2-NEXT: 10010324: bl 0x10010350 # T2-NEXT: 10010328: blr # T2-LABEL: <__plt_callee>: @@ -49,9 +49,9 @@ # T2-NEXT: 10010340: bctr # T2-LABEL: <__plt_pcrel_callee>: -# T2-NEXT: 10010344: pld 12, 332(0), 1 -# T2-NEXT: 1001034c: mtctr 12 -# T2-NEXT: 10010350: bctr +# T2-NEXT: 10010350: pld 12, 328(0), 1 +# T2-NEXT: 10010358: mtctr 12 +# T2-NEXT: 1001035c: bctr .ifdef T2 .section .text_start, "ax", %progbits p9codegen: diff --git a/lld/test/ELF/ppc64-plt-stub.s b/lld/test/ELF/ppc64-plt-stub.s --- a/lld/test/ELF/ppc64-plt-stub.s +++ b/lld/test/ELF/ppc64-plt-stub.s @@ -15,8 +15,8 @@ # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s ## DT_PLTGOT points to .plt -# SEC: .plt NOBITS 00000000100303e8 0003e8 000018 -# SEC: 0x0000000000000003 (PLTGOT) 0x100303e8 +# SEC: .plt NOBITS 00000000100303f0 0003f0 000018 +# SEC: 0x0000000000000003 (PLTGOT) 0x100303f0 ## .plt[0] holds the address of _dl_runtime_resolve. ## .plt[1] holds the link map. @@ -24,9 +24,9 @@ # RELOC: 0x10030010 R_PPC64_JMP_SLOT foo 0x0 # CHECK: <_start>: -# CHECK: 10010298: bl 0x100102a8 +# CHECK: 10010298: bl 0x100102b0 -# CHECK-LABEL: 00000000100102a8 <__plt_foo>: +# CHECK-LABEL: 00000000100102b0 <__plt_foo>: # CHECK-NEXT: std 2, 24(1) # CHECK-NEXT: addis 12, 2, 1 # CHECK-NEXT: ld 12, -32744(12) diff --git a/lld/test/ELF/ppc64-thunk-alignment.s b/lld/test/ELF/ppc64-thunk-alignment.s new file mode 100644 --- /dev/null +++ b/lld/test/ELF/ppc64-thunk-alignment.s @@ -0,0 +1,107 @@ +# REQUIRES: ppc +# RUN: echo 'SECTIONS { \ +# RUN: .text_start 0x10010300 : { *(.text_start) } \ +# RUN: }' > %t.script + +# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s --defsym T1=1 -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s --defsym T2=1 -o %t2.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s --defsym T3=1 -o %t3.o +# RUN: ld.lld --shared %t1.o -o %t1.so +# RUN: ld.lld -T %t.script %t1.so %t2.o -o %t2 +# RUN: ld.lld -T %t.script %t1.so %t3.o -o %t3 +# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t2 | FileCheck %s --check-prefix=T2 +# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t3 | FileCheck %s --check-prefix=T3 + +# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s --defsym T1=1 -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s --defsym T2=1 -o %t2.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s --defsym T3=1 -o %t3.o +# RUN: ld.lld --shared %t1.o -o %t1.so +# RUN: ld.lld -T %t.script %t1.so %t2.o -o %t2 +# RUN: ld.lld -T %t.script %t1.so %t3.o -o %t3 +# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t2 | FileCheck %s --check-prefix=T2 +# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=pwr10 %t3 | FileCheck %s --check-prefix=T3 + +.ifdef T1 +.globl callee +callee: + blr +.endif + +# T2-LABEL: <__plt_callee>: +# T2-NEXT: 10010330: std 2, 24(1) +# T2-NEXT: 10010334: addis 12, 2, 0 +# T2-NEXT: 10010338: ld 12, -32744(12) +# T2-NEXT: 1001033c: mtctr 12 +# T2-NEXT: 10010340: bctr +## start address for "__plt_pcrel_callee" stub 0x10010350 is 16 byte aligned. +# T2-LABEL: <__plt_pcrel_callee>: +# T2-NEXT: 10010350: pld 12, 328(0), 1 +# T2-NEXT: 10010358: mtctr 12 +# T2-NEXT: 1001035c: bctr +.ifdef T2 +.section .text_start, "ax", %progbits +p9codegen: +.Lfunc_gep0: + addis 2, 12, .TOC.-.Lfunc_gep0@ha + addi 2, 2, .TOC.-.Lfunc_gep0@l +.Lfunc_lep0: + .localentry p9codegen, .Lfunc_lep0-.Lfunc_gep0 + addis 4, 2, Global@toc@ha + lwa 3, Global@toc@l(4) + bl callee + nop + blr +p10codegen: + .localentry main, 1 + plwa 3, Global@PCREL(0), 1 + bl callee@notoc + blr +.globl Global +Global: + .long 10 + .size Global, 4 +.endif + +# T3-LABEL: <__plt_callee>: +# T3-NEXT: 10010340: std 2, 24(1) +# T3-NEXT: 10010344: addis 12, 2, 0 +# T3-NEXT: 10010348: ld 12, -32744(12) +# T3-NEXT: 1001034c: mtctr 12 +# T3-NEXT: 10010350: bctr +## start address for "__gep_setup_callee_local" stub 0x10010360 is 16 byte aligned. +# T3-LABEL: <__gep_setup_callee_local>: +# T3-NEXT: 10010360: paddi 12, 0, -68, 1 +# T3-NEXT: 10010368: mtctr 12 +# T3-NEXT: 1001036c: bctr +.ifdef T3 +.section .text_start, "ax", %progbits +p9codegen: +.Lfunc_gep0: + addis 2, 12, .TOC.-.Lfunc_gep0@ha + addi 2, 2, .TOC.-.Lfunc_gep0@l +.Lfunc_lep0: + .localentry p9codegen, .Lfunc_lep0-.Lfunc_gep0 + addis 4, 2, Global@toc@ha + lwa 3, Global@toc@l(4) + bl callee + nop + blr + +callee_local: +.Lfunc_gep1: + addis 2, 12, .TOC.-.Lfunc_gep1@ha + addi 2, 2, .TOC.-.Lfunc_gep1@l +.Lfunc_lep1: + .localentry callee_local, .Lfunc_lep1-.Lfunc_gep1 + addis 4, 2, Global@toc@ha + lwz 4, Global@toc@l(4) + blr +p10codegen: + .localentry p10codegen, 1 + bl callee_local@notoc + blr +.globl Global +Global: + .long 10 + .size Global, 4 +.endif diff --git a/lld/test/ELF/ppc64-tls-gd.s b/lld/test/ELF/ppc64-tls-gd.s --- a/lld/test/ELF/ppc64-tls-gd.s +++ b/lld/test/ELF/ppc64-tls-gd.s @@ -16,29 +16,29 @@ # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s # GD-REL: .rela.dyn { -# GD-REL-NEXT: 0x20538 R_PPC64_DTPMOD64 a 0x0 -# GD-REL-NEXT: 0x20540 R_PPC64_DTPREL64 a 0x0 -# GD-REL-NEXT: 0x20548 R_PPC64_DTPMOD64 b 0x0 -# GD-REL-NEXT: 0x20550 R_PPC64_DTPREL64 b 0x0 -# GD-REL-NEXT: 0x20558 R_PPC64_DTPMOD64 c 0x0 -# GD-REL-NEXT: 0x20560 R_PPC64_DTPREL64 c 0x0 +# GD-REL-NEXT: 0x20548 R_PPC64_DTPMOD64 a 0x0 +# GD-REL-NEXT: 0x20550 R_PPC64_DTPREL64 a 0x0 +# GD-REL-NEXT: 0x20558 R_PPC64_DTPMOD64 b 0x0 +# GD-REL-NEXT: 0x20560 R_PPC64_DTPREL64 b 0x0 +# GD-REL-NEXT: 0x20568 R_PPC64_DTPMOD64 c 0x0 +# GD-REL-NEXT: 0x20570 R_PPC64_DTPREL64 c 0x0 # GD-REL-NEXT: } ## &DTPMOD(a) - .TOC. = &.got[0] - (.got+0x8000) = -32768 # GD: addis 3, 2, 0 # GD-NEXT: addi 3, 3, -32768 -# GD-NEXT: bl 0x103f4 +# GD-NEXT: bl 0x10400 # GD-NEXT: ld 2, 24(1) ## &DTPMOD(b) - .TOC. = &.got[2] - (.got+0x8000) = -32752 # GD-NEXT: addis 3, 2, 0 # GD-NEXT: addi 3, 3, -32752 -# GD-NEXT: bl 0x103f4 +# GD-NEXT: bl 0x10400 # GD-NEXT: ld 2, 24(1) ## &DTPMOD(b) - .TOC. = &.got[4] - (.got+0x8000) = -32736 # GD-NEXT: li 3, -32736 -# GD-NEXT: bl 0x103f4 +# GD-NEXT: bl 0x10400 # GD-NEXT: ld 2, 24(1) # NOREL: no relocations diff --git a/lld/test/ELF/ppc64-toc-call-to-pcrel.s b/lld/test/ELF/ppc64-toc-call-to-pcrel.s --- a/lld/test/ELF/ppc64-toc-call-to-pcrel.s +++ b/lld/test/ELF/ppc64-toc-call-to-pcrel.s @@ -21,18 +21,18 @@ # SYMBOL: 10010000 0 NOTYPE LOCAL DEFAULT [] 1 callee # SYMBOL: 10020000 0 NOTYPE LOCAL DEFAULT [] 2 caller # SYMBOL: 10020020 0 NOTYPE LOCAL DEFAULT [] 2 caller_14 -# SYMBOL: 1002003c 8 FUNC LOCAL DEFAULT 2 __toc_save_callee +# SYMBOL: 10020040 8 FUNC LOCAL DEFAULT 2 __toc_save_callee # CHECK-LABEL: callee # CHECK: blr # CHECK-LABEL: caller -# CHECK: bl 0x1002003c +# CHECK: bl 0x10020040 # CHECK-NEXT: ld 2, 24(1) # CHECK-NEXT: blr # CHECK-LABEL: caller_14 -# CHECK: bfl 0, 0x1002003c +# CHECK: bfl 0, 0x10020040 # CHECK-NEXT: ld 2, 24(1) # CHECK-NEXT: blr diff --git a/lld/test/ELF/ppc64-toc-restore-recursive-call.s b/lld/test/ELF/ppc64-toc-restore-recursive-call.s --- a/lld/test/ELF/ppc64-toc-restore-recursive-call.s +++ b/lld/test/ELF/ppc64-toc-restore-recursive-call.s @@ -15,10 +15,10 @@ # with non-recursive calls. # CHECK-LABEL: 0000000000010290 : -# CHECK: 102b8: bl 0x102d8 +# CHECK: 102b8: bl 0x102e0 # CHECK-NEXT: ld 2, 24(1) -# CHECK-LABEL: 00000000000102d8 <__plt_recursive_func>: +# CHECK-LABEL: 00000000000102e0 <__plt_recursive_func>: .abiversion 2 .section ".text" diff --git a/lld/test/ELF/ppc64-toc-restore.s b/lld/test/ELF/ppc64-toc-restore.s --- a/lld/test/ELF/ppc64-toc-restore.s +++ b/lld/test/ELF/ppc64-toc-restore.s @@ -29,7 +29,7 @@ nop bl bar_local // CHECK-LABEL: <_start>: -// CHECK-NEXT: 100102c8: bl 0x10010304 +// CHECK-NEXT: 100102c8: bl 0x10010310 // CHECK-NEXT: 100102cc: ld 2, 24(1) // CHECK-NEXT: 100102d0: bl 0x100102c0 // CHECK-EMPTY: @@ -61,5 +61,5 @@ bl foo nop // CHECK-LABEL: : -// CHECK-NEXT: 100102e4: bl 0x10010304 +// CHECK-NEXT: 100102e4: bl 0x10010310 // CHECK-NEXT: 100102e8: ld 2, 24(1)