[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.
This commit is contained in:
Fangrui Song 2021-05-22 17:48:45 -07:00
parent 5ff79f001f
commit 0f298ec6cc
10 changed files with 42 additions and 71 deletions

View File

@ -1,4 +1,6 @@
.global bar, _start
.weak group
group:
.section .text.foo,"aG",@progbits,group,comdat

View File

@ -1,3 +1,5 @@
.weak zed
zed:
.section .text3,"axG",@progbits,zed,comdat,unique,0
.global abc
.global abc
abc:

View File

@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t1.o
# RUN: echo '.section .text.foo,"axG",@progbits,foo,comdat; .globl foo; foo:' |\
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t2.o
# RUN: echo '.section .text.foo,"axG",@progbits,foo,comdat; .globl bar; bar:' |\
# RUN: echo '.weak foo; foo: .section .text.foo,"axG",@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",@progbits,foo,comdat
.globl foo
foo:
.data
.quad .text.foo

View File

@ -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",@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",@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

View File

@ -23,6 +23,8 @@
# RELOC-NEXT: R_X86_64_NONE
# RELOC-NEXT: }
.globl group
group:
.section .text.bar1,"aG",@progbits,group,comdat
## .text.bar1 in this file is discarded. Warn on the relocation.

View File

@ -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",@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@plt>
.weak zed
zed:
.section .text3,"axG",@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

View File

@ -1,3 +1,5 @@
.weak c
c:
.section .text.f,"axG",@progbits,c,comdat
.globl foo

View File

@ -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",@progbits,abc,comdat
.byte 42
.section .rodata.foo,"aG",@progbits,abc,comdat

View File

@ -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@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",@progbits,zed,comdat
.global zed
zed:

View File

@ -50,6 +50,7 @@ Symbols:
Section: .data
- Name: foo
Section: .text.foo
Binding: STB_GLOBAL
- Name: for
Section: .data