[PATCH] D24041: [ELF] Linkerscript: allow .eh_frame_hdr to go before .eh_frame
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 00:52:14 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280203: Allow .eh_frame_hdr to be placed before .eh_frame (authored by evgeny777).
Changed prior to commit:
https://reviews.llvm.org/D24041?vs=69718&id=69805#toc
Repository:
rL LLVM
https://reviews.llvm.org/D24041
Files:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/linkerscript/linkerscript-eh-frame-hdr.s
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1306,8 +1306,13 @@
}
for (OutputSectionBase<ELFT> *Sec : OutputSections)
- if (Sec != Out<ELFT>::Opd)
+ if (Sec != Out<ELFT>::Opd && Sec != Out<ELFT>::EhFrameHdr)
Sec->writeTo(Buf + Sec->getFileOff());
+
+ // The .eh_frame_hdr depends on .eh_frame section contents, therefore
+ // it should be written after .eh_frame is written.
+ if (!Out<ELFT>::EhFrame->empty() && Out<ELFT>::EhFrameHdr)
+ Out<ELFT>::EhFrameHdr->writeTo(Buf + Out<ELFT>::EhFrameHdr->getFileOff());
}
template <class ELFT> void Writer<ELFT>::writeBuildId() {
Index: lld/trunk/test/ELF/linkerscript/linkerscript-eh-frame-hdr.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-eh-frame-hdr.s
+++ lld/trunk/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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24041.69805.patch
Type: text/x-patch
Size: 1529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160831/2580ff1d/attachment.bin>
More information about the llvm-commits
mailing list