Files
clang-p2996/lld/lib/ReaderWriter/ELF/Layout.h
Shankar Easwaran 9e07346679 [ELF] Add section group/COMDAT support.
SHF_GROUP: Group Member Sections
----------------------------------
A section which is part of a group, and is to be retained or discarded with the
group as a whole, is identified by a new section header attribute: SHF_GROUP
This section is a member (perhaps the only one) of a group of sections, and the
linker should retain or discard all or none of the members. This section must be
referenced in a SHT_GROUP section. This attribute flag may be set in any section
header, and no other modification or indication is made in the grouped sections.
All additional information is contained in the associated SHT_GROUP section.

SHT_GROUP: Section Group Definition
-------------------------------------
Represents a group section.

The section group's sh_link field identifies a symbol table section, and its
sh_info field the index of a symbol in that section. The name of that symbol is
treated as the identifier of the section group.

More information: https://mentorembedded.github.io/cxx-abi/abi/prop-72-comdat.html

Added a lot of extensive tests, that tests functionality.

llvm-svn: 230195
2015-02-23 00:30:00 +00:00

60 lines
2.0 KiB
C++

//===- lib/ReaderWriter/ELF/Layout.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_LAYOUT_H
#define LLD_READER_WRITER_ELF_LAYOUT_H
#include "lld/Core/DefinedAtom.h"
#include "lld/ReaderWriter/AtomLayout.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/ErrorOr.h"
namespace lld {
namespace elf {
/// \brief The ELFLayout is an abstract class for managing the final layout for
/// the kind of binaries(Shared Libraries / Relocatables / Executables 0
/// Each architecture (Hexagon, MIPS) would have a concrete
/// subclass derived from Layout for generating each binary thats
// needed by the lld linker
class Layout {
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
virtual SectionOrder getSectionOrder(StringRef name, int32_t contentType,
int32_t contentPerm) = 0;
/// \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.
virtual ErrorOr<const lld::AtomLayout *> addAtom(const Atom *atom) = 0;
/// find the Atom in the current layout
virtual const AtomLayout *findAtomLayoutByName(StringRef name) const = 0;
/// 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:
Layout() {}
virtual ~Layout() { }
};
} // end namespace elf
} // end namespace lld
#endif