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 set output section flags except SHF_{ALLOC,WRITE,EXECI…
…NSTR}. This is PR34546. Currently LLD creates output sections even if it has no input sections, but its command contains an assignment. Committed code just assigns the same flag that was used in previous live section. That does not work sometimes. For example if we have following script: .ARM.exidx : { *(.ARM.exidx*) } .foo : { _foo = 0; } } Then first section has SHF_LINK_ORDER flag. But section foo should not. That was a reason of crash in OutputSection::finalize(). LLD tried to calculate Link value, calling front() on empty input sections list. We should only keep access flags and omit all others when creating such sections. Patch fixes the crash observed. Differential revision: https://reviews.llvm.org/D37736 llvm-svn: 315441
- Loading branch information
George Rimar
committed
Oct 11, 2017
1 parent
3b81809
commit 26fa916
Showing
3 changed files
with
59 additions
and
4 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,19 @@ | ||
# REQUIRES: arm | ||
# RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o | ||
# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \ | ||
# RUN: .ARM.exidx : { *(.ARM.exidx*) } \ | ||
# RUN: .foo : { _foo = 0; } }" > %t.script | ||
# RUN: ld.lld -T %t.script %t.o -shared -o %t.so | ||
# RUN: llvm-readobj -s %t.so | FileCheck %s | ||
|
||
# CHECK: Section { | ||
# CHECK: Index: | ||
# CHECK: Name: .foo | ||
# CHECK-NEXT: Type: SHT_PROGBITS | ||
# CHECK-NEXT: Flags [ | ||
# CHECK-NEXT: SHF_ALLOC | ||
# CHECK-NEXT: ] | ||
|
||
.fnstart | ||
.cantunwind | ||
.fnend |
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,20 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o | ||
# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \ | ||
# RUN: .tbss : { *(.tbss) } \ | ||
# RUN: .foo : { bar = .; } }" > %t.script | ||
# RUN: ld.lld -o %t --script %t.script %t.o | ||
# RUN: llvm-readobj -s %t | FileCheck %s | ||
|
||
## Check .foo does not get SHF_TLS flag. | ||
# CHECK: Section { | ||
# CHECK: Index: | ||
# CHECK: Name: .foo | ||
# CHECK-NEXT: Type: SHT_PROGBITS | ||
# CHECK-NEXT: Flags [ | ||
# CHECK-NEXT: SHF_ALLOC | ||
# CHECK-NEXT: SHF_WRITE | ||
# CHECK-NEXT: ] | ||
|
||
.section .tbss,"awT",@nobits | ||
.quad 0 |