aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/MC/ELFObjectWriter.cpp6
-rw-r--r--lib/MC/MCELFStreamer.cpp15
-rw-r--r--test/CodeGen/ARM/2010-12-15-elf-lcomm.ll35
3 files changed, 53 insertions, 3 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index 206570b..93c3b09 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -1565,8 +1565,12 @@ unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target,
Type = ELF::R_ARM_GOT_BREL; break;
case MCSymbolRefExpr::VK_ARM_TLSGD:
Type = ELF::R_ARM_TLS_GD32; break;
+ case MCSymbolRefExpr::VK_ARM_TPOFF:
+ Type = ELF::R_ARM_TLS_LE32; break;
case MCSymbolRefExpr::VK_ARM_GOTTPOFF:
Type = ELF::R_ARM_TLS_IE32; break;
+ case MCSymbolRefExpr::VK_None:
+ Type = ELF::R_ARM_ABS32; break;
case MCSymbolRefExpr::VK_ARM_GOTOFF:
Type = ELF::R_ARM_GOTOFF32; break;
} break;
@@ -1579,6 +1583,8 @@ unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target,
case ARM::fixup_arm_thumb_br:
assert(0 && "Unimplemented"); break;
case ARM::fixup_arm_branch:
+ // FIXME: Differentiate between R_ARM_CALL and
+ // R_ARM_JUMP24 (latter used for conditional jumps)
Type = ELF::R_ARM_CALL; break;
case ARM::fixup_arm_movt_hi16:
Type = ELF::R_ARM_MOVT_ABS; break;
diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp
index 6900b24..4636e2a 100644
--- a/lib/MC/MCELFStreamer.cpp
+++ b/lib/MC/MCELFStreamer.cpp
@@ -113,9 +113,8 @@ public:
SD.setSize(Value);
}
- virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {
- assert(0 && "ELF doesn't support this directive");
- }
+ virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size);
+
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
unsigned Size = 0, unsigned ByteAlignment = 0) {
assert(0 && "ELF doesn't support this directive");
@@ -362,6 +361,16 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
SD.setSize(MCConstantExpr::Create(Size, getContext()));
}
+void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {
+ // FIXME: Should this be caught and done earlier?
+ MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
+ SetBinding(SD, ELF::STB_LOCAL);
+ SD.setExternal(false);
+ BindingExplicitlySet.insert(Symbol);
+ // FIXME: ByteAlignment is not needed here, but is required.
+ EmitCommonSymbol(Symbol, Size, 1);
+}
+
void MCELFStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) {
// TODO: This is exactly the same as WinCOFFStreamer. Consider merging into
// MCObjectStreamer.
diff --git a/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll b/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll
new file mode 100644
index 0000000..e08fe8d5
--- /dev/null
+++ b/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll
@@ -0,0 +1,35 @@
+; RUN: llc %s -mtriple=armv7-linux-gnueabi -arm-use-movt -filetype=obj -o - | \
+; RUN: elf-dump --dump-section-data | FileCheck -check-prefix=OBJ %s
+; RUN: llc %s -mtriple=armv7-linux-gnueabi -arm-use-movt -o - | \
+; RUN: FileCheck -check-prefix=ASM %s
+
+
+@dummy = internal global i32 666
+@array00 = internal global [20 x i32] zeroinitializer
+@sum = internal global i32 55
+@STRIDE = internal global i32 8
+
+; ASM: .type array00,%object @ @array00
+; ASM-NEXT: .lcomm array00,80 @ @array00
+; ASM-NEXT: .type _MergedGlobals,%object @ @_MergedGlobals
+
+
+
+; OBJ: Section 0x00000003
+; OBJ-NEXT: '.bss'
+
+; OBJ: 'array00'
+; OBJ-NEXT: 'st_value', 0x00000000
+; OBJ-NEXT: 'st_size', 0x00000050
+; OBJ-NEXT: 'st_bind', 0x00000000
+; OBJ-NEXT: 'st_type', 0x00000001
+; OBJ-NEXT: 'st_other', 0x00000000
+; OBJ-NEXT: 'st_shndx', 0x00000003
+
+define i32 @main(i32 %argc) nounwind {
+ %1 = load i32* @sum, align 4
+ %2 = getelementptr [20 x i32]* @array00, i32 0, i32 %argc
+ %3 = load i32* %2, align 4
+ %4 = add i32 %1, %3
+ ret i32 %4;
+}