Skip to content

Commit

Permalink
[lld][COFF] Merge .00cfg section into .rdata. (#75207)
Browse files Browse the repository at this point in the history
.00cfg section is used by crt for load config and is merged by MS
link.exe into .rdata.
  • Loading branch information
cjacek committed Dec 13, 2023
1 parent 8691337 commit f78024c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions lld/COFF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
parseMerge(".didat=.rdata");
parseMerge(".edata=.rdata");
parseMerge(".xdata=.rdata");
parseMerge(".00cfg=.rdata");
parseMerge(".bss=.data");

if (config->mingw) {
Expand Down
2 changes: 1 addition & 1 deletion lld/test/COFF/Inputs/loadconfig-arm64ec.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.section .rdata,"dr"
.section .00cfg,"dr"
.globl _load_config_used
.p2align 3, 0
_load_config_used:
Expand Down
2 changes: 1 addition & 1 deletion lld/test/COFF/Inputs/loadconfig-cfg-x64.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the _load_config_used definition needed for /guard:cf tests.

.section .rdata,"dr"
.section .00cfg,"dr"
.globl _load_config_used
_load_config_used:
.long 256
Expand Down
17 changes: 17 additions & 0 deletions lld/test/COFF/merge-00cfg.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// REQUIRES: x86

// RUN: llvm-mc -filetype=obj -triple=x86_64-windows %s -o %t-x86_64.obj
// RUN: llvm-mc -filetype=obj -triple=i686-windows %s -o %t-x86.obj
// RUN: lld-link -machine:amd64 -out:%t-x86_64.dll %t-x86_64.obj -dll -noentry
// RUN: lld-link -machine:x86 -out:%t-x86.dll %t-x86.obj -dll -noentry -safeseh:no

// RUN: llvm-readobj --hex-dump=.rdata %t-x86_64.dll | FileCheck %s -check-prefix=RDATA
// RUN: llvm-readobj --hex-dump=.rdata %t-x86.dll | FileCheck %s -check-prefix=RDATA
// RDATA: 78563412

// RUN: llvm-readobj --sections %t-x86_64.dll | FileCheck %s -check-prefix=SECTIONS
// RUN: llvm-readobj --sections %t-x86.dll | FileCheck %s -check-prefix=SECTIONS
// SECTIONS-NOT: .00cfg

.section ".00cfg", "dr"
.long 0x12345678

0 comments on commit f78024c

Please sign in to comment.