This patch implements runtime ARM specific
authorJack Carter <jcarter@mips.com>
Wed, 30 Jan 2013 02:24:33 +0000 (02:24 +0000)
committerJack Carter <jcarter@mips.com>
Wed, 30 Jan 2013 02:24:33 +0000 (02:24 +0000)
setting of ELF header e_flags.

Contributer: Jack Carter

llvm-svn: 173885

llvm/include/llvm/Support/ELF.h
llvm/lib/Target/ARM/ARMAsmPrinter.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/test/MC/ARM/elf-eflags-eabi-cg.ll [new file with mode: 0644]
llvm/test/MC/ARM/elf-eflags-eabi.s

index e35924495eb733d8cc0f9eb968dec14e143afd83..746ea317bd1e19eb5004cf2ccf2313b40c0777da 100644 (file)
@@ -495,7 +495,15 @@ enum {
 };
 
 // ARM Specific e_flags
-enum { EF_ARM_EABIMASK = 0xFF000000U };
+enum {
+  EF_ARM_EABI_UNKNOWN =   0x00000000U,
+  EF_ARM_EABI_VER1 =      0x01000000U,
+  EF_ARM_EABI_VER2 =      0x02000000U,
+  EF_ARM_EABI_VER3 =      0x03000000U,
+  EF_ARM_EABI_VER4 =      0x04000000U,
+  EF_ARM_EABI_VER5 =      0x05000000U,
+  EF_ARM_EABIMASK =       0xFF000000U
+};
 
 // ELF Relocation types for ARM
 // Meets 2.08 ABI Specs.
index ee2a2289b15b6b5ce8d52d175b677d540f5a14e9..397736a2bf38585544dd72d15e5e9ebf5930672e 100644 (file)
@@ -37,6 +37,7 @@
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCAssembler.h"
 #include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCELFStreamer.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCInstBuilder.h"
 #include "llvm/MC/MCObjectStreamer.h"
@@ -45,6 +46,7 @@
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ELF.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
@@ -699,6 +701,15 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
     // generates code that does this, it is always safe to set.
     OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
   }
+  // FIXME: This should eventually end up somewhere else where more
+  // intelligent flag decisions can be made. For now we are just maintaining
+  // the status quo for ARM and setting EF_ARM_EABI_VER5 as the default.
+  if (Subtarget->isTargetELF()) {
+    if (OutStreamer.hasRawTextSupport()) return;
+
+    MCELFStreamer &MES = static_cast<MCELFStreamer &>(OutStreamer);
+    MES.getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
+  }
 }
 
 //===----------------------------------------------------------------------===//
index e9bdc4ad9ba281c28b5188053a94477470736ff4..77620e92189a4919091ec4c6f4822a43cf54e86f 100644 (file)
@@ -18,7 +18,9 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCAssembler.h"
 #include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCELFStreamer.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCInstrDesc.h"
@@ -28,6 +30,7 @@
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/ELF.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -250,6 +253,13 @@ public:
 
     // Not in an ITBlock to start with.
     ITState.CurPosition = ~0U;
+
+    // Set ELF header flags.
+    // FIXME: This should eventually end up somewhere else where more
+    // intelligent flag decisions can be made. For now we are just maintaining
+    // the status quo for ARM and setting EF_ARM_EABI_VER5 as the default.
+    MCELFStreamer &MES = static_cast<MCELFStreamer &>(Parser.getStreamer());
+    MES.getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
   }
 
   // Implementation of the MCTargetAsmParser interface:
diff --git a/llvm/test/MC/ARM/elf-eflags-eabi-cg.ll b/llvm/test/MC/ARM/elf-eflags-eabi-cg.ll
new file mode 100644 (file)
index 0000000..2e86a0f
--- /dev/null
@@ -0,0 +1,13 @@
+; Codegen version to check for ELF header flags.
+;
+; RUN: llc %s -mtriple=thumbv7-linux-gnueabi -relocation-model=pic \
+; RUN: -filetype=obj -o - | elf-dump --dump-section-data | \
+; RUN: FileCheck %s
+
+define void @bar() nounwind {
+entry:
+  ret void
+}
+
+; For now the only e_flag set is EF_ARM_EABI_VER5
+;CHECK:    'e_flags', 0x05000000
index 6f70a5b9a79cae87a551975fbed4d6be7e18d13d..ea89eacf74fb3453f9ccb4695c9a1f3762a8bde3 100644 (file)
@@ -1,4 +1,3 @@
-@ XFAIL:
 @ RUN: llvm-mc %s -triple=armv7-linux-gnueabi -filetype=obj -o - | \
 @ RUN:    elf-dump --dump-section-data  | FileCheck -check-prefix=OBJ %s
        .syntax unified