[ELF][test] Improve LTO tests

Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output

llvm-svn: 371292
This commit is contained in:
Fangrui Song 2019-09-07 08:20:09 +00:00
parent f2b9dc4758
commit 89f7859641
15 changed files with 85 additions and 78 deletions

View File

@ -1,4 +1,8 @@
; REQUIRES: x86
;; Test we don't get "duplicate symbol" error when bitcode/regular object
;; comdats are used together.
; RUN: llvm-as %s -o %t.o
; RUN: llvm-mc -triple=x86_64-pc-linux %p/Inputs/comdat.s -o %t2.o -filetype=obj
; RUN: ld.lld %t.o %t2.o -o %t.so -shared
@ -18,7 +22,7 @@ define protected void @foo() comdat($c) {
; CHECK: Symbol {
; CHECK: Name: foo
; CHECK-NEXT: Value: 0x1000
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global
; CHECK-NEXT: Type: Function
@ -30,7 +34,7 @@ define protected void @foo() comdat($c) {
; OTHER: Symbol {
; OTHER: Name: foo
; OTHER-NEXT: Value: 0x1000
; OTHER-NEXT: Value:
; OTHER-NEXT: Size: 0
; OTHER-NEXT: Binding: Global
; OTHER-NEXT: Type: None

View File

@ -1,28 +0,0 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
# RUN: llvm-as %p/Inputs/data-ordering-lto.ll -o %t.bc
# Set up the symbol file
# RUN: echo "tin " > %t_order_lto.txt
# RUN: echo "dipsy " >> %t_order_lto.txt
# RUN: echo "pat " >> %t_order_lto.txt
# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out
# RUN: llvm-readelf --symbols %t2.out| FileCheck %s
# Check that the order is tin -> dipsy -> pat.
# CHECK: Symbol table '.symtab' contains 6 entries:
# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# CHECK-NEXT: 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS {{.*}}.o
# CHECK-NEXT: 2: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 1 _start
# CHECK-NEXT: 3: 0000000000202004 4 OBJECT GLOBAL DEFAULT 2 dipsy
# CHECK-NEXT: 4: 0000000000202008 4 OBJECT GLOBAL DEFAULT 2 pat
# CHECK-NEXT: 5: 0000000000202000 4 OBJECT GLOBAL DEFAULT 2 tin
.globl _start
_start:
movl $pat, %ecx
movl $dipsy, %ebx
movl $tin, %eax

View File

@ -1,11 +1,14 @@
; REQUIRES: x86
;; Test we parse dynamic lists before LTO, so symbols can be exported correctly.
; RUN: llvm-as %s -o %t.o
; RUN: echo "{ foo; };" > %t.list
; RUN: ld.lld -o %t --dynamic-list %t.list -pie %t.o
; RUN: llvm-readobj --dyn-syms %t | FileCheck %s
; CHECK: Name: foo
; CHECK-NEXT: Value: 0x1010
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global (0x1)
; CHECK-NEXT: Type: Function

View File

@ -8,17 +8,17 @@
; RUN: llvm-objdump -d %t3 | FileCheck %s --check-prefix=IPO
; IPO: Disassembly of section .text:
; IPO: _start:
; IPO-NEXT: 201000: {{.*}} movl $1, %eax
; IPO-NEXT: 201005: {{.*}} retq
; IPO-NEXT: movl $1, %eax
; IPO-NEXT: retq
;; Check that LTO does not do IPO for symbols assigned by script.
; RUN: ld.lld %t1.o %t2.o -o %t4 --script %t.script -save-temps
; RUN: llvm-objdump -d %t4 | FileCheck %s --check-prefix=NOIPO
; NOIPO: Disassembly of section .text:
; NOIPO: foo:
; NOIPO-NEXT: {{.*}} movl $2, %eax
; NOIPO-NEXT: movl $2, %eax
; NOIPO: _start:
; NOIPO-NEXT: {{.*}} jmp -21 <foo>
; NOIPO-NEXT: jmp -21 <foo>
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

View File

@ -6,16 +6,14 @@
; Test to ensure that obj-path creates the ELF file.
; RUN: rm -f %t4.o
; RUN: ld.lld --plugin-opt=obj-path=%t4.o -shared %t1.o %t2.o -o %t3
; RUN: llvm-readobj --symbols %t3 | FileCheck %s
; RUN: llvm-nm %t3 | FileCheck %s
; RUN: llvm-readobj -h %t4.o1 | FileCheck %s -check-prefix=ELF1
; RUN: llvm-readobj -h %t4.o2 | FileCheck %s -check-prefix=ELF2
; RUN: llvm-nm %t4.o1 2>&1 | FileCheck %s -check-prefix=NM1
; RUN: llvm-nm %t4.o2 2>&1 | FileCheck %s -check-prefix=NM2
; CHECK: Name: g
; CHECK-NEXT: Value: 0x1010
; CHECK: Name: f
; CHECK-NEXT: Value: 0x1000
; CHECK: T f
; CHECK-NEXT: T g
; NM1: T f
; ELF1: Format: ELF64-x86-64

View File

@ -37,7 +37,7 @@
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: bar
; CHECK-NEXT: Value: 0x201010
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 8
; CHECK-NEXT: Binding: Local (0x0)
; CHECK-NEXT: Type: Function (0x2)
@ -48,7 +48,7 @@
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: foo
; CHECK-NEXT: Value: 0x201000
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 8
; CHECK-NEXT: Binding: Global (0x1)
; CHECK-NEXT: Type: Function (0x2)

View File

@ -7,7 +7,7 @@
; RUN: llvm-readobj --dyn-syms %t | FileCheck %s
; CHECK: Name: __progname
; CHECK-NEXT: Value: 0x201010
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global (0x1)
; CHECK-NEXT: Type: Function

View File

@ -0,0 +1,24 @@
# REQUIRES: x86
## Test we enable data sections for LTO so --symbol-ordering-fils is respected
## for data symbols.
# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
# RUN: llvm-as %p/Inputs/data-ordering-lto.ll -o %t.bc
# RUN: echo "tin " > %t_order_lto.txt
# RUN: echo "dipsy " >> %t_order_lto.txt
# RUN: echo "pat " >> %t_order_lto.txt
# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t
# RUN: llvm-nm -v %t | FileCheck %s
# CHECK: D tin
# CHECK-NEXT: D dipsy
# CHECK-NEXT: D pat
.globl _start
_start:
movl $pat, %ecx
movl $dipsy, %ebx
movl $tin, %eax

View File

@ -0,0 +1,23 @@
# REQUIRES: x86
## Test we enable function sections for LTO so --symbol-ordering-fils is respected
## for function symbols.
# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
# RUN: llvm-as %p/Inputs/symbol-ordering-lto.ll -o %t.bc
# RUN: echo "tin " > %t_order_lto.txt
# RUN: echo "_start " >> %t_order_lto.txt
# RUN: echo "pat " >> %t_order_lto.txt
# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t
# RUN: llvm-nm -v %t | FileCheck %s
# CHECK: T tin
# CHECK-NEXT: T _start
# CHECK-NEXT: T pat
.globl _start
_start:
call pat
call tin

View File

@ -1,26 +0,0 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
# RUN: llvm-as %p/Inputs/symbol-ordering-lto.ll -o %t.bc
# Set up the symbol file
# RUN: echo "tin " > %t_order_lto.txt
# RUN: echo "_start " >> %t_order_lto.txt
# RUN: echo "pat " >> %t_order_lto.txt
# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out
# RUN: llvm-readelf --symbols %t2.out| FileCheck %s
# Check that the order is tin -> _start -> pat.
# CHECK: Symbol table '.symtab' contains 5 entries:
# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# CHECK-NEXT: 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS {{.*}}.o
# CHECK-NEXT: 2: 0000000000201008 0 NOTYPE GLOBAL DEFAULT 1 _start
# CHECK-NEXT: 3: 0000000000201020 6 FUNC GLOBAL DEFAULT 1 pat
# CHECK-NEXT: 4: 0000000000201000 6 FUNC GLOBAL DEFAULT 1 tin
.globl _start
_start:
call pat
call tin

View File

@ -19,8 +19,8 @@ declare i32 @printf(i8*, ...)
; Check that puts symbol is present in the dynamic symbol table and
; there's a relocation for it.
; CHECK: Dynamic Relocations {
; CHECK-NEXT: 0x203018 R_X86_64_JUMP_SLOT puts 0x0
; CHECK: Dynamic Relocations {
; CHECK-NEXT: R_X86_64_JUMP_SLOT puts 0x0
; CHECK-NEXT: }
; CHECK: DynamicSymbols [

View File

@ -3,7 +3,7 @@
; RUN: echo "VERSION_1.0{ global: foo; local: *; }; VERSION_2.0{ global: bar; local: *; };" > %t.script
; RUN: ld.lld %t.o -o %t2 -shared --version-script %t.script -save-temps
; RUN: llvm-dis < %t2.0.0.preopt.bc | FileCheck %s
; RUN: llvm-readobj -V --dyn-syms %t2 | FileCheck --check-prefix=DSO %s
; RUN: llvm-readobj --dyn-syms %t2 | FileCheck --check-prefix=DSO %s
target triple = "x86_64-unknown-linux-gnu"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@ -31,7 +31,7 @@ define void @bar() {
; DSO: }
; DSO: Symbol {
; DSO: Name: foo@@VERSION_1.0
; DSO: Value: 0x1000
; DSO: Value:
; DSO: Size: 1
; DSO: Binding: Global
; DSO: Type: Function
@ -40,7 +40,7 @@ define void @bar() {
; DSO: }
; DSO: Symbol {
; DSO: Name: bar@@VERSION_2.0
; DSO: Value: 0x1010
; DSO: Value:
; DSO: Size: 1
; DSO: Binding: Global
; DSO: Type: Function

View File

@ -1,10 +1,13 @@
; REQUIRES: x86
;; Test we parse symbol versions before LTO, otherwise we may get a symbol
;; named "foo@@VER1", but not "foo" with the version VER1.
; RUN: llvm-as %s -o %t.o
; RUN: echo "VER1 {};" > %t.script
; RUN: ld.lld %t.o -o %t.so -shared --version-script %t.script
; RUN: llvm-readobj --dyn-syms %t.so | FileCheck %s
; test that we have the correct version.
; CHECK: Name: foo@@VER1 (
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

View File

@ -6,7 +6,7 @@
; RUN: llvm-readobj --symbols %t.so | FileCheck %s
; CHECK: Name: g
; CHECK-NEXT: Value: 0x1000
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local
; CHECK-NEXT: Type: None
@ -16,7 +16,7 @@
; CHECK-NEXT: Section: .text
; CHECK: Name: a
; CHECK-NEXT: Value: 0x3000
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local
; CHECK-NEXT: Type: None

View File

@ -1,4 +1,7 @@
; REQUIRES: x86
;; Test weak symbols are supported in LTO.
; RUN: llvm-as %s -o %t.o
; RUN: ld.lld %t.o %t.o -o %t.so -shared
; RUN: llvm-readobj --symbols %t.so | FileCheck %s
@ -11,6 +14,9 @@ define weak void @f() {
}
; CHECK: Name: f
; CHECK-NEXT: Value: 0x1000
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Weak
; CHECK-NEXT: Type: Function
; CHECK-NEXT: Other: 0
; CHECK-NEXT: Section: .text