diff options
author | Petr Hosek <phosek@chromium.org> | 2017-02-24 04:11:02 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2017-02-24 04:11:02 +0000 |
commit | f087e312b66c8c84a573ae2dc0500e8ab2ed94ef (patch) | |
tree | b4dfa752c7fc0b6661538d9c52dcab8938ce0712 /lld | |
parent | 1e7ecd3e64461bc001495239eb168b0748d29c3d (diff) | |
download | bcm5719-llvm-f087e312b66c8c84a573ae2dc0500e8ab2ed94ef.tar.gz bcm5719-llvm-f087e312b66c8c84a573ae2dc0500e8ab2ed94ef.zip |
[ELF] Make __ehdr_start point to ELF file headers
__ehdr_start should be pointing to ELF file headers, not program
headers.
This is a reland of D30319.
Differential Revision: https://reviews.llvm.org/D30323
llvm-svn: 296085
Diffstat (limited to 'lld')
-rw-r--r-- | lld/ELF/Writer.cpp | 6 | ||||
-rw-r--r-- | lld/test/ELF/ehdr_start.s | 22 |
2 files changed, 21 insertions, 7 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 835f4d0bcde..91027752842 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -844,9 +844,9 @@ template <class ELFT> void Writer<ELFT>::addReservedSymbols() { 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 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() { // 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) { diff --git a/lld/test/ELF/ehdr_start.s b/lld/test/ELF/ehdr_start.s index 67d23cf7164..32bcf4b8475 100644 --- a/lld/test/ELF/ehdr_start.s +++ b/lld/test/ELF/ehdr_start.s @@ -2,8 +2,16 @@ # 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 @@ -11,6 +19,12 @@ _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) |