Skip to content

Commit f78024c

Browse files
authored
[lld][COFF] Merge .00cfg section into .rdata. (#75207)
.00cfg section is used by crt for load config and is merged by MS link.exe into .rdata.
1 parent 8691337 commit f78024c

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

lld/COFF/Driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
19401940
parseMerge(".didat=.rdata");
19411941
parseMerge(".edata=.rdata");
19421942
parseMerge(".xdata=.rdata");
1943+
parseMerge(".00cfg=.rdata");
19431944
parseMerge(".bss=.data");
19441945

19451946
if (config->mingw) {

lld/test/COFF/Inputs/loadconfig-arm64ec.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.section .rdata,"dr"
1+
.section .00cfg,"dr"
22
.globl _load_config_used
33
.p2align 3, 0
44
_load_config_used:

lld/test/COFF/Inputs/loadconfig-cfg-x64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is the _load_config_used definition needed for /guard:cf tests.
22

3-
.section .rdata,"dr"
3+
.section .00cfg,"dr"
44
.globl _load_config_used
55
_load_config_used:
66
.long 256

lld/test/COFF/merge-00cfg.s

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// REQUIRES: x86
2+
3+
// RUN: llvm-mc -filetype=obj -triple=x86_64-windows %s -o %t-x86_64.obj
4+
// RUN: llvm-mc -filetype=obj -triple=i686-windows %s -o %t-x86.obj
5+
// RUN: lld-link -machine:amd64 -out:%t-x86_64.dll %t-x86_64.obj -dll -noentry
6+
// RUN: lld-link -machine:x86 -out:%t-x86.dll %t-x86.obj -dll -noentry -safeseh:no
7+
8+
// RUN: llvm-readobj --hex-dump=.rdata %t-x86_64.dll | FileCheck %s -check-prefix=RDATA
9+
// RUN: llvm-readobj --hex-dump=.rdata %t-x86.dll | FileCheck %s -check-prefix=RDATA
10+
// RDATA: 78563412
11+
12+
// RUN: llvm-readobj --sections %t-x86_64.dll | FileCheck %s -check-prefix=SECTIONS
13+
// RUN: llvm-readobj --sections %t-x86.dll | FileCheck %s -check-prefix=SECTIONS
14+
// SECTIONS-NOT: .00cfg
15+
16+
.section ".00cfg", "dr"
17+
.long 0x12345678

0 commit comments

Comments
 (0)