[PATCH] D27341: [ELF] - Change the way how we compute offsets for binary output.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 2 23:33:51 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288580: [ELF] - Change the way how we compute offsets for binary output. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D27341?vs=80062&id=80171#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27341
Files:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/oformat-binary-ttext.s
Index: lld/trunk/test/ELF/oformat-binary-ttext.s
===================================================================
--- lld/trunk/test/ELF/oformat-binary-ttext.s
+++ lld/trunk/test/ELF/oformat-binary-ttext.s
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: ld.lld -N -Ttext 0x100 -o %t.out %t --oformat binary
+# RUN: od -t x1 -v %t.out | FileCheck %s --check-prefix=BIN
+
+# BIN: 0000000 90 00 00 00 00 00 00 00
+# BIN-NEXT: 0000010
+# BIN-NOT: 0000020
+
+## The same but without OMAGIC.
+# RUN: ld.lld -Ttext 0x100 -o %t.out %t --oformat binary
+# RUN: od -t x1 -v %t.out | FileCheck %s --check-prefix=BIN
+
+.text
+.globl _start
+_start:
+ nop
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -180,10 +180,15 @@
if (Config->Relocatable) {
assignFileOffsets();
} else {
- Phdrs = Script<ELFT>::X->hasPhdrsCommands() ? Script<ELFT>::X->createPhdrs()
- : createPhdrs();
- addPtArmExid(Phdrs);
- fixHeaders();
+ // Binary output does not have PHDRS.
+ if (!Config->OFormatBinary) {
+ Phdrs = Script<ELFT>::X->hasPhdrsCommands()
+ ? Script<ELFT>::X->createPhdrs()
+ : createPhdrs();
+ addPtArmExid(Phdrs);
+ fixHeaders();
+ }
+
if (ScriptConfig->HasSections) {
Script<ELFT>::X->assignAddresses(Phdrs);
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27341.80171.patch
Type: text/x-patch
Size: 1533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161203/45bb91e0/attachment.bin>
More information about the llvm-commits
mailing list