Teach ARM/MC/ELF about EF_ARM_EABI_VERSION. The magic number is set to
authorJason W Kim <jason.w.kim.2009@gmail.com>
Fri, 4 Feb 2011 21:41:11 +0000 (21:41 +0000)
committerJason W Kim <jason.w.kim.2009@gmail.com>
Fri, 4 Feb 2011 21:41:11 +0000 (21:41 +0000)
5 to match the current doc.
Added FIXME reminder Make it really configurable later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124899 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/ELF.h
lib/MC/ELFObjectWriter.cpp
test/MC/ARM/elf-eflags-eabi.s [new file with mode: 0644]

index 58c216bdfe2f526c95ced39359d95d9484dd1443..cc72bd59cb70af4ad9197350b75f141122adba75 100644 (file)
@@ -290,6 +290,10 @@ enum {
   R_MICROBLAZE_COPY           = 21
 };
 
+
+// ARM Specific e_flags
+enum { EF_ARM_EABIMASK = 0xFF000000U };
+
 // ELF Relocation types for ARM
 // Meets 2.08 ABI Specs.
 
index 629d7468264f89364d1039452a7b2022e5b83e93..bd5d048f26940c185d98b6905e65d4aefbc28841 100644 (file)
@@ -276,6 +276,9 @@ namespace {
 
     virtual void WriteHeader(uint64_t SectionDataSize, unsigned NumberOfSections);
 
+    /// Default e_flags = 0
+    virtual void WriteEFlags() { Write32(0); }
+
     virtual void WriteSymbolEntry(MCDataFragment *SymtabF, MCDataFragment *ShndxF,
                           uint64_t name, uint8_t info,
                           uint64_t value, uint64_t size,
@@ -387,11 +390,16 @@ namespace {
 
   class ARMELFObjectWriter : public ELFObjectWriter {
   public:
+    // FIXME: MCAssembler can't yet return the Subtarget,
+    enum { DefaultEABIVersion = 0x05000000U };
+
     ARMELFObjectWriter(MCELFObjectTargetWriter *MOTW,
                        raw_ostream &_OS,
                        bool IsLittleEndian);
 
     virtual ~ARMELFObjectWriter();
+
+    virtual void WriteEFlags();
   protected:
     virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
                                   bool IsPCRel, bool IsRelocWithSymbol,
@@ -459,8 +467,8 @@ void ELFObjectWriter::WriteHeader(uint64_t SectionDataSize,
   WriteWord(SectionDataSize + (is64Bit() ? sizeof(ELF::Elf64_Ehdr) :
             sizeof(ELF::Elf32_Ehdr)));  // e_shoff = sec hdr table off in bytes
 
-  // FIXME: Make this configurable.
-  Write32(0);   // e_flags = whatever the target wants
+  // e_flags = whatever the target wants
+  WriteEFlags();
 
   // e_ehsize = ELF header size
   Write16(is64Bit() ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr));
@@ -1477,6 +1485,11 @@ ARMELFObjectWriter::ARMELFObjectWriter(MCELFObjectTargetWriter *MOTW,
 ARMELFObjectWriter::~ARMELFObjectWriter()
 {}
 
+// FIXME: get the real EABI Version from the Triple.
+void ARMELFObjectWriter::WriteEFlags() {
+  Write32(ELF::EF_ARM_EABIMASK & DefaultEABIVersion);
+}
+
 unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target,
                                           const MCFixup &Fixup,
                                           bool IsPCRel,
diff --git a/test/MC/ARM/elf-eflags-eabi.s b/test/MC/ARM/elf-eflags-eabi.s
new file mode 100644 (file)
index 0000000..ea89eac
--- /dev/null
@@ -0,0 +1,13 @@
+@ RUN: llvm-mc %s -triple=armv7-linux-gnueabi -filetype=obj -o - | \
+@ RUN:    elf-dump --dump-section-data  | FileCheck -check-prefix=OBJ %s
+       .syntax unified
+       .text
+       .globl  barf
+       .align  2
+       .type   barf,%function
+barf:                                   @ @barf
+@ BB#0:                                 @ %entry
+        b foo
+
+@@@ make sure the EF_ARM_EABIMASK comes out OK
+@OBJ:    'e_flags', 0x05000000