Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] - Do not crash when discarding sections that are referenced by …
…others. SHF_LINK_ORDER sections adds special ordering requirements. Such sections references other sections. Previously we would crash if section that other were referenced to was discarded by script. Patch fixes that by discarding all dependent sections in that case. It supports chained dependencies, testcase is provided. Differential revision: https://reviews.llvm.org/D30033 llvm-svn: 295332
- Loading branch information
George Rimar
committed
Feb 16, 2017
1 parent
cb2d950
commit 505ac8d
Showing
2 changed files
with
37 additions
and
0 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,32 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t | ||
# RUN: echo "SECTIONS { /DISCARD/ : { *(.foo) } }" > %t.script | ||
# RUN: ld.lld -o %t1 --script %t.script %t | ||
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s | ||
|
||
# CHECK-NOT: .foo | ||
# CHECK-NOT: .bar | ||
# CHECK-NOT: .zed | ||
# CHECK-NOT: .moo | ||
|
||
## Sections dependency tree for testcase is: | ||
## (.foo) | ||
## | | | ||
## | --(.bar) | ||
## | | ||
## --(.zed) | ||
## | | ||
## --(.moo) | ||
## | ||
|
||
.section .foo,"a" | ||
.quad 0 | ||
|
||
.section .bar,"am",@progbits,.foo | ||
.quad 0 | ||
|
||
.section .zed,"am",@progbits,.foo | ||
.quad 0 | ||
|
||
.section .moo,"am",@progbits,.zed | ||
.quad 0 |