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.

llvm-svn: 292512
This commit is contained in:
Rafael Espindola 2017-01-19 19:43:34 +00:00
parent 38b5d3ca54
commit b92e99cc1e
3 changed files with 42 additions and 1 deletions

View File

@ -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);
}

View File

@ -0,0 +1,2 @@
.data
.quad _end

View File

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