Skip to content

Commit 1c74c2f

Browse files
author
George Rimar
committedMar 9, 2017
[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
1 parent e2de03f commit 1c74c2f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
 

‎lld/ELF/Writer.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,11 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
435435
In<ELFT>::Iplt = make<PltSection<ELFT>>(0);
436436
Add(In<ELFT>::Iplt);
437437

438-
if (Config->EhFrameHdr) {
439-
In<ELFT>::EhFrameHdr = make<EhFrameHeader<ELFT>>();
440-
Add(In<ELFT>::EhFrameHdr);
441-
}
442-
443438
if (!Config->Relocatable) {
439+
if (Config->EhFrameHdr) {
440+
In<ELFT>::EhFrameHdr = make<EhFrameHeader<ELFT>>();
441+
Add(In<ELFT>::EhFrameHdr);
442+
}
444443
In<ELFT>::EhFrame = make<EhFrameSection<ELFT>>();
445444
Add(In<ELFT>::EhFrame);
446445
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# REQUIRES: x86
2+
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3+
# RUN: ld.lld --eh-frame-hdr -r %t.o -o %t
4+
# RUN: llvm-readobj -s %t | FileCheck %s
5+
6+
# CHECK: Sections [
7+
# CHECK-NOT: Name: .eh_frame_hdr
8+
9+
.section .foo,"ax",@progbits
10+
.cfi_startproc
11+
.cfi_endproc

0 commit comments

Comments
 (0)
Please sign in to comment.