Skip to content

Commit f1cacab

Browse files
committed
Merging part of r358975:
Only merged the test changes in files that were also changed in r360405. ------------------------------------------------------------------------ r358975 | maskray | 2019-04-23 04:47:28 -0700 (Tue, 23 Apr 2019) | 18 lines [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: 362273
1 parent 5733e36 commit f1cacab

File tree

4 files changed

+81
-94
lines changed

4 files changed

+81
-94
lines changed

lld/test/ELF/ppc64-call-reach.s

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
44
# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \
55
# RUN: %t.o -o %t
6-
# RUN: llvm-objdump -d %t | FileCheck %s
6+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
77
# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \
88
# RUN: %t.o -o %t
9-
# RUN: llvm-objdump -d %t | FileCheck %s
9+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
1010
# RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \
1111
# RUN: %t.o -o %t
12-
# RUN: llvm-objdump -d %t | FileCheck --check-prefix=NEGOFFSET %s
12+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NEGOFFSET %s
1313
# RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \
1414
# RUN: %t.o -o %t
15-
# RUN: llvm-objdump -d %t | FileCheck --check-prefix=THUNK %s
15+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=THUNK %s
1616
# RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s
1717
# RUN: not ld.lld --defsym callee=0x1001002D --defsym tail_callee=0x1001002F \
1818
# RUN: %t.o -o %t 2>&1 | FileCheck --check-prefix=MISSALIGNED %s
1919

2020
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
2121
# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \
2222
# RUN: %t.o -o %t
23-
# RUN: llvm-objdump -d %t | FileCheck %s
23+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
2424
# RUN: ld.lld --defsym callee=0x12010010 --defsym tail_callee=0x12010020 \
2525
# RUN: %t.o -o %t
26-
# RUN: llvm-objdump -d %t | FileCheck %s
26+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
2727
# RUN: ld.lld --defsym callee=0xE010014 --defsym tail_callee=0xE010024 \
2828
# RUN: %t.o -o %t
29-
# RUN: llvm-objdump -d %t | FileCheck --check-prefix=NEGOFFSET %s
29+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NEGOFFSET %s
3030
# RUN: ld.lld --defsym callee=0x12010018 --defsym tail_callee=0x12010028 \
3131
# RUN: %t.o -o %t
32-
# RUN: llvm-objdump -d %t | FileCheck --check-prefix=THUNK %s
32+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=THUNK %s
3333
# RUN: llvm-readelf --sections %t | FileCheck --check-prefix=BRANCHLT %s
3434
# RUN: not ld.lld --defsym callee=0x1001002D --defsym tail_callee=0x1001002F \
3535
# RUN: %t.o -o %t 2>&1 | FileCheck --check-prefix=MISSALIGNED %s
@@ -58,23 +58,23 @@ test:
5858
# Check that we are branching to the definitions, and not range-extending
5959
# thunks.
6060
# CHECK-LABEL: test
61-
# CHECK: 10010014: {{.*}} bl .+33554428
62-
# CHECK: 10010024: {{.*}} b .+33554428
61+
# CHECK: 10010014: bl .+33554428
62+
# CHECK: 10010024: b .+33554428
6363

6464
# NEGOFFSET-LABEL: test
65-
# NEGOFFSET: 10010014: {{.*}} bl .-33554432
66-
# NEGOFFSET: 10010024: {{.*}} b .+33554432
65+
# NEGOFFSET: 10010014: bl .-33554432
66+
# NEGOFFSET: 10010024: b .+33554432
6767

6868
# .branch_lt[0]
6969
# THUNK-LABEL: __long_branch_callee:
70-
# THUNK-NEXT: 10010000: {{.*}} addis 12, 2, -1
70+
# THUNK-NEXT: 10010000: addis 12, 2, -1
7171
# THUNK-NEXT: ld 12, -32768(12)
7272
# THUNK-NEXT: mtctr 12
7373
# THUNK-NEXT: bctr
7474

7575
# .branch_lt[1]
7676
# THUNK-LABEL: __long_branch_tail_callee:
77-
# THUNK-NEXT: 10010010: {{.*}} addis 12, 2, -1
77+
# THUNK-NEXT: 10010010: addis 12, 2, -1
7878
# THUNK-NEXT: ld 12, -32760(12)
7979
# THUNK-NEXT: mtctr 12
8080
# THUNK-NEXT: bctr
@@ -83,12 +83,11 @@ test:
8383
# the offset is interpreted as a signed 26 bit value so 67108812 is actually
8484
# -52.
8585
# THUNK-LABEL: test:
86-
# THUNK: 10010034: {{.*}} bl .-52
87-
# THUNK: 10010044: {{.*}} b .+67108812
86+
# THUNK: 10010034: bl .-52
87+
# THUNK: 10010044: b .+67108812
8888

8989
# The offset from the TOC to the .branch_lt section is (-1 << 16) - 32768.
9090
# Name Type Address Off Size
9191
# BRANCHLT: .branch_lt PROGBITS 0000000010020000 020000 000010
9292
# BRANCHLT: .got PROGBITS 0000000010030000 030000 000008
9393
# BRANCHLT-NOT: .plt
94-

lld/test/ELF/ppc64-ifunc.s

Lines changed: 44 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,75 @@
11
# REQUIRES: ppc
22

33
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
4-
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o
5-
# RUN: ld.lld -shared %t2.o -o %t2.so
6-
# RUN: ld.lld %t.o %t2.so -o %t
7-
# RUN: llvm-objdump -D %t | FileCheck %s
8-
# RUN: llvm-readelf -dynamic-table %t | FileCheck --check-prefix=DT %s
9-
# RUN: llvm-readelf -dyn-relocations %t | FileCheck --check-prefix=DYNREL %s
4+
# RUN: ld.lld %t.o -o %t
5+
# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
6+
# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SECTIONS %s
7+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
8+
# RUN: llvm-readelf -r %t | FileCheck --check-prefix=DYNREL %s
109

1110
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
12-
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o
13-
# RUN: ld.lld -shared %t2.o -o %t2.so
14-
# RUN: ld.lld %t.o %t2.so -o %t
15-
# RUN: llvm-objdump -D %t | FileCheck %s
16-
# RUN: llvm-readelf -dynamic-table %t | FileCheck --check-prefix=DT %s
17-
# RUN: llvm-readelf -dyn-relocations %t | FileCheck --check-prefix=DYNREL %s
11+
# RUN: ld.lld %t.o -o %t
12+
# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
13+
# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SECTIONS %s
14+
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
15+
# RUN: llvm-readelf -r %t | FileCheck --check-prefix=DYNREL %s
1816

19-
# CHECK: Disassembly of section .text:
17+
# NM-DAG: 0000000010028000 d .TOC.
18+
# NM-DAG: 0000000010010028 T ifunc
19+
# NM-DAG: 000000001001002c T ifunc2
2020

21-
# Tocbase + (0 << 16) + 32560
22-
# 0x100280e0 + 0 + 32560 = 0x10030010 (.plt[2])
23-
# CHECK: __plt_foo:
21+
# SECTIONS: .plt NOBITS 0000000010030000
22+
23+
# .plt[0] - .TOC. = 0x10030000 - 0x10028000 = (1<<16) - 32768
24+
# CHECK: __plt_ifunc:
2425
# CHECK-NEXT: std 2, 24(1)
25-
# CHECK-NEXT: addis 12, 2, 0
26-
# CHECK-NEXT: ld 12, 32560(12)
26+
# CHECK-NEXT: addis 12, 2, 1
27+
# CHECK-NEXT: ld 12, -32768(12)
2728
# CHECK-NEXT: mtctr 12
2829
# CHECK-NEXT: bctr
2930

30-
# Tocbase + (0 << 16) + 32568
31-
# 0x100280e0 + 0 + 32568 = 0x1003018 (.plt[3])
32-
# CHECK: __plt_ifunc:
31+
# .plt[1] - .TOC. = 0x10030000+8 - 0x10028000 = (1<<16) - 32760
32+
# CHECK: __plt_ifunc2:
3333
# CHECK-NEXT: std 2, 24(1)
34-
# CHECK-NEXT: addis 12, 2, 0
35-
# CHECK-NEXT: ld 12, 32568(12)
34+
# CHECK-NEXT: addis 12, 2, 1
35+
# CHECK-NEXT: ld 12, -32760(12)
3636
# CHECK-NEXT: mtctr 12
3737
# CHECK-NEXT: bctr
3838

39-
# CHECK: ifunc:
40-
# CHECK-NEXT: 10010028: {{.*}} nop
41-
39+
# __plt_ifunc - . = 0x10010000 - 0x10010038 = -56
40+
# __plt_ifunc2 - . = 0x10010014 - 0x10010040 = -44
4241
# CHECK: _start:
43-
# CHECK-NEXT: addis 2, 12, 2
44-
# CHECK-NEXT: addi 2, 2, -32588
45-
# CHECK-NEXT: bl .-52
46-
# CHECK-NEXT: ld 2, 24(1)
47-
# CHECK-NEXT: bl .-40
48-
# CHECK-NEXT: ld 2, 24(1)
49-
50-
# Check tocbase
51-
# CHECK: Disassembly of section .got:
52-
# CHECK-NEXT: .got:
53-
# CHECK-NEXT: 100200e0
54-
55-
# Check .plt address
56-
# DT_PLTGOT should point to the start of the .plt section.
57-
# DT: 0x0000000000000003 PLTGOT 0x10030000
58-
59-
# Check that we emit the correct dynamic relocation type for an ifunc
60-
# DYNREL: 'PLT' relocation section at offset 0x{{[0-9a-f]+}} contains 48 bytes:
61-
# 48 bytes --> 2 Elf64_Rela relocations
62-
# DYNREL-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
63-
# DYNREL-NEXT: {{[0-9a-f]+}} {{[0-9a-f]+}} R_PPC64_JMP_SLOT {{0+}} foo + 0
64-
# DYNREL-NEXT: {{[0-9a-f]+}} {{[0-9a-f]+}} R_PPC64_IRELATIVE 10010028
42+
# CHECK-NEXT: addis 2, 12, 1
43+
# CHECK-NEXT: addi 2, 2, 32720
44+
# CHECK-NEXT: 10010038: bl .-56
45+
# CHECK-NEXT: ld 2, 24(1)
46+
# CHECK-NEXT: 10010040: bl .-44
47+
# CHECK-NEXT: ld 2, 24(1)
6548

66-
67-
.text
68-
.abiversion 2
49+
# Check that we emit 2 R_PPC64_IRELATIVE.
50+
# DYNREL: R_PPC64_IRELATIVE 10010028
51+
# DYNREL: R_PPC64_IRELATIVE 1001002c
6952

7053
.type ifunc STT_GNU_IFUNC
7154
.globl ifunc
7255
ifunc:
73-
nop
56+
nop
57+
58+
.type ifunc2 STT_GNU_IFUNC
59+
.globl ifunc2
60+
ifunc2:
61+
nop
7462

75-
.global _start
76-
.type _start,@function
63+
.global _start
64+
.type _start,@function
7765

7866
_start:
7967
.Lfunc_gep0:
8068
addis 2, 12, .TOC.-.Lfunc_gep0@ha
8169
addi 2, 2, .TOC.-.Lfunc_gep0@l
8270
.Lfunc_lep0:
8371
.localentry _start, .Lfunc_lep0-.Lfunc_gep0
84-
bl foo
85-
nop
8672
bl ifunc
8773
nop
74+
bl ifunc2
75+
nop

lld/test/ELF/ppc64-toc-restore-recursive-call.s

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# REQUIRES: ppc
22

3-
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
4-
# RUN: ld.lld -shared %t1.o -o %t
5-
# RUN: llvm-objdump -d -r %t | FileCheck %s
3+
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
4+
# RUN: ld.lld -shared %t.o -o %t.so
5+
# RUN: llvm-objdump -d --no-show-raw-insn -r %t.so | FileCheck %s
66

77
# For a recursive call that is interposable the linker calls the plt-stub rather
88
# then calling the function directly. Since the call is through a plt stub and
@@ -18,8 +18,8 @@
1818
# CHECK-NEXT: 10000:
1919
# CHECK-LABEL: recursive_func
2020
# CHECK-NEXT: 10014:
21-
# CHECK: 1003c: {{.*}} bl .-60
22-
# CHECK-NEXT: ld 2, 24(1)
21+
# CHECK: 1003c: bl .-60
22+
# CHECK-NEXT: 10040: ld 2, 24(1)
2323

2424
.abiversion 2
2525
.section ".text"

lld/test/ELF/ppc64-toc-restore.s

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-func.s -o %t3.o
66
// RUN: ld.lld -shared %t2.o -o %t2.so
77
// RUN: ld.lld %t.o %t2.so %t3.o -o %t
8-
// RUN: llvm-objdump -d %t | FileCheck %s
8+
// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
99

1010
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
1111
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o
1212
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-func.s -o %t3.o
1313
// RUN: ld.lld -shared %t2.o -o %t2.so
1414
// RUN: ld.lld %t.o %t2.so %t3.o -o %t
15-
// RUN: llvm-objdump -d %t | FileCheck %s
15+
// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
1616

1717
.text
1818
.abiversion 2
@@ -32,12 +32,12 @@ _start:
3232

3333
// CHECK: Disassembly of section .text:
3434
// CHECK: _start:
35-
// CHECK: 1001001c: {{.*}} bl .-28
36-
// CHECK-NOT: 10010020: {{.*}} nop
37-
// CHECK: 10010020: {{.*}} ld 2, 24(1)
38-
// CHECK: 10010024: {{.*}} bl .-16
39-
// CHECK-NOT: 10010028: {{.*}} nop
40-
// CHECK-NOT: 10010028: {{.*}} ld 2, 24(1)
35+
// CHECK: 1001001c: bl .-28
36+
// CHECK-NOT: 10010020: nop
37+
// CHECK: 10010020: ld 2, 24(1)
38+
// CHECK: 10010024: bl .-16
39+
// CHECK-NOT: 10010028: nop
40+
// CHECK-NOT: 10010028: ld 2, 24(1)
4141

4242
# Calling a function in another object file which will have same
4343
# TOC base does not need a nop. If nop present, do not rewrite to
@@ -49,24 +49,24 @@ _diff_object:
4949
nop
5050

5151
// CHECK: _diff_object:
52-
// CHECK-NEXT: 10010028: {{.*}} bl .+24
53-
// CHECK-NEXT: 1001002c: {{.*}} bl .+20
54-
// CHECK-NEXT: 10010030: {{.*}} nop
52+
// CHECK-NEXT: 10010028: bl .+24
53+
// CHECK-NEXT: 1001002c: bl .+20
54+
// CHECK-NEXT: 10010030: nop
5555

5656
# Branching to a local function does not need a nop
5757
.global noretbranch
5858
noretbranch:
5959
b bar_local
6060
// CHECK: noretbranch:
61-
// CHECK: 10010034: {{.*}} b .+67108832
62-
// CHECK-NOT: 10010038: {{.*}} nop
63-
// CHECK-NOT: 1001003c: {{.*}} ld 2, 24(1)
61+
// CHECK: 10010034: b .+67108832
62+
// CHECK-NOT: 10010038: nop
63+
// CHECK-NOT: 1001003c: ld 2, 24(1)
6464

6565
// This should come last to check the end-of-buffer condition.
6666
.global last
6767
last:
6868
bl foo
6969
nop
7070
// CHECK: last:
71-
// CHECK: 10010038: {{.*}} bl .-56
72-
// CHECK-NEXT: 1001003c: {{.*}} ld 2, 24(1)
71+
// CHECK: 10010038: bl .-56
72+
// CHECK-NEXT: 1001003c: ld 2, 24(1)

0 commit comments

Comments
 (0)