Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] Disallow input section description without a filename
GNU ld does not allow `.foo : { (*foo) }`, but we may recognize it as three input section descriptions: file "(" with any section name, file "*foo" with any section name, file ")" with any section name. Disallow the error-prone usage. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D125523
- Loading branch information
Showing
2 changed files
with
21 additions
and
2 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 |
---|---|---|
@@ -1,17 +1,34 @@ | ||
# REQUIRES: x86 | ||
# RUN: rm -rf %t && split-file %s %t | ||
# RUN: echo '.section .bar, "a"; .quad 1;' | \ | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %tfile1.o | ||
# RUN: echo '.section .zed, "a"; .quad 2;' | \ | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %tfile2.o | ||
|
||
## We have a file name and no input sections description. In that case, all | ||
## sections from the file specified should be included. Check that. | ||
# RUN: ld.lld -o %t --script %s %tfile1.o %tfile2.o | ||
# RUN: llvm-objdump -s %t | FileCheck %s | ||
# RUN: ld.lld -o %t/a -T %t/a.t %tfile1.o %tfile2.o | ||
# RUN: llvm-objdump -s %t/a | FileCheck %s | ||
|
||
# CHECK: Contents of section .foo: | ||
# CHECK-NEXT: 01000000 00000000 02000000 00000000 | ||
|
||
# RUN: not ld.lld -o /dev/null -T %t/b.t %tfile1.o 2>&1 | FileCheck %s --check-prefix=ERR | ||
# RUN: not ld.lld -o /dev/null -T %t/c.t %tfile1.o 2>&1 | FileCheck %s --check-prefix=ERR | ||
# RUN: not ld.lld -o /dev/null -T %t/d.t %tfile1.o 2>&1 | FileCheck %s --check-prefix=ERR | ||
|
||
# ERR: error: {{.*}}.t:1: expected filename pattern | ||
|
||
#--- a.t | ||
SECTIONS { | ||
.foo : { *file1.o *file2.o } | ||
} | ||
|
||
#--- b.t | ||
SECTIONS { .foo : { (*foo) } } | ||
|
||
#--- c.t | ||
SECTIONS { .foo : { (*(foo)) } } | ||
|
||
#--- d.t | ||
SECTIONS { .foo : { )(*foo) } } |