Skip to content

Commit 161e168

Browse files
authored
[llvm-readobj][ELF] Test multivalued rpath entries and alter the output for readobj to emphasize the single valued nature of NEEDED, SONAME, USED etc. (#96562)
In the context of #95976 it became clear that the output for readobj implied multi valued entries in several cases in the elf headers that the documentation only allowed for a single value. DT_NEEDED is the example here where the value is an offset into the string table without any sort of separator that could give you multiple entries. This patch alters the LLVM output so that the single valued nature is emphasized. For example the output was: ``` DynamicSection [ (35 entries) Tag Type Name/Value 0x000000000000001D RUNPATH Library runpath: [$ORIGIN/../lib:] 0x0000000000000001 NEEDED Shared library: [libm.so.6] 0x0000000000000001 NEEDED Shared library: [libz.so.1] 0x0000000000000001 NEEDED Shared library: [libzstd.so.1] ``` and is now ``` Tag Type Name/Value 0x000000000000001D RUNPATH Library runpath: [$ORIGIN/../lib:] 0x0000000000000001 NEEDED Shared library: libm.so.6 0x0000000000000001 NEEDED Shared library: libz.so.1 0x0000000000000001 NEEDED Shared library: libzstd.so.1 ``` This pr also tests that multi-valued rpaths are handled correctly in the JSON case (i.e. they become proper lists) like: ``` { "Tag": 15, "Type": "RPATH", "Value": 9, "Path": [ "x", "w", "U" ] }, ``` when separated by :
1 parent e5e0d87 commit 161e168

19 files changed

+106
-105
lines changed

lld/test/ELF/as-needed-no-reloc.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# There must be a NEEDED entry for each undefined
1010

11-
# CHECK: (NEEDED) Shared library: [{{.*}}as-needed-no-reloc{{.*}}2.so]
11+
# CHECK: (NEEDED) Shared library: {{.*}}as-needed-no-reloc{{.*}}2.so
1212
# CHECK: UND bar
1313

1414
.globl _start

lld/test/ELF/as-needed.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
// RUN: ld.lld %t.o %t.script -o %t2
3333
// RUN: llvm-readobj --dynamic-table %t2 | FileCheck -check-prefix=CHECK2 %s
3434

35-
// CHECK: NEEDED Shared library: [shared1]
36-
// CHECK: NEEDED Shared library: [shared2]
37-
// CHECK: NEEDED Shared library: [shared3]
35+
// CHECK: NEEDED Shared library: shared1
36+
// CHECK: NEEDED Shared library: shared2
37+
// CHECK: NEEDED Shared library: shared3
3838

39-
// CHECK2: NEEDED Shared library: [shared1]
40-
// CHECK2-NOT: NEEDED Shared library: [shared2]
41-
// CHECK2-NOT: NEEDED Shared library: [shared3]
39+
// CHECK2: NEEDED Shared library: shared1
40+
// CHECK2-NOT: NEEDED Shared library: shared2
41+
// CHECK2-NOT: NEEDED Shared library: shared3
4242

4343
.global _start
4444
_start:

lld/test/ELF/auxiliary.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
# CHECK: DynamicSection [
99
# CHECK-NEXT: Tag Type Name/Value
10-
# CHECK-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: [aaa]
11-
# CHECK-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: [bbb]
10+
# CHECK-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: aaa
11+
# CHECK-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: bbb
1212

1313
# RUN: not ld.lld %t.o -f aaa --auxiliary bbb -o /dev/null 2>&1 \
1414
# RUN: | FileCheck -check-prefix=ERR %s

lld/test/ELF/dynamic-reloc.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
// CHECK: DynamicSection [
3434
// CHECK-NEXT: Tag Type Name/Value
35-
// CHECK-NEXT: 0x0000000000000001 NEEDED Shared library: [so]
35+
// CHECK-NEXT: 0x0000000000000001 NEEDED Shared library: so
3636
// CHECK-NEXT: 0x0000000000000015 DEBUG 0x0
3737
// CHECK-NEXT: 0x0000000000000017 JMPREL
3838
// CHECK-NEXT: 0x0000000000000002 PLTRELSZ 24 (bytes)

lld/test/ELF/filter.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
# CHECK: DynamicSection [
1515
# CHECK-NEXT: Tag Type Name/Value
16-
# CHECK-NEXT: 0x000000007FFFFFFF FILTER Filter library: [foo.so]
17-
# CHECK-NEXT: 0x000000007FFFFFFF FILTER Filter library: [boo.so]
16+
# CHECK-NEXT: 0x000000007FFFFFFF FILTER Filter library: foo.so
17+
# CHECK-NEXT: 0x000000007FFFFFFF FILTER Filter library: boo.so
1818

1919
# RUN: not ld.lld %t.o -F x -o /dev/null 2>&1 | FileCheck -check-prefix=ERR %s
2020
# ERR: -F may not be used without -shared

lld/test/ELF/gc-sections-shared.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# this case is checked with symbol qux and %t4.so.
1616

1717
# CHECK-NOT: NEEDED
18-
# CHECK: (NEEDED) Shared library: [{{.*}}3.so]
18+
# CHECK: (NEEDED) Shared library: {{.*}}3.so
1919
# CHECK-NOT: NEEDED
2020

2121
# CHECK-DAG: FUNC WEAK DEFAULT UND qux

lld/test/ELF/no-soname.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66
// RUN: ld.lld %t.o %t.dir/no-soname/libfoo.so -o %t
77
// RUN: llvm-readobj --dynamic-table %t | FileCheck %s
88

9-
// CHECK: 0x0000000000000001 NEEDED Shared library: [{{.*}}/no-soname/libfoo.so]
9+
// CHECK: 0x0000000000000001 NEEDED Shared library: {{.*}}/no-soname/libfoo.so
1010
// CHECK-NOT: NEEDED
1111

1212
// RUN: ld.lld %t.o %t.dir/no-soname/../no-soname/libfoo.so -o %t
1313
// RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=CHECK2
1414

15-
// CHECK2: 0x0000000000000001 NEEDED Shared library: [{{.*}}/no-soname/../no-soname/libfoo.so]
15+
// CHECK2: 0x0000000000000001 NEEDED Shared library: {{.*}}/no-soname/../no-soname/libfoo.so
1616
// CHECK2-NOT: NEEDED
1717

1818
// RUN: ld.lld %t.o -L%t.dir/no-soname/../no-soname -lfoo -o %t
1919
// RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=CHECK3
2020

21-
// CHECK3: 0x0000000000000001 NEEDED Shared library: [libfoo.so]
21+
// CHECK3: 0x0000000000000001 NEEDED Shared library: libfoo.so
2222
// CHECK3-NOT: NEEDED
2323

2424
// RUN: ld.lld %t.o -shared -soname libbar.so -o %t.dir/no-soname/libbar.so
2525
// RUN: ld.lld %t.o %t.dir/no-soname/libbar.so -o %t
2626
// RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=CHECK4
2727

28-
// CHECK4: 0x0000000000000001 NEEDED Shared library: [libbar.so]
28+
// CHECK4: 0x0000000000000001 NEEDED Shared library: libbar.so
2929
// CHECK4-NOT: NEEDED
3030

3131
.global _start

lld/test/ELF/partition-synthetic-sections.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474

7575
// CHECK: Dynamic section
7676
// CHECK-NEXT: Tag
77-
// CHECK-NEXT: 0x0000000000000001 (NEEDED) Shared library: [verneed1.so.0]
78-
// PART0-NEXT: 0x000000000000000e (SONAME) Library soname: [main.so]
79-
// PART1-NEXT: 0x0000000000000001 (NEEDED) Shared library: [main.so]
80-
// PART1-NEXT: 0x000000000000000e (SONAME) Library soname: [part1]
77+
// CHECK-NEXT: 0x0000000000000001 (NEEDED) Shared library: verneed1.so.0
78+
// PART0-NEXT: 0x000000000000000e (SONAME) Library soname: main.so
79+
// PART1-NEXT: 0x0000000000000001 (NEEDED) Shared library: main.so
80+
// PART1-NEXT: 0x000000000000000e (SONAME) Library soname: part1
8181
// CHECK-NEXT: 0x0000000000000007 (RELA) 0x[[RELA_DYN_ADDR]]
8282
// CHECK-NEXT: 0x0000000000000008 (RELASZ)
8383
// CHECK-NEXT: 0x0000000000000009 (RELAENT) 24 (bytes)

lld/test/ELF/push-state.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
// RUN: ld.lld -o %t.exe -push-state -as-needed -pop-state %t.so %t1.o
2626
// RUN: llvm-readobj --dynamic-table %t.exe | FileCheck -check-prefix=NO-AS-NEEDED %s
27-
// NO-AS-NEEDED: NEEDED Shared library: [libfoo]
27+
// NO-AS-NEEDED: NEEDED Shared library: libfoo
2828

2929

3030
// RUN: mkdir -p %t.dir

lld/test/ELF/shared-ppc64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// CHECK: DynamicSection [
2929
// CHECK-NEXT: Tag Type Name/Value
3030
// CHECK-NEXT: 0x000000000000001D RUNPATH Library runpath: [foo:bar]
31-
// CHECK-NEXT: 0x0000000000000001 NEEDED Shared library: [{{.*}}2.so]
31+
// CHECK-NEXT: 0x0000000000000001 NEEDED Shared library: {{.*}}2.so
3232
// CHECK-NEXT: 0x0000000000000015 DEBUG 0x0
3333
// CHECK-NEXT: 0x0000000000000007 RELA [[RELADDR]]
3434
// CHECK-NEXT: 0x0000000000000008 RELASZ [[RELSIZE]] (bytes)

0 commit comments

Comments
 (0)