summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2013-07-10 20:58:17 +0000
committerTim Northover <tnorthover@apple.com>2013-07-10 20:58:17 +0000
commita630fb0b67fc4a877ad319a311e9d1fa03e51f91 (patch)
tree26413d09501dea39fa46ac6cb94e19e826e134aa
parentfb6ab540008a418aaadd929ae0e5a6e41c80d324 (diff)
downloadbcm5719-llvm-a630fb0b67fc4a877ad319a311e9d1fa03e51f91.tar.gz
bcm5719-llvm-a630fb0b67fc4a877ad319a311e9d1fa03e51f91.zip
Put ELF COMDAT relocations into the relevant COMDAT group.
Patch from Игорь Пашев (I do hope we support utf-8 commit messages; I also hope he'll forgive me for transliterating it as Igor Pashev in case things go horribly wrong). llvm-svn: 186034
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp11
-rw-r--r--llvm/test/MC/ELF/comdat-reloc.s29
-rw-r--r--llvm/test/MC/ELF/comdat.s2
3 files changed, 39 insertions, 3 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 4f66156f6de..2db59acd504 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1002,11 +1002,18 @@ void ELFObjectWriter::CreateRelocationSections(MCAssembler &Asm,
else
EntrySize = is64Bit() ? sizeof(ELF::Elf64_Rel) : sizeof(ELF::Elf32_Rel);
+ unsigned Flags = 0;
+ StringRef Group = "";
+ if (Section.getFlags() & ELF::SHF_GROUP) {
+ Flags = ELF::SHF_GROUP;
+ Group = Section.getGroup()->getName();
+ }
+
const MCSectionELF *RelaSection =
Ctx.getELFSection(RelaSectionName, hasRelocationAddend() ?
- ELF::SHT_RELA : ELF::SHT_REL, 0,
+ ELF::SHT_RELA : ELF::SHT_REL, Flags,
SectionKind::getReadOnly(),
- EntrySize, "");
+ EntrySize, Group);
RelMap[&Section] = RelaSection;
Asm.getOrCreateSectionData(*RelaSection);
}
diff --git a/llvm/test/MC/ELF/comdat-reloc.s b/llvm/test/MC/ELF/comdat-reloc.s
new file mode 100644
index 00000000000..d893a7b149e
--- /dev/null
+++ b/llvm/test/MC/ELF/comdat-reloc.s
@@ -0,0 +1,29 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sd | FileCheck %s
+
+ .text
+ .globl hello
+ .type hello,@function
+hello:
+ call world
+ ret
+
+ .section .text.world,"axG",@progbits,world,comdat
+ .type world,@function
+world:
+ call doctor
+ ret
+
+// CHECK: Name: .group
+// CHECK-NOT: SectionData
+// CHECK: SectionData
+// CHECK-NEXT: 0000: 01000000 06000000 07000000
+
+// CHECK: Index: 6
+// CHECK-NEXT: Name: .text.world
+// CHECK-NOT: Section {
+// CHECK: SHF_GROUP
+
+// CHECK: Index: 7
+// CHECK-NEXT: Name: .rela.text.world
+// CHECK-NOT: Section {
+// CHECK: SHF_GROUP
diff --git a/llvm/test/MC/ELF/comdat.s b/llvm/test/MC/ELF/comdat.s
index f9469dfae27..6dbe583df01 100644
--- a/llvm/test/MC/ELF/comdat.s
+++ b/llvm/test/MC/ELF/comdat.s
@@ -39,7 +39,7 @@
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x0
// CHECK-NEXT: Offset: 0x54
-// CHECK-NEXT: Size: 8
+// CHECK-NEXT: Size: 12
// CHECK-NEXT: Link: 13
// CHECK-NEXT: Info: 13
// CHECK-NEXT: AddressAlignment: 4
OpenPOWER on IntegriCloud