[llvm] r186034 - Put ELF COMDAT relocations into the relevant COMDAT group.
Tim Northover
tnorthover at apple.com
Wed Jul 10 13:58:17 PDT 2013
Author: tnorthover
Date: Wed Jul 10 15:58:17 2013
New Revision: 186034
URL: http://llvm.org/viewvc/llvm-project?rev=186034&view=rev
Log:
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).
Added:
llvm/trunk/test/MC/ELF/comdat-reloc.s
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ELF/comdat.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=186034&r1=186033&r2=186034&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed Jul 10 15:58:17 2013
@@ -1002,11 +1002,18 @@ void ELFObjectWriter::CreateRelocationSe
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);
}
Added: llvm/trunk/test/MC/ELF/comdat-reloc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/comdat-reloc.s?rev=186034&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/comdat-reloc.s (added)
+++ llvm/trunk/test/MC/ELF/comdat-reloc.s Wed Jul 10 15:58:17 2013
@@ -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, at function
+hello:
+ call world
+ ret
+
+ .section .text.world,"axG", at progbits,world,comdat
+ .type world, at 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
Modified: llvm/trunk/test/MC/ELF/comdat.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/comdat.s?rev=186034&r1=186033&r2=186034&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/comdat.s (original)
+++ llvm/trunk/test/MC/ELF/comdat.s Wed Jul 10 15:58:17 2013
@@ -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
More information about the llvm-commits
mailing list