[lld] r304803 - Define __executable_start.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 09:18:49 PDT 2017
Author: rafael
Date: Tue Jun 6 11:18:48 2017
New Revision: 304803
URL: http://llvm.org/viewvc/llvm-project?rev=304803&view=rev
Log:
Define __executable_start.
This is defined by both bfd and gold and used by the android libc.
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/ehdr_start.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=304803&r1=304802&r2=304803&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jun 6 11:18:48 2017
@@ -901,16 +901,18 @@ template <class ELFT> void Writer<ELFT>:
if (!InX::DynSymTab)
Symtab<ELFT>::X->addIgnored("__tls_get_addr");
- // __dso_handle symbol is passed to cxa_finalize as a marker to identify
- // each DSO. The address of the symbol doesn't matter as long as they are
- // different in different DSOs, so we chose the start address of the DSO.
- addOptionalRegular<ELFT>("__dso_handle", Out::ElfHeader, 0, STV_HIDDEN);
-
// __ehdr_start is the location of ELF file headers. Note that we define
// this symbol unconditionally even when using a linker script, which
// differs from the behavior implemented by GNU linker which only define
// this symbol if ELF headers are in the memory mapped segment.
- addOptionalRegular<ELFT>("__ehdr_start", Out::ElfHeader, 0, STV_HIDDEN);
+ // __executable_start is not documented, but the expectation of at
+ // least the android libc is that it points to the elf header too.
+ // __dso_handle symbol is passed to cxa_finalize as a marker to identify
+ // each DSO. The address of the symbol doesn't matter as long as they are
+ // different in different DSOs, so we chose the start address of the DSO.
+ for (const char *Name :
+ {"__ehdr_start", "__executable_start", "__dso_handle"})
+ addOptionalRegular<ELFT>(Name, Out::ElfHeader, 0, STV_HIDDEN);
// If linker script do layout we do not need to create any standart symbols.
if (Script->Opt.HasSections)
Modified: lld/trunk/test/ELF/ehdr_start.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ehdr_start.s?rev=304803&r1=304802&r2=304803&view=diff
==============================================================================
--- lld/trunk/test/ELF/ehdr_start.s (original)
+++ lld/trunk/test/ELF/ehdr_start.s Tue Jun 6 11:18:48 2017
@@ -13,10 +13,21 @@
# CHECK-NEXT: ]
# CHECK-NEXT: Section: .text (0x1)
+# CHECK: Name: __executable_start
+# CHECK-NEXT: Value: 0x200000
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Local
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other [
+# CHECK-NEXT: STV_HIDDEN
+# CHECK-NEXT: ]
+# CHECK-NEXT: Section: .text
+
.text
.global _start, __ehdr_start
_start:
.quad __ehdr_start
+ .quad __executable_start
# RUN: ld.lld -r %t.o -o %t.r
# RUN: llvm-readobj -symbols %t.r | FileCheck %s --check-prefix=RELOCATABLE
More information about the llvm-commits
mailing list