Skip to content

[lld][COFF] Merge .00cfg section into .rdata. #75207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we lose test coverage by removing .rdata? If not, LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't lose coverage. We still have other tests that declare _load_config_used in .rdata, so we should be protected from somehow accidentally depending on it being in .00cfg. I made the change to Inputs/ to widen coverage of merging and making shared load config more similar to real-world case feels right.

Thanks for reviews!

.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