Skip to content

[LLD] [COFF] Preserve directives and export names from LTO objects #78802

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
Jan 20, 2024
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
2 changes: 1 addition & 1 deletion lld/COFF/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ void BitcodeFile::parse() {
if (objSym.isUsed())
ctx.config.gcroot.push_back(sym);
}
directives = obj->getCOFFLinkerOpts();
directives = saver.save(obj->getCOFFLinkerOpts());
}

void BitcodeFile::parseLazy() {
Expand Down
Binary file added lld/test/COFF/Inputs/lto-directives.obj
Binary file not shown.
15 changes: 15 additions & 0 deletions lld/test/COFF/lto-directives.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; REQUIRES: x86

;; Test linking an LTO object file that contains directives. The
;; LTO object file is built with an older toolchain, to force it
;; to be upgraded when loaded.

;; The input file is compiled from source that looks like this:
;; void __declspec(dllexport) entry(void) { }
;; with this command:
;; clang -target x86_64-windows-msvc -c main.c -flto

; RUN: lld-link /entry:entry /subsystem:console %p/Inputs/lto-directives.obj /dll /out:%t.dll
; RUN: llvm-readobj --coff-exports %t.dll | FileCheck %s

; CHECK: Name: entry