Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] - Optimize .eh_frame section: remove CIE if all FDEs referencin…
…g it were removed. This patch performs little optimization for eh_frame section. If all FDE`s that referenced CIE are removed then CIE is also removed from output. That can happen for example when dropping FDEs that point to dropped sections. Testcase showing that is included. The same optimization was added to ld about 14 years ago: https://sourceware.org/ml/binutils/2001-12/msg00144.html, gold does not do that it seems. Differential revision: http://reviews.llvm.org/D15564 llvm-svn: 256638
- Loading branch information
George Rimar
committed
Dec 30, 2015
1 parent
1589071
commit 5728664
Showing
2 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// REQUIRES: x86 | ||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o | ||
// RUN: ld.lld --gc-sections %t.o -o %t | ||
// RUN: llvm-readobj -s -section-data %t | FileCheck %s | ||
|
||
// Here we check that if all FDEs referencing a CIE | ||
// were removed, CIE is also removed. | ||
// CHECK: Section { | ||
// CHECK: Index: | ||
// CHECK: Name: .eh_frame | ||
// CHECK-NEXT: Type: SHT_X86_64_UNWIND | ||
// CHECK-NEXT: Flags [ | ||
// CHECK-NEXT: SHF_ALLOC | ||
// CHECK-NEXT: ] | ||
// CHECK-NEXT: Address: 0x10120 | ||
// CHECK-NEXT: Offset: 0x120 | ||
// CHECK-NEXT: Size: 0 | ||
// CHECK-NEXT: Link: 0 | ||
// CHECK-NEXT: Info: 0 | ||
// CHECK-NEXT: AddressAlignment: 8 | ||
// CHECK-NEXT: EntrySize: 0 | ||
// CHECK-NEXT: SectionData ( | ||
// CHECK-NEXT: ) | ||
// CHECK-NEXT: } | ||
|
||
.section foo,"ax",@progbits | ||
.cfi_startproc | ||
nop | ||
.cfi_endproc | ||
|
||
.section bar,"ax",@progbits | ||
.cfi_startproc | ||
nop | ||
nop | ||
.cfi_endproc | ||
|
||
.text | ||
.globl _start; | ||
_start: |