[ELF] Fix header sort order.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 29 Jan 2013 19:53:41 +0000 (19:53 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 29 Jan 2013 19:53:41 +0000 (19:53 +0000)
llvm-svn: 173822

24 files changed:
lld/lib/ReaderWriter/ELF/AtomsELF.h
lld/lib/ReaderWriter/ELF/DefaultELFLayout.h
lld/lib/ReaderWriter/ELF/DefaultELFTargetHandler.h
lld/lib/ReaderWriter/ELF/ELFChunk.h
lld/lib/ReaderWriter/ELF/ELFHeaderChunks.h
lld/lib/ReaderWriter/ELF/ELFLayout.h
lld/lib/ReaderWriter/ELF/ELFSectionChunks.h
lld/lib/ReaderWriter/ELF/ELFSegmentChunks.h
lld/lib/ReaderWriter/ELF/ELFTargetHandler.h
lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
lld/lib/ReaderWriter/ELF/ELFTargetLayout.h [new file with mode: 0644]
lld/lib/ReaderWriter/ELF/ELFTargets.h
lld/lib/ReaderWriter/ELF/ELFWriter.h
lld/lib/ReaderWriter/ELF/ExecutableAtoms.h
lld/lib/ReaderWriter/ELF/FileELF.h
lld/lib/ReaderWriter/ELF/HexagonReference.cpp
lld/lib/ReaderWriter/ELF/PPCReference.cpp
lld/lib/ReaderWriter/ELF/ReaderELF.cpp
lld/lib/ReaderWriter/ELF/ReferenceKinds.cpp
lld/lib/ReaderWriter/ELF/ReferenceKinds.h
lld/lib/ReaderWriter/ELF/WriterELF.cpp
lld/lib/ReaderWriter/ELF/X86Reference.cpp
lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFTarget.h
lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFTargetInfo.h

index b725fc9..e35358b 100644 (file)
@@ -1,9 +1,21 @@
-#ifndef LLD_ELFATOMS_H
-#define LLD_ELFATOMS_H
+//===- lib/ReaderWriter/ELF/AtomELF.h -------------------------------------===//
+//
+//                             The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_READER_WRITER_ELF_ATOMS_ELF_H
+#define LLD_READER_WRITER_ELF_ATOMS_ELF_H
 
-#include "lld/Core/LLVM.h"
 #include "ELFTargetHandler.h"
 
+#include "lld/Core/LLVM.h"
+
+#include "llvm/ADT/ArrayRef.h"
+
 #include <memory>
 #include <vector>
 
index eb0418c..cd05d2c 100644 (file)
 #ifndef LLD_READER_WRITER_DEFAULT_ELF_LAYOUT_H_
 #define LLD_READER_WRITER_DEFAULT_ELF_LAYOUT_H_
 
+#include "ELFChunk.h"
+#include "ELFHeaderChunks.h"
+#include "ELFLayout.h"
+#include "ELFSectionChunks.h"
+#include "ELFSegmentChunks.h"
+
 #include "lld/Core/LinkerOptions.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 
-#include "ELFChunk.h"
-#include "ELFHeaderChunks.h"
-#include "ELFLayout.h"
-#include "ELFSectionChunks.h"
-#include "ELFSegmentChunks.h"
-
 #include <map>
-#include <unordered_map>
 #include <tuple>
+#include <unordered_map>
 
 /// \brief The DefaultELFLayout class is used by the Writer to arrange
 ///        sections and segments in the order determined by the target ELF
index b70901c..acbe55f 100644 (file)
@@ -9,16 +9,15 @@
 #ifndef LLD_READER_WRITER_DEFAULT_ELF_TARGETHANDLER_H
 #define LLD_READER_WRITER_DEFAULT_ELF_TARGETHANDLER_H
 
-#include "lld/ReaderWriter/ELFTargetInfo.h"
+#include "DefaultELFLayout.h"
+#include "ELFTargetHandler.h"
 
 #include "lld/Core/LinkerOptions.h"
+#include "lld/ReaderWriter/ELFTargetInfo.h"
 
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/ELF.h"
 
-#include "DefaultELFLayout.h"
-#include "ELFTargetHandler.h"
-
 namespace lld {
 namespace elf {
 
index 771646a..cfed0ec 100644 (file)
@@ -20,8 +20,9 @@
 #include "llvm/Support/FileOutputBuffer.h"
 
 namespace lld {
-namespace elf {  
+class ELFTargetInfo;
 
+namespace elf {
 class ELFWriter;
 
 /// \brief A chunk is a contiguous region of space
index a749055..50f2dba 100644 (file)
 #ifndef LLD_READER_WRITER_ELF_HEADER_CHUNKS_H_
 #define LLD_READER_WRITER_ELF_HEADER_CHUNKS_H_
 
-#include "llvm/Object/ELF.h"
+#include "ELFSegmentChunks.h"
 
+#include "llvm/Object/ELF.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileOutputBuffer.h"
 
-#include "ELFSegmentChunks.h"
-
 /// \brief An ELFHeader represents the Elf[32/64]_Ehdr structure at the
 ///        start of an ELF executable file.
 namespace lld {
index 20f9de3..48754ab 100644 (file)
@@ -13,9 +13,7 @@
 #include "lld/Core/DefinedAtom.h"
 
 #include "llvm/ADT/StringRef.h"
-
 #include "llvm/Object/ELF.h"
-
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ELF.h"
index 9253938..0a645ad 100644 (file)
 #ifndef LLD_READER_WRITER_ELF_SECTION_CHUNKS_H_
 #define LLD_READER_WRITER_ELF_SECTION_CHUNKS_H_
 
+#include "ELFChunk.h"
+#include "ELFLayout.h"
+#include "ELFTargetHandler.h"
+#include "ELFWriter.h"
+
 #include "lld/Core/DefinedAtom.h"
 #include "lld/Core/range.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringRef.h"
-
 #include "llvm/Object/ELF.h"
-
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileOutputBuffer.h"
 
-#include "ELFChunk.h"
-#include "ELFLayout.h"
-#include "ELFWriter.h"
-
 namespace lld {
 namespace elf {
 
index 611af34..849a62b 100644 (file)
 #ifndef LLD_READER_WRITER_ELF_SEGMENT_CHUNKS_H_
 #define LLD_READER_WRITER_ELF_SEGMENT_CHUNKS_H_
 
+#include "ELFChunk.h"
+#include "ELFLayout.h"
+#include "ELFSectionChunks.h"
+#include "ELFWriter.h"
+
 #include "lld/Core/range.h"
 #include "lld/ReaderWriter/Writer.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringRef.h"
-
 #include "llvm/Object/ELF.h"
-
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileOutputBuffer.h"
 
-#include "ELFChunk.h"
-#include "ELFLayout.h"
-#include "ELFSectionChunks.h"
-#include "ELFWriter.h"
-
 /// \brief A segment can be divided into segment slices
 ///        depending on how the segments can be split
 namespace lld {
index 6afbd96..196f143 100644 (file)
 #ifndef LLD_READER_WRITER_ELF_TARGETHANDLER_H
 #define LLD_READER_WRITER_ELF_TARGETHANDLER_H
 
+#include "lld/Core/InputFiles.h"
 #include "lld/Core/LinkerOptions.h"
 #include "lld/Core/LLVM.h"
 #include "lld/Core/TargetInfo.h"
 #include "lld/ReaderWriter/ELFTargetInfo.h"
-#include "DefaultELFLayout.h"
-#include "AtomsELF.h"
+
+#include "llvm/ADT/Hashing.h"
 
 #include <memory>
 #include <vector>
 namespace lld {
 template <class ELFT> class ELFDefinedAtom;
 namespace elf {
+template <class ELFT> class ELFTargetLayout;
+template <class ELFT> class ELFHeader;
+template <class ELFT> class Section;
+
 /// \brief The target registers a set of handlers for overriding target specific
 /// attributes for a DefinedAtom. The Reader uses this class to query for the
 /// type of atom and its permissions 
@@ -52,52 +57,6 @@ public:
   }
 };
 
-/// \brief The target can override certain functions in the DefaultELFLayout
-/// class so that the order, the name of the section and the segment type could
-/// be changed in the final layout
-template <class ELFT> class ELFTargetLayout : public DefaultELFLayout<ELFT> {
-public:
-  ELFTargetLayout(ELFTargetInfo &targetInfo, DefaultELFLayout<ELFT> &layout)
-      : _targetInfo(targetInfo), _layout(layout) {
-  }
-
-  /// isTargetSection provides a way to determine if the section that
-  /// we are processing has been registered by the target and the target
-  /// wants to handle them. 
-  /// For example: the Writer may be processing a section but the target
-  /// might want to override the functionality on how atoms are inserted
-  /// into the section. Such sections are set the K_TargetSection flag in
-  /// the SectionKind after they are created
-  virtual bool isTargetSection(const StringRef name, const int32_t contentType,
-                               const int32_t contentPermissions) = 0;
-
-  /// The target may want to override the sectionName to a different
-  /// section Name in the output
-  virtual StringRef sectionName(const StringRef name, const int32_t contentType,
-                                const int32_t contentPermissions) = 0;
-
-  /// The target may want to override the section order that has been 
-  /// set by the DefaultLayout
-  virtual ELFLayout::SectionOrder getSectionOrder(
-      const StringRef name, int32_t contentType,
-      int32_t contentPermissions) = 0;
-
-  /// The target can set the segment type for a Section
-  virtual ELFLayout::SegmentType segmentType(Section<ELFT> *section) const = 0;
-
-  /// Returns true/false depending on whether the section has a Output
-  //  segment or not
-  bool hasOutputSegment(Section<ELFT> *section) = 0;
-
-  /// Returns the target Section for a section name and content Type
-  Section<ELFT> *getSection(const StringRef name,
-                            DefinedAtom::ContentPermissions permissions) = 0;
-
-private:
-  const ELFTargetInfo &_targetInfo;
-  const DefaultELFLayout<ELFT> &_layout;
-};
-
 /// \brief An interface to override functions that are provided by the 
 /// the default ELF Layout
 template <class ELFT> class ELFTargetHandler : public ELFTargetHandlerBase {
index ea0fd11..97526aa 100644 (file)
@@ -9,14 +9,14 @@
 
 #include "lld/ReaderWriter/ELFTargetInfo.h"
 
+#include "ELFTargetHandler.h"
+#include "ELFTargets.h"
+
 #include "lld/Core/LinkerOptions.h"
 
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/ELF.h"
 
-#include "ELFTargetHandler.h"
-#include "ELFTargets.h"
-
 namespace lld {
 uint16_t ELFTargetInfo::getOutputType() const {
   switch (_options._outputKind) {
diff --git a/lld/lib/ReaderWriter/ELF/ELFTargetLayout.h b/lld/lib/ReaderWriter/ELF/ELFTargetLayout.h
new file mode 100644 (file)
index 0000000..20a701d
--- /dev/null
@@ -0,0 +1,67 @@
+//===- lib/ReaderWriter/ELF/ELFTargetLayout.h -----------------------------===//
+//
+//                             The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_READER_WRITER_ELF_TARGET_LAYOUT_H
+#define LLD_READER_WRITER_ELF_TARGET_LAYOUT_H
+
+#include "DefaultELFLayout.h"
+
+#include "lld/Core/LLVM.h"
+
+namespace lld {
+namespace elf {
+/// \brief The target can override certain functions in the DefaultELFLayout
+/// class so that the order, the name of the section and the segment type could
+/// be changed in the final layout
+template <class ELFT> class ELFTargetLayout : public DefaultELFLayout<ELFT> {
+public:
+  ELFTargetLayout(ELFTargetInfo &targetInfo, DefaultELFLayout<ELFT> &layout)
+      : _targetInfo(targetInfo), _layout(layout) {
+  }
+
+  /// isTargetSection provides a way to determine if the section that
+  /// we are processing has been registered by the target and the target
+  /// wants to handle them. 
+  /// For example: the Writer may be processing a section but the target
+  /// might want to override the functionality on how atoms are inserted
+  /// into the section. Such sections are set the K_TargetSection flag in
+  /// the SectionKind after they are created
+  virtual bool isTargetSection(const StringRef name, const int32_t contentType,
+                               const int32_t contentPermissions) = 0;
+
+  /// The target may want to override the sectionName to a different
+  /// section Name in the output
+  virtual StringRef sectionName(const StringRef name, const int32_t contentType,
+                                const int32_t contentPermissions) = 0;
+
+  /// The target may want to override the section order that has been 
+  /// set by the DefaultLayout
+  virtual ELFLayout::SectionOrder getSectionOrder(
+      const StringRef name, int32_t contentType,
+      int32_t contentPermissions) = 0;
+
+  /// The target can set the segment type for a Section
+  virtual ELFLayout::SegmentType segmentType(Section<ELFT> *section) const = 0;
+
+  /// Returns true/false depending on whether the section has a Output
+  //  segment or not
+  bool hasOutputSegment(Section<ELFT> *section) = 0;
+
+  /// Returns the target Section for a section name and content Type
+  Section<ELFT> *getSection(const StringRef name,
+                            DefinedAtom::ContentPermissions permissions) = 0;
+
+private:
+  const ELFTargetInfo &_targetInfo;
+  const DefaultELFLayout<ELFT> &_layout;
+};
+} // end namespace elf
+} // end namespace lld
+
+#endif
index bbf85cc..d87be82 100644 (file)
@@ -6,12 +6,13 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+
 #ifndef LLD_READER_WRITER_ELF_TARGETS_H
 #define LLD_READER_WRITER_ELF_TARGETS_H
 
-#include "X86/X86ELFTarget.h"
-#include "X86_64/X86_64ELFTarget.h"
 #include "Hexagon/HexagonELFTarget.h"
 #include "PPC/PPCELFTarget.h"
+#include "X86/X86ELFTarget.h"
+#include "X86_64/X86_64ELFTarget.h"
 
 #endif
index 20b83fd..44e5471 100644 (file)
 #ifndef LLD_READER_WRITER_ELF_WRITER_H_
 #define LLD_READER_WRITER_ELF_WRITER_H_
 
+#include "ReferenceKinds.h"
+
 #include "lld/Core/File.h"
 #include "lld/Core/InputFiles.h"
 #include "lld/ReaderWriter/Writer.h"
-#include "ReferenceKinds.h"
 
 namespace lld {
 namespace elf {
index 930b7f4..3276bb4 100644 (file)
 #ifndef LLD_READER_WRITER_ELF_EXECUTABLE_ATOM_H_
 #define LLD_READER_WRITER_ELF_EXECUTABLE_ATOM_H_
 
+#include "AtomsELF.h"
+#include "FileELF.h"
+
 #include "lld/Core/DefinedAtom.h"
 #include "lld/Core/File.h"
 #include "lld/Core/Reference.h"
 #include "lld/Core/UndefinedAtom.h"
 #include "lld/ReaderWriter/Writer.h"
-#include "AtomsELF.h"
-#include "FileELF.h"
 
 namespace lld {
 namespace elf {
index 9eecb70..7b66a78 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef LLD_READER_WRITER_FILE_ELF_H
 #define LLD_READER_WRITER_FILE_ELF_H
 
+#include "AtomsELF.h"
+
 #include "lld/Core/Reference.h"
 #include "lld/ReaderWriter/ELFTargetInfo.h"
 #include "lld/ReaderWriter/ReaderArchive.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/ErrorOr.h"
-#include "llvm/Support/Path.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Memory.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/system_error.h"
-#include "AtomsELF.h"
+
+#include <map>
 
 namespace lld {
 
@@ -322,10 +324,8 @@ private:
   /// relocations will also have a section named ".rel.text" or ".rela.text"
   /// which will hold the entries. -- .rel or .rela is prepended to create
   /// the SHT_REL(A) section name.
-  std::map<llvm::StringRef,
-           std::vector<const Elf_Rela *> > _relocationAddendRefences;
-  std::map<llvm::StringRef,
-           std::vector<const Elf_Rel *> > _relocationReferences;
+  std::map<StringRef, std::vector<const Elf_Rela *> > _relocationAddendRefences;
+  std::map<StringRef, std::vector<const Elf_Rel *> > _relocationReferences;
   std::vector<ELFReference<ELFT> *> _references;
   llvm::DenseMap<const Elf_Sym *, Atom *> _symbolToAtomMapping;
   llvm::BumpPtrAllocator _readerStorage;
@@ -333,4 +333,4 @@ private:
 };
 } // lld
 
-#endif // LLD_READER_WRITER_FILE_ELF_H
+#endif
index 7f14b87..286af00 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
-
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ELF.h"
index ec7df8f..9cfe284 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
-
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ELF.h"
index a94f307..3439b96 100644 (file)
@@ -15,6 +15,9 @@
 
 #include "lld/ReaderWriter/Reader.h"
 
+#include "AtomsELF.h"
+#include "FileELF.h"
+
 #include "lld/Core/Reference.h"
 #include "lld/ReaderWriter/ELFTargetInfo.h"
 #include "lld/ReaderWriter/ReaderArchive.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/ErrorOr.h"
-#include "llvm/Support/Path.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Memory.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/system_error.h"
-#include "AtomsELF.h"
-#include "FileELF.h"
 
 #include <map>
 #include <vector>
index 769895a..edf029c 100644 (file)
@@ -12,9 +12,8 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
-
-#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ELF.h"
+#include "llvm/Support/ErrorHandling.h"
 
 namespace lld {
 namespace elf {
index 45f6cae..18ff5ba 100644 (file)
@@ -7,6 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#ifndef LLD_READER_WRITER_ELF_REFERENCE_KINDS_H
+#define LLD_READER_WRITER_ELF_REFERENCE_KINDS_H
+
 #include "lld/Core/LLVM.h"
 #include "lld/Core/Reference.h"
 #include "lld/ReaderWriter/Writer.h"
@@ -20,9 +23,6 @@
 #include <map>
 #include <memory>
 
-#ifndef LLD_READER_WRITER_ELF_REFERENCE_KINDS_H
-#define LLD_READER_WRITER_ELF_REFERENCE_KINDS_H
-
 namespace lld {
 namespace elf {
 /// \brief the abstract interface to Reference::Kind values for ELF files.
index fa744ca..f9d70bd 100644 (file)
@@ -7,11 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lld/ReaderWriter/ELFTargetInfo.h"
+#include "lld/ReaderWriter/Writer.h"
 
 #include "DefaultELFLayout.h"
 #include "ExecutableAtoms.h"
 
+#include "lld/ReaderWriter/ELFTargetInfo.h"
+
 using namespace llvm;
 using namespace llvm::object;
 namespace lld {
index 46dd878..b79f8df 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
-
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
index 29af114..383cfaf 100644 (file)
@@ -6,4 +6,5 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+
 #include "X86_64ELFTargetInfo.h"
index a7380e8..98cc43f 100644 (file)
 #ifndef LLD_READER_WRITER_ELF_X86_64_TARGETINFO_H
 #define LLD_READER_WRITER_ELF_X86_64_TARGETINFO_H
 
-#include "lld/ReaderWriter/ELFTargetInfo.h"
+#include "DefaultELFTargetHandler.h"
 
 #include "lld/Core/LinkerOptions.h"
+#include "lld/ReaderWriter/ELFTargetInfo.h"
+
 #include "llvm/Object/ELF.h"
 #include "llvm/Support/ELF.h"
 
-#include "DefaultELFTargetHandler.h"
-
 namespace lld {
 namespace elf {
 class X86_64ELFTargetInfo LLVM_FINAL : public ELFTargetInfo {