Skip to content

PR for llvm/llvm-project#67261 #725

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
Oct 10, 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
2 changes: 2 additions & 0 deletions lld/COFF/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ std::optional<Symbol *> ObjFile::createDefined(
if (prevailing) {
SectionChunk *c = readSection(sectionNumber, def, getName());
sparseChunks[sectionNumber] = c;
if (!c)
return nullptr;
c->sym = cast<DefinedRegular>(leader);
c->selection = selection;
cast<DefinedRegular>(leader)->data = &c->repl;
Expand Down
31 changes: 31 additions & 0 deletions lld/test/COFF/comdat-drectve.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# REQUIRES: x86

# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj

# RUN: lld-link %t.obj -out:%t.exe -debug:symtab -subsystem:console
# RUN: llvm-readobj --coff-exports %t.exe | FileCheck %s

# CHECK: Name: exportedFunc

## This assembly snippet has been reduced from what Clang generates from
## this C snippet, with -fsanitize=address. Normally, the .drectve
## section would be a regular section - but when compiled with
## -fsanitize=address, it becomes a comdat section.
##
# void exportedFunc(void) {}
# void mainCRTStartup(void) {}
# static __attribute__((section(".drectve"), used)) const char export_chkstk[] =
# "-export:exportedFunc";

.text
.globl exportedFunc
exportedFunc:
retq

.globl mainCRTStartup
mainCRTStartup:
retq

.section .drectve,"dr",one_only,export_chkstk
export_chkstk:
.asciz "-export:exportedFunc"