From 003c18a39c72399d5156abd2a08f82e7b79fc861 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 23 Apr 2019 11:47:28 +0000 Subject: [PATCH] [PPC][PPC64] Improve some llvm-objdump -d -D tests Various improvement: Some offsets in disassembly are incorrect after several layout adjustment. Fix them. llvm-objdump -D should not be used. -D dumps unrelated non-text sections. Replace them with llvm-objdump -d, llvm-readelf -x, etc Many llvm-objdump -d tests use {{.*}} . Add the option --no-show-raw-insn to avoid check hex bytes. ppc64-long-branch.s does not need a shared object. Delete it. Make ppc64-ifunc.s check 2 ifuncs. Reviewers: ruiu, espindola Subscribers: emaste, nemanjai, arichardson, kbarton, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60998 llvm-svn: 358975 --- lld/test/ELF/ppc-relocs.s | 35 ++++---- lld/test/ELF/ppc64-call-reach.s | 45 ++++++----- lld/test/ELF/ppc64-dtprel.s | 49 +++++------- lld/test/ELF/ppc64-entry-point.s | 40 +++++----- lld/test/ELF/ppc64-ifunc.s | 100 +++++++++++------------ lld/test/ELF/ppc64-long-branch.s | 101 +++++++++--------------- lld/test/ELF/ppc64-relocs.s | 70 ++++++++-------- lld/test/ELF/ppc64-tls-gd-le-small.s | 8 +- lld/test/ELF/ppc64-tls-ie-le.s | 4 +- lld/test/ELF/ppc64-tls-ld-le.s | 4 +- lld/test/ELF/ppc64-toc-addis-nop-lqsq.s | 5 +- lld/test/ELF/ppc64-toc-addis-nop.s | 22 +++--- lld/test/ELF/ppc64-toc-rel.s | 51 ++++++------ lld/test/ELF/ppc64-toc-restore-recursive-call.s | 10 +-- lld/test/ELF/ppc64-toc-restore.s | 32 ++++---- lld/test/ELF/ppc64-weak-undef-call.s | 10 +-- 16 files changed, 261 insertions(+), 325 deletions(-) diff --git a/lld/test/ELF/ppc-relocs.s b/lld/test/ELF/ppc-relocs.s index 40536b6..b0259c8 100644 --- a/lld/test/ELF/ppc-relocs.s +++ b/lld/test/ELF/ppc-relocs.s @@ -1,7 +1,8 @@ # REQUIRES: ppc -# RUN: llvm-mc -filetype=obj -triple=powerpc-unknown-freebsd %s -o %t -# RUN: ld.lld %t -o %t2 -# RUN: llvm-objdump -d %t2 | FileCheck %s +# RUN: llvm-mc -filetype=obj -triple=powerpc-unknown-freebsd %s -o %t.o +# RUN: ld.lld %t.o -o %t +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s +# RUN: llvm-objdump -s --no-show-raw-insn %t | FileCheck --check-prefix=HEX %s .section .R_PPC_ADDR16_HA,"ax",@progbits .globl _start @@ -13,9 +14,9 @@ msg: # CHECK: Disassembly of section .R_PPC_ADDR16_HA: # CHECK: _start: -# CHECK: 11000: 3c 80 00 01 lis 4, 1 +# CHECK: 11000: lis 4, 1 # CHECK: msg: -# CHECK: 11004: 66 6f 6f 00 oris 15, 19, 28416 +# CHECK: 11004: oris 15, 19, 28416 .section .R_PPC_ADDR16_HI,"ax",@progbits .globl _starti @@ -27,9 +28,9 @@ msgi: # CHECK: Disassembly of section .R_PPC_ADDR16_HI: # CHECK: _starti: -# CHECK: 11008: 3c 80 00 01 lis 4, 1 +# CHECK: 11008: lis 4, 1 # CHECK: msgi: -# CHECK: 1100c: 66 6f 6f 00 oris 15, 19, 28416 +# CHECK: 1100c: oris 15, 19, 28416 .section .R_PPC_ADDR16_LO,"ax",@progbits addi 4, 4, msg@l @@ -39,9 +40,9 @@ mystr: # CHECK: Disassembly of section .R_PPC_ADDR16_LO: # CHECK: .R_PPC_ADDR16_LO: -# CHECK: 11010: 38 84 10 04 addi 4, 4, 4100 +# CHECK: 11010: addi 4, 4, 4100 # CHECK: mystr: -# CHECK: 11014: 62 6c 61 68 ori 12, 19, 24936 +# CHECK: 11014: ori 12, 19, 24936 .align 2 .section .R_PPC_REL24,"ax",@progbits @@ -53,7 +54,7 @@ mystr: # CHECK: Disassembly of section .R_PPC_REL24: # CHECK: .FR_PPC_REL24: -# CHECK: 1101c: 48 00 00 04 b .+4 +# CHECK: 1101c: b .+4 .section .R_PPC_REL14,"ax",@progbits .globl .FR_PPC_REL14 @@ -64,7 +65,7 @@ mystr: # CHECK: Disassembly of section .R_PPC_REL14: # CHECK: .FR_PPC_REL14: -# CHECK: 11020: {{.*}} bt 2, .+4 +# CHECK: 11020: bt 2, .+4 .section .R_PPC_REL32,"ax",@progbits .globl .FR_PPC_REL32 @@ -73,9 +74,8 @@ mystr: .section .R_PPC_REL32_2,"ax",@progbits .Lfoox3: -# CHECK: Disassembly of section .R_PPC_REL32: -# CHECK: .FR_PPC_REL32: -# CHECK: 11024: 00 00 00 04 +# HEX: .R_PPC_REL32: +# HEX-NEXT: 11024 00000004 .section .R_PPC_ADDR32,"ax",@progbits .globl .FR_PPC_ADDR32 @@ -84,9 +84,8 @@ mystr: .section .R_PPC_ADDR32_2,"ax",@progbits .Lfoox2: -# CHECK: Disassembly of section .R_PPC_ADDR32: -# CHECK: .FR_PPC_ADDR32: -# CHECK: 11028: 00 01 10 2c +# HEX: .R_PPC_ADDR32: +# HEX-NEXT: 11028 0001102c .align 2 .section .R_PPC_PLTREL24,"ax",@progbits @@ -98,4 +97,4 @@ mystr: # CHECK: Disassembly of section .R_PPC_PLTREL24: # CHECK: .R_PPC_PLTREL24: -# CHECK: 1102c: 48 00 00 04 b .+4 +# CHECK: 1102c: b .+4 diff --git a/lld/test/ELF/ppc64-call-reach.s b/lld/test/ELF/ppc64-call-reach.s index b6cfb6e..980df26 100644 --- a/lld/test/ELF/ppc64-call-reach.s +++ b/lld/test/ELF/ppc64-call-reach.s @@ -3,16 +3,16 @@ # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o # RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \ # RUN: %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s # RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \ # RUN: %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s # RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \ # RUN: %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck --check-prefix=NEGOFFSET %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NEGOFFSET %s # RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \ # RUN: %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck --check-prefix=THUNK %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=THUNK %s # RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s # RUN: not ld.lld --defsym callee=0x1001002D --defsym tail_callee=0x1001002F \ # RUN: %t.o -o %t 2>&1 | FileCheck --check-prefix=MISSALIGNED %s @@ -20,16 +20,16 @@ # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o # RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \ # RUN: %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s # RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \ # RUN: %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s # RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \ # RUN: %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck --check-prefix=NEGOFFSET %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NEGOFFSET %s # RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \ # RUN: %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck --check-prefix=THUNK %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=THUNK %s # RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s # RUN: not ld.lld --defsym callee=0x1001002D --defsym tail_callee=0x1001002F \ # RUN: %t.o -o %t 2>&1 | FileCheck --check-prefix=MISSALIGNED %s @@ -58,37 +58,36 @@ test: # Check that we are branching to the definitions, and not range-extending # thunks. # CHECK-LABEL: test -# CHECK: 10010014: {{.*}} bl .+33554428 -# CHECK: 10010024: {{.*}} b .+33554428 +# CHECK: 10010014: bl .+33554428 +# CHECK: 10010024: b .+33554428 # NEGOFFSET-LABEL: test -# NEGOFFSET: 10010014: {{.*}} bl .-33554432 -# NEGOFFSET: 10010024: {{.*}} b .+33554432 +# NEGOFFSET: 10010014: bl .-33554432 +# NEGOFFSET: 10010024: b .+33554432 # .branch_lt[0] # THUNK-LABEL: __long_branch_callee: -# THUNK-NEXT: 10010000: {{.*}} addis 12, 2, 1 -# THUNK-NEXT: ld 12, -32768(12) -# THUNK-NEXT: mtctr 12 -# THUNK-NEXT: bctr +# THUNK-NEXT: 10010000: addis 12, 2, 1 +# THUNK-NEXT: ld 12, -32768(12) +# THUNK-NEXT: mtctr 12 +# THUNK-NEXT: bctr # .branch_lt[1] # THUNK-LABEL: __long_branch_tail_callee: -# THUNK-NEXT: 10010010: {{.*}} addis 12, 2, 1 -# THUNK-NEXT: ld 12, -32760(12) -# THUNK-NEXT: mtctr 12 -# THUNK-NEXT: bctr +# THUNK-NEXT: 10010010: addis 12, 2, 1 +# THUNK-NEXT: ld 12, -32760(12) +# THUNK-NEXT: mtctr 12 +# THUNK-NEXT: bctr # Each call now branches to a thunk, and although it is printed as positive # the offset is interpreted as a signed 26 bit value so 67108812 is actually # -52. # THUNK-LABEL: test: -# THUNK: 10010034: {{.*}} bl .-52 -# THUNK: 10010044: {{.*}} b .+67108812 +# THUNK: 10010034: bl .-52 +# THUNK: 10010044: b .+67108812 # The offset from the TOC to the .branch_lt section is (-1 << 16) - 32768. # Name Type Address Off Size # BRANCHLT: .got PROGBITS 0000000010020000 020000 000008 # BRANCHLT: .branch_lt PROGBITS 0000000010030000 030000 000010 # BRANCHLT-NOT: .plt - diff --git a/lld/test/ELF/ppc64-dtprel.s b/lld/test/ELF/ppc64-dtprel.s index e5ac83a..a7ece1d 100644 --- a/lld/test/ELF/ppc64-dtprel.s +++ b/lld/test/ELF/ppc64-dtprel.s @@ -4,15 +4,15 @@ // RUN: ld.lld -shared %t.o -o %t.so // RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s // RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=OutputRelocs %s -// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s -// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=GotDisLE %s +// RUN: llvm-readelf -x .got %t.so | FileCheck --check-prefix=HEX-LE %s +// RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=Dis %s // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o // RUN: ld.lld -shared %t.o -o %t.so // RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s // RUN: llvm-readelf -r %t.so | FileCheck --check-prefix=OutputRelocs %s -// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=Dis %s -// RUN: llvm-objdump -D %t.so | FileCheck --check-prefix=GotDisBE %s +// RUN: llvm-readelf -x .got %t.so | FileCheck --check-prefix=HEX-BE %s +// RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=Dis %s .text .abiversion 2 @@ -150,10 +150,19 @@ k: // OutputRelocs-NEXT: R_PPC64_DTPMOD64 -// i@dtprel --> (1024 - 0x8000) = -31744 -// Dis: test: -// Dis: addi 4, 3, -31744 -// Dis: lwa 4, -31744(3) +// The got entry for i is at .got+8*3 = 0x420510 +// i@dtprel = 1024 - 0x8000 = -31744 = 0xffffffffffff8400 +// HEX-LE: section '.got': +// HEX-LE-NEXT: 4204f8 f8844200 00000000 00000000 00000000 +// HEX-LE-NEXT: 420508 00000000 00000000 0084ffff ffffffff + +// HEX-BE: section '.got': +// HEX-BE-NEXT: 4204f8 00000000 004284f8 00000000 00000000 +// HEX-BE-NEXT: 420508 00000000 00000000 ffffffff ffff8400 + +// Dis: test: +// Dis: addi 4, 3, -31744 +// Dis-NEXT: lwa 4, -31744(3) // #k@dtprel(1024 + 4 + 1024 * 1024 * 4) = 0x400404 @@ -177,26 +186,10 @@ k: // Dis: oris 4, 4, 63 // Dis: ori 4, 4, 33796 -// Check for GOT entry for i. There should be a got entry which holds the offset -// of i relative to the dynamic thread pointer. -// i@dtprel -> (1024 - 0x8000) = 0xffff8400 -// GotDisBE: Disassembly of section .got: -// GotDisBE: 4204f8: 00 00 00 00 -// GotDisBE: 4204fc: 00 42 84 f8 -// GotDisBE: 420510: ff ff ff ff -// GotDisBE: 420514: ff ff 84 00 - -// GotDisLE: Disassembly of section .got: -// GotDisLE: 4204f8: f8 84 42 00 -// GotDisLE: 420510: 00 84 ff ff -// GotDisLE: 420514: ff ff ff ff - -// Check that we have the correct offset to the got entry for i@got@dtprel -// The got entry for i is 0x420510, and the TOC pointer is 0x4284f8. -// #ha(i@got@dtprel) --> ((0x420510 - 0x4284f8 + 0x8000) >> 16) & 0xffff = 0 -// #lo(i@got@dtprel) --> (0x420510 - 0x4284f8) & 0xffff = -32744 -// #hi(i@got@dtprel) --> ((0x420510 - 0x4284f8) >> 16) & 0xffff = -1 -// i@got@dtprel --> 0x420510 - 0x4284f8 = -32744 +// #ha(i@got@dtprel) = ((0x420510 - (.got+0x8000) + 0x8000) >> 16) & 0xffff = 0 +// #lo(i@got@dtprel) = (0x420510 - (.got+0x8000)) & 0xffff = -32744 +// #hi(i@got@dtprel) = ((0x420510 - (.got+0x8000)) >> 16) & 0xffff = -1 +// i@got@dtprel --> 0x420510 - (.got+0x8000) = -32744 // Dis: test_got_dtprel: // Dis: addis 3, 2, 0 // Dis: ld 3, -32744(3) diff --git a/lld/test/ELF/ppc64-entry-point.s b/lld/test/ELF/ppc64-entry-point.s index 6dbfc53..0977158 100644 --- a/lld/test/ELF/ppc64-entry-point.s +++ b/lld/test/ELF/ppc64-entry-point.s @@ -1,14 +1,14 @@ # REQUIRES: ppc -# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 -# RUN: llvm-objdump -D %t2 | FileCheck %s -# RUN: llvm-objdump -D %t2 | FileCheck -check-prefix=CHECK-LE %s +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t +# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s -# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 -# RUN: llvm-objdump -D %t2 | FileCheck %s -# RUN: llvm-objdump -D %t2 | FileCheck -check-prefix=CHECK-BE %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-objdump -d --no-show-raw-insn %t | FileCheck %s .text .abiversion 2 @@ -23,8 +23,8 @@ _start: addi 4, 4, .Lfunc_gep0@l # now r4 should contain the address of _start - lis 5, .TOC.-.Lfunc_gep0@ha - addi 5, 5, .TOC.-.Lfunc_gep0@l + lis 5, .TOC.-.Lfunc_gep0@ha # R_PPC64_REL16_HA + addi 5, 5, .TOC.-.Lfunc_gep0@l # R_PPC64_REL16_LO # now r5 should contain the offset s.t. r4 + r5 = TOC base # exit 55 @@ -34,16 +34,12 @@ _start: .Lfunc_end0: .size _start, .Lfunc_end0-.Lfunc_begin0 -// CHECK: 10010000: {{.*}} lis 4, 4097 -// CHECK-NEXT: 10010004: {{.*}} addi 4, 4, 0 -// CHECK-NEXT: 10010008: {{.*}} lis 5, 2 -// CHECK-NEXT: 1001000c: {{.*}} addi 5, 5, -32768 +# NM-DAG: 0000000010028000 d .TOC. +# NM-DAG: 0000000010010000 T _start -// CHECK-LE: Disassembly of section .got: -// CHECK-LE-NEXT: .got: -// CHECK-LE-NEXT: 10020000: 00 80 02 10 - -// CHECK-BE: Disassembly of section .got: -// CHECK-BE-NEXT: .got: -// CHECK-BE-NEXT: 10020000: 00 00 00 00 {{.*}} -// CHECK-BE-NEXT: 10020004: 10 02 80 00 {{.*}} +# 0x10010000 = (4097<<16) + 0 +# CHECK: 10010000: lis 4, 4097 +# CHECK-NEXT: 10010004: addi 4, 4, 0 +# .TOC. - _start = (2<<16) - 32768 +# CHECK-NEXT: 10010008: lis 5, 2 +# CHECK-NEXT: 1001000c: addi 5, 5, -32768 diff --git a/lld/test/ELF/ppc64-ifunc.s b/lld/test/ELF/ppc64-ifunc.s index bd7f761..4bf50b9 100644 --- a/lld/test/ELF/ppc64-ifunc.s +++ b/lld/test/ELF/ppc64-ifunc.s @@ -1,79 +1,67 @@ # REQUIRES: ppc # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o -# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o -# RUN: ld.lld -shared %t2.o -o %t2.so -# RUN: ld.lld %t.o %t2.so -o %t -# RUN: llvm-objdump -D %t | FileCheck %s -# RUN: llvm-readelf -dynamic-table %t | FileCheck --check-prefix=DT %s -# RUN: llvm-readelf -dyn-relocations %t | FileCheck --check-prefix=DYNREL %s +# 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-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o -# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o -# RUN: ld.lld -shared %t2.o -o %t2.so -# RUN: ld.lld %t.o %t2.so -o %t -# RUN: llvm-objdump -D %t | FileCheck %s -# RUN: llvm-readelf -dynamic-table %t | FileCheck --check-prefix=DT %s -# RUN: llvm-readelf -dyn-relocations %t | FileCheck --check-prefix=DYNREL %s +# 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 -# CHECK: Disassembly of section .text: +# NM-DAG: 0000000010028000 d .TOC. +# NM-DAG: 0000000010010028 T ifunc +# NM-DAG: 000000001001002c T ifunc2 -# Tocbase + (0 << 16) + 32560 -# 0x100280e0 + 0 + 32560 = 0x10030010 (.plt[2]) -# CHECK: __plt_foo: +# SECTIONS: .plt NOBITS 0000000010030000 + +# .plt[0] - .TOC. = 0x10030000 - 0x10028000 = (1<<16) - 32768 +# CHECK: __plt_ifunc: # CHECK-NEXT: std 2, 24(1) -# CHECK-NEXT: addis 12, 2, 0 -# CHECK-NEXT: ld 12, 32560(12) +# CHECK-NEXT: addis 12, 2, 1 +# CHECK-NEXT: ld 12, -32768(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr -# Tocbase + (0 << 16) + 32568 -# 0x100280e0 + 0 + 32568 = 0x1003018 (.plt[3]) -# CHECK: __plt_ifunc: +# .plt[1] - .TOC. = 0x10030000+8 - 0x10028000 = (1<<16) - 32760 +# CHECK: __plt_ifunc2: # CHECK-NEXT: std 2, 24(1) -# CHECK-NEXT: addis 12, 2, 0 -# CHECK-NEXT: ld 12, 32568(12) +# CHECK-NEXT: addis 12, 2, 1 +# CHECK-NEXT: ld 12, -32760(12) # CHECK-NEXT: mtctr 12 # CHECK-NEXT: bctr -# CHECK: ifunc: -# CHECK-NEXT: 10010028: {{.*}} nop - +# __plt_ifunc - . = 0x10010000 - 0x10010038 = -56 +# __plt_ifunc2 - . = 0x10010014 - 0x10010040 = -44 # CHECK: _start: -# CHECK-NEXT: addis 2, 12, 2 -# CHECK-NEXT: addi 2, 2, -32588 -# CHECK-NEXT: bl .-52 -# CHECK-NEXT: ld 2, 24(1) -# CHECK-NEXT: bl .-40 -# CHECK-NEXT: ld 2, 24(1) - -# Check tocbase -# CHECK: Disassembly of section .got: -# CHECK-NEXT: .got: -# CHECK-NEXT: 100200e0 - -# Check .plt address -# DT_PLTGOT should point to the start of the .plt section. -# DT: 0x0000000000000003 PLTGOT 0x10030000 - -# Check that we emit the correct dynamic relocation type for an ifunc -# DYNREL: 'PLT' relocation section at offset 0x{{[0-9a-f]+}} contains 48 bytes: -# 48 bytes --> 2 Elf64_Rela relocations -# DYNREL-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend -# DYNREL-NEXT: {{[0-9a-f]+}} {{[0-9a-f]+}} R_PPC64_JMP_SLOT {{0+}} foo + 0 -# DYNREL-NEXT: {{[0-9a-f]+}} {{[0-9a-f]+}} R_PPC64_IRELATIVE 10010028 +# CHECK-NEXT: addis 2, 12, 1 +# CHECK-NEXT: addi 2, 2, 32720 +# CHECK-NEXT: 10010038: bl .-56 +# CHECK-NEXT: ld 2, 24(1) +# CHECK-NEXT: 10010040: bl .-44 +# CHECK-NEXT: ld 2, 24(1) - - .text - .abiversion 2 +# Check that we emit 2 R_PPC64_IRELATIVE. +# DYNREL: R_PPC64_IRELATIVE 10010028 +# DYNREL: R_PPC64_IRELATIVE 1001002c .type ifunc STT_GNU_IFUNC .globl ifunc ifunc: - nop + nop + +.type ifunc2 STT_GNU_IFUNC +.globl ifunc2 +ifunc2: + nop - .global _start - .type _start,@function +.global _start +.type _start,@function _start: .Lfunc_gep0: @@ -81,7 +69,7 @@ _start: addi 2, 2, .TOC.-.Lfunc_gep0@l .Lfunc_lep0: .localentry _start, .Lfunc_lep0-.Lfunc_gep0 - bl foo - nop bl ifunc nop + bl ifunc2 + nop diff --git a/lld/test/ELF/ppc64-long-branch.s b/lld/test/ELF/ppc64-long-branch.s index ce49e46..bf13b64 100644 --- a/lld/test/ELF/ppc64-long-branch.s +++ b/lld/test/ELF/ppc64-long-branch.s @@ -1,22 +1,16 @@ # REQUIRES: ppc # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o -# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-func-global-entry.s -o %t2.o -# RUN: ld.lld -shared %t2.o -o %t3.so -# RUN: ld.lld --no-toc-optimize %t.o %t3.so -o %t -# RUN: llvm-objdump -d -start-address=0x10010000 -stop-address=0x10010018 %t | FileCheck %s -check-prefix=CALLEE_DUMP -# RUN: llvm-objdump -d -start-address=0x12010020 -stop-address=0x12010084 %t | FileCheck %s -check-prefix=CALLER_DUMP -# RUN: llvm-objdump -D -start-address=0x12030008 -stop-address=0x12030010 %t | FileCheck %s -check-prefix=BRANCH_LT_LE -# RUN: llvm-readelf --sections %t | FileCheck %s -check-prefix=SECTIONS +# RUN: ld.lld --no-toc-optimize %t.o -o %t +# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s +# RUN: llvm-readelf -x .branch_lt %t | FileCheck %s -check-prefix=BRANCH-LE +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o -# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-func-global-entry.s -o %t2.o -# RUN: ld.lld -shared %t2.o -o %t3.so -# RUN: ld.lld --no-toc-optimize %t.o %t3.so -o %t -# RUN: llvm-objdump -d -start-address=0x10010000 -stop-address=0x10010018 %t | FileCheck %s -check-prefix=CALLEE_DUMP -# RUN: llvm-objdump -d -start-address=0x12010020 -stop-address=0x12010084 %t | FileCheck %s -check-prefix=CALLER_DUMP -# RUN: llvm-objdump -D -start-address=0x12030008 -stop-address=0x12030010 %t | FileCheck %s -check-prefix=BRANCH_LT_BE -# RUN: llvm-readelf --sections %t | FileCheck %s -check-prefix=SECTIONS +# RUN: ld.lld --no-toc-optimize %t.o -o %t +# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s +# RUN: llvm-readelf -x .branch_lt %t | FileCheck %s -check-prefix=BRANCH-BE +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s .text .abiversion 2 @@ -52,24 +46,14 @@ _start: std 0, 16(1) stdu 1, -32(1) bl callee - bl foo_external_diff - nop + bl callee addi 1, 1, 32 ld 0, 16(1) mtlr 0 - addis 4, 2, .LC1@toc@ha - ld 4, .LC1@toc@l(4) - lwz 4, 0(4) - add 3, 3, 4 - blr - - .section .toc,"aw",@progbits .LC0: .tc a[TC],a -.LC1: - .tc b[TC],b .data @@ -80,42 +64,31 @@ a: .long 11 .size a, 4 - .type b,@object - .global b - .p2align 2 -b: - .long 33 - .size b, 4 - -# Verify address of the callee -# CALLEE_DUMP: callee: -# CALLEE_DUMP: 10010000: {{.*}} addis 2, 12, 514 -# CALLEE_DUMP: 10010004: {{.*}} addi 2, 2, -32544 -# CALLEE_DUMP: 10010008: {{.*}} addis 4, 2, 0 - -# Verify the address of _start, and the call to the long-branch thunk. -# CALLER_DUMP: _start: -# CALLER_DUMP: 12010020: {{.*}} addis 2, 12, 2 -# CALLER_DUMP: 12010038: {{.*}} bl .+56 - -# Verify the thunks contents: TOC-pointer + offset = .branch_lt[0] -# 0x120380e8 + (-2 << 16 + 32552) = 0x12020008 -# CALLER_DUMP: __long_branch_callee: -# CALLER_DUMP: 12010060: {{.*}} addis 12, 2, 0 -# CALLER_DUMP: 12010064: {{.*}} ld 12, 32552(12) -# CALLER_DUMP: 12010068: {{.*}} mtctr 12 -# CALLER_DUMP: 1201006c: {{.*}} bctr - -# BRANCH_LT_LE: Disassembly of section .branch_lt: -# BRANCH_LT_LE-NEXT: .branch_lt: -# BRANCH_LT_LE-NEXT: 12030008: 08 00 01 10 -# BRANCH_LT_LE-NEXT: 1203000c: 00 00 00 00 - -# BRANCH_LT_BE: Disassembly of section .branch_lt: -# BRANCH_LT_BE-NEXT: .branch_lt: -# BRANCH_LT_BE-NEXT: 12030008: 00 00 00 00 -# BRANCH_LT_BE-NEXT: 1203000c: 10 01 00 08 - -# [Nr] Name Type Address Off Size -# SECTIONS: [ 9] .got PROGBITS 00000000120200e0 20200e0 000008 -# SECTIONS: [12] .branch_lt PROGBITS 0000000012030008 2030008 000008 +# NM: 0000000012028000 d .TOC. + +# Without --toc-optimize, compute the address of .toc[0] first. .toc[0] stores +# the address of a. +# .TOC. - callee = 0x12030000 - 0x10010000 = (514<<16) - 32768 +# CHECK: callee: +# CHECK: 10010000: addis 2, 12, 514 +# CHECK: 10010004: addi 2, 2, -32768 +# CHECK: 10010008: addis 4, 2, 0 + +# __long_branch_callee - . = 0x12010050 - 0x12010034 = 20 +# __long_branch_callee is not a PLT call stub. Calling it does not need TOC +# restore, so it doesn't have to be followed by a nop. +# CHECK: _start: +# CHECK: 12010034: bl .+20 +# CHECK: 12010038: bl .+16 + +# BRANCH-LE: section '.branch_lt': +# BRANCH-LE-NEXT: 0x12030008 08000110 00000000 +# BRANCH-BE: section '.branch_lt': +# BRANCH-BE-NEXT: 0x12030008 00000000 10010008 + +# .branch_lt - .TOC. = 0x12030008 - 0x12028000 = (1<<16) - 32760 +# CHECK: __long_branch_callee: +# CHECK-NEXT: 12010048: addis 12, 2, 1 +# CHECK-NEXT: ld 12, -32760(12) +# CHECK-NEXT: mtctr 12 +# CHECK-NEXT: bctr diff --git a/lld/test/ELF/ppc64-relocs.s b/lld/test/ELF/ppc64-relocs.s index 938a4aa..b739966 100644 --- a/lld/test/ELF/ppc64-relocs.s +++ b/lld/test/ELF/ppc64-relocs.s @@ -2,13 +2,13 @@ # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 -# RUN: llvm-objdump -D %t2 | FileCheck %s --check-prefix=DATALE -# RUN: llvm-objdump -D %t2 | FileCheck %s +# RUN: llvm-readelf -x .rodata -x .eh_frame %t2 | FileCheck %s --check-prefix=DATALE +# RUN: llvm-objdump -d --no-show-raw-insn %t2 | FileCheck %s # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 -# RUN: llvm-objdump -D %t2 | FileCheck %s --check-prefix=DATABE -# RUN: llvm-objdump -D %t2 | FileCheck %s +# RUN: llvm-readelf -x .rodata -x .eh_frame %t2 | FileCheck %s --check-prefix=DATABE +# RUN: llvm-objdump -d --no-show-raw-insn %t2 | FileCheck %s .text .global _start @@ -36,7 +36,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_TOC16_LO_DS: # CHECK: .FR_PPC64_TOC16_LO_DS: -# CHECK: 1001000c: {{.*}} ld 1, -32768(2) +# CHECK: 1001000c: ld 1, -32768(2) .section .R_PPC64_TOC16_LO,"ax",@progbits .globl .FR_PPC64_TOC16_LO @@ -45,7 +45,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_TOC16_LO: # CHECK: .FR_PPC64_TOC16_LO: -# CHECK: 10010010: {{.*}} addi 1, 2, -32768 +# CHECK: 10010010: addi 1, 2, -32768 .section .R_PPC64_TOC16_HI,"ax",@progbits .globl .FR_PPC64_TOC16_HI @@ -54,7 +54,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_TOC16_HI: # CHECK: .FR_PPC64_TOC16_HI: -# CHECK: 10010014: {{.*}} addis 1, 2, -1 +# CHECK: 10010014: addis 1, 2, -1 .section .R_PPC64_TOC16_HA,"ax",@progbits .globl .FR_PPC64_TOC16_HA @@ -63,7 +63,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_TOC16_HA: # CHECK: .FR_PPC64_TOC16_HA: -# CHECK: 10010018: {{.*}} nop +# CHECK: 10010018: nop .section .R_PPC64_REL24,"ax",@progbits .globl .FR_PPC64_REL24 @@ -74,7 +74,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_REL24: # CHECK: .FR_PPC64_REL24: -# CHECK: 1001001c: {{.*}} b .+4 +# CHECK: 1001001c: b .+4 .section .R_PPC64_REL14,"ax",@progbits .globl .FR_PPC64_REL14 @@ -85,7 +85,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_REL14: # CHECK: .FR_PPC64_REL14: -# CHECK: 10010020: {{.*}} bt 2, .+4 +# CHECK: 10010020: bt 2, .+4 .section .R_PPC64_ADDR16_LO,"ax",@progbits .globl .FR_PPC64_ADDR16_LO @@ -94,7 +94,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_ADDR16_LO: # CHECK: .FR_PPC64_ADDR16_LO: -# CHECK: 10010024: {{.*}} li 1, 0 +# CHECK: 10010024: li 1, 0 .section .R_PPC64_ADDR16_HI,"ax",@progbits .globl .FR_PPC64_ADDR16_HI @@ -103,7 +103,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_ADDR16_HI: # CHECK: .FR_PPC64_ADDR16_HI: -# CHECK: 10010028: {{.*}} li 1, 4097 +# CHECK: 10010028: li 1, 4097 .section .R_PPC64_ADDR16_HA,"ax",@progbits .globl .FR_PPC64_ADDR16_HA @@ -112,7 +112,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_ADDR16_HA: # CHECK: .FR_PPC64_ADDR16_HA: -# CHECK: 1001002c: {{.*}} li 1, 4097 +# CHECK: 1001002c: li 1, 4097 .section .R_PPC64_ADDR16_HIGHER,"ax",@progbits .globl .FR_PPC64_ADDR16_HIGHER @@ -121,7 +121,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHER: # CHECK: .FR_PPC64_ADDR16_HIGHER: -# CHECK: 10010030: {{.*}} li 1, 0 +# CHECK: 10010030: li 1, 0 .section .R_PPC64_ADDR16_HIGHERA,"ax",@progbits .globl .FR_PPC64_ADDR16_HIGHERA @@ -130,7 +130,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHERA: # CHECK: .FR_PPC64_ADDR16_HIGHERA: -# CHECK: 10010034: {{.*}} li 1, 0 +# CHECK: 10010034: li 1, 0 .section .R_PPC64_ADDR16_HIGHEST,"ax",@progbits .globl .FR_PPC64_ADDR16_HIGHEST @@ -139,7 +139,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHEST: # CHECK: .FR_PPC64_ADDR16_HIGHEST: -# CHECK: 10010038: {{.*}} li 1, 0 +# CHECK: 10010038: li 1, 0 .section .R_PPC64_ADDR16_HIGHESTA,"ax",@progbits .globl .FR_PPC64_ADDR16_HIGHESTA @@ -148,7 +148,7 @@ _start: # CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHESTA: # CHECK: .FR_PPC64_ADDR16_HIGHESTA: -# CHECK: 1001003c: {{.*}} li 1, 0 +# CHECK: 1001003c: li 1, 0 .section .R_PPC64_REL32, "ax",@progbits .globl .FR_PPC64_REL32 @@ -158,22 +158,20 @@ _start: .LBB0_2: add 3, 3, 4 -# DATALE: Disassembly of section .rodata: -# DATALE: .rodata: -# DATALE: 100001c8: 80 fe 00 00 +# DATALE: '.rodata': +# DATALE: 0x100001c8 80fe0000 -# DATABE: Disassembly of section .rodata: -# DATABE: .rodata: -# DATABE: 100001c8: 00 00 fe 80 +# DATABE: '.rodata': +# DATABE: 0x100001c8 0000fe80 # Address of rodata + value stored at rodata entry # should equal address of LBB0_2. # 0x10000190 + 0xfeb4 = 0x10010044 # CHECK: Disassembly of section .R_PPC64_REL32: # CHECK: .FR_PPC64_REL32: -# CHECK: 10010040: {{.*}} nop -# CHECK: 10010044: {{.*}} ld 5, -32736(2) -# CHECK: 10010048: {{.*}} add 3, 3, 4 +# CHECK: 10010040: nop +# CHECK: 10010044: ld 5, -32736(2) +# CHECK: 10010048: add 3, 3, 4 .section .R_PPC64_REL64, "ax",@progbits .globl .FR_PPC64_REL64 @@ -187,18 +185,14 @@ _start: __foo: li 3,0 -# Check that address of eh_frame entry + value stored -# should equal the address of foo. Since it is not aligned, -# the entry is not stored exactly at 10000198. It starts at -# address 0x1000019a and has the value 0xfeaa. -# 0x100001aa + 0xfeae = 0x10010058 -# DATALE: Disassembly of section .eh_frame: -# DATALE: .eh_frame: -# DATALE: 100001d0: {{.*}} 00 00 +# Check that the personality (relocated by R_PPC64_REL64) in the .eh_frame +# equals the address of __foo. +# 0x100001e2 + 0x76fe = 0x10010058 +# DATALE: section '.eh_frame': +# DATALE: 0x100001e0 {{....}}76fe -# DATABE: Disassembly of section .eh_frame: -# DATABE: .eh_frame: -# DATABE: 100001e8: fe 76 {{.*}} +# DATABE: section '.eh_frame': +# DATABE: 0x100001e0 {{[0-9a-f]+ [0-9a-f]+}} fe76{{....}} # CHECK: __foo -# CHECK-NEXT: 10010058: {{.*}} li 3, 0 +# CHECK-NEXT: 10010058: li 3, 0 diff --git a/lld/test/ELF/ppc64-tls-gd-le-small.s b/lld/test/ELF/ppc64-tls-gd-le-small.s index f5a1ec6..4d80f0a 100644 --- a/lld/test/ELF/ppc64-tls-gd-le-small.s +++ b/lld/test/ELF/ppc64-tls-gd-le-small.s @@ -1,15 +1,15 @@ # REQUIRES: ppc # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o -# RUN: llvm-objdump -d -r %t.o | FileCheck --check-prefix=CHECK-INPUT %s +# RUN: llvm-objdump -d --no-show-raw-insn -r %t.o | FileCheck --check-prefix=CHECK-INPUT %s # RUN: ld.lld --defsym __tls_get_addr=0x10001000 %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck --check-prefix=CHECK-DIS %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=CHECK-DIS %s # RUN: llvm-readelf -relocations %t | FileCheck --check-prefix=DYN-RELOCS %s # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o -# RUN: llvm-objdump -d -r %t.o | FileCheck --check-prefix=CHECK-INPUT %s +# RUN: llvm-objdump -d --no-show-raw-insn -r %t.o | FileCheck --check-prefix=CHECK-INPUT %s # RUN: ld.lld --defsym __tls_get_addr=0x10001000 %t.o -o %t -# RUN: llvm-objdump -d %t | FileCheck --check-prefix=CHECK-DIS %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=CHECK-DIS %s # RUN: llvm-readelf -relocations %t | FileCheck --check-prefix=DYN-RELOCS %s # Test checks the relaxation of a 'small' general-dynamic tls access into a diff --git a/lld/test/ELF/ppc64-tls-ie-le.s b/lld/test/ELF/ppc64-tls-ie-le.s index 358d3e8..c989310 100644 --- a/lld/test/ELF/ppc64-tls-ie-le.s +++ b/lld/test/ELF/ppc64-tls-ie-le.s @@ -5,14 +5,14 @@ // RUN: ld.lld -dynamic-linker /lib64/ld64.so.2 %t.o %t2.o -o %t // RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s // RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s -// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s +// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=Dis %s // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-tls-ie-le.s -o %t2.o // RUN: ld.lld -dynamic-linker /lib64/ld64.so.2 %t.o %t2.o -o %t // RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s // RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s -// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s +// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=Dis %s .text .abiversion 2 diff --git a/lld/test/ELF/ppc64-tls-ld-le.s b/lld/test/ELF/ppc64-tls-ld-le.s index 572de08..f348bb9 100644 --- a/lld/test/ELF/ppc64-tls-ld-le.s +++ b/lld/test/ELF/ppc64-tls-ld-le.s @@ -3,13 +3,13 @@ // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o // RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s // RUN: ld.lld %t.o -o %t -// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s +// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=Dis %s // RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o // RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s // RUN: ld.lld %t.o -o %t -// RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s +// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=Dis %s // RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s .text diff --git a/lld/test/ELF/ppc64-toc-addis-nop-lqsq.s b/lld/test/ELF/ppc64-toc-addis-nop-lqsq.s index da57f38..07c41cc 100644 --- a/lld/test/ELF/ppc64-toc-addis-nop-lqsq.s +++ b/lld/test/ELF/ppc64-toc-addis-nop-lqsq.s @@ -6,10 +6,10 @@ # RUN: ld.lld -shared %t2.o -o %t2.so # RUN: ld.lld %t2.so %p/Inputs/ppc64le-quadword-ldst.o -o %t -# RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s +# RUN: llvm-objdump -d %t | FileCheck --check-prefix=Dis %s # RUN: ld.lld --no-toc-optimize %t2.so %p/Inputs/ppc64le-quadword-ldst.o -o %t -# RUN: llvm-objdump -D %t | FileCheck --check-prefix=NoOpt %s +# RUN: llvm-objdump -d %t | FileCheck --check-prefix=NoOpt %s # QuadInputRelocs: Relocation section '.rela.text' # QuadInputRelocs: R_PPC64_TOC16_LO_DS 0000000000000000 quadLd @@ -70,4 +70,3 @@ # NoOpt-NEXT: addis 3, 2, 0 # NoOpt-NEXT: 82 7f 83 f8 # NoOpt-NEXT: blr - diff --git a/lld/test/ELF/ppc64-toc-addis-nop.s b/lld/test/ELF/ppc64-toc-addis-nop.s index a8c850c..76c45b1 100644 --- a/lld/test/ELF/ppc64-toc-addis-nop.s +++ b/lld/test/ELF/ppc64-toc-addis-nop.s @@ -1,16 +1,16 @@ # REQUIRES: ppc # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o -# RUN: llvm-readelf -relocations --wide %t.o | FileCheck --check-prefix=InputRelocs %s +# RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o # RUN: ld.lld -shared %t2.o -o %t2.so # # RUN: ld.lld %t2.so %t.o -o %t -# RUN: llvm-objdump -D %t | FileCheck --check-prefix=Dis %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=Dis %s # # RUN: ld.lld --no-toc-optimize %t2.so %t.o -o %t -# RUN: llvm-objdump -D %t | FileCheck --check-prefix=NoOpt %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NoOpt %s # InputRelocs: Relocation section '.rela.text' # InputRelocs: R_PPC64_TOC16_HA @@ -35,7 +35,7 @@ bytes: addis 4, 2, byteSt@toc@ha stb 3, byteSt@toc@l(4) blr -# Dis-LABEL: bytes +# Dis-LABEL: bytes: # Dis-NEXT: addis # Dis-NEXT: addi # Dis-NEXT: nop @@ -44,7 +44,7 @@ bytes: # Dis-NEXT: stb 3, 32625(2) # Dis-NEXT: blr -# NoOpt-LABEL: bytes +# NoOpt-LABEL: bytes: # NoOpt-NEXT: addis # NoOpt-NEXT: addi # NoOpt-NEXT: addis 3, 2, 0 @@ -69,7 +69,7 @@ halfs: addis 5, 2, halfSt@toc@ha sth 4, halfSt@toc@l(5) blr -# Dis-LABEL: halfs +# Dis-LABEL: halfs: # Dis-NEXT: addis # Dis-NEXT: addi # Dis-NEXT: nop @@ -80,7 +80,7 @@ halfs: # Dis-NEXT: sth 4, 32628(2) # Dis-NEXT: blr -# NoOpt-LABEL: halfs +# NoOpt-LABEL: halfs: # NoOpt-NEXT: addis # NoOpt-NEXT: addi # NoOpt-NEXT: addis 3, 2, 0 @@ -178,7 +178,7 @@ vec_dq: stxv 3, vecSt@toc@l(3) blr -# Dis-LABEL: vec_dq +# Dis-LABEL: vec_dq: # Dis-NEXT: addis # Dis-NEXT: addi # Dis-NEXT: nop @@ -187,7 +187,7 @@ vec_dq: # Dis-NEXT: stxv 3, 32672(2) # Dis-NEXT: blr -# NoOpt-LABEL: vec_dq +# NoOpt-LABEL: vec_dq: # NoOpt-NEXT: addis # NoOpt-NEXT: addi # NoOpt-NEXT: addis 3, 2, 0 @@ -214,7 +214,7 @@ vec_ds: addis 3, 2, vecSt@toc@ha stxssp 3, vecSt@toc@l(3) blr -# Dis-LABEL: vec_ds +# Dis-LABEL: vec_ds: # Dis-NEXT: addis # Dis-NEXT: addi # Dis-NEXT: nop @@ -227,7 +227,7 @@ vec_ds: # Dis-NEXT: stxssp 3, 32672(2) # Dis-NEXT: blr -# NoOpt-LABEL: vec_ds +# NoOpt-LABEL: vec_ds: # NoOpt-NEXT: addis # NoOpt-NEXT: addi # NoOpt-NEXT: addis 3, 2, 0 diff --git a/lld/test/ELF/ppc64-toc-rel.s b/lld/test/ELF/ppc64-toc-rel.s index d49eb9f..87be086 100644 --- a/lld/test/ELF/ppc64-toc-rel.s +++ b/lld/test/ELF/ppc64-toc-rel.s @@ -2,15 +2,17 @@ # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o # RUN: llvm-readobj -relocations %t.o | FileCheck -check-prefix=RELOCS-LE %s -# RUN: ld.lld %t.o -o %t2 -# RUN: llvm-objdump -D %t2 | FileCheck %s -# RUN: llvm-objdump -D %t2 | FileCheck -check-prefix=CHECK-LE %s +# RUN: ld.lld %t.o -o %t +# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s +# RUN: llvm-readelf -x .got %t | FileCheck --check-prefix=HEX-LE %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=CHECK %s # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o # RUN: llvm-readobj -relocations %t.o | FileCheck -check-prefix=RELOCS-BE %s -# RUN: ld.lld %t.o -o %t2 -# RUN: llvm-objdump -D %t2 | FileCheck %s -# RUN: llvm-objdump -D %t2 | FileCheck -check-prefix=CHECK-BE %s +# RUN: ld.lld %t.o -o %t +# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s +# RUN: llvm-readelf -x .got %t | FileCheck --check-prefix=HEX-BE %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=CHECK %s # Make sure we calculate the offset correctly for a toc-relative access to a # global variable as described by the PPC64 Elf V2 abi. @@ -57,26 +59,19 @@ _start: # RELOCS-BE: 0xA R_PPC64_TOC16_HA global_a 0x0 # RELOCS-BE: 0xE R_PPC64_TOC16_LO global_a 0x0 -# Want to check _start for the values used to build the offset from the TOC base -# to global_a. The .TOC. symbol is expected at address 0x10030000, and the -# TOC base is address-of(.TOC.) + 0x8000. The expected offset is: -# 0x10020000(global_a) - 0x10038000(Toc base) = -0x18000(Offset) -# which gets materialized into r3 as ((-1 << 16) - 32768). +# The .TOC. symbol represents the TOC base address: .got + 0x8000 = 0x10028000, +# which is stored in the first entry of .got +# NM: 0000000010028000 d .TOC. +# NM: 0000000010030000 D global_a +# HEX-LE: section '.got': +# HEX-LE-NEXT: 0x10020000 00800210 00000000 +# HEX-BE: section '.got': +# HEX-BE-NEXT: 0x10020000 00000000 10028000 -# CHECK: Disassembly of section .text: -# CHECK-NEXT: _start: -# CHECK: 10010008: {{.*}} addis 3, 2, 1 -# CHECK-NEXT: 1001000c: {{.*}} addi 3, 3, -32768 - -# CHECK: Disassembly of section .data: -# CHECK-NEXT: global_a: -# CHECK-NEXT: 10030000: {{.*}} - -# CHECK-LE: Disassembly of section .got: -# CHECK-LE-NEXT: .got: -# CHECK-LE-NEXT: 10020000: 00 80 02 10 - -# CHECK-BE: Disassembly of section .got: -# CHECK-BE-NEXT: .got: -# CHECK-BE-NEXT: 10020000: 00 00 00 00 -# CHECK-BE-NEXT: 10020004: 10 02 80 00 +# r2 stores the TOC base address. To access global_a with r3, it +# computes the address with TOC plus an offset. +# The offset global_a - .TOC. = 0x10030000 - 0x10028000 = 0x8000 +# gets materialized as (1 << 16) - 32768. +# CHECK: _start: +# CHECK: 10010008: addis 3, 2, 1 +# CHECK-NEXT: 1001000c: addi 3, 3, -32768 diff --git a/lld/test/ELF/ppc64-toc-restore-recursive-call.s b/lld/test/ELF/ppc64-toc-restore-recursive-call.s index d194ada..538b12c 100644 --- a/lld/test/ELF/ppc64-toc-restore-recursive-call.s +++ b/lld/test/ELF/ppc64-toc-restore-recursive-call.s @@ -1,8 +1,8 @@ # REQUIRES: ppc -# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o -# RUN: ld.lld -shared %t1.o -o %t -# RUN: llvm-objdump -d -r %t | FileCheck %s +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o +# RUN: ld.lld -shared %t.o -o %t.so +# RUN: llvm-objdump -d --no-show-raw-insn -r %t.so | FileCheck %s # For a recursive call that is interposable the linker calls the plt-stub rather # then calling the function directly. Since the call is through a plt stub and @@ -18,8 +18,8 @@ # CHECK-NEXT: 10000: # CHECK-LABEL: recursive_func # CHECK-NEXT: 10014: -# CHECK: 1003c: {{.*}} bl .-60 -# CHECK-NEXT: ld 2, 24(1) +# CHECK: 1003c: bl .-60 +# CHECK-NEXT: 10040: ld 2, 24(1) .abiversion 2 .section ".text" diff --git a/lld/test/ELF/ppc64-toc-restore.s b/lld/test/ELF/ppc64-toc-restore.s index 8c26207..8ffe213 100644 --- a/lld/test/ELF/ppc64-toc-restore.s +++ b/lld/test/ELF/ppc64-toc-restore.s @@ -5,14 +5,14 @@ // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-func.s -o %t3.o // RUN: ld.lld -shared %t2.o -o %t2.so // RUN: ld.lld %t.o %t2.so %t3.o -o %t -// RUN: llvm-objdump -d %t | FileCheck %s +// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-func.s -o %t3.o // RUN: ld.lld -shared %t2.o -o %t2.so // RUN: ld.lld %t.o %t2.so %t3.o -o %t -// RUN: llvm-objdump -d %t | FileCheck %s +// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s .text .abiversion 2 @@ -32,12 +32,12 @@ _start: // CHECK: Disassembly of section .text: // CHECK: _start: -// CHECK: 1001001c: {{.*}} bl .-28 -// CHECK-NOT: 10010020: {{.*}} nop -// CHECK: 10010020: {{.*}} ld 2, 24(1) -// CHECK: 10010024: {{.*}} bl .-16 -// CHECK-NOT: 10010028: {{.*}} nop -// CHECK-NOT: 10010028: {{.*}} ld 2, 24(1) +// CHECK: 1001001c: bl .-28 +// CHECK-NOT: 10010020: nop +// CHECK: 10010020: ld 2, 24(1) +// CHECK: 10010024: bl .-16 +// CHECK-NOT: 10010028: nop +// CHECK-NOT: 10010028: ld 2, 24(1) # Calling a function in another object file which will have same # TOC base does not need a nop. If nop present, do not rewrite to @@ -49,18 +49,18 @@ _diff_object: nop // CHECK: _diff_object: -// CHECK-NEXT: 10010028: {{.*}} bl .+24 -// CHECK-NEXT: 1001002c: {{.*}} bl .+20 -// CHECK-NEXT: 10010030: {{.*}} nop +// CHECK-NEXT: 10010028: bl .+24 +// CHECK-NEXT: 1001002c: bl .+20 +// CHECK-NEXT: 10010030: nop # Branching to a local function does not need a nop .global noretbranch noretbranch: b bar_local // CHECK: noretbranch: -// CHECK: 10010034: {{.*}} b .+67108832 -// CHECK-NOT: 10010038: {{.*}} nop -// CHECK-NOT: 1001003c: {{.*}} ld 2, 24(1) +// CHECK: 10010034: b .+67108832 +// CHECK-NOT: 10010038: nop +// CHECK-NOT: 1001003c: ld 2, 24(1) // This should come last to check the end-of-buffer condition. .global last @@ -68,5 +68,5 @@ last: bl foo nop // CHECK: last: -// CHECK: 10010038: {{.*}} bl .-56 -// CHECK-NEXT: 1001003c: {{.*}} ld 2, 24(1) +// CHECK: 10010038: bl .-56 +// CHECK-NEXT: 1001003c: ld 2, 24(1) diff --git a/lld/test/ELF/ppc64-weak-undef-call.s b/lld/test/ELF/ppc64-weak-undef-call.s index 30c1686..02f1dac 100644 --- a/lld/test/ELF/ppc64-weak-undef-call.s +++ b/lld/test/ELF/ppc64-weak-undef-call.s @@ -2,11 +2,11 @@ # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 -# RUN: llvm-objdump -d %t2 | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn %t2 | FileCheck %s # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 -# RUN: llvm-objdump -d %t2 | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn %t2 | FileCheck %s # CHECK: Disassembly of section .text: @@ -23,6 +23,6 @@ _start: # be unreachable. But, we should link successfully. We should not, however, # generate a .plt entry (this would be wasted space). For now, we do nothing # (leaving the zero relative offset present in the input). -# CHECK: 10010000: {{.*}} bl .+0 -# CHECK: 10010004: {{.*}} nop -# CHECK: 10010008: {{.*}} blr +# CHECK: 10010000: bl .+0 +# CHECK: 10010004: nop +# CHECK: 10010008: blr -- 2.7.4