Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently lld creates a single section to collect all commons. There …
…is no way to separate commons based on file name patterns. The following linker script construct does not work because commons are allocated before section placement is done and the only synthesized BssSection that holds all commons has no file associated with it: SECTIONS { .common_0 : { *file0.o(COMMON) }} This patch changes the allocation of commons to create a section per common symbol and let the section logic do the layout. Differential revision: https://reviews.llvm.org/D37489 llvm-svn: 312796
- Loading branch information
Showing
15 changed files
with
243 additions
and
71 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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.comm common_uniq_1,8,8 | ||
.comm common_multiple,16,8 |
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,2 @@ | ||
.comm common_uniq_2,16,16 | ||
.comm common_multiple,32,8 |
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,86 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile0.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec1.s -o %tfile1.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec2.s -o %tfile2.o | ||
# RUN: echo "SECTIONS { .common.incl : { *(EXCLUDE_FILE (*file2.o) COMMON) } .common.excl : { *(COMMON) } }" > %t.script | ||
# RUN: ld.lld -o %t1 --script %t.script %tfile0.o %tfile1.o %tfile2.o | ||
# RUN: llvm-readobj -s -t %t1 | FileCheck %s | ||
|
||
# Commons from file0 and file1 are not excluded, so they must be in .common.incl | ||
# Commons from file2 are excluded from the first rule and should be caught by | ||
# the second in .common.excl | ||
# CHECK: Section { | ||
# CHECK: Index: | ||
# CHECK: Name: .common.incl | ||
# CHECK-NEXT: Type: SHT_NOBITS | ||
# CHECK-NEXT: Flags [ | ||
# CHECK-NEXT: SHF_ALLOC | ||
# CHECK-NEXT: SHF_WRITE | ||
# CHECK-NEXT: ] | ||
# CHECK-NEXT: Address: 0x8 | ||
# CHECK-NEXT: Offset: 0x | ||
# CHECK-NEXT: Size: 16 | ||
# CHECK-NEXT: Link: 0 | ||
# CHECK-NEXT: Info: 0 | ||
# CHECK-NEXT: AddressAlignment: 8 | ||
# CHECK-NEXT: EntrySize: 0 | ||
# CHECK-NEXT: } | ||
# CHECK: Section { | ||
# CHECK: Index: | ||
# CHECK: Name: .common.excl | ||
# CHECK-NEXT: Type: SHT_NOBITS | ||
# CHECK-NEXT: Flags [ | ||
# CHECK-NEXT: SHF_ALLOC | ||
# CHECK-NEXT: SHF_WRITE | ||
# CHECK-NEXT: ] | ||
# CHECK-NEXT: Address: 0x20 | ||
# CHECK-NEXT: Offset: 0x | ||
# CHECK-NEXT: Size: 48 | ||
# CHECK-NEXT: Link: 0 | ||
# CHECK-NEXT: Info: 0 | ||
# CHECK-NEXT: AddressAlignment: 16 | ||
# CHECK-NEXT: EntrySize: 0 | ||
# CHECK-NEXT: } | ||
# CHECK: Symbol { | ||
# CHECK: Name: common_multiple | ||
# CHECK-NEXT: Value: 0x20 | ||
# CHECK-NEXT: Size: 32 | ||
# CHECK-NEXT: Binding: Global | ||
# CHECK-NEXT: Type: Object | ||
# CHECK-NEXT: Other: 0 | ||
# CHECK-NEXT: Section: .common.excl | ||
# CHECK-NEXT: } | ||
# CHECK: Symbol { | ||
# CHECK: Name: common_uniq_0 | ||
# CHECK-NEXT: Value: 0x8 | ||
# CHECK-NEXT: Size: 4 | ||
# CHECK-NEXT: Binding: Global | ||
# CHECK-NEXT: Type: Object | ||
# CHECK-NEXT: Other: 0 | ||
# CHECK-NEXT: Section: .common.incl | ||
# CHECK-NEXT: } | ||
# CHECK: Symbol { | ||
# CHECK: Name: common_uniq_1 | ||
# CHECK-NEXT: Value: 0x10 | ||
# CHECK-NEXT: Size: 8 | ||
# CHECK-NEXT: Binding: Global | ||
# CHECK-NEXT: Type: Object | ||
# CHECK-NEXT: Other: 0 | ||
# CHECK-NEXT: Section: .common.incl | ||
# CHECK-NEXT: } | ||
# CHECK: Symbol { | ||
# CHECK: Name: common_uniq_2 | ||
# CHECK-NEXT: Value: 0x40 | ||
# CHECK-NEXT: Size: 16 | ||
# CHECK-NEXT: Binding: Global | ||
# CHECK-NEXT: Type: Object | ||
# CHECK-NEXT: Other: 0 | ||
# CHECK-NEXT: Section: .common.excl | ||
# CHECK-NEXT: } | ||
|
||
.globl _start | ||
_start: | ||
jmp _start | ||
|
||
.comm common_uniq_0,4,4 | ||
.comm common_multiple,8,8 |
Oops, something went wrong.