2013-01-30 06:03:39 +08:00
|
|
|
//===- lib/ReaderWriter/ELF/Layout.h --------------------------------------===//
|
2013-01-22 04:09:55 +08:00
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-30 06:03:39 +08:00
|
|
|
#ifndef LLD_READER_WRITER_ELF_LAYOUT_H
|
|
|
|
#define LLD_READER_WRITER_ELF_LAYOUT_H
|
2013-01-22 04:09:55 +08:00
|
|
|
|
|
|
|
#include "lld/Core/DefinedAtom.h"
|
2013-06-17 01:14:58 +08:00
|
|
|
#include "lld/ReaderWriter/AtomLayout.h"
|
2013-01-22 04:09:55 +08:00
|
|
|
#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"
|
2013-01-30 09:25:06 +08:00
|
|
|
#include "llvm/Support/ErrorOr.h"
|
2013-01-22 04:09:55 +08:00
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace elf {
|
2013-01-30 09:25:06 +08:00
|
|
|
|
|
|
|
/// \brief The ELFLayout is an abstract class for managing the final layout for
|
2013-01-22 04:09:55 +08:00
|
|
|
/// the kind of binaries(Shared Libraries / Relocatables / Executables 0
|
2015-01-30 09:18:43 +08:00
|
|
|
/// Each architecture (Hexagon, MIPS) would have a concrete
|
2013-01-30 06:03:39 +08:00
|
|
|
/// subclass derived from Layout for generating each binary thats
|
2013-01-22 04:09:55 +08:00
|
|
|
// needed by the lld linker
|
2013-01-30 06:03:39 +08:00
|
|
|
class Layout {
|
2013-01-22 04:09:55 +08:00
|
|
|
public:
|
|
|
|
typedef uint32_t SectionOrder;
|
|
|
|
typedef uint32_t SegmentType;
|
|
|
|
typedef uint32_t Flags;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// Return the order the section would appear in the output file
|
2013-02-15 04:24:38 +08:00
|
|
|
virtual SectionOrder getSectionOrder(StringRef name, int32_t contentType,
|
|
|
|
int32_t contentPerm) = 0;
|
2013-01-30 09:25:06 +08:00
|
|
|
/// \brief Append the Atom to the layout and create appropriate sections.
|
|
|
|
/// \returns A reference to the atom layout or an error. The atom layout will
|
|
|
|
/// be updated as linking progresses.
|
2015-02-23 08:30:00 +08:00
|
|
|
virtual ErrorOr<const lld::AtomLayout *> addAtom(const Atom *atom) = 0;
|
2014-12-04 21:43:35 +08:00
|
|
|
/// find the Atom in the current layout
|
|
|
|
virtual const AtomLayout *findAtomLayoutByName(StringRef name) const = 0;
|
2013-01-22 04:09:55 +08:00
|
|
|
/// associates a section to a segment
|
|
|
|
virtual void assignSectionsToSegments() = 0;
|
|
|
|
/// associates a virtual address to the segment, section, and the atom
|
|
|
|
virtual void assignVirtualAddress() = 0;
|
|
|
|
|
|
|
|
public:
|
2013-01-30 06:03:39 +08:00
|
|
|
Layout() {}
|
2013-01-22 04:09:55 +08:00
|
|
|
|
2013-01-30 06:03:39 +08:00
|
|
|
virtual ~Layout() { }
|
2013-01-22 04:09:55 +08:00
|
|
|
};
|
2013-01-30 06:03:39 +08:00
|
|
|
} // end namespace elf
|
|
|
|
} // end namespace lld
|
2013-01-22 04:09:55 +08:00
|
|
|
|
2013-01-30 06:03:39 +08:00
|
|
|
#endif
|