Skip to content

Commit 2de984c

Browse files
committedJun 14, 2019
[COFF] Strip section name suffix from mingw comdats
This is the second part of the fix for PR42217. Differential Revision: https://reviews.llvm.org/D63352 llvm-svn: 363457
1 parent c3b1d73 commit 2de984c

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
 

‎lld/COFF/Writer.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,13 @@ void Writer::createSections() {
797797
SC->printDiscardedMessage();
798798
continue;
799799
}
800-
PartialSection *PSec = createPartialSection(C->getSectionName(),
800+
StringRef Name = C->getSectionName();
801+
// On MinGW, comdat groups are formed by putting the comdat group name
802+
// after the '$' in the section name. Such a section name suffix shouldn't
803+
// imply separate alphabetical sorting of those section chunks though.
804+
if (Config->MinGW && SC && SC->isCOMDAT())
805+
Name = Name.split('$').first;
806+
PartialSection *PSec = createPartialSection(Name,
801807
C->getOutputCharacteristics());
802808
PSec->Chunks.push_back(C);
803809
}
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# REQUIRES: x86
2+
3+
# RUN: llvm-mc -triple=i686-windows-gnu %s -filetype=obj -o %t.main.o
4+
# RUN: llvm-mc -filetype=obj -triple=i686-windows-gnu \
5+
# RUN: %p/Inputs/eh_frame_terminator-crtend.s -o %t.crtend.o
6+
7+
# RUN: lld-link -lldmingw -entry:main %t.main.o %t.crtend.o -out:%t.exe
8+
# RUN: llvm-objdump -s %t.exe | FileCheck %s
9+
10+
# Check that the contents of .eh_frame$foo was placed before .eh_frame from
11+
# crtend.o, even if the former had a section name suffix.
12+
13+
# CHECK: Contents of section .eh_fram:
14+
# CHECK: 403000 4203
15+
16+
.text
17+
.def _main;
18+
.scl 2;
19+
.type 32;
20+
.endef
21+
.globl _main
22+
.p2align 4, 0x90
23+
_main:
24+
call _foo
25+
ret
26+
27+
.section .eh_frame$foo,"dr"
28+
.linkonce discard
29+
.byte 0x42
30+
31+
.def _foo;
32+
.scl 2;
33+
.type 32;
34+
.endef
35+
.section .text$foo,"xr",discard,foo
36+
.globl _foo
37+
.p2align 4
38+
_foo:
39+
ret

0 commit comments

Comments
 (0)
Please sign in to comment.