Skip to content

Commit d60ef93

Browse files
committed
[ELF] Support quoted output section names
Similar to e7a7ad1 and 2bf06d9 for other linker script syntax. Close #60496
1 parent f4e69d9 commit d60ef93

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

lld/ELF/ScriptParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,8 @@ OutputDesc *ScriptParser::readOverlaySectionDescription() {
900900
}
901901

902902
OutputDesc *ScriptParser::readOutputSectionDescription(StringRef outSec) {
903-
OutputDesc *cmd = script->createOutputSection(outSec, getCurrentLocation());
903+
OutputDesc *cmd =
904+
script->createOutputSection(unquote(outSec), getCurrentLocation());
904905
OutputSection *osec = &cmd->osec;
905906
// Maybe relro. Will reset to false if DATA_SEGMENT_RELRO_END is absent.
906907
osec->relro = seenDataAlign && !seenRelroEnd;
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# REQUIRES: x86
22

33
## Handling of quotes is tricky sometimes. Check we do that right and include
4-
## "foo bar" section into .data as expected.
4+
## "foo bar" section into ".data foo" as expected.
55

6-
# RUN: echo '.section "foo bar", "aw"; nop' | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t
7-
# RUN: ld.lld %t --script %s -o %t2 --print-map | FileCheck %s
8-
# CHECK: .data
6+
# RUN: echo '.section "foo bar", "aw"; nop' | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o
7+
# RUN: ld.lld %t.o --script %s -o %t --print-map | FileCheck %s
8+
# RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=SEC
9+
# CHECK: .data foo
910
# CHECK-NEXT: {{.*}}(foo bar)
1011

12+
# SEC: ]{{ }}.data foo
13+
# SEC: ]{{ }}.data bar
14+
1115
SECTIONS {
12-
.data : { *("foo bar") }
16+
" .data foo" : { *("foo bar") }
17+
}
18+
19+
OVERWRITE_SECTIONS {
20+
" .data bar" : { bar = .; }
1321
}

0 commit comments

Comments
 (0)