[ELF] Fix header sort order.

llvm-svn: 173822
This commit is contained in:
Michael J. Spencer 2013-01-29 19:53:41 +00:00
parent ddaa9be978
commit 43ecac5a2c
24 changed files with 147 additions and 113 deletions

View File

@ -1,8 +1,20 @@
#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 "ELFTargetHandler.h"
#include "lld/Core/LLVM.h"
#include "ELFTargetHandler.h"
#include "llvm/ADT/ArrayRef.h"
#include <memory>
#include <vector>

View File

@ -10,6 +10,12 @@
#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"
@ -22,15 +28,9 @@
#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

View 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 {

View 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

View File

@ -10,16 +10,15 @@
#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 {

View 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"

View File

@ -10,25 +10,24 @@
#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 {

View File

@ -10,26 +10,24 @@
#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 {

View File

@ -16,12 +16,13 @@
#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>
@ -30,6 +31,10 @@
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 {

View 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) {

View File

@ -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

View 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

View File

@ -10,10 +10,11 @@
#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 {

View File

@ -10,13 +10,14 @@
#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 {

View 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"
@ -23,18 +25,18 @@
#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

View 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"

View 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"

View 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"
@ -26,19 +29,16 @@
#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>

View 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 {

View 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.

View 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 {

View 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"

View File

@ -6,4 +6,5 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "X86_64ELFTargetInfo.h"

View File

@ -10,14 +10,14 @@
#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 {