[PATCH] D24041: [ELF] Linkerscript: allow .eh_frame_hdr to go before .eh_frame
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 30 10:06:48 PDT 2016
evgeny777 created this revision.
evgeny777 added reviewers: ruiu, rafael.
evgeny777 added subscribers: grimar, ikudrin, llvm-commits.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.
Currently .eh_frame_hdr must be written after .eh_frame, because EhFrameHeader is filled in EhOutputSection::writeTo(). This patch fixes it in a cost of one extra disk seek.
Repository:
rL LLVM
https://reviews.llvm.org/D24041
Files:
ELF/Writer.cpp
test/ELF/linkerscript/linkerscript-eh-frame-hdr.s
Index: test/ELF/linkerscript/linkerscript-eh-frame-hdr.s
===================================================================
--- test/ELF/linkerscript/linkerscript-eh-frame-hdr.s
+++ test/ELF/linkerscript/linkerscript-eh-frame-hdr.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { \
+# RUN: .eh_frame_hdr : {} \
+# RUN: .eh_frame : {} \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t
+# RUN: llvm-objdump -s -section=".eh_frame_hdr" %t1 | FileCheck %s
+
+# CHECK: 0158 011b033b 14000000 01000000 49000000
+# CHECK-NEXT: 0168 30000000
+
+.global _start
+_start:
+ nop
+
+.section .dah,"ax", at progbits
+.cfi_startproc
+ nop
+.cfi_endproc
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1306,8 +1306,11 @@
}
for (OutputSectionBase<ELFT> *Sec : OutputSections)
- if (Sec != Out<ELFT>::Opd)
+ if (Sec != Out<ELFT>::Opd && Sec != Out<ELFT>::EhFrameHdr)
Sec->writeTo(Buf + Sec->getFileOff());
+
+ if (!Out<ELFT>::EhFrame->empty() && Out<ELFT>::EhFrameHdr)
+ Out<ELFT>::EhFrameHdr->writeTo(Buf + Out<ELFT>::EhFrameHdr->getFileOff());
}
template <class ELFT> void Writer<ELFT>::writeBuildId() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24041.69718.patch
Type: text/x-patch
Size: 1341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160830/7cf06224/attachment.bin>
More information about the llvm-commits
mailing list