2015-09-22 08:01:39 +08:00
|
|
|
//===- InputSection.h -------------------------------------------*- C++ -*-===//
|
2015-07-25 05:03:07 +08:00
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-09-22 08:01:39 +08:00
|
|
|
#ifndef LLD_ELF_INPUT_SECTION_H
|
|
|
|
#define LLD_ELF_INPUT_SECTION_H
|
2015-07-25 05:03:07 +08:00
|
|
|
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
#include "Config.h"
|
2016-05-25 04:24:43 +08:00
|
|
|
#include "Relocations.h"
|
2016-07-09 00:10:27 +08:00
|
|
|
#include "Thunks.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
#include "lld/Core/LLVM.h"
|
2016-12-19 11:14:16 +08:00
|
|
|
#include "llvm/ADT/CachedHashString.h"
|
2016-05-24 00:55:43 +08:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2016-02-23 11:34:37 +08:00
|
|
|
#include "llvm/ADT/TinyPtrVector.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
#include "llvm/Object/ELF.h"
|
2017-05-25 02:31:48 +08:00
|
|
|
#include "llvm/Support/Threading.h"
|
2016-11-18 13:05:43 +08:00
|
|
|
#include <mutex>
|
2015-07-25 05:03:07 +08:00
|
|
|
|
|
|
|
namespace lld {
|
2016-02-28 08:25:54 +08:00
|
|
|
namespace elf {
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2016-08-31 21:28:33 +08:00
|
|
|
class DefinedCommon;
|
2016-04-15 22:41:56 +08:00
|
|
|
class SymbolBody;
|
2016-10-06 02:40:00 +08:00
|
|
|
struct SectionPiece;
|
2016-04-15 22:41:56 +08:00
|
|
|
|
2017-03-01 03:29:55 +08:00
|
|
|
class DefinedRegular;
|
2017-03-07 05:17:18 +08:00
|
|
|
class SyntheticSection;
|
2017-02-24 06:06:28 +08:00
|
|
|
template <class ELFT> class EhFrameSection;
|
2017-03-07 04:23:56 +08:00
|
|
|
class MergeSyntheticSection;
|
2017-07-27 06:13:32 +08:00
|
|
|
template <class ELFT> class ObjFile;
|
2017-02-24 23:07:30 +08:00
|
|
|
class OutputSection;
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2017-03-09 06:36:28 +08:00
|
|
|
// This is the base class of all sections that lld handles. Some are sections in
|
|
|
|
// input files, some are sections in the produced output file and some exist
|
|
|
|
// just as a convenience for implementing special ways of combining some
|
|
|
|
// sections.
|
|
|
|
class SectionBase {
|
2016-09-01 17:55:57 +08:00
|
|
|
public:
|
2017-03-09 06:36:28 +08:00
|
|
|
enum Kind { Regular, EHFrame, Merge, Synthetic, Output };
|
2016-09-01 17:55:57 +08:00
|
|
|
|
2016-09-08 20:33:41 +08:00
|
|
|
Kind kind() const { return (Kind)SectionKind; }
|
2016-09-12 21:13:53 +08:00
|
|
|
|
2017-02-23 10:32:18 +08:00
|
|
|
StringRef Name;
|
2016-10-26 08:54:03 +08:00
|
|
|
|
2017-02-23 10:32:18 +08:00
|
|
|
unsigned SectionKind : 3;
|
2016-09-01 17:55:57 +08:00
|
|
|
|
2017-03-09 06:36:28 +08:00
|
|
|
// The next two bit fields are only used by InputSectionBase, but we
|
|
|
|
// put them here so the struct packs better.
|
|
|
|
|
2017-02-23 10:32:18 +08:00
|
|
|
// The garbage collector sets sections' Live bits.
|
|
|
|
// If GC is disabled, all sections are considered live by default.
|
|
|
|
unsigned Live : 1; // for garbage collection
|
|
|
|
unsigned Assigned : 1; // for linker script
|
|
|
|
|
|
|
|
uint32_t Alignment;
|
2015-08-14 06:21:37 +08:00
|
|
|
|
2016-10-26 08:54:03 +08:00
|
|
|
// These corresponds to the fields in Elf_Shdr.
|
2017-02-23 10:28:28 +08:00
|
|
|
uint64_t Flags;
|
|
|
|
uint64_t Entsize;
|
2016-10-26 08:54:03 +08:00
|
|
|
uint32_t Type;
|
|
|
|
uint32_t Link;
|
|
|
|
uint32_t Info;
|
|
|
|
|
2017-03-09 06:36:28 +08:00
|
|
|
OutputSection *getOutputSection();
|
|
|
|
const OutputSection *getOutputSection() const {
|
|
|
|
return const_cast<SectionBase *>(this)->getOutputSection();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Translate an offset in the input section to an offset in the output
|
|
|
|
// section.
|
|
|
|
uint64_t getOffset(uint64_t Offset) const;
|
|
|
|
|
|
|
|
uint64_t getOffset(const DefinedRegular &Sym) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SectionBase(Kind SectionKind, StringRef Name, uint64_t Flags,
|
|
|
|
uint64_t Entsize, uint64_t Alignment, uint32_t Type,
|
|
|
|
uint32_t Info, uint32_t Link)
|
|
|
|
: Name(Name), SectionKind(SectionKind), Alignment(Alignment),
|
|
|
|
Flags(Flags), Entsize(Entsize), Type(Type), Link(Link), Info(Info) {
|
|
|
|
Live = false;
|
|
|
|
Assigned = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// This corresponds to a section of an input file.
|
|
|
|
class InputSectionBase : public SectionBase {
|
|
|
|
public:
|
|
|
|
static bool classof(const SectionBase *S);
|
|
|
|
|
|
|
|
// The file this section is from.
|
|
|
|
InputFile *File;
|
|
|
|
|
|
|
|
ArrayRef<uint8_t> Data;
|
2017-03-08 23:57:17 +08:00
|
|
|
uint64_t getOffsetInFile() const;
|
2017-03-08 22:12:52 +08:00
|
|
|
|
2017-03-07 06:36:19 +08:00
|
|
|
static InputSectionBase Discarded;
|
|
|
|
|
2016-09-08 22:06:08 +08:00
|
|
|
InputSectionBase()
|
2017-03-09 06:36:28 +08:00
|
|
|
: SectionBase(Regular, "", /*Flags*/ 0, /*Entsize*/ 0, /*Alignment*/ 0,
|
|
|
|
/*Type*/ 0,
|
|
|
|
/*Info*/ 0, /*Link*/ 0),
|
|
|
|
Repl(this) {
|
|
|
|
Live = false;
|
|
|
|
Assigned = false;
|
2016-11-10 22:53:24 +08:00
|
|
|
NumRelocations = 0;
|
|
|
|
AreRelocsRela = false;
|
|
|
|
}
|
2016-04-04 22:04:16 +08:00
|
|
|
|
2017-02-23 10:28:28 +08:00
|
|
|
template <class ELFT>
|
2017-07-27 06:13:32 +08:00
|
|
|
InputSectionBase(ObjFile<ELFT> *File, const typename ELFT::Shdr *Header,
|
2016-09-08 22:06:08 +08:00
|
|
|
StringRef Name, Kind SectionKind);
|
2017-02-23 10:28:28 +08:00
|
|
|
|
|
|
|
InputSectionBase(InputFile *File, uint64_t Flags, uint32_t Type,
|
|
|
|
uint64_t Entsize, uint32_t Link, uint32_t Info,
|
2017-03-09 03:35:29 +08:00
|
|
|
uint32_t Alignment, ArrayRef<uint8_t> Data, StringRef Name,
|
2016-10-26 08:54:03 +08:00
|
|
|
Kind SectionKind);
|
2017-06-01 04:17:44 +08:00
|
|
|
|
|
|
|
// Input sections are part of an output section. Special sections
|
|
|
|
// like .eh_frame and merge sections are first combined into a
|
|
|
|
// synthetic section that is then added to an output section. In all
|
|
|
|
// cases this points one level up.
|
|
|
|
SectionBase *Parent = nullptr;
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
|
2016-11-10 22:53:24 +08:00
|
|
|
// Relocations that refer to this section.
|
2017-02-23 10:28:28 +08:00
|
|
|
const void *FirstRelocation = nullptr;
|
2016-11-10 22:53:24 +08:00
|
|
|
unsigned NumRelocations : 31;
|
|
|
|
unsigned AreRelocsRela : 1;
|
2017-02-23 10:28:28 +08:00
|
|
|
template <class ELFT> ArrayRef<typename ELFT::Rel> rels() const {
|
2016-11-10 22:53:24 +08:00
|
|
|
assert(!AreRelocsRela);
|
2017-02-23 10:28:28 +08:00
|
|
|
return llvm::makeArrayRef(
|
|
|
|
static_cast<const typename ELFT::Rel *>(FirstRelocation),
|
|
|
|
NumRelocations);
|
2016-11-10 22:53:24 +08:00
|
|
|
}
|
2017-02-23 10:28:28 +08:00
|
|
|
template <class ELFT> ArrayRef<typename ELFT::Rela> relas() const {
|
2016-11-10 22:53:24 +08:00
|
|
|
assert(AreRelocsRela);
|
2017-02-23 10:28:28 +08:00
|
|
|
return llvm::makeArrayRef(
|
|
|
|
static_cast<const typename ELFT::Rela *>(FirstRelocation),
|
|
|
|
NumRelocations);
|
2016-11-10 22:53:24 +08:00
|
|
|
}
|
|
|
|
|
2016-02-26 02:43:51 +08:00
|
|
|
// This pointer points to the "real" instance of this instance.
|
|
|
|
// Usually Repl == this. However, if ICF merges two sections,
|
|
|
|
// Repl pointer of one section points to another section. So,
|
|
|
|
// if you need to get a pointer to this instance, do not use
|
|
|
|
// this but instead this->Repl.
|
2017-02-23 10:28:28 +08:00
|
|
|
InputSectionBase *Repl;
|
2016-02-26 02:43:51 +08:00
|
|
|
|
2017-02-18 03:34:05 +08:00
|
|
|
// InputSections that are dependent on us (reverse dependency for GC)
|
2017-02-23 10:28:28 +08:00
|
|
|
llvm::TinyPtrVector<InputSectionBase *> DependentSections;
|
2017-02-18 03:34:05 +08:00
|
|
|
|
2016-11-08 22:47:16 +08:00
|
|
|
// Returns the size of this section (even if this is a common or BSS.)
|
2017-03-08 23:44:30 +08:00
|
|
|
size_t getSize() const;
|
2016-11-08 22:47:16 +08:00
|
|
|
|
2017-07-27 06:13:32 +08:00
|
|
|
template <class ELFT> ObjFile<ELFT> *getFile() const;
|
2017-02-23 10:28:28 +08:00
|
|
|
|
|
|
|
template <class ELFT> llvm::object::ELFFile<ELFT> getObj() const {
|
|
|
|
return getFile<ELFT>()->getObj();
|
|
|
|
}
|
|
|
|
|
2017-06-01 03:09:52 +08:00
|
|
|
InputSection *getLinkOrderDep() const;
|
2015-11-12 00:50:37 +08:00
|
|
|
|
2017-03-21 17:08:58 +08:00
|
|
|
void uncompress();
|
2016-06-24 19:18:44 +08:00
|
|
|
|
2016-11-26 02:51:53 +08:00
|
|
|
// Returns a source location string. Used to construct an error message.
|
2017-02-23 10:28:28 +08:00
|
|
|
template <class ELFT> std::string getLocation(uint64_t Offset);
|
2017-03-31 03:13:47 +08:00
|
|
|
template <class ELFT> std::string getSrcMsg(uint64_t Offset);
|
|
|
|
template <class ELFT> std::string getObjMsg(uint64_t Offset);
|
2016-11-26 02:51:53 +08:00
|
|
|
|
2017-02-23 10:28:28 +08:00
|
|
|
template <class ELFT> void relocate(uint8_t *Buf, uint8_t *BufEnd);
|
2017-05-19 00:45:36 +08:00
|
|
|
void relocateAlloc(uint8_t *Buf, uint8_t *BufEnd);
|
|
|
|
template <class ELFT> void relocateNonAlloc(uint8_t *Buf, uint8_t *BufEnd);
|
2017-02-23 10:32:18 +08:00
|
|
|
|
|
|
|
std::vector<Relocation> Relocations;
|
|
|
|
|
|
|
|
template <typename T> llvm::ArrayRef<T> getDataAs() const {
|
|
|
|
size_t S = Data.size();
|
|
|
|
assert(S % sizeof(T) == 0);
|
|
|
|
return llvm::makeArrayRef<T>((const T *)Data.data(), S / sizeof(T));
|
|
|
|
}
|
2015-10-20 05:00:02 +08:00
|
|
|
};
|
|
|
|
|
2016-05-22 08:13:04 +08:00
|
|
|
// SectionPiece represents a piece of splittable section contents.
|
2016-10-20 18:55:58 +08:00
|
|
|
// We allocate a lot of these and binary search on them. This means that they
|
|
|
|
// have to be as compact as possible, which is why we don't store the size (can
|
|
|
|
// be found by looking at the next one) and put the hash in a side table.
|
2016-05-22 08:13:04 +08:00
|
|
|
struct SectionPiece {
|
2016-10-20 18:55:58 +08:00
|
|
|
SectionPiece(size_t Off, bool Live = false)
|
|
|
|
: InputOff(Off), OutputOff(-1), Live(Live || !Config->GcSections) {}
|
2016-05-22 09:15:32 +08:00
|
|
|
|
2016-05-22 08:13:04 +08:00
|
|
|
size_t InputOff;
|
2016-10-20 18:55:58 +08:00
|
|
|
ssize_t OutputOff : 8 * sizeof(ssize_t) - 1;
|
2016-10-20 23:59:08 +08:00
|
|
|
size_t Live : 1;
|
2016-05-22 08:13:04 +08:00
|
|
|
};
|
2016-10-20 18:55:58 +08:00
|
|
|
static_assert(sizeof(SectionPiece) == 2 * sizeof(size_t),
|
|
|
|
"SectionPiece is too big");
|
2016-05-22 08:13:04 +08:00
|
|
|
|
2015-10-20 05:00:02 +08:00
|
|
|
// This corresponds to a SHF_MERGE section of an input file.
|
2017-03-07 04:23:56 +08:00
|
|
|
class MergeInputSection : public InputSectionBase {
|
2015-10-20 05:00:02 +08:00
|
|
|
public:
|
2017-03-07 04:23:56 +08:00
|
|
|
template <class ELFT>
|
2017-07-27 06:13:32 +08:00
|
|
|
MergeInputSection(ObjFile<ELFT> *F, const typename ELFT::Shdr *Header,
|
2016-09-08 22:06:08 +08:00
|
|
|
StringRef Name);
|
2017-03-09 06:36:28 +08:00
|
|
|
static bool classof(const SectionBase *S);
|
2016-05-24 00:55:43 +08:00
|
|
|
void splitIntoPieces();
|
|
|
|
|
|
|
|
// Mark the piece at a given offset live. Used by GC.
|
2017-03-07 04:23:56 +08:00
|
|
|
void markLiveAt(uint64_t Offset) {
|
2016-10-26 20:36:56 +08:00
|
|
|
assert(this->Flags & llvm::ELF::SHF_ALLOC);
|
2016-10-20 07:13:40 +08:00
|
|
|
LiveOffsets.insert(Offset);
|
|
|
|
}
|
2016-05-24 00:55:43 +08:00
|
|
|
|
|
|
|
// Translate an offset in the input section to an offset
|
|
|
|
// in the output section.
|
2017-03-07 04:23:56 +08:00
|
|
|
uint64_t getOffset(uint64_t Offset) const;
|
2016-05-24 00:55:43 +08:00
|
|
|
|
2016-07-21 21:32:37 +08:00
|
|
|
// Splittable sections are handled as a sequence of data
|
|
|
|
// rather than a single large blob of data.
|
|
|
|
std::vector<SectionPiece> Pieces;
|
2016-12-06 10:19:30 +08:00
|
|
|
|
|
|
|
// Returns I'th piece's data. This function is very hot when
|
|
|
|
// string merging is enabled, so we want to inline.
|
|
|
|
LLVM_ATTRIBUTE_ALWAYS_INLINE
|
|
|
|
llvm::CachedHashStringRef getData(size_t I) const {
|
|
|
|
size_t Begin = Pieces[I].InputOff;
|
|
|
|
size_t End;
|
|
|
|
if (Pieces.size() - 1 == I)
|
|
|
|
End = this->Data.size();
|
|
|
|
else
|
|
|
|
End = Pieces[I + 1].InputOff;
|
|
|
|
|
|
|
|
StringRef S = {(const char *)(this->Data.data() + Begin), End - Begin};
|
|
|
|
return {S, Hashes[I]};
|
|
|
|
}
|
2016-07-21 21:32:37 +08:00
|
|
|
|
|
|
|
// Returns the SectionPiece at a given input section offset.
|
2017-03-07 04:23:56 +08:00
|
|
|
SectionPiece *getSectionPiece(uint64_t Offset);
|
|
|
|
const SectionPiece *getSectionPiece(uint64_t Offset) const;
|
2016-07-21 21:32:37 +08:00
|
|
|
|
2017-06-01 04:17:44 +08:00
|
|
|
SyntheticSection *getParent() const;
|
2017-02-03 21:06:18 +08:00
|
|
|
|
2016-05-24 00:55:43 +08:00
|
|
|
private:
|
2016-11-26 23:15:11 +08:00
|
|
|
void splitStrings(ArrayRef<uint8_t> A, size_t Size);
|
|
|
|
void splitNonStrings(ArrayRef<uint8_t> A, size_t Size);
|
2016-08-03 12:39:42 +08:00
|
|
|
|
2016-11-18 13:05:43 +08:00
|
|
|
std::vector<uint32_t> Hashes;
|
|
|
|
|
2017-03-07 04:23:56 +08:00
|
|
|
mutable llvm::DenseMap<uint64_t, uint64_t> OffsetMap;
|
2017-05-25 02:31:48 +08:00
|
|
|
mutable llvm::once_flag InitOffsetMap;
|
2016-11-18 13:05:43 +08:00
|
|
|
|
2017-03-07 04:23:56 +08:00
|
|
|
llvm::DenseSet<uint64_t> LiveOffsets;
|
2015-10-20 05:00:02 +08:00
|
|
|
};
|
|
|
|
|
2016-07-22 04:18:30 +08:00
|
|
|
struct EhSectionPiece : public SectionPiece {
|
2017-02-23 10:32:18 +08:00
|
|
|
EhSectionPiece(size_t Off, InputSectionBase *ID, uint32_t Size,
|
2016-11-23 17:45:17 +08:00
|
|
|
unsigned FirstRelocation)
|
|
|
|
: SectionPiece(Off, false), ID(ID), Size(Size),
|
2016-10-06 02:40:00 +08:00
|
|
|
FirstRelocation(FirstRelocation) {}
|
2017-02-23 10:32:18 +08:00
|
|
|
InputSectionBase *ID;
|
2016-10-20 18:55:58 +08:00
|
|
|
uint32_t Size;
|
|
|
|
uint32_t size() const { return Size; }
|
|
|
|
|
2016-11-23 17:45:17 +08:00
|
|
|
ArrayRef<uint8_t> data() { return {ID->Data.data() + this->InputOff, Size}; }
|
2016-07-22 04:18:30 +08:00
|
|
|
unsigned FirstRelocation;
|
|
|
|
};
|
|
|
|
|
2015-11-12 03:54:14 +08:00
|
|
|
// This corresponds to a .eh_frame section of an input file.
|
2017-03-07 05:17:18 +08:00
|
|
|
class EhInputSection : public InputSectionBase {
|
2015-11-12 03:54:14 +08:00
|
|
|
public:
|
2017-03-07 05:17:18 +08:00
|
|
|
template <class ELFT>
|
2017-07-27 06:13:32 +08:00
|
|
|
EhInputSection(ObjFile<ELFT> *F, const typename ELFT::Shdr *Header,
|
2017-03-07 05:17:18 +08:00
|
|
|
StringRef Name);
|
2017-03-09 06:36:28 +08:00
|
|
|
static bool classof(const SectionBase *S);
|
2017-03-07 05:17:18 +08:00
|
|
|
template <class ELFT> void split();
|
|
|
|
template <class ELFT, class RelTy> void split(ArrayRef<RelTy> Rels);
|
2015-11-12 03:54:14 +08:00
|
|
|
|
2016-07-21 21:32:37 +08:00
|
|
|
// Splittable sections are handled as a sequence of data
|
|
|
|
// rather than a single large blob of data.
|
2016-07-22 04:18:30 +08:00
|
|
|
std::vector<EhSectionPiece> Pieces;
|
2017-06-01 04:17:44 +08:00
|
|
|
|
|
|
|
SyntheticSection *getParent() const;
|
2015-11-12 03:54:14 +08:00
|
|
|
};
|
|
|
|
|
2017-02-24 21:06:59 +08:00
|
|
|
// This is a section that is added directly to an output section
|
|
|
|
// instead of needing special combination via a synthetic section. This
|
|
|
|
// includes all input sections with the exceptions of SHF_MERGE and
|
|
|
|
// .eh_frame. It also includes the synthetic sections themselves.
|
2017-02-24 00:49:07 +08:00
|
|
|
class InputSection : public InputSectionBase {
|
2015-10-20 05:00:02 +08:00
|
|
|
public:
|
2017-03-09 03:35:29 +08:00
|
|
|
InputSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
|
2017-02-23 10:32:18 +08:00
|
|
|
ArrayRef<uint8_t> Data, StringRef Name, Kind K = Regular);
|
2017-02-24 00:49:07 +08:00
|
|
|
template <class ELFT>
|
2017-07-27 06:13:32 +08:00
|
|
|
InputSection(ObjFile<ELFT> *F, const typename ELFT::Shdr *Header,
|
2017-02-24 00:49:07 +08:00
|
|
|
StringRef Name);
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
// Write this section to a mmap'ed file, assuming Buf is pointing to
|
|
|
|
// beginning of the output section.
|
2017-02-24 00:49:07 +08:00
|
|
|
template <class ELFT> void writeTo(uint8_t *Buf);
|
2015-10-20 05:00:02 +08:00
|
|
|
|
2017-06-01 04:17:44 +08:00
|
|
|
OutputSection *getParent() const;
|
|
|
|
|
2015-10-15 05:00:23 +08:00
|
|
|
// The offset from beginning of the output sections this section was assigned
|
|
|
|
// to. The writer sets a value.
|
2015-10-15 09:58:40 +08:00
|
|
|
uint64_t OutSecOff = 0;
|
2015-10-15 05:00:23 +08:00
|
|
|
|
2017-03-09 06:36:28 +08:00
|
|
|
static bool classof(const SectionBase *S);
|
2016-02-25 16:23:37 +08:00
|
|
|
|
2017-03-21 17:13:27 +08:00
|
|
|
InputSectionBase *getRelocatedSection();
|
2016-02-25 16:23:37 +08:00
|
|
|
|
2017-02-24 00:49:07 +08:00
|
|
|
template <class ELFT, class RelTy>
|
2016-04-29 02:42:04 +08:00
|
|
|
void relocateNonAlloc(uint8_t *Buf, llvm::ArrayRef<RelTy> Rels);
|
|
|
|
|
2016-11-20 10:39:59 +08:00
|
|
|
// Used by ICF.
|
2016-12-06 02:11:35 +08:00
|
|
|
uint32_t Class[2] = {0, 0};
|
2016-02-26 02:43:51 +08:00
|
|
|
|
|
|
|
// Called by ICF to merge two input sections.
|
2017-02-24 00:49:07 +08:00
|
|
|
void replace(InputSection *Other);
|
2016-02-26 02:43:51 +08:00
|
|
|
|
2016-11-20 10:39:59 +08:00
|
|
|
private:
|
2017-02-24 00:49:07 +08:00
|
|
|
template <class ELFT, class RelTy>
|
2016-11-20 10:39:59 +08:00
|
|
|
void copyRelocations(uint8_t *Buf, llvm::ArrayRef<RelTy> Rels);
|
2017-05-29 16:37:50 +08:00
|
|
|
|
2017-06-09 11:19:08 +08:00
|
|
|
template <class ELFT> void copyShtGroup(uint8_t *Buf);
|
2015-07-25 05:03:07 +08:00
|
|
|
};
|
|
|
|
|
2017-02-27 10:32:08 +08:00
|
|
|
// The list of all input sections.
|
|
|
|
extern std::vector<InputSectionBase *> InputSections;
|
|
|
|
|
2017-08-04 18:25:29 +08:00
|
|
|
// Builds section order for handling --symbol-ordering-file.
|
|
|
|
template <class ELFT> llvm::DenseMap<SectionBase *, int> buildSectionOrder();
|
|
|
|
|
2016-02-28 08:25:54 +08:00
|
|
|
} // namespace elf
|
2017-01-06 18:04:08 +08:00
|
|
|
|
2017-02-23 10:28:28 +08:00
|
|
|
std::string toString(const elf::InputSectionBase *);
|
2015-07-25 05:03:07 +08:00
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|