Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] - Referencing __start or __stop should keep the section from GC.
This fixes the https://llvm.org/bugs/show_bug.cgi?id=22906 bug. In GNU Binutils, a reference to start or stop is sufficient to prevent the section from being garbage collected. Patch implements the same behavior for lld. Differential revision: http://reviews.llvm.org/D17502 llvm-svn: 261840
- Loading branch information
George Rimar
committed
Feb 25, 2016
1 parent
3d3d0f4
commit 12737b7
Showing
6 changed files
with
54 additions
and
14 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
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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
.global foo | ||
foo: | ||
|
||
.section bar,"a" | ||
.section .bar,"a" | ||
zed: | ||
|
||
// CHECK: Name: .strtab | ||
|
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 | ||
|
||
## Default run: sections foo and bar exist in output | ||
# RUN: ld.lld %t -o %tout | ||
# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s | ||
|
||
## Check that foo and bar sections are not garbage collected, | ||
## we do not want to reclaim sections if they can be referred | ||
## by __start_* and __stop_* symbols. | ||
# RUN: ld.lld %t --gc-sections -o %tout | ||
# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s | ||
|
||
# DISASM: _start: | ||
# DISASM-NEXT: 11000: 90 nop | ||
# DISASM-NEXT: Disassembly of section foo: | ||
# DISASM-NEXT: foo: | ||
# DISASM-NEXT: 11001: 90 nop | ||
# DISASM-NEXT: Disassembly of section bar: | ||
# DISASM-NEXT: bar: | ||
# DISASM-NEXT: 11002: 90 nop | ||
|
||
.global _start | ||
.text | ||
_start: | ||
nop | ||
|
||
.section foo,"ax" | ||
nop | ||
|
||
.section bar,"ax" | ||
nop |