; 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
; CHECK: Symbol {
; CHECK: Name: foo
-; CHECK-NEXT: Value: 0x1000
+; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Binding: Global
; CHECK-NEXT: Type: Function
; OTHER: Symbol {
; OTHER: Name: foo
-; OTHER-NEXT: Value: 0x1000
+; OTHER-NEXT: Value:
; OTHER-NEXT: Size: 0
; OTHER-NEXT: Binding: Global
; OTHER-NEXT: Type: None
+++ /dev/null
-# 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
; 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
; 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"
; 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
; 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)
; 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)
; 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
--- /dev/null
+# 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
--- /dev/null
+# 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
+++ /dev/null
-# 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
; 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 [
; 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"
; DSO: }
; DSO: Symbol {
; DSO: Name: foo@@VERSION_1.0
-; DSO: Value: 0x1000
+; DSO: Value:
; DSO: Size: 1
; DSO: Binding: Global
; DSO: Type: Function
; DSO: }
; DSO: Symbol {
; DSO: Name: bar@@VERSION_2.0
-; DSO: Value: 0x1010
+; DSO: Value:
; DSO: Size: 1
; DSO: Binding: Global
; DSO: Type: Function
; 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"
; 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
; 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
; 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
}
; 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