[PATCH] D33700: Define __executable_start
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 30 15:52:51 PDT 2017
rafael created this revision.
Herald added subscribers: emaste, srhines.
It is a bit odd to define two symbols pointing to the same location, but it is a trivial change, so it is probably ok.
This is defined by both gold and bfd.
https://reviews.llvm.org/D33700
Files:
ELF/Writer.cpp
test/ELF/ehdr_start.s
Index: test/ELF/ehdr_start.s
===================================================================
--- test/ELF/ehdr_start.s
+++ test/ELF/ehdr_start.s
@@ -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
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -911,7 +911,10 @@
// 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.
+ for (const char *Name : {"__ehdr_start", "__executable_start"})
+ 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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33700.100792.patch
Type: text/x-patch
Size: 1538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170530/f3c9561d/attachment.bin>
More information about the llvm-commits
mailing list