2015-09-22 05:38:08 +08:00
|
|
|
//===- OutputSections.h -----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_ELF_OUTPUT_SECTIONS_H
|
|
|
|
#define LLD_ELF_OUTPUT_SECTIONS_H
|
|
|
|
|
2016-03-14 04:28:29 +08:00
|
|
|
#include "Config.h"
|
2016-10-20 17:19:48 +08:00
|
|
|
#include "GdbIndex.h"
|
2016-06-20 05:39:37 +08:00
|
|
|
#include "Relocations.h"
|
2015-09-22 05:38:08 +08:00
|
|
|
|
2016-03-14 04:28:29 +08:00
|
|
|
#include "lld/Core/LLVM.h"
|
2015-09-22 05:38:08 +08:00
|
|
|
#include "llvm/MC/StringTableBuilder.h"
|
|
|
|
#include "llvm/Object/ELF.h"
|
|
|
|
|
|
|
|
namespace lld {
|
2016-02-28 08:25:54 +08:00
|
|
|
namespace elf {
|
2015-09-22 05:38:08 +08:00
|
|
|
|
|
|
|
class SymbolBody;
|
2016-07-22 04:18:30 +08:00
|
|
|
struct EhSectionPiece;
|
2015-10-10 05:07:25 +08:00
|
|
|
template <class ELFT> class SymbolTable;
|
2015-09-22 05:38:08 +08:00
|
|
|
template <class ELFT> class SymbolTableSection;
|
2015-10-16 06:27:29 +08:00
|
|
|
template <class ELFT> class StringTableSection;
|
2016-05-24 12:19:20 +08:00
|
|
|
template <class ELFT> class EhInputSection;
|
2015-09-22 05:38:08 +08:00
|
|
|
template <class ELFT> class InputSection;
|
2015-11-12 03:54:14 +08:00
|
|
|
template <class ELFT> class InputSectionBase;
|
2015-10-20 05:00:02 +08:00
|
|
|
template <class ELFT> class MergeInputSection;
|
2015-09-22 05:38:08 +08:00
|
|
|
template <class ELFT> class OutputSection;
|
|
|
|
template <class ELFT> class ObjectFile;
|
2016-04-28 04:22:31 +08:00
|
|
|
template <class ELFT> class SharedFile;
|
|
|
|
template <class ELFT> class SharedSymbol;
|
2015-09-22 05:38:08 +08:00
|
|
|
template <class ELFT> class DefinedRegular;
|
|
|
|
|
2015-09-22 08:16:19 +08:00
|
|
|
// This represents a section in an output file.
|
|
|
|
// Different sub classes represent different types of sections. Some contain
|
|
|
|
// input sections, others are created by the linker.
|
|
|
|
// The writer creates multiple OutputSections and assign them unique,
|
2015-09-22 05:38:08 +08:00
|
|
|
// non-overlapping file offsets and VAs.
|
2016-11-10 07:23:45 +08:00
|
|
|
class OutputSectionBase {
|
2015-09-22 05:38:08 +08:00
|
|
|
public:
|
2016-08-11 02:10:41 +08:00
|
|
|
enum Kind {
|
|
|
|
Base,
|
|
|
|
EHFrame,
|
|
|
|
EHFrameHdr,
|
|
|
|
GnuHashTable,
|
|
|
|
HashTable,
|
|
|
|
Merge,
|
|
|
|
Plt,
|
|
|
|
Regular,
|
|
|
|
SymTable,
|
|
|
|
VersDef,
|
|
|
|
VersNeed,
|
|
|
|
VersTable
|
|
|
|
};
|
2015-09-22 05:38:08 +08:00
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
OutputSectionBase(StringRef Name, uint32_t Type, uint64_t Flags);
|
|
|
|
void setLMAOffset(uint64_t LMAOff) { LMAOffset = LMAOff; }
|
|
|
|
uint64_t getLMA() const { return Addr + LMAOffset; }
|
|
|
|
template <typename ELFT> void writeHeaderTo(typename ELFT::Shdr *SHdr);
|
2016-11-04 21:20:45 +08:00
|
|
|
StringRef getName() const { return Name; }
|
2015-09-22 05:38:08 +08:00
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
virtual void addSection(InputSectionData *C) {}
|
2016-08-11 02:10:41 +08:00
|
|
|
virtual Kind getKind() const { return Base; }
|
2016-11-10 07:23:45 +08:00
|
|
|
static bool classof(const OutputSectionBase *B) {
|
2016-08-11 02:10:41 +08:00
|
|
|
return B->getKind() == Base;
|
|
|
|
}
|
2015-12-26 13:51:07 +08:00
|
|
|
|
2015-10-16 04:55:22 +08:00
|
|
|
unsigned SectionIndex;
|
2015-09-22 05:38:08 +08:00
|
|
|
|
2016-07-27 22:10:56 +08:00
|
|
|
uint32_t getPhdrFlags() const;
|
2016-07-14 13:46:24 +08:00
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
void updateAlignment(uint64_t Alignment) {
|
2016-11-09 09:42:41 +08:00
|
|
|
if (Alignment > Addralign)
|
|
|
|
Addralign = Alignment;
|
2015-11-03 22:13:40 +08:00
|
|
|
}
|
2015-09-22 05:38:08 +08:00
|
|
|
|
2016-03-31 03:41:51 +08:00
|
|
|
// If true, this section will be page aligned on disk.
|
|
|
|
// Typically the first section of each PT_LOAD segment has this flag.
|
|
|
|
bool PageAlign = false;
|
|
|
|
|
2016-09-29 17:20:33 +08:00
|
|
|
// Pointer to the first section in PT_LOAD segment, which this section
|
|
|
|
// also resides in. This field is used to correctly compute file offset
|
|
|
|
// of a section. When two sections share the same load segment, difference
|
|
|
|
// between their file offsets should be equal to difference between their
|
|
|
|
// virtual addresses. To compute some section offset we use the following
|
|
|
|
// formula: Off = Off_first + VA - VA_first.
|
2016-11-10 07:23:45 +08:00
|
|
|
OutputSectionBase *FirstInPtLoad = nullptr;
|
2016-09-29 17:20:33 +08:00
|
|
|
|
2015-09-22 05:38:08 +08:00
|
|
|
virtual void finalize() {}
|
Avoid doing binary search.
MergedInputSection::getOffset is the busiest function in LLD if string
merging is enabled and input files have lots of mergeable sections.
It is usually the case when creating executable with debug info,
so it is pretty common.
The reason why it is slow is because it has to do faily complex
computations. For non-mergeable sections, section contents are
contiguous in output, so in order to compute an output offset,
we only have to add the output section's base address to an input
offset. But for mergeable strings, section contents are split for
merging, so they are not contigous. We've got to do some lookups.
We used to do binary search on the list of section pieces.
It is slow because I think it's hostile to branch prediction.
This patch replaces it with hash table lookup. Seems it's working
pretty well. Below is "perf stat -r10" output when linking clang
with debug info. In this case this patch speeds up about 4%.
Before:
6584.153205 task-clock (msec) # 1.001 CPUs utilized ( +- 0.09% )
238 context-switches # 0.036 K/sec ( +- 6.59% )
0 cpu-migrations # 0.000 K/sec ( +- 50.92% )
1,067,675 page-faults # 0.162 M/sec ( +- 0.15% )
18,369,931,470 cycles # 2.790 GHz ( +- 0.09% )
9,640,680,143 stalled-cycles-frontend # 52.48% frontend cycles idle ( +- 0.18% )
<not supported> stalled-cycles-backend
21,206,747,787 instructions # 1.15 insns per cycle
# 0.45 stalled cycles per insn ( +- 0.04% )
3,817,398,032 branches # 579.786 M/sec ( +- 0.04% )
132,787,249 branch-misses # 3.48% of all branches ( +- 0.02% )
6.579106511 seconds time elapsed ( +- 0.09% )
After:
6312.317533 task-clock (msec) # 1.001 CPUs utilized ( +- 0.19% )
221 context-switches # 0.035 K/sec ( +- 4.11% )
1 cpu-migrations # 0.000 K/sec ( +- 45.21% )
1,280,775 page-faults # 0.203 M/sec ( +- 0.37% )
17,611,539,150 cycles # 2.790 GHz ( +- 0.19% )
10,285,148,569 stalled-cycles-frontend # 58.40% frontend cycles idle ( +- 0.30% )
<not supported> stalled-cycles-backend
18,794,779,900 instructions # 1.07 insns per cycle
# 0.55 stalled cycles per insn ( +- 0.03% )
3,287,450,865 branches # 520.799 M/sec ( +- 0.03% )
72,259,605 branch-misses # 2.20% of all branches ( +- 0.01% )
6.307411828 seconds time elapsed ( +- 0.19% )
Differential Revision: http://reviews.llvm.org/D20645
llvm-svn: 270999
2016-05-27 22:39:13 +08:00
|
|
|
virtual void finalizePieces() {}
|
2016-06-23 12:33:42 +08:00
|
|
|
virtual void assignOffsets() {}
|
2016-02-11 06:43:13 +08:00
|
|
|
virtual void writeTo(uint8_t *Buf) {}
|
2015-12-26 15:01:26 +08:00
|
|
|
virtual ~OutputSectionBase() = default;
|
2015-09-22 05:38:08 +08:00
|
|
|
|
|
|
|
StringRef Name;
|
2016-11-09 09:42:41 +08:00
|
|
|
|
|
|
|
// The following fields correspond to Elf_Shdr members.
|
2016-11-10 07:23:45 +08:00
|
|
|
uint64_t Size = 0;
|
|
|
|
uint64_t Entsize = 0;
|
|
|
|
uint64_t Addralign = 0;
|
|
|
|
uint64_t Offset = 0;
|
|
|
|
uint64_t Flags = 0;
|
|
|
|
uint64_t LMAOffset = 0;
|
|
|
|
uint64_t Addr = 0;
|
2016-11-09 09:42:41 +08:00
|
|
|
uint32_t ShName = 0;
|
|
|
|
uint32_t Type = 0;
|
|
|
|
uint32_t Info = 0;
|
|
|
|
uint32_t Link = 0;
|
2015-09-22 05:38:08 +08:00
|
|
|
};
|
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
template <class ELFT> class GdbIndexSection final : public OutputSectionBase {
|
2016-10-20 17:19:48 +08:00
|
|
|
typedef typename ELFT::uint uintX_t;
|
|
|
|
|
|
|
|
const unsigned OffsetTypeSize = 4;
|
|
|
|
const unsigned CuListOffset = 6 * OffsetTypeSize;
|
|
|
|
const unsigned CompilationUnitSize = 16;
|
|
|
|
const unsigned AddressEntrySize = 16 + OffsetTypeSize;
|
|
|
|
const unsigned SymTabEntrySize = 2 * OffsetTypeSize;
|
|
|
|
|
|
|
|
public:
|
|
|
|
GdbIndexSection();
|
|
|
|
void finalize() override;
|
|
|
|
void writeTo(uint8_t *Buf) override;
|
|
|
|
|
|
|
|
// Pairs of [CU Offset, CU length].
|
|
|
|
std::vector<std::pair<uintX_t, uintX_t>> CompilationUnits;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void parseDebugSections();
|
|
|
|
void readDwarf(InputSection<ELFT> *I);
|
|
|
|
|
|
|
|
uint32_t CuTypesOffset;
|
|
|
|
};
|
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
template <class ELFT> class PltSection final : public OutputSectionBase {
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::uint uintX_t;
|
2015-09-22 05:38:08 +08:00
|
|
|
|
|
|
|
public:
|
2015-10-08 03:18:16 +08:00
|
|
|
PltSection();
|
2015-10-09 05:51:31 +08:00
|
|
|
void finalize() override;
|
2015-09-22 05:38:08 +08:00
|
|
|
void writeTo(uint8_t *Buf) override;
|
2016-03-11 20:06:30 +08:00
|
|
|
void addEntry(SymbolBody &Sym);
|
2015-09-22 05:38:08 +08:00
|
|
|
bool empty() const { return Entries.empty(); }
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return Plt; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == Plt;
|
|
|
|
}
|
2015-09-22 05:38:08 +08:00
|
|
|
|
|
|
|
private:
|
2015-11-26 06:15:01 +08:00
|
|
|
std::vector<std::pair<const SymbolBody *, unsigned>> Entries;
|
2015-09-22 05:38:08 +08:00
|
|
|
};
|
|
|
|
|
2016-10-20 07:49:27 +08:00
|
|
|
struct SymbolTableEntry {
|
|
|
|
SymbolBody *Symbol;
|
2016-10-20 08:13:34 +08:00
|
|
|
size_t StrTabOffset;
|
2016-10-20 07:49:27 +08:00
|
|
|
};
|
|
|
|
|
2015-09-22 05:38:08 +08:00
|
|
|
template <class ELFT>
|
2016-11-10 07:23:45 +08:00
|
|
|
class SymbolTableSection final : public OutputSectionBase {
|
|
|
|
typedef OutputSectionBase Base;
|
2016-08-11 02:10:41 +08:00
|
|
|
|
2015-09-22 05:38:08 +08:00
|
|
|
public:
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::Shdr Elf_Shdr;
|
|
|
|
typedef typename ELFT::Sym Elf_Sym;
|
|
|
|
typedef typename ELFT::SymRange Elf_Sym_Range;
|
|
|
|
typedef typename ELFT::uint uintX_t;
|
2016-05-24 12:25:47 +08:00
|
|
|
SymbolTableSection(StringTableSection<ELFT> &StrTabSec);
|
2015-09-22 05:38:08 +08:00
|
|
|
|
2015-10-08 00:58:54 +08:00
|
|
|
void finalize() override;
|
2015-09-22 05:38:08 +08:00
|
|
|
void writeTo(uint8_t *Buf) override;
|
2015-10-21 05:47:58 +08:00
|
|
|
void addSymbol(SymbolBody *Body);
|
2015-10-16 06:27:29 +08:00
|
|
|
StringTableSection<ELFT> &getStrTabSec() const { return StrTabSec; }
|
2016-01-28 00:41:24 +08:00
|
|
|
unsigned getNumSymbols() const { return NumLocals + Symbols.size() + 1; }
|
2016-08-11 02:10:41 +08:00
|
|
|
typename Base::Kind getKind() const override { return Base::SymTable; }
|
|
|
|
static bool classof(const Base *B) { return B->getKind() == Base::SymTable; }
|
2015-09-22 05:38:08 +08:00
|
|
|
|
2016-10-20 16:36:42 +08:00
|
|
|
ArrayRef<SymbolTableEntry> getSymbols() const { return Symbols; }
|
2016-01-29 09:24:25 +08:00
|
|
|
|
|
|
|
unsigned NumLocals = 0;
|
|
|
|
StringTableSection<ELFT> &StrTabSec;
|
2015-10-21 05:47:58 +08:00
|
|
|
|
2015-09-22 05:38:08 +08:00
|
|
|
private:
|
2015-09-30 08:32:10 +08:00
|
|
|
void writeLocalSymbols(uint8_t *&Buf);
|
2015-10-19 16:01:51 +08:00
|
|
|
void writeGlobalSymbols(uint8_t *Buf);
|
2015-09-30 08:32:10 +08:00
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
const OutputSectionBase *getOutputSection(SymbolBody *Sym);
|
2015-10-21 04:52:14 +08:00
|
|
|
|
2016-02-17 13:06:40 +08:00
|
|
|
// A vector of symbols and their string table offsets.
|
2016-10-20 07:49:27 +08:00
|
|
|
std::vector<SymbolTableEntry> Symbols;
|
2015-09-22 05:38:08 +08:00
|
|
|
};
|
|
|
|
|
2016-04-28 04:22:31 +08:00
|
|
|
// For more information about .gnu.version and .gnu.version_r see:
|
|
|
|
// https://www.akkadia.org/drepper/symbol-versioning
|
|
|
|
|
2016-06-20 19:55:12 +08:00
|
|
|
// The .gnu.version_d section which has a section type of SHT_GNU_verdef shall
|
|
|
|
// contain symbol version definitions. The number of entries in this section
|
|
|
|
// shall be contained in the DT_VERDEFNUM entry of the .dynamic section.
|
|
|
|
// The section shall contain an array of Elf_Verdef structures, optionally
|
|
|
|
// followed by an array of Elf_Verdaux structures.
|
|
|
|
template <class ELFT>
|
2016-11-10 07:23:45 +08:00
|
|
|
class VersionDefinitionSection final : public OutputSectionBase {
|
2016-06-20 19:55:12 +08:00
|
|
|
typedef typename ELFT::Verdef Elf_Verdef;
|
|
|
|
typedef typename ELFT::Verdaux Elf_Verdaux;
|
|
|
|
|
|
|
|
public:
|
|
|
|
VersionDefinitionSection();
|
|
|
|
void finalize() override;
|
|
|
|
void writeTo(uint8_t *Buf) override;
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return VersDef; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == VersDef;
|
|
|
|
}
|
2016-07-16 10:29:45 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void writeOne(uint8_t *Buf, uint32_t Index, StringRef Name, size_t NameOff);
|
|
|
|
|
|
|
|
unsigned FileDefNameOff;
|
2016-06-20 19:55:12 +08:00
|
|
|
};
|
|
|
|
|
2016-04-28 04:22:31 +08:00
|
|
|
// The .gnu.version section specifies the required version of each symbol in the
|
|
|
|
// dynamic symbol table. It contains one Elf_Versym for each dynamic symbol
|
|
|
|
// table entry. An Elf_Versym is just a 16-bit integer that refers to a version
|
2016-06-20 19:55:12 +08:00
|
|
|
// identifier defined in the either .gnu.version_r or .gnu.version_d section.
|
|
|
|
// The values 0 and 1 are reserved. All other values are used for versions in
|
|
|
|
// the own object or in any of the dependencies.
|
2016-04-28 04:22:31 +08:00
|
|
|
template <class ELFT>
|
2016-11-10 07:23:45 +08:00
|
|
|
class VersionTableSection final : public OutputSectionBase {
|
2016-04-28 04:22:31 +08:00
|
|
|
typedef typename ELFT::Versym Elf_Versym;
|
|
|
|
|
|
|
|
public:
|
|
|
|
VersionTableSection();
|
|
|
|
void finalize() override;
|
|
|
|
void writeTo(uint8_t *Buf) override;
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return VersTable; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == VersTable;
|
|
|
|
}
|
2016-04-28 04:22:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// The .gnu.version_r section defines the version identifiers used by
|
|
|
|
// .gnu.version. It contains a linked list of Elf_Verneed data structures. Each
|
|
|
|
// Elf_Verneed specifies the version requirements for a single DSO, and contains
|
|
|
|
// a reference to a linked list of Elf_Vernaux data structures which define the
|
|
|
|
// mapping from version identifiers to version names.
|
|
|
|
template <class ELFT>
|
2016-11-10 07:23:45 +08:00
|
|
|
class VersionNeedSection final : public OutputSectionBase {
|
2016-04-28 04:22:31 +08:00
|
|
|
typedef typename ELFT::Verneed Elf_Verneed;
|
|
|
|
typedef typename ELFT::Vernaux Elf_Vernaux;
|
|
|
|
|
|
|
|
// A vector of shared files that need Elf_Verneed data structures and the
|
|
|
|
// string table offsets of their sonames.
|
|
|
|
std::vector<std::pair<SharedFile<ELFT> *, size_t>> Needed;
|
|
|
|
|
2016-06-20 19:55:12 +08:00
|
|
|
// The next available version identifier.
|
|
|
|
unsigned NextIndex;
|
2016-04-28 04:22:31 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
VersionNeedSection();
|
|
|
|
void addSymbol(SharedSymbol<ELFT> *SS);
|
|
|
|
void finalize() override;
|
|
|
|
void writeTo(uint8_t *Buf) override;
|
|
|
|
size_t getNeedNum() const { return Needed.size(); }
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return VersNeed; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == VersNeed;
|
|
|
|
}
|
2016-04-28 04:22:31 +08:00
|
|
|
};
|
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
template <class ELFT> class OutputSection final : public OutputSectionBase {
|
2016-08-11 02:10:41 +08:00
|
|
|
|
2015-09-22 05:38:08 +08:00
|
|
|
public:
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::Shdr Elf_Shdr;
|
|
|
|
typedef typename ELFT::Sym Elf_Sym;
|
|
|
|
typedef typename ELFT::Rel Elf_Rel;
|
|
|
|
typedef typename ELFT::Rela Elf_Rela;
|
|
|
|
typedef typename ELFT::uint uintX_t;
|
2016-02-18 22:20:08 +08:00
|
|
|
OutputSection(StringRef Name, uint32_t Type, uintX_t Flags);
|
2016-11-10 07:23:45 +08:00
|
|
|
void addSection(InputSectionData *C) override;
|
2016-11-10 17:05:20 +08:00
|
|
|
void sort(std::function<unsigned(InputSection<ELFT> *S)> Order);
|
2016-02-12 07:41:38 +08:00
|
|
|
void sortInitFini();
|
|
|
|
void sortCtorsDtors();
|
2015-09-22 05:38:08 +08:00
|
|
|
void writeTo(uint8_t *Buf) override;
|
2016-02-25 16:23:37 +08:00
|
|
|
void finalize() override;
|
2016-06-23 12:33:42 +08:00
|
|
|
void assignOffsets() override;
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return Regular; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == Regular;
|
|
|
|
}
|
2015-09-22 08:16:19 +08:00
|
|
|
std::vector<InputSection<ELFT> *> Sections;
|
2015-09-22 05:38:08 +08:00
|
|
|
};
|
|
|
|
|
2015-10-20 05:00:02 +08:00
|
|
|
template <class ELFT>
|
2016-11-10 07:23:45 +08:00
|
|
|
class MergeOutputSection final : public OutputSectionBase {
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::uint uintX_t;
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
public:
|
2016-02-19 22:17:40 +08:00
|
|
|
MergeOutputSection(StringRef Name, uint32_t Type, uintX_t Flags,
|
|
|
|
uintX_t Alignment);
|
2016-11-10 07:23:45 +08:00
|
|
|
void addSection(InputSectionData *S) override;
|
2015-10-20 05:00:02 +08:00
|
|
|
void writeTo(uint8_t *Buf) override;
|
2016-10-18 06:24:36 +08:00
|
|
|
unsigned getOffset(llvm::CachedHashStringRef Val);
|
2015-10-25 06:51:01 +08:00
|
|
|
void finalize() override;
|
Avoid doing binary search.
MergedInputSection::getOffset is the busiest function in LLD if string
merging is enabled and input files have lots of mergeable sections.
It is usually the case when creating executable with debug info,
so it is pretty common.
The reason why it is slow is because it has to do faily complex
computations. For non-mergeable sections, section contents are
contiguous in output, so in order to compute an output offset,
we only have to add the output section's base address to an input
offset. But for mergeable strings, section contents are split for
merging, so they are not contigous. We've got to do some lookups.
We used to do binary search on the list of section pieces.
It is slow because I think it's hostile to branch prediction.
This patch replaces it with hash table lookup. Seems it's working
pretty well. Below is "perf stat -r10" output when linking clang
with debug info. In this case this patch speeds up about 4%.
Before:
6584.153205 task-clock (msec) # 1.001 CPUs utilized ( +- 0.09% )
238 context-switches # 0.036 K/sec ( +- 6.59% )
0 cpu-migrations # 0.000 K/sec ( +- 50.92% )
1,067,675 page-faults # 0.162 M/sec ( +- 0.15% )
18,369,931,470 cycles # 2.790 GHz ( +- 0.09% )
9,640,680,143 stalled-cycles-frontend # 52.48% frontend cycles idle ( +- 0.18% )
<not supported> stalled-cycles-backend
21,206,747,787 instructions # 1.15 insns per cycle
# 0.45 stalled cycles per insn ( +- 0.04% )
3,817,398,032 branches # 579.786 M/sec ( +- 0.04% )
132,787,249 branch-misses # 3.48% of all branches ( +- 0.02% )
6.579106511 seconds time elapsed ( +- 0.09% )
After:
6312.317533 task-clock (msec) # 1.001 CPUs utilized ( +- 0.19% )
221 context-switches # 0.035 K/sec ( +- 4.11% )
1 cpu-migrations # 0.000 K/sec ( +- 45.21% )
1,280,775 page-faults # 0.203 M/sec ( +- 0.37% )
17,611,539,150 cycles # 2.790 GHz ( +- 0.19% )
10,285,148,569 stalled-cycles-frontend # 58.40% frontend cycles idle ( +- 0.30% )
<not supported> stalled-cycles-backend
18,794,779,900 instructions # 1.07 insns per cycle
# 0.55 stalled cycles per insn ( +- 0.03% )
3,287,450,865 branches # 520.799 M/sec ( +- 0.03% )
72,259,605 branch-misses # 2.20% of all branches ( +- 0.01% )
6.307411828 seconds time elapsed ( +- 0.19% )
Differential Revision: http://reviews.llvm.org/D20645
llvm-svn: 270999
2016-05-27 22:39:13 +08:00
|
|
|
void finalizePieces() override;
|
2016-05-05 12:10:12 +08:00
|
|
|
bool shouldTailMerge() const;
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return Merge; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == Merge;
|
|
|
|
}
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
private:
|
2016-02-19 22:17:40 +08:00
|
|
|
llvm::StringTableBuilder Builder;
|
Avoid doing binary search.
MergedInputSection::getOffset is the busiest function in LLD if string
merging is enabled and input files have lots of mergeable sections.
It is usually the case when creating executable with debug info,
so it is pretty common.
The reason why it is slow is because it has to do faily complex
computations. For non-mergeable sections, section contents are
contiguous in output, so in order to compute an output offset,
we only have to add the output section's base address to an input
offset. But for mergeable strings, section contents are split for
merging, so they are not contigous. We've got to do some lookups.
We used to do binary search on the list of section pieces.
It is slow because I think it's hostile to branch prediction.
This patch replaces it with hash table lookup. Seems it's working
pretty well. Below is "perf stat -r10" output when linking clang
with debug info. In this case this patch speeds up about 4%.
Before:
6584.153205 task-clock (msec) # 1.001 CPUs utilized ( +- 0.09% )
238 context-switches # 0.036 K/sec ( +- 6.59% )
0 cpu-migrations # 0.000 K/sec ( +- 50.92% )
1,067,675 page-faults # 0.162 M/sec ( +- 0.15% )
18,369,931,470 cycles # 2.790 GHz ( +- 0.09% )
9,640,680,143 stalled-cycles-frontend # 52.48% frontend cycles idle ( +- 0.18% )
<not supported> stalled-cycles-backend
21,206,747,787 instructions # 1.15 insns per cycle
# 0.45 stalled cycles per insn ( +- 0.04% )
3,817,398,032 branches # 579.786 M/sec ( +- 0.04% )
132,787,249 branch-misses # 3.48% of all branches ( +- 0.02% )
6.579106511 seconds time elapsed ( +- 0.09% )
After:
6312.317533 task-clock (msec) # 1.001 CPUs utilized ( +- 0.19% )
221 context-switches # 0.035 K/sec ( +- 4.11% )
1 cpu-migrations # 0.000 K/sec ( +- 45.21% )
1,280,775 page-faults # 0.203 M/sec ( +- 0.37% )
17,611,539,150 cycles # 2.790 GHz ( +- 0.19% )
10,285,148,569 stalled-cycles-frontend # 58.40% frontend cycles idle ( +- 0.30% )
<not supported> stalled-cycles-backend
18,794,779,900 instructions # 1.07 insns per cycle
# 0.55 stalled cycles per insn ( +- 0.03% )
3,287,450,865 branches # 520.799 M/sec ( +- 0.03% )
72,259,605 branch-misses # 2.20% of all branches ( +- 0.01% )
6.307411828 seconds time elapsed ( +- 0.19% )
Differential Revision: http://reviews.llvm.org/D20645
llvm-svn: 270999
2016-05-27 22:39:13 +08:00
|
|
|
std::vector<MergeInputSection<ELFT> *> Sections;
|
2015-10-20 05:00:02 +08:00
|
|
|
};
|
|
|
|
|
2016-05-23 07:16:14 +08:00
|
|
|
struct CieRecord {
|
2016-07-22 04:18:30 +08:00
|
|
|
EhSectionPiece *Piece = nullptr;
|
|
|
|
std::vector<EhSectionPiece *> FdePieces;
|
2015-11-12 03:54:14 +08:00
|
|
|
};
|
|
|
|
|
2016-05-23 07:16:14 +08:00
|
|
|
// Output section for .eh_frame.
|
2016-11-10 07:23:45 +08:00
|
|
|
template <class ELFT> class EhOutputSection final : public OutputSectionBase {
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::uint uintX_t;
|
|
|
|
typedef typename ELFT::Shdr Elf_Shdr;
|
|
|
|
typedef typename ELFT::Rel Elf_Rel;
|
|
|
|
typedef typename ELFT::Rela Elf_Rela;
|
2016-05-23 23:12:41 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
EhOutputSection();
|
2015-11-12 03:54:14 +08:00
|
|
|
void writeTo(uint8_t *Buf) override;
|
2016-04-07 22:22:09 +08:00
|
|
|
void finalize() override;
|
2016-05-24 00:24:16 +08:00
|
|
|
bool empty() const { return Sections.empty(); }
|
2015-11-12 03:54:14 +08:00
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
void addSection(InputSectionData *S) override;
|
|
|
|
Kind getKind() const override { return EHFrame; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == EHFrame;
|
|
|
|
}
|
2016-05-23 07:16:14 +08:00
|
|
|
|
2016-05-24 00:30:41 +08:00
|
|
|
size_t NumFdes = 0;
|
|
|
|
|
2016-05-23 07:16:14 +08:00
|
|
|
private:
|
2016-03-13 13:06:50 +08:00
|
|
|
template <class RelTy>
|
2016-05-24 12:19:20 +08:00
|
|
|
void addSectionAux(EhInputSection<ELFT> *S, llvm::ArrayRef<RelTy> Rels);
|
2015-11-12 03:54:14 +08:00
|
|
|
|
2016-05-23 07:16:14 +08:00
|
|
|
template <class RelTy>
|
2016-07-22 04:18:30 +08:00
|
|
|
CieRecord *addCie(EhSectionPiece &Piece, EhInputSection<ELFT> *Sec,
|
|
|
|
ArrayRef<RelTy> Rels);
|
2016-05-23 07:16:14 +08:00
|
|
|
|
|
|
|
template <class RelTy>
|
2016-07-22 04:18:30 +08:00
|
|
|
bool isFdeLive(EhSectionPiece &Piece, EhInputSection<ELFT> *Sec,
|
|
|
|
ArrayRef<RelTy> Rels);
|
2015-11-12 03:54:14 +08:00
|
|
|
|
2016-05-23 11:00:33 +08:00
|
|
|
uintX_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
|
|
|
|
|
2016-05-24 12:19:20 +08:00
|
|
|
std::vector<EhInputSection<ELFT> *> Sections;
|
2016-05-23 07:16:14 +08:00
|
|
|
std::vector<CieRecord *> Cies;
|
|
|
|
|
|
|
|
// CIE records are uniquified by their contents and personality functions.
|
|
|
|
llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
|
2015-11-12 03:54:14 +08:00
|
|
|
};
|
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
template <class ELFT> class HashTableSection final : public OutputSectionBase {
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::Word Elf_Word;
|
2015-09-22 05:38:08 +08:00
|
|
|
|
|
|
|
public:
|
2015-10-08 03:18:16 +08:00
|
|
|
HashTableSection();
|
2015-10-08 00:58:54 +08:00
|
|
|
void finalize() override;
|
|
|
|
void writeTo(uint8_t *Buf) override;
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return HashTable; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == HashTable;
|
|
|
|
}
|
2015-09-22 05:38:08 +08:00
|
|
|
};
|
|
|
|
|
2015-10-22 16:21:35 +08:00
|
|
|
// Outputs GNU Hash section. For detailed explanation see:
|
|
|
|
// https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections
|
|
|
|
template <class ELFT>
|
2016-11-10 07:23:45 +08:00
|
|
|
class GnuHashTableSection final : public OutputSectionBase {
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::Off Elf_Off;
|
|
|
|
typedef typename ELFT::Word Elf_Word;
|
|
|
|
typedef typename ELFT::uint uintX_t;
|
2015-10-22 16:21:35 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
GnuHashTableSection();
|
|
|
|
void finalize() override;
|
|
|
|
void writeTo(uint8_t *Buf) override;
|
|
|
|
|
2015-10-28 15:05:56 +08:00
|
|
|
// Adds symbols to the hash table.
|
|
|
|
// Sorts the input to satisfy GNU hash section requirements.
|
2016-10-20 07:49:27 +08:00
|
|
|
void addSymbols(std::vector<SymbolTableEntry> &Symbols);
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return GnuHashTable; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == GnuHashTable;
|
2016-08-11 02:10:41 +08:00
|
|
|
}
|
2015-10-22 16:21:35 +08:00
|
|
|
|
|
|
|
private:
|
2015-10-28 15:05:56 +08:00
|
|
|
static unsigned calcNBuckets(unsigned NumHashed);
|
2015-10-22 16:21:35 +08:00
|
|
|
static unsigned calcMaskWords(unsigned NumHashed);
|
|
|
|
|
|
|
|
void writeHeader(uint8_t *&Buf);
|
|
|
|
void writeBloomFilter(uint8_t *&Buf);
|
|
|
|
void writeHashTable(uint8_t *Buf);
|
|
|
|
|
2016-02-17 13:40:03 +08:00
|
|
|
struct SymbolData {
|
2015-10-28 15:05:56 +08:00
|
|
|
SymbolBody *Body;
|
2016-02-17 13:06:40 +08:00
|
|
|
size_t STName;
|
2015-10-28 15:05:56 +08:00
|
|
|
uint32_t Hash;
|
|
|
|
};
|
|
|
|
|
2016-02-17 13:40:03 +08:00
|
|
|
std::vector<SymbolData> Symbols;
|
2015-10-28 15:05:56 +08:00
|
|
|
|
2015-10-22 16:21:35 +08:00
|
|
|
unsigned MaskWords;
|
|
|
|
unsigned NBuckets;
|
|
|
|
unsigned Shift2;
|
|
|
|
};
|
|
|
|
|
2016-01-15 21:34:52 +08:00
|
|
|
// --eh-frame-hdr option tells linker to construct a header for all the
|
|
|
|
// .eh_frame sections. This header is placed to a section named .eh_frame_hdr
|
|
|
|
// and also to a PT_GNU_EH_FRAME segment.
|
|
|
|
// At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by
|
|
|
|
// calling dl_iterate_phdr.
|
|
|
|
// This section contains a lookup table for quick binary search of FDEs.
|
|
|
|
// Detailed info about internals can be found in Ian Lance Taylor's blog:
|
|
|
|
// http://www.airs.com/blog/archives/460 (".eh_frame")
|
|
|
|
// http://www.airs.com/blog/archives/462 (".eh_frame_hdr")
|
2016-11-10 07:23:45 +08:00
|
|
|
template <class ELFT> class EhFrameHeader final : public OutputSectionBase {
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::uint uintX_t;
|
2016-01-15 21:34:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
EhFrameHeader();
|
2016-05-24 00:30:41 +08:00
|
|
|
void finalize() override;
|
2016-01-15 21:34:52 +08:00
|
|
|
void writeTo(uint8_t *Buf) override;
|
2016-05-23 11:00:33 +08:00
|
|
|
void addFde(uint32_t Pc, uint32_t FdeVA);
|
2016-11-10 07:23:45 +08:00
|
|
|
Kind getKind() const override { return EHFrameHdr; }
|
|
|
|
static bool classof(const OutputSectionBase *B) {
|
|
|
|
return B->getKind() == EHFrameHdr;
|
2016-08-11 02:10:41 +08:00
|
|
|
}
|
2016-01-15 21:34:52 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct FdeData {
|
2016-05-23 11:00:33 +08:00
|
|
|
uint32_t Pc;
|
|
|
|
uint32_t FdeVA;
|
2016-01-15 21:34:52 +08:00
|
|
|
};
|
|
|
|
|
2016-05-23 11:00:33 +08:00
|
|
|
std::vector<FdeData> Fdes;
|
2016-01-15 21:34:52 +08:00
|
|
|
};
|
|
|
|
|
2015-10-08 03:18:16 +08:00
|
|
|
// All output sections that are hadnled by the linker specially are
|
|
|
|
// globally accessible. Writer initializes them, so don't use them
|
|
|
|
// until Writer is initialized.
|
|
|
|
template <class ELFT> struct Out {
|
2016-03-15 07:16:09 +08:00
|
|
|
typedef typename ELFT::uint uintX_t;
|
|
|
|
typedef typename ELFT::Phdr Elf_Phdr;
|
2016-11-02 07:12:51 +08:00
|
|
|
|
|
|
|
static uint8_t First;
|
2016-01-15 21:34:52 +08:00
|
|
|
static EhFrameHeader<ELFT> *EhFrameHdr;
|
2016-05-24 00:24:16 +08:00
|
|
|
static EhOutputSection<ELFT> *EhFrame;
|
2016-10-20 17:19:48 +08:00
|
|
|
static GdbIndexSection<ELFT> *GdbIndex;
|
2015-10-22 16:21:35 +08:00
|
|
|
static GnuHashTableSection<ELFT> *GnuHashTab;
|
2015-10-08 03:18:16 +08:00
|
|
|
static HashTableSection<ELFT> *HashTab;
|
|
|
|
static OutputSection<ELFT> *Bss;
|
2015-11-12 12:39:49 +08:00
|
|
|
static OutputSection<ELFT> *MipsRldMap;
|
2016-11-10 07:23:45 +08:00
|
|
|
static OutputSectionBase *Opd;
|
[ELF2/PPC64] Resolve local-call relocations using the correct function-descriptor values
Under PPC64 ELF v1 ABI, the symbols associated with each function name don't
point directly to the code in the .text section (or similar), but rather to a
function descriptor structure in a special data section named .opd. The
elements in the .opd structure include a pointer to the actual code, and a the
relevant TOC base value. Both of these are themselves set by relocations.
When we have a local call, we need the relevant relocation to refer directly to
the target code, not to the function-descriptor in the .opd section. Only when
we have a .plt stub do we care about the address of the .opd function
descriptor itself.
So we make a few changes here:
1. Always write .opd first, so that its relocated data values are available
for later use when writing the text sections. Record a pointer to the .opd
structure, and its corresponding buffer.
2. When processing a relative branch relocation under ppc64, if the
destination points into the .opd section, read the code pointer out of the
function descriptor structure and use that instead.
This this, I can link, and run, a dynamically-compiled "hello world"
application on big-Endian PPC64/Linux (ELF v1 ABI) using lld.
llvm-svn: 250122
2015-10-13 07:16:53 +08:00
|
|
|
static uint8_t *OpdBuf;
|
2015-10-08 03:18:16 +08:00
|
|
|
static PltSection<ELFT> *Plt;
|
|
|
|
static SymbolTableSection<ELFT> *DynSymTab;
|
|
|
|
static SymbolTableSection<ELFT> *SymTab;
|
2016-06-20 19:55:12 +08:00
|
|
|
static VersionDefinitionSection<ELFT> *VerDef;
|
2016-04-28 04:22:31 +08:00
|
|
|
static VersionTableSection<ELFT> *VerSym;
|
|
|
|
static VersionNeedSection<ELFT> *VerNeed;
|
2015-11-07 06:14:44 +08:00
|
|
|
static Elf_Phdr *TlsPhdr;
|
2016-11-10 07:23:45 +08:00
|
|
|
static OutputSectionBase *DebugInfo;
|
|
|
|
static OutputSectionBase *ElfHeader;
|
|
|
|
static OutputSectionBase *ProgramHeaders;
|
|
|
|
static OutputSectionBase *PreinitArray;
|
|
|
|
static OutputSectionBase *InitArray;
|
|
|
|
static OutputSectionBase *FiniArray;
|
2015-10-08 03:18:16 +08:00
|
|
|
};
|
2015-10-10 03:34:55 +08:00
|
|
|
|
2016-07-12 17:49:43 +08:00
|
|
|
template <bool Is64Bits> struct SectionKey {
|
|
|
|
typedef typename std::conditional<Is64Bits, uint64_t, uint32_t>::type uintX_t;
|
|
|
|
StringRef Name;
|
|
|
|
uint32_t Type;
|
|
|
|
uintX_t Flags;
|
|
|
|
uintX_t Alignment;
|
|
|
|
};
|
|
|
|
|
|
|
|
// This class knows how to create an output section for a given
|
|
|
|
// input section. Output section type is determined by various
|
|
|
|
// factors, including input section's sh_flags, sh_type and
|
|
|
|
// linker scripts.
|
|
|
|
template <class ELFT> class OutputSectionFactory {
|
|
|
|
typedef typename ELFT::Shdr Elf_Shdr;
|
|
|
|
typedef typename ELFT::uint uintX_t;
|
|
|
|
typedef typename elf::SectionKey<ELFT::Is64Bits> Key;
|
|
|
|
|
|
|
|
public:
|
2016-11-10 07:23:45 +08:00
|
|
|
std::pair<OutputSectionBase *, bool> create(InputSectionBase<ELFT> *C,
|
|
|
|
StringRef OutsecName);
|
|
|
|
std::pair<OutputSectionBase *, bool>
|
2016-09-13 22:23:14 +08:00
|
|
|
create(const SectionKey<ELFT::Is64Bits> &Key, InputSectionBase<ELFT> *C);
|
2016-07-12 17:49:43 +08:00
|
|
|
|
|
|
|
private:
|
2016-11-10 07:23:45 +08:00
|
|
|
llvm::SmallDenseMap<Key, OutputSectionBase *> Map;
|
2016-07-12 17:49:43 +08:00
|
|
|
};
|
|
|
|
|
2016-09-23 00:47:21 +08:00
|
|
|
template <class ELFT> uint64_t getHeaderSize() {
|
|
|
|
if (Config->OFormatBinary)
|
|
|
|
return 0;
|
2016-11-09 09:42:41 +08:00
|
|
|
return Out<ELFT>::ElfHeader->Size + Out<ELFT>::ProgramHeaders->Size;
|
2016-09-23 00:47:21 +08:00
|
|
|
}
|
|
|
|
|
2016-11-02 07:12:51 +08:00
|
|
|
template <class ELFT> uint8_t Out<ELFT>::First;
|
2016-01-15 21:34:52 +08:00
|
|
|
template <class ELFT> EhFrameHeader<ELFT> *Out<ELFT>::EhFrameHdr;
|
2016-05-24 00:24:16 +08:00
|
|
|
template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;
|
2016-10-20 17:19:48 +08:00
|
|
|
template <class ELFT> GdbIndexSection<ELFT> *Out<ELFT>::GdbIndex;
|
2015-10-22 16:21:35 +08:00
|
|
|
template <class ELFT> GnuHashTableSection<ELFT> *Out<ELFT>::GnuHashTab;
|
2015-10-10 03:34:55 +08:00
|
|
|
template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab;
|
2015-11-04 06:01:20 +08:00
|
|
|
template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
|
2015-11-12 12:39:49 +08:00
|
|
|
template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;
|
2016-11-10 07:23:45 +08:00
|
|
|
template <class ELFT> OutputSectionBase *Out<ELFT>::Opd;
|
[ELF2/PPC64] Resolve local-call relocations using the correct function-descriptor values
Under PPC64 ELF v1 ABI, the symbols associated with each function name don't
point directly to the code in the .text section (or similar), but rather to a
function descriptor structure in a special data section named .opd. The
elements in the .opd structure include a pointer to the actual code, and a the
relevant TOC base value. Both of these are themselves set by relocations.
When we have a local call, we need the relevant relocation to refer directly to
the target code, not to the function-descriptor in the .opd section. Only when
we have a .plt stub do we care about the address of the .opd function
descriptor itself.
So we make a few changes here:
1. Always write .opd first, so that its relocated data values are available
for later use when writing the text sections. Record a pointer to the .opd
structure, and its corresponding buffer.
2. When processing a relative branch relocation under ppc64, if the
destination points into the .opd section, read the code pointer out of the
function descriptor structure and use that instead.
This this, I can link, and run, a dynamically-compiled "hello world"
application on big-Endian PPC64/Linux (ELF v1 ABI) using lld.
llvm-svn: 250122
2015-10-13 07:16:53 +08:00
|
|
|
template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
|
2015-10-10 03:34:55 +08:00
|
|
|
template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt;
|
|
|
|
template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab;
|
|
|
|
template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab;
|
2016-06-20 19:55:12 +08:00
|
|
|
template <class ELFT> VersionDefinitionSection<ELFT> *Out<ELFT>::VerDef;
|
2016-04-28 04:22:31 +08:00
|
|
|
template <class ELFT> VersionTableSection<ELFT> *Out<ELFT>::VerSym;
|
|
|
|
template <class ELFT> VersionNeedSection<ELFT> *Out<ELFT>::VerNeed;
|
2016-03-15 07:16:09 +08:00
|
|
|
template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;
|
2016-11-10 07:23:45 +08:00
|
|
|
template <class ELFT> OutputSectionBase *Out<ELFT>::DebugInfo;
|
|
|
|
template <class ELFT> OutputSectionBase *Out<ELFT>::ElfHeader;
|
|
|
|
template <class ELFT> OutputSectionBase *Out<ELFT>::ProgramHeaders;
|
|
|
|
template <class ELFT> OutputSectionBase *Out<ELFT>::PreinitArray;
|
|
|
|
template <class ELFT> OutputSectionBase *Out<ELFT>::InitArray;
|
|
|
|
template <class ELFT> OutputSectionBase *Out<ELFT>::FiniArray;
|
2016-02-28 08:25:54 +08:00
|
|
|
} // namespace elf
|
2015-11-04 10:11:57 +08:00
|
|
|
} // namespace lld
|
|
|
|
|
2016-07-12 17:49:43 +08:00
|
|
|
namespace llvm {
|
|
|
|
template <bool Is64Bits> struct DenseMapInfo<lld::elf::SectionKey<Is64Bits>> {
|
|
|
|
typedef typename lld::elf::SectionKey<Is64Bits> Key;
|
|
|
|
|
|
|
|
static Key getEmptyKey();
|
|
|
|
static Key getTombstoneKey();
|
|
|
|
static unsigned getHashValue(const Key &Val);
|
|
|
|
static bool isEqual(const Key &LHS, const Key &RHS);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|