[lld] 0f298ec - [ELF][test] Avoid local signature symbols for section groups to match reality
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat May 22 17:48:52 PDT 2021
Author: Fangrui Song
Date: 2021-05-22T17:48:45-07:00
New Revision: 0f298ec6ccc0877117e4ee8036a58d10e5ff1ac3
URL: https://github.com/llvm/llvm-project/commit/0f298ec6ccc0877117e4ee8036a58d10e5ff1ac3
DIFF: https://github.com/llvm/llvm-project/commit/0f298ec6ccc0877117e4ee8036a58d10e5ff1ac3.diff
LOG: [ELF][test] Avoid local signature symbols for section groups to match reality
If we support local signature symbols (PR43094), these tests would fail.
When the support is added, new tests (local signature symbol specific) should be developed.
Added:
Modified:
lld/test/ELF/Inputs/comdat-discarded-reloc.s
lld/test/ELF/Inputs/comdat.s
lld/test/ELF/comdat-discarded-error.s
lld/test/ELF/comdat-discarded-lazy.s
lld/test/ELF/comdat-discarded-reloc.s
lld/test/ELF/comdat.s
lld/test/ELF/lto/Inputs/comdat.s
lld/test/ELF/relocatable-comdat.s
lld/test/ELF/start-lib-comdat.s
lld/test/ELF/undef-not-suggest.test
Removed:
################################################################################
diff --git a/lld/test/ELF/Inputs/comdat-discarded-reloc.s b/lld/test/ELF/Inputs/comdat-discarded-reloc.s
index d89575f27e944..449ed60a04ffd 100644
--- a/lld/test/ELF/Inputs/comdat-discarded-reloc.s
+++ b/lld/test/ELF/Inputs/comdat-discarded-reloc.s
@@ -1,4 +1,6 @@
.global bar, _start
+.weak group
+group:
.section .text.foo,"aG", at progbits,group,comdat
diff --git a/lld/test/ELF/Inputs/comdat.s b/lld/test/ELF/Inputs/comdat.s
index 467bfa4b8da21..4fe4c73f91b4a 100644
--- a/lld/test/ELF/Inputs/comdat.s
+++ b/lld/test/ELF/Inputs/comdat.s
@@ -1,3 +1,5 @@
+.weak zed
+zed:
.section .text3,"axG", at progbits,zed,comdat,unique,0
- .global abc
+.global abc
abc:
diff --git a/lld/test/ELF/comdat-discarded-error.s b/lld/test/ELF/comdat-discarded-error.s
index d5aa4aa68df77..b818b15d5efff 100644
--- a/lld/test/ELF/comdat-discarded-error.s
+++ b/lld/test/ELF/comdat-discarded-error.s
@@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t1.o
# RUN: echo '.section .text.foo,"axG", at progbits,foo,comdat; .globl foo; foo:' |\
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t2.o
-# RUN: echo '.section .text.foo,"axG", at progbits,foo,comdat; .globl bar; bar:' |\
+# RUN: echo '.weak foo; foo: .section .text.foo,"axG", at progbits,foo,comdat; .globl bar; bar:' |\
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t3.o
# RUN: not ld.lld %t2.o %t3.o %t1.o -o /dev/null 2>&1 | FileCheck %s
@@ -24,5 +24,7 @@ _start:
jmp bar
.section .text.foo,"axG", at progbits,foo,comdat
+.globl foo
+foo:
.data
.quad .text.foo
diff --git a/lld/test/ELF/comdat-discarded-lazy.s b/lld/test/ELF/comdat-discarded-lazy.s
index 4a7c0089d05cc..e19e4b24fa8ed 100644
--- a/lld/test/ELF/comdat-discarded-lazy.s
+++ b/lld/test/ELF/comdat-discarded-lazy.s
@@ -11,7 +11,7 @@
## *before* the symbol fetching the lazy object.
## The test relies on the symbol table order of llvm-mc (lexical), which will
## need adjustment if llvm-mc changes its behavior.
-# RUN: echo '.globl aa, f2; f2: call aa; \
+# RUN: echo '.globl aa, f2; f2: .weak foo; foo: call aa; \
# RUN: .section .text.foo,"axG", at progbits,foo,comdat; aa:' | \
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %taa.o
# RUN: llvm-nm -p %taa.o | FileCheck --check-prefix=AA-NM %s
@@ -30,7 +30,7 @@
## Test the case when the symbol causing a "discarded section" is ordered
## *after* the symbol fetching the lazy object.
-# RUN: echo '.globl f2, zz; f2: call zz; \
+# RUN: echo '.globl f2, zz; .weak foo; foo: f2: call zz; \
# RUN: .section .text.foo,"axG", at progbits,foo,comdat; zz:' | \
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %tzz.o
# RUN: llvm-nm -p %tzz.o | FileCheck --check-prefix=ZZ-NM %s
diff --git a/lld/test/ELF/comdat-discarded-reloc.s b/lld/test/ELF/comdat-discarded-reloc.s
index 11252bf1516bc..41a706607c8f5 100644
--- a/lld/test/ELF/comdat-discarded-reloc.s
+++ b/lld/test/ELF/comdat-discarded-reloc.s
@@ -23,6 +23,8 @@
# RELOC-NEXT: R_X86_64_NONE
# RELOC-NEXT: }
+.globl group
+group:
.section .text.bar1,"aG", at progbits,group,comdat
## .text.bar1 in this file is discarded. Warn on the relocation.
diff --git a/lld/test/ELF/comdat.s b/lld/test/ELF/comdat.s
index 689b8ca9d50a1..a9a5f5fa3bb62 100644
--- a/lld/test/ELF/comdat.s
+++ b/lld/test/ELF/comdat.s
@@ -3,7 +3,7 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/comdat.s -o %t2.o
// RUN: ld.lld -shared %t.o %t2.o -o %t
// RUN: llvm-objdump -d %t | FileCheck %s
-// RUN: llvm-readobj -S --symbols %t | FileCheck --check-prefix=READ %s
+// RUN: llvm-readelf -S -s %t | FileCheck --check-prefix=READ %s
// Check that we don't crash with --gc-section and that we print a list of
// reclaimed sections on stderr.
@@ -14,6 +14,7 @@
// GC: removing unused section {{.*}}.o:(.text)
// GC: removing unused section {{.*}}.o:(.text)
+.globl foo
.section .text2,"axG", at progbits,foo,comdat,unique,0
foo:
nop
@@ -21,7 +22,7 @@ foo:
// CHECK: Disassembly of section .text2:
// CHECK-EMPTY:
// CHECK-NEXT: <foo>:
-// CHECK-NEXT: 1234: {{.*}} nop
+// CHECK-NEXT: nop
// CHECK-NOT: nop
.section bar, "ax"
@@ -30,63 +31,17 @@ foo:
// CHECK: Disassembly of section bar:
// CHECK-EMPTY:
// CHECK-NEXT: <bar>:
-// 0x1234 - 0x1235 - 5 = -6
-// CHECK-NEXT: 1235: {{.*}} callq 0x1234
+// CHECK-NEXT: callq {{.*}} <foo at plt>
+.weak zed
+zed:
.section .text3,"axG", at progbits,zed,comdat,unique,0
+# READ: .text2 PROGBITS {{.*}} AX
+# READ: .text3 PROGBITS {{.*}} AX
-// READ: Name: .text2
-// READ-NEXT: Type: SHT_PROGBITS
-// READ-NEXT: Flags [
-// READ-NEXT: SHF_ALLOC
-// READ-NEXT: SHF_EXECINSTR
-// READ-NEXT: ]
-
-// READ: Name: .text3
-// READ-NEXT: Type: SHT_PROGBITS
-// READ-NEXT: Flags [
-// READ-NEXT: SHF_ALLOC
-// READ-NEXT: SHF_EXECINSTR
-// READ-NEXT: ]
-
-// READ: Symbols [
-// READ-NEXT: Symbol {
-// READ-NEXT: Name: (0)
-// READ-NEXT: Value: 0x0
-// READ-NEXT: Size: 0
-// READ-NEXT: Binding: Local
-// READ-NEXT: Type: None
-// READ-NEXT: Other: 0
-// READ-NEXT: Section: Undefined
-// READ-NEXT: }
-// READ-NEXT: Symbol {
-// READ-NEXT: Name: foo
-// READ-NEXT: Value
-// READ-NEXT: Size: 0
-// READ-NEXT: Binding: Local
-// READ-NEXT: Type: None
-// READ-NEXT: Other: 0
-// READ-NEXT: Section: .text
-// READ-NEXT: }
-// READ-NEXT: Symbol {
-// READ-NEXT: Name: _DYNAMIC
-// READ-NEXT: Value: 0x2240
-// READ-NEXT: Size: 0
-// READ-NEXT: Binding: Local
-// READ-NEXT: Type: None
-// READ-NEXT: Other [ (0x2)
-// READ-NEXT: STV_HIDDEN
-// READ-NEXT: ]
-// READ-NEXT: Section: .dynamic
-// READ-NEXT: }
-// READ-NEXT: Symbol {
-// READ-NEXT: Name: abc
-// READ-NEXT: Value: 0x0
-// READ-NEXT: Size: 0
-// READ-NEXT: Binding: Global
-// READ-NEXT: Type: None
-// READ-NEXT: Other: 0
-// READ-NEXT: Section: Undefined
-// READ-NEXT: }
-// READ-NEXT: ]
+# SYM: NOTYPE LOCAL DEFAULT UND
+# SYM: NOTYPE LOCAL HIDDEN [[#]] _DYNAMIC
+# SYM: NOTYPE GLOBAL DEFAULT [[#]] foo
+# SYM: NOTYPE GLOBAL DEFAULT [[#]] zed
+# SYM: NOTYPE GLOBAL DEFAULT UND abc
diff --git a/lld/test/ELF/lto/Inputs/comdat.s b/lld/test/ELF/lto/Inputs/comdat.s
index 6f6e5ae1d9df7..a71792303025d 100644
--- a/lld/test/ELF/lto/Inputs/comdat.s
+++ b/lld/test/ELF/lto/Inputs/comdat.s
@@ -1,3 +1,5 @@
+.weak c
+c:
.section .text.f,"axG", at progbits,c,comdat
.globl foo
diff --git a/lld/test/ELF/relocatable-comdat.s b/lld/test/ELF/relocatable-comdat.s
index b290bae4ee328..160c48d9fb4d9 100644
--- a/lld/test/ELF/relocatable-comdat.s
+++ b/lld/test/ELF/relocatable-comdat.s
@@ -7,8 +7,8 @@
# RUN: ld.lld -r %t.o %t.o -o %t.ro
# RUN: llvm-readelf -g -S %t.ro | FileCheck %s
-# CHECK: Name Type Address Off Size ES Flg Lk Inf Al
-# CHECK: .group GROUP 0000000000000000 {{.*}} 000014 04 {{[1-9]}} 1 4
+# CHECK: Name Type Address Off Size ES Flg Lk Inf Al
+# CHECK: .group GROUP 0000000000000000 {{.*}} 000014 04 {{[1-9]}} [[#]] 4
# CHECK: COMDAT group section [{{.*}}] `.group' [abc] contains 4 sections:
# CHECK-NEXT: Name
@@ -22,8 +22,8 @@
# RUN: ld.lld -r -T %t1.lds %t.o %t.o -o %t1.ro
# RUN: llvm-readelf -g -S %t1.ro | FileCheck %s --check-prefix=SCRIPT1
-# SCRIPT1: Name Type Address Off Size ES Flg Lk Inf Al
-# SCRIPT1: .group GROUP 0000000000000000 {{.*}} 00000c 04 {{[1-9]}} 1 4
+# SCRIPT1: Name Type Address Off Size ES Flg Lk Inf Al
+# SCRIPT1: .group GROUP 0000000000000000 {{.*}} 00000c 04 {{[1-9]}} [[#]] 4
# SCRIPT1: COMDAT group section [{{.*}}] `.group' [abc] contains 2 sections:
# SCRIPT1-NEXT: Name
@@ -35,14 +35,17 @@
# RUN: llvm-readelf -g -S %t2.ro | FileCheck %s --check-prefix=SCRIPT2
## Handle discarded group members.
-# SCRIPT2: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
-# SCRIPT2: [ 2] .group GROUP 0000000000000000 {{.*}} 00000c 04 {{[1-9]}} 1 4
+# SCRIPT2: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
+# SCRIPT2: [ 2] .group GROUP 0000000000000000 {{.*}} 00000c 04 {{[1-9]}} [[#]] 4
# SCRIPT2: COMDAT group section [{{.*}}] `.group' [abc] contains 2 sections:
# SCRIPT2-NEXT: Name
# SCRIPT2-NEXT: .text.bar
# SCRIPT2-NEXT: .text.foo
+.weak abc
+abc:
+
.section .rodata.bar,"aG", at progbits,abc,comdat
.byte 42
.section .rodata.foo,"aG", at progbits,abc,comdat
diff --git a/lld/test/ELF/start-lib-comdat.s b/lld/test/ELF/start-lib-comdat.s
index 996ddb485bab3..e4d666967c315 100644
--- a/lld/test/ELF/start-lib-comdat.s
+++ b/lld/test/ELF/start-lib-comdat.s
@@ -4,9 +4,9 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \
// RUN: %p/Inputs/start-lib-comdat.s -o %t2.o
// RUN: ld.lld -shared -o %t3 %t1.o --start-lib %t2.o --end-lib
-// RUN: llvm-readobj --symbols %t3 | FileCheck %s
+// RUN: llvm-readobj --dyn-syms %t3 | FileCheck %s
// RUN: ld.lld -shared -o %t3 --start-lib %t2.o --end-lib %t1.o
-// RUN: llvm-readobj --symbols %t3 | FileCheck /dev/null --implicit-check-not='Name: zed'
+// RUN: llvm-readobj --dyn-syms %t3 | FileCheck %s
// CHECK: Name: zed
// CHECK-NEXT: Value:
@@ -14,10 +14,12 @@
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type:
// CHECK-NEXT: Other:
-// CHECK-NEXT: Section: Undefined
+// CHECK-NEXT: Section: .sec
call bar at plt
// The other file also has a section in the zed comdat, but it defines the
// symbol zed. That means that we will have a lazy symbol zed, but when adding
// the actual file zed will be undefined.
.section .sec,"aG", at progbits,zed,comdat
+.global zed
+zed:
diff --git a/lld/test/ELF/undef-not-suggest.test b/lld/test/ELF/undef-not-suggest.test
index b8eebd3148f7e..f863f36f118a1 100644
--- a/lld/test/ELF/undef-not-suggest.test
+++ b/lld/test/ELF/undef-not-suggest.test
@@ -50,6 +50,7 @@ Symbols:
Section: .data
- Name: foo
Section: .text.foo
+ Binding: STB_GLOBAL
- Name: for
Section: .data
More information about the llvm-commits
mailing list