I did this using Perl.
Differential Revision: https://reviews.llvm.org/D60003
llvm-svn: 357372
// FIXME: We could open the file in createFutureForFile and avoid needing to
// return an error here, but for the moment that would cost us a file descriptor
// (a limited resource on Windows) for the duration that the future is pending.
-typedef std::pair<std::unique_ptr<MemoryBuffer>, std::error_code> MBErrPair;
+using MBErrPair = std::pair<std::unique_ptr<MemoryBuffer>, std::error_code>;
// Create a std::future that opens and maps a file using the best strategy for
// the host platform.
using namespace lld;
using namespace lld::coff;
-typedef DenseMap<const SectionChunk *, SmallVector<DefinedRegular *, 4>>
- SymbolMapTy;
+using SymbolMapTy =
+ DenseMap<const SectionChunk *, SmallVector<DefinedRegular *, 4>>;
static const std::string Indent8 = " "; // 8 spaces
static const std::string Indent16 = " "; // 16 spaces
constexpr uint64_t MAX_CLUSTER_SIZE = 1024 * 1024;
} // end anonymous namespace
-typedef std::pair<const InputSectionBase *, const InputSectionBase *>
- SectionPair;
+using SectionPair =
+ std::pair<const InputSectionBase *, const InputSectionBase *>;
// Take the edge list in Config->CallGraphProfile, resolve symbol names to
// Symbols, and generate a graph between InputSections with the provided
template <typename ELFT> class ELFFileBase : public InputFile {
public:
- typedef typename ELFT::Shdr Elf_Shdr;
- typedef typename ELFT::Sym Elf_Sym;
- typedef typename ELFT::Word Elf_Word;
- typedef typename ELFT::SymRange Elf_Sym_Range;
+ using Elf_Shdr = typename ELFT::Shdr;
+ using Elf_Sym = typename ELFT::Sym;
+ using Elf_Word = typename ELFT::Word;
+ using Elf_Sym_Range = typename ELFT::SymRange;
ELFFileBase(Kind K, MemoryBufferRef M);
static bool classof(const InputFile *F) { return F->isElf(); }
// .o file.
template <class ELFT> class ObjFile : public ELFFileBase<ELFT> {
- typedef ELFFileBase<ELFT> Base;
- typedef typename ELFT::Rel Elf_Rel;
- typedef typename ELFT::Rela Elf_Rela;
- typedef typename ELFT::Sym Elf_Sym;
- typedef typename ELFT::Shdr Elf_Shdr;
- typedef typename ELFT::Word Elf_Word;
- typedef typename ELFT::CGProfile Elf_CGProfile;
+ using Base = ELFFileBase<ELFT>;
+ using Elf_Rel = typename ELFT::Rel;
+ using Elf_Rela = typename ELFT::Rela;
+ using Elf_Sym = typename ELFT::Sym;
+ using Elf_Shdr = typename ELFT::Shdr;
+ using Elf_Word = typename ELFT::Word;
+ using Elf_CGProfile = typename ELFT::CGProfile;
StringRef getShtGroupSignature(ArrayRef<Elf_Shdr> Sections,
const Elf_Shdr &Sec);
// .so file.
template <class ELFT> class SharedFile : public ELFFileBase<ELFT> {
- typedef ELFFileBase<ELFT> Base;
- typedef typename ELFT::Dyn Elf_Dyn;
- typedef typename ELFT::Shdr Elf_Shdr;
- typedef typename ELFT::Sym Elf_Sym;
- typedef typename ELFT::SymRange Elf_Sym_Range;
- typedef typename ELFT::Verdef Elf_Verdef;
- typedef typename ELFT::Versym Elf_Versym;
+ using Base = ELFFileBase<ELFT>;
+ using Elf_Dyn = typename ELFT::Dyn;
+ using Elf_Shdr = typename ELFT::Shdr;
+ using Elf_Sym = typename ELFT::Sym;
+ using Elf_Sym_Range = typename ELFT::SymRange;
+ using Elf_Verdef = typename ELFT::Verdef;
+ using Elf_Versym = typename ELFT::Versym;
const Elf_Shdr *VersymSec = nullptr;
const Elf_Shdr *VerdefSec = nullptr;
// by zlib-compressed data. This function parses a header to initialize
// `UncompressedSize` member and remove the header from `RawData`.
void InputSectionBase::parseCompressedHeader() {
- typedef typename ELF64LE::Chdr Chdr64;
- typedef typename ELF32LE::Chdr Chdr32;
+ using Chdr64 = typename ELF64LE::Chdr;
+ using Chdr32 = typename ELF32LE::Chdr;
// Old-style header
if (Name.startswith(".zdebug")) {
// Copy SHT_GROUP section contents. Used only for the -r option.
template <class ELFT> void InputSection::copyShtGroup(uint8_t *Buf) {
// ELFT::Word is the 32-bit integral type in the target endianness.
- typedef typename ELFT::Word u32;
+ using u32 = typename ELFT::Word;
ArrayRef<u32> From = getDataAs<u32>();
auto *To = reinterpret_cast<u32 *>(Buf);
// This represents an expression in the linker script.
// ScriptParser::readExpr reads an expression and returns an Expr.
// Later, we evaluate the expression by calling the function.
-typedef std::function<ExprValue()> Expr;
+using Expr = std::function<ExprValue()>;
// This enum is used to implement linker script SECTIONS command.
// https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS
using namespace lld;
using namespace lld::elf;
-typedef DenseMap<const SectionBase *, SmallVector<Defined *, 4>> SymbolMapTy;
+using SymbolMapTy = DenseMap<const SectionBase *, SmallVector<Defined *, 4>>;
static const std::string Indent8 = " "; // 8 spaces
static const std::string Indent16 = " "; // 16 spaces
static void sortByOrder(MutableArrayRef<InputSection *> In,
llvm::function_ref<int(InputSectionBase *S)> Order) {
- typedef std::pair<int, InputSection *> Pair;
+ using Pair = std::pair<int, InputSection *>;
auto Comp = [](const Pair &A, const Pair &B) { return A.first < B.first; };
std::vector<Pair> V;
// Compress section contents if this section contains debug info.
template <class ELFT> void OutputSection::maybeCompress() {
- typedef typename ELFT::Chdr Elf_Chdr;
+ using Elf_Chdr = typename ELFT::Chdr;
// Compress only DWARF debug sections.
if (!Config->CompressDebugSections || (Flags & SHF_ALLOC) ||
// Returns true if a given shared symbol is in a read-only segment in a DSO.
template <class ELFT> static bool isReadOnly(SharedSymbol &SS) {
- typedef typename ELFT::Phdr Elf_Phdr;
+ using Elf_Phdr = typename ELFT::Phdr;
// Determine if the symbol is read-only by scanning the DSO's program headers.
const SharedFile<ELFT> &File = SS.getFile<ELFT>();
// Otherwise, they would refer to different places at runtime.
template <class ELFT>
static SmallSet<SharedSymbol *, 4> getSymbolsAt(SharedSymbol &SS) {
- typedef typename ELFT::Sym Elf_Sym;
+ using Elf_Sym = typename ELFT::Sym;
SharedFile<ELFT> &File = SS.getFile<ELFT>();
class SectionBase;
// Represents a relocation type, such as R_X86_64_PC32 or R_ARM_THM_CALL.
-typedef uint32_t RelType;
+using RelType = uint32_t;
// List of target-independent relocation types. Relocations read
// from files are converted to these types so that the main code
static std::vector<GdbIndexSection::GdbSymbol>
createSymbols(ArrayRef<std::vector<GdbIndexSection::NameAttrEntry>> NameAttrs,
const std::vector<GdbIndexSection::GdbChunk> &Chunks) {
- typedef GdbIndexSection::GdbSymbol GdbSymbol;
- typedef GdbIndexSection::NameAttrEntry NameAttrEntry;
+ using GdbSymbol = GdbIndexSection::GdbSymbol;
+ using NameAttrEntry = GdbIndexSection::NameAttrEntry;
// For each chunk, compute the number of compilation units preceding it.
uint32_t CuIdx = 0;
// It is sorted by PC.
void EhFrameHeader::write() {
uint8_t *Buf = Out::BufferStart + getParent()->Offset + OutSecOff;
- typedef EhFrameSection::FdeData FdeData;
+ using FdeData = EhFrameSection::FdeData;
std::vector<FdeData> Fdes = In.EhFrame->getFdeData();
uint64_t Size = 0;
// Symbol and addend.
- typedef std::pair<Symbol *, int64_t> GotEntry;
+ using GotEntry = std::pair<Symbol *, int64_t>;
struct FileGot {
InputFile *File = nullptr;
};
template <class ELFT> class DynamicSection final : public SyntheticSection {
- typedef typename ELFT::Dyn Elf_Dyn;
- typedef typename ELFT::Rel Elf_Rel;
- typedef typename ELFT::Rela Elf_Rela;
- typedef typename ELFT::Relr Elf_Relr;
- typedef typename ELFT::Shdr Elf_Shdr;
- typedef typename ELFT::Sym Elf_Sym;
+ using Elf_Dyn = typename ELFT::Dyn;
+ using Elf_Rel = typename ELFT::Rel;
+ using Elf_Rela = typename ELFT::Rela;
+ using Elf_Relr = typename ELFT::Relr;
+ using Elf_Shdr = typename ELFT::Shdr;
+ using Elf_Sym = typename ELFT::Sym;
// finalizeContents() fills this vector with the section contents.
std::vector<std::pair<int32_t, std::function<uint64_t()>>> Entries;
template <class ELFT>
class RelocationSection final : public RelocationBaseSection {
- typedef typename ELFT::Rel Elf_Rel;
- typedef typename ELFT::Rela Elf_Rela;
+ using Elf_Rel = typename ELFT::Rel;
+ using Elf_Rela = typename ELFT::Rela;
public:
RelocationSection(StringRef Name, bool Sort);
template <class ELFT>
class AndroidPackedRelocationSection final : public RelocationBaseSection {
- typedef typename ELFT::Rel Elf_Rel;
- typedef typename ELFT::Rela Elf_Rela;
+ using Elf_Rel = typename ELFT::Rel;
+ using Elf_Rela = typename ELFT::Rela;
public:
AndroidPackedRelocationSection(StringRef Name);
// https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg
// For more details, see the comment in RelrSection::updateAllocSize().
template <class ELFT> class RelrSection final : public RelrBaseSection {
- typedef typename ELFT::Relr Elf_Relr;
+ using Elf_Relr = typename ELFT::Relr;
public:
RelrSection();
template <class ELFT>
class SymbolTableSection final : public SymbolTableBaseSection {
- typedef typename ELFT::Sym Elf_Sym;
+ using Elf_Sym = typename ELFT::Sym;
public:
SymbolTableSection(StringTableSection &StrTabSec);
// mapping from version identifiers to version names.
template <class ELFT>
class VersionNeedSection final : public VersionNeedBaseSection {
- typedef typename ELFT::Verneed Elf_Verneed;
- typedef typename ELFT::Vernaux Elf_Vernaux;
+ using Elf_Verneed = typename ELFT::Verneed;
+ using Elf_Vernaux = typename ELFT::Vernaux;
// A vector of shared files that need Elf_Verneed data structures and the
// string table offsets of their sonames.
// .MIPS.abiflags section.
template <class ELFT>
class MipsAbiFlagsSection final : public SyntheticSection {
- typedef llvm::object::Elf_Mips_ABIFlags<ELFT> Elf_Mips_ABIFlags;
+ using Elf_Mips_ABIFlags = llvm::object::Elf_Mips_ABIFlags<ELFT>;
public:
static MipsAbiFlagsSection *create();
// .MIPS.options section.
template <class ELFT> class MipsOptionsSection final : public SyntheticSection {
- typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
- typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
+ using Elf_Mips_Options = llvm::object::Elf_Mips_Options<ELFT>;
+ using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo<ELFT>;
public:
static MipsOptionsSection *create();
// MIPS .reginfo section.
template <class ELFT> class MipsReginfoSection final : public SyntheticSection {
- typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
+ using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo<ELFT>;
public:
static MipsReginfoSection *create();
template <class ELFT> class Writer {
public:
Writer() : Buffer(errorHandler().OutputBuffer) {}
- typedef typename ELFT::Shdr Elf_Shdr;
- typedef typename ELFT::Ehdr Elf_Ehdr;
- typedef typename ELFT::Phdr Elf_Phdr;
+ using Elf_Shdr = typename ELFT::Shdr;
+ using Elf_Ehdr = typename ELFT::Ehdr;
+ using Elf_Phdr = typename ELFT::Phdr;
void run();