-#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>
#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
#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 {
#include "llvm/Support/FileOutputBuffer.h"
namespace lld {
-namespace elf {
+class ELFTargetInfo;
+namespace elf {
class ELFWriter;
/// \brief A chunk is a contiguous region of space
#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 {
#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"
#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 {
#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 {
#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
}
};
-/// \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 {
#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) {
--- /dev/null
+//===- 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
// 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
#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 {
#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 {
#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 {
/// 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;
};
} // lld
-#endif // LLD_READER_WRITER_FILE_ELF_H
+#endif
#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"
#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"
#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>
#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 {
//
//===----------------------------------------------------------------------===//
+#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"
#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.
//
//===----------------------------------------------------------------------===//
-#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 {
#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"
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
#include "X86_64ELFTargetInfo.h"
#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 {