[lld] r238191 - [ARM] Move out .ARM.exidx related things to ARM backend

Denis Protivensky dprotivensky at accesssoftek.com
Tue May 26 03:26:16 PDT 2015


Author: denis-protivensky
Date: Tue May 26 05:26:15 2015
New Revision: 238191

URL: http://llvm.org/viewvc/llvm-project?rev=238191&view=rev
Log:
[ARM] Move out .ARM.exidx related things to ARM backend

Modified:
    lld/trunk/include/lld/Core/DefinedAtom.h
    lld/trunk/lib/Core/DefinedAtom.cpp
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMSymbolTable.h
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
    lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp
    lld/trunk/lib/ReaderWriter/ELF/TargetLayout.h

Modified: lld/trunk/include/lld/Core/DefinedAtom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/DefinedAtom.h?rev=238191&r1=238190&r2=238191&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/DefinedAtom.h (original)
+++ lld/trunk/include/lld/Core/DefinedAtom.h Tue May 26 05:26:15 2015
@@ -151,7 +151,6 @@ public:
     typeNoAlloc,            // Identifies non allocatable sections [ELF]
     typeGroupComdat,        // Identifies a section group [ELF, COFF]
     typeGnuLinkOnce,        // Identifies a gnu.linkonce section [ELF]
-    typeARMExidx,           // Identifies a ARM_EXIDX section [ELF/ARM]
   };
 
   // Permission bits for atoms and segments. The order of these values are

Modified: lld/trunk/lib/Core/DefinedAtom.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/DefinedAtom.cpp?rev=238191&r1=238190&r2=238191&view=diff
==============================================================================
--- lld/trunk/lib/Core/DefinedAtom.cpp (original)
+++ lld/trunk/lib/Core/DefinedAtom.cpp Tue May 26 05:26:15 2015
@@ -43,7 +43,6 @@ DefinedAtom::ContentPermissions DefinedA
   case typeProcessedUnwindInfo:
   case typeRONote:
   case typeNoAlloc:
-  case typeARMExidx:
     return permR__;
 
   case typeData:

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h?rev=238191&r1=238190&r2=238191&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h Tue May 26 05:26:15 2015
@@ -17,11 +17,46 @@ namespace elf {
 
 class ARMLinkingContext;
 
-class ARMELFMappingAtom : public ELFDefinedAtom<ELF32LE> {
+class ARMELFBaseDefinedAtom : public ELFDefinedAtom<ELF32LE> {
+public:
+  /// The values of custom content type enum must not interfere
+  /// with ones in base defined atom class' enum.
+  enum ARMContentType {
+    typeARMExidx = 0x1000,   // Identifies ARM_EXIDX section
+  };
+
+  template <typename... T>
+  ARMELFBaseDefinedAtom(T &&... args)
+      : ELFDefinedAtom<ELF32LE>(std::forward<T>(args)...) {}
+
+  DefinedAtom::ContentPermissions permissions() const override {
+    if (_permissions != DefinedAtom::permUnknown)
+      return _permissions;
+
+    switch (_section->sh_type) {
+    case llvm::ELF::SHT_ARM_EXIDX:
+      return _permissions = permR__;
+    }
+    return ELFDefinedAtom::permissions();
+  }
+
+  DefinedAtom::ContentType contentType() const override {
+    if (_contentType != DefinedAtom::typeUnknown)
+      return _contentType;
+
+    switch (_section->sh_type) {
+    case llvm::ELF::SHT_ARM_EXIDX:
+      return _contentType = (DefinedAtom::ContentType)typeARMExidx;
+    }
+    return ELFDefinedAtom::contentType();
+  }
+};
+
+class ARMELFMappingAtom : public ARMELFBaseDefinedAtom {
 public:
   template <typename... T>
   ARMELFMappingAtom(DefinedAtom::CodeModel model, T &&... args)
-      : ELFDefinedAtom<ELF32LE>(std::forward<T>(args)...), _model(model) {}
+      : ARMELFBaseDefinedAtom(std::forward<T>(args)...), _model(model) {}
 
   DefinedAtom::CodeModel codeModel() const override { return _model; }
 
@@ -29,11 +64,11 @@ private:
   DefinedAtom::CodeModel _model;
 };
 
-class ARMELFDefinedAtom : public ELFDefinedAtom<ELF32LE> {
+class ARMELFDefinedAtom : public ARMELFBaseDefinedAtom {
 public:
   template <typename... T>
   ARMELFDefinedAtom(T &&... args)
-      : ELFDefinedAtom<ELF32LE>(std::forward<T>(args)...) {}
+      : ARMELFBaseDefinedAtom(std::forward<T>(args)...) {}
 
   bool isThumbFunc() const {
     const auto *symbol = _symbol;

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMSymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMSymbolTable.h?rev=238191&r1=238190&r2=238191&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMSymbolTable.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMSymbolTable.h Tue May 26 05:26:15 2015
@@ -12,6 +12,7 @@
 
 #include "SectionChunks.h"
 #include "TargetLayout.h"
+#include "ARMELFFile.h"
 
 namespace lld {
 namespace elf {
@@ -34,7 +35,8 @@ void ARMSymbolTable::addDefinedAtom(Elf_
                                     int64_t addr) {
   SymbolTable::addDefinedAtom(sym, da, addr);
 
-  if (da->contentType() == DefinedAtom::typeARMExidx)
+  if ((ARMELFDefinedAtom::ARMContentType)da->contentType() ==
+      ARMELFDefinedAtom::typeARMExidx)
     sym.st_value = addr;
 
   // Set zero bit to distinguish real symbols addressing Thumb instructions.

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h?rev=238191&r1=238190&r2=238191&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h Tue May 26 05:26:15 2015
@@ -27,7 +27,8 @@ class ARMExidxSection : public AtomSecti
 public:
   ARMExidxSection(const ELFLinkingContext &ctx, StringRef sectionName,
                   int32_t permissions, int32_t order)
-      : Base(ctx, sectionName, DefinedAtom::typeARMExidx, permissions, order) {
+      : Base(ctx, sectionName, ARMELFDefinedAtom::typeARMExidx, permissions,
+             order) {
     this->_type = SHT_ARM_EXIDX;
     this->_isLoadedInMemory = true;
   }
@@ -36,7 +37,8 @@ public:
 
   const AtomLayout *appendAtom(const Atom *atom) override {
     const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
-    assert(definedAtom->contentType() == DefinedAtom::typeARMExidx &&
+    assert((ARMELFDefinedAtom::ARMContentType)definedAtom->contentType() ==
+               ARMELFDefinedAtom::typeARMExidx &&
            "atom content type for .ARM.exidx section has to be typeARMExidx");
 
     DefinedAtom::Alignment atomAlign = definedAtom->alignment();
@@ -61,12 +63,16 @@ public:
 
 class ARMTargetLayout : public TargetLayout<ELF32LE> {
 public:
+  enum ARMSectionOrder {
+    ORDER_ARM_EXIDX = TargetLayout::ORDER_EH_FRAME + 1,
+  };
+
   ARMTargetLayout(ELFLinkingContext &ctx) : TargetLayout(ctx) {}
 
   SectionOrder getSectionOrder(StringRef name, int32_t contentType,
                                int32_t contentPermissions) override {
-    switch (contentType) {
-    case DefinedAtom::typeARMExidx:
+    switch ((ARMELFDefinedAtom::ARMContentType)contentType) {
+    case ARMELFDefinedAtom::typeARMExidx:
       return ORDER_ARM_EXIDX;
     default:
       return TargetLayout::getSectionOrder(name, contentType,
@@ -96,7 +102,8 @@ public:
   createSection(StringRef name, int32_t contentType,
                 DefinedAtom::ContentPermissions contentPermissions,
                 SectionOrder sectionOrder) override {
-    if (contentType == DefinedAtom::typeARMExidx)
+    if ((ARMELFDefinedAtom::ARMContentType)contentType ==
+        ARMELFDefinedAtom::typeARMExidx)
       return new ARMExidxSection(_ctx, name, contentPermissions, sectionOrder);
 
     return TargetLayout::createSection(name, contentType, contentPermissions,

Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp?rev=238191&r1=238190&r2=238191&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp Tue May 26 05:26:15 2015
@@ -84,8 +84,6 @@ DefinedAtom::ContentType ELFDefinedAtom<
   if (_symbol->st_shndx == SHN_COMMON)
     return _contentType = typeZeroFill;
 
-  if (_section->sh_type == SHT_ARM_EXIDX)
-    return typeARMExidx;
   if (_section->sh_type == SHT_PROGBITS) {
     flags &= ~SHF_ALLOC;
     flags &= ~SHF_GROUP;
@@ -218,9 +216,6 @@ DefinedAtom::ContentPermissions ELFDefin
   case llvm::ELF::SHT_FINI_ARRAY:
     return _permissions = permRW_;
 
-  case llvm::ELF::SHT_ARM_EXIDX:
-    return _permissions = permR__;
-
   default:
     return _permissions = perm___;
   }

Modified: lld/trunk/lib/ReaderWriter/ELF/TargetLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/TargetLayout.h?rev=238191&r1=238190&r2=238191&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/TargetLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/TargetLayout.h Tue May 26 05:26:15 2015
@@ -52,7 +52,6 @@ public:
     ORDER_FINI = 90,
     ORDER_REL = 95,
     ORDER_RODATA = 100,
-    ORDER_ARM_EXIDX = 105,
     ORDER_EH_FRAME = 110,
     ORDER_EH_FRAMEHDR = 120,
     ORDER_TDATA = 124,





More information about the llvm-commits mailing list