[PATCH] D33643: [ELF] - Allow multiple comdats when producing relocatable output.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 23:39:06 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304769: [ELF] - Allow multiple comdats when producing relocatable output. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D33643?vs=100669&id=101514#toc
Repository:
rL LLVM
https://reviews.llvm.org/D33643
Files:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/test/ELF/Inputs/relocatable-comdat-multiple.s
lld/trunk/test/ELF/relocatable-comdat-multiple.s
Index: lld/trunk/test/ELF/Inputs/relocatable-comdat-multiple.s
===================================================================
--- lld/trunk/test/ELF/Inputs/relocatable-comdat-multiple.s
+++ lld/trunk/test/ELF/Inputs/relocatable-comdat-multiple.s
@@ -0,0 +1,2 @@
+.section .text.c,"axG", at progbits,bbb,comdat
+.section .text.d,"axG", at progbits,bbb,comdat
Index: lld/trunk/test/ELF/relocatable-comdat-multiple.s
===================================================================
--- lld/trunk/test/ELF/relocatable-comdat-multiple.s
+++ lld/trunk/test/ELF/relocatable-comdat-multiple.s
@@ -0,0 +1,31 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/relocatable-comdat-multiple.s -o %t2.o
+# RUN: ld.lld -r %t.o %t2.o -o %t
+# RUN: llvm-readobj -elf-section-groups %t | FileCheck %s
+
+# CHECK: Groups {
+# CHECK-NEXT: Group {
+# CHECK-NEXT: Name: .group
+# CHECK-NEXT: Index: 2
+# CHECK-NEXT: Type: COMDAT
+# CHECK-NEXT: Signature: aaa
+# CHECK-NEXT: Section(s) in group [
+# CHECK-NEXT: .text.a
+# CHECK-NEXT: .text.b
+# CHECK-NEXT: ]
+# CHECK-NEXT: }
+# CHECK-NEXT: Group {
+# CHECK-NEXT: Name: .group
+# CHECK-NEXT: Index: 5
+# CHECK-NEXT: Type: COMDAT
+# CHECK-NEXT: Signature: bbb
+# CHECK-NEXT: Section(s) in group [
+# CHECK-NEXT: .text.c
+# CHECK-NEXT: .text.d
+# CHECK-NEXT: ]
+# CHECK-NEXT: }
+# CHECK-NEXT: }
+
+.section .text.a,"axG", at progbits,aaa,comdat
+.section .text.b,"axG", at progbits,aaa,comdat
Index: lld/trunk/ELF/OutputSections.cpp
===================================================================
--- lld/trunk/ELF/OutputSections.cpp
+++ lld/trunk/ELF/OutputSections.cpp
@@ -345,6 +345,17 @@
void OutputSectionFactory::addInputSec(InputSectionBase *IS,
StringRef OutsecName) {
+ // Sections with the SHT_GROUP attribute reach here only when the - r option
+ // is given. Such sections define "section groups", and InputFiles.cpp has
+ // dedup'ed section groups by their signatures. For the -r, we want to pass
+ // through all SHT_GROUP sections without merging them because merging them
+ // creates broken section contents.
+ if (IS->Type == SHT_GROUP) {
+ OutputSection *Out = nullptr;
+ addInputSec(IS, OutsecName, Out);
+ return;
+ }
+
SectionKey Key = createKey(IS, OutsecName);
OutputSection *&Sec = Map[Key];
return addInputSec(IS, OutsecName, Sec);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33643.101514.patch
Type: text/x-patch
Size: 2536 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170606/20c7fe65/attachment.bin>
More information about the llvm-commits
mailing list