[PATCH] D30885: [ELF] Fix crash when eh_frame or eh_frame_hdr is discarded in linker script
Eugene Leviant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 14 02:01:27 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297712: [ELF] Fix crash when .eh_frame(_hdr) is discarded (authored by evgeny777).
Changed prior to commit:
https://reviews.llvm.org/D30885?vs=91535&id=91686#toc
Repository:
rL LLVM
https://reviews.llvm.org/D30885
Files:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/linkerscript/pt_gnu_eh_frame.s
Index: lld/trunk/test/ELF/linkerscript/pt_gnu_eh_frame.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/pt_gnu_eh_frame.s
+++ lld/trunk/test/ELF/linkerscript/pt_gnu_eh_frame.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.eh_frame*) *(.eh_frame_hdr*) } }" > %t.script
+# RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t
+
+.global _start
+_start:
+ nop
+
+.section .dah,"ax", at progbits
+.cfi_startproc
+ nop
+.cfi_endproc
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1355,7 +1355,8 @@
Ret.push_back(std::move(RelRo));
// PT_GNU_EH_FRAME is a special section pointing on .eh_frame_hdr.
- if (!In<ELFT>::EhFrame->empty() && In<ELFT>::EhFrameHdr)
+ if (!In<ELFT>::EhFrame->empty() && In<ELFT>::EhFrameHdr &&
+ In<ELFT>::EhFrame->OutSec && In<ELFT>::EhFrameHdr->OutSec)
AddHdr(PT_GNU_EH_FRAME, In<ELFT>::EhFrameHdr->OutSec->getPhdrFlags())
->add(In<ELFT>::EhFrameHdr->OutSec);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30885.91686.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170314/b47613ac/attachment.bin>
More information about the llvm-commits
mailing list