[lld] r329557 - [ELF] - Allow LLD to produce file symbols.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 9 04:43:52 PDT 2018
Author: grimar
Date: Mon Apr 9 04:43:52 2018
New Revision: 329557
URL: http://llvm.org/viewvc/llvm-project?rev=329557&view=rev
Log:
[ELF] - Allow LLD to produce file symbols.
This is for PR36716 and
this enables emitting STT_FILE symbols.
Output size affect is minor:
lld binary size changes from 52,883,408 to 52,949,400
clang binary size changes from 83,136,456 to 83,219,600
Differential revision: https://reviews.llvm.org/D45261
Added:
lld/trunk/test/ELF/local-symbols-order.s
Removed:
lld/trunk/test/ELF/file-sym.s
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/lto/data-ordering-lto.s
lld/trunk/test/ELF/lto/parallel-internalize.ll
lld/trunk/test/ELF/lto/relocatable.ll
lld/trunk/test/ELF/lto/symbol-ordering-lto.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=329557&r1=329556&r2=329557&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Apr 9 04:43:52 2018
@@ -494,7 +494,7 @@ template <class ELFT> void Writer<ELFT>:
static bool shouldKeepInSymtab(SectionBase *Sec, StringRef SymName,
const Symbol &B) {
- if (B.isFile() || B.isSection())
+ if (B.isSection())
return false;
// If sym references a section in a discarded group, don't keep it.
Removed: lld/trunk/test/ELF/file-sym.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/file-sym.s?rev=329556&view=auto
==============================================================================
--- lld/trunk/test/ELF/file-sym.s (original)
+++ lld/trunk/test/ELF/file-sym.s (removed)
@@ -1,12 +0,0 @@
-# Check that we do not keep STT_FILE symbols in the symbol table
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: ld.lld %t.o -shared -o %t.so
-# RUN: llvm-readobj -symbols %t.so | FileCheck %s
-
-# REQUIRES: x86
-
-# CHECK-NOT: Name: xxx
-
-.file "xxx"
-.file ""
Added: lld/trunk/test/ELF/local-symbols-order.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/local-symbols-order.s?rev=329557&view=auto
==============================================================================
--- lld/trunk/test/ELF/local-symbols-order.s (added)
+++ lld/trunk/test/ELF/local-symbols-order.s Mon Apr 9 04:43:52 2018
@@ -0,0 +1,27 @@
+# REQUIRES: x86
+
+# RUN: echo '.file "file2"; foo2:; .global bar2; .hidden bar2; bar2:' > %t2.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t2.s -o %t2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+
+# RUN: ld.lld -o %t %t1.o %t2.o
+# RUN: llvm-readobj -symbols -elf-output-style=GNU %t | FileCheck %s
+
+## Show the order of the local symbols produced currently by LLD.
+
+# CHECK: 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 file1
+# CHECK-NEXT: 2: 0000000000201000 0 NOTYPE LOCAL DEFAULT 1 foo1
+# CHECK-NEXT: 3: 0000000000000000 0 FILE LOCAL DEFAULT ABS file2
+# CHECK-NEXT: 4: 0000000000201000 0 NOTYPE LOCAL DEFAULT 1 foo2
+# CHECK-NEXT: 5: 0000000000201000 0 NOTYPE LOCAL HIDDEN 1 bar1
+# CHECK-NEXT: 6: 0000000000201000 0 NOTYPE LOCAL HIDDEN 1 bar2
+
+foo1:
+
+.global bar1
+.hidden bar1
+bar1:
+
+.file "file1"
Modified: lld/trunk/test/ELF/lto/data-ordering-lto.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/data-ordering-lto.s?rev=329557&r1=329556&r2=329557&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/data-ordering-lto.s (original)
+++ lld/trunk/test/ELF/lto/data-ordering-lto.s Mon Apr 9 04:43:52 2018
@@ -12,13 +12,14 @@
# Check that the order is tin -> dipsy -> pat.
-# CHECK: Symbol table '.symtab' contains 5 entries:
+# 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: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 1 _start
-# CHECK-NEXT: 2: 0000000000202004 4 OBJECT GLOBAL DEFAULT 2 dipsy
-# CHECK-NEXT: 3: 0000000000202008 4 OBJECT GLOBAL DEFAULT 2 pat
-# CHECK-NEXT: 4: 0000000000202000 4 OBJECT GLOBAL DEFAULT 2 tin
+# 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:
Modified: lld/trunk/test/ELF/lto/parallel-internalize.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/parallel-internalize.ll?rev=329557&r1=329556&r2=329557&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/parallel-internalize.ll (original)
+++ lld/trunk/test/ELF/lto/parallel-internalize.ll Mon Apr 9 04:43:52 2018
@@ -18,6 +18,24 @@
; CHECK-NEXT: Section: Undefined (0x0)
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: {{.*}}.o
+; CHECK-NEXT: Value: 0x0
+; CHECK-NEXT: Size: 0
+; CHECK-NEXT: Binding: Local
+; CHECK-NEXT: Type: File
+; CHECK-NEXT: Other: 0
+; CHECK-NEXT: Section: Absolute
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: {{.*}}.o
+; CHECK-NEXT: Value: 0x0
+; CHECK-NEXT: Size: 0
+; CHECK-NEXT: Binding: Local
+; CHECK-NEXT: Type: File
+; CHECK-NEXT: Other: 0
+; CHECK-NEXT: Section: Absolute
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: bar
; CHECK-NEXT: Value: 0x201010
; CHECK-NEXT: Size: 8
Modified: lld/trunk/test/ELF/lto/relocatable.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/relocatable.ll?rev=329557&r1=329556&r2=329557&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/relocatable.ll (original)
+++ lld/trunk/test/ELF/lto/relocatable.ll Mon Apr 9 04:43:52 2018
@@ -14,6 +14,15 @@
; CHECK-NEXT: Section: Undefined
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: {{.*}}.o
+; CHECK-NEXT: Value: 0x0
+; CHECK-NEXT: Size: 0
+; CHECK-NEXT: Binding: Local
+; CHECK-NEXT: Type: File
+; CHECK-NEXT: Other: 0
+; CHECK-NEXT: Section: Absolute
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name:
; CHECK-NEXT: Value: 0x0
; CHECK-NEXT: Size: 0
Modified: lld/trunk/test/ELF/lto/symbol-ordering-lto.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/symbol-ordering-lto.s?rev=329557&r1=329556&r2=329557&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/symbol-ordering-lto.s (original)
+++ lld/trunk/test/ELF/lto/symbol-ordering-lto.s Mon Apr 9 04:43:52 2018
@@ -12,12 +12,13 @@
# Check that the order is tin -> _start -> pat.
-# CHECK: Symbol table '.symtab' contains 4 entries:
+# 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: 0000000000201008 0 NOTYPE GLOBAL DEFAULT 1 _start
-# CHECK-NEXT: 2: 0000000000201020 6 FUNC GLOBAL DEFAULT 1 pat
-# CHECK-NEXT: 3: 0000000000201000 6 FUNC GLOBAL DEFAULT 1 tin
+# 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:
More information about the llvm-commits
mailing list