[PATCH] D30323: [ELF] Make __ehdr_start point to ELF file headers
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 23 20:13:32 PST 2017
phosek created this revision.
phosek added a project: lld.
__ehdr_start should be pointing to ELF file headers, not program headers.
This is a reland of https://reviews.llvm.org/D30319.
Repository:
rL LLVM
https://reviews.llvm.org/D30323
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
@@ -2,15 +2,29 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t
-# RUN: llvm-objdump -t %t | FileCheck %s
-# CHECK: 0000000000200040 .text 00000000 .hidden __ehdr_start
+# RUN: llvm-readobj -symbols %t | FileCheck %s
+# CHECK: Name: __ehdr_start (1)
+# CHECK-NEXT: Value: 0x200000
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Local (0x0)
+# CHECK-NEXT: Type: None (0x0)
+# CHECK-NEXT: Other [ (0x2)
+# CHECK-NEXT: STV_HIDDEN (0x2)
+# CHECK-NEXT: ]
+# CHECK-NEXT: Section: .text (0x1)
.text
.global _start, __ehdr_start
_start:
.quad __ehdr_start
# RUN: ld.lld -r %t.o -o %t.r
-# RUN: llvm-objdump -t %t.r | FileCheck %s --check-prefix=RELOCATABLE
+# RUN: llvm-readobj -symbols %t.r | FileCheck %s --check-prefix=RELOCATABLE
-# RELOCATABLE: 0000000000000000 *UND* 00000000 __ehdr_start
+# RELOCATABLE: Name: __ehdr_start (1)
+# RELOCATABLE-NEXT: Value: 0x0
+# RELOCATABLE-NEXT: Size: 0
+# RELOCATABLE-NEXT: Binding: Global (0x1)
+# RELOCATABLE-NEXT: Type: None (0x0)
+# RELOCATABLE-NEXT: Other: 0
+# RELOCATABLE-NEXT: Section: Undefined (0x0)
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -844,9 +844,9 @@
if (ScriptConfig->HasSections)
return;
- // __ehdr_start is the location of program headers.
+ // __ehdr_start is the location of ELF file headers.
ElfSym<ELFT>::EhdrStart =
- addOptionalSynthetic<ELFT>("__ehdr_start", Out<ELFT>::ProgramHeaders, 0);
+ addOptionalSynthetic<ELFT>("__ehdr_start", Out<ELFT>::ElfHeader, 0);
auto Define = [](StringRef S, DefinedSynthetic *&Sym1,
DefinedSynthetic *&Sym2) {
@@ -1138,7 +1138,7 @@
// This is a bit of a hack. A value of 0 means undef, so we set it
// to 1 t make __ehdr_start defined. The section number is not
// particularly relevant.
- Out<ELFT>::ProgramHeaders->SectionIndex = 1;
+ Out<ELFT>::ElfHeader->SectionIndex = 1;
unsigned I = 1;
for (OutputSectionBase *Sec : OutputSections) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30323.89608.patch
Type: text/x-patch
Size: 2259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170224/3a9649bd/attachment.bin>
More information about the llvm-commits
mailing list