[lld] r292512 - Create _end symbol even if a .so defines it.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 11:43:35 PST 2017


Author: rafael
Date: Thu Jan 19 13:43:34 2017
New Revision: 292512

URL: http://llvm.org/viewvc/llvm-project?rev=292512&view=rev
Log:
Create _end symbol even if a .so defines it.

The freebsd sbrk implementation uses _end to find the initial value of
brk, so it has to be defined in the main binary.

This should fix the emacs build.

Added:
    lld/trunk/test/ELF/Inputs/resolution-end.s
    lld/trunk/test/ELF/resolution-end.s
Modified:
    lld/trunk/ELF/SymbolTable.cpp

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=292512&r1=292511&r2=292512&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Thu Jan 19 13:43:34 2017
@@ -140,7 +140,7 @@ template <class ELFT>
 DefinedRegular<ELFT> *SymbolTable<ELFT>::addIgnored(StringRef Name,
                                                     uint8_t Visibility) {
   SymbolBody *S = find(Name);
-  if (!S || !S->isUndefined())
+  if (!S || S->isInCurrentDSO())
     return nullptr;
   return addAbsolute(Name, Visibility);
 }

Added: lld/trunk/test/ELF/Inputs/resolution-end.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/resolution-end.s?rev=292512&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/resolution-end.s (added)
+++ lld/trunk/test/ELF/Inputs/resolution-end.s Thu Jan 19 13:43:34 2017
@@ -0,0 +1,2 @@
+.data
+        .quad _end

Added: lld/trunk/test/ELF/resolution-end.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/resolution-end.s?rev=292512&view=auto
==============================================================================
--- lld/trunk/test/ELF/resolution-end.s (added)
+++ lld/trunk/test/ELF/resolution-end.s Thu Jan 19 13:43:34 2017
@@ -0,0 +1,39 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/resolution-end.s -o %t2.o
+# RUN: ld.lld -shared -o %t2.so %t2.o
+# RUN: ld.lld %t1.o %t2.so -o %t
+# RUN: llvm-readobj -t -s -section-data  %t | FileCheck %s
+# REQUIRES: x86
+
+# Test that we resolve _end to the this executable.
+
+# CHECK:      Name: .text
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT:   SHF_ALLOC
+# CHECK-NEXT:   SHF_EXECINSTR
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Link:
+# CHECK-NEXT: Info:
+# CHECK-NEXT: AddressAlignment:
+# CHECK-NEXT: EntrySize:
+# CHECK-NEXT: SectionData (
+# CHECK-NEXT:   0000: 80202000 00000000
+# CHECK-NEXT: )
+
+# CHECK:      Symbol {
+# CHECK:        Name: _end
+# CHECK-NEXT:   Value: 0x202080
+# CHECK-NEXT:   Size:
+# CHECK-NEXT:   Binding: Global
+# CHECK-NEXT:   Type:
+# CHECK-NEXT:   Other:
+# CHECK-NEXT:   Section:
+# CHECK-NEXT: }
+
+.global _start
+_start:
+.quad _end




More information about the llvm-commits mailing list