aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-03-09 08:45:25 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-03-09 08:45:25 +0000
commit1c74c2f2a8f86e8b98c87bdf401ae776cf114be7 (patch)
tree4b4f7f1be466b6f038d76032acbf1f52f4e21b38
parente2de03fd7d8761d73c22accf7a22fd0d0189821e (diff)
downloadllvm-1c74c2f2a8f86e8b98c87bdf401ae776cf114be7.zip
llvm-1c74c2f2a8f86e8b98c87bdf401ae776cf114be7.tar.gz
llvm-1c74c2f2a8f86e8b98c87bdf401ae776cf114be7.tar.bz2
[ELF] - Do not try to create .eh_frame_hdr for relocatable output.
.eh_frame_hdr is a header constructed for .eh_frame sections. We do not proccess .eh_frame when doing relocatable output, so should not try to create .eh_frame_hdr too. Previous behavior without this patch is segfault. Fixes PR32118. Differential revision: https://reviews.llvm.org/D30566 llvm-svn: 297365
-rw-r--r--lld/ELF/Writer.cpp9
-rw-r--r--lld/test/ELF/relocatable-eh-frame-hdr.s11
2 files changed, 15 insertions, 5 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index ce8f19e..6652dcc 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -435,12 +435,11 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
In<ELFT>::Iplt = make<PltSection<ELFT>>(0);
Add(In<ELFT>::Iplt);
- if (Config->EhFrameHdr) {
- In<ELFT>::EhFrameHdr = make<EhFrameHeader<ELFT>>();
- Add(In<ELFT>::EhFrameHdr);
- }
-
if (!Config->Relocatable) {
+ if (Config->EhFrameHdr) {
+ In<ELFT>::EhFrameHdr = make<EhFrameHeader<ELFT>>();
+ Add(In<ELFT>::EhFrameHdr);
+ }
In<ELFT>::EhFrame = make<EhFrameSection<ELFT>>();
Add(In<ELFT>::EhFrame);
}
diff --git a/lld/test/ELF/relocatable-eh-frame-hdr.s b/lld/test/ELF/relocatable-eh-frame-hdr.s
new file mode 100644
index 0000000..f7b5724
--- /dev/null
+++ b/lld/test/ELF/relocatable-eh-frame-hdr.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --eh-frame-hdr -r %t.o -o %t
+# RUN: llvm-readobj -s %t | FileCheck %s
+
+# CHECK: Sections [
+# CHECK-NOT: Name: .eh_frame_hdr
+
+.section .foo,"ax",@progbits
+.cfi_startproc
+.cfi_endproc