[lld] r344842 - Add an addAbsolute static function to Writer.cpp
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 20 04:12:51 PDT 2018
Author: arichardson
Date: Sat Oct 20 04:12:50 2018
New Revision: 344842
URL: http://llvm.org/viewvc/llvm-project?rev=344842&view=rev
Log:
Add an addAbsolute static function to Writer.cpp
Summary:
SymbolTable::addAbsolute() was removed in rL344305.
To me this is more readable than the lambda named `Add` and in our
out-of-tree CHERI target we use addAbsolute() in another function.
Reviewers: ruiu, espindola
Reviewed By: ruiu
Subscribers: kristina, emaste, llvm-commits
Differential Revision: https://reviews.llvm.org/D53393
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=344842&r1=344841&r2=344842&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Oct 20 04:12:50 2018
@@ -176,33 +176,33 @@ static Defined *addOptionalRegular(Strin
return cast<Defined>(Sym);
}
+static Defined *addAbsolute(StringRef Name) {
+ return cast<Defined>(Symtab->addDefined(Name, STV_HIDDEN, STT_NOTYPE, 0, 0,
+ STB_GLOBAL, nullptr, nullptr));
+};
+
// The linker is expected to define some symbols depending on
// the linking result. This function defines such symbols.
void elf::addReservedSymbols() {
if (Config->EMachine == EM_MIPS) {
- auto Add = [](StringRef Name) {
- return cast<Defined>(Symtab->addDefined(Name, STV_HIDDEN, STT_NOTYPE, 0,
- 0, STB_GLOBAL, nullptr, nullptr));
- };
-
// Define _gp for MIPS. st_value of _gp symbol will be updated by Writer
// so that it points to an absolute address which by default is relative
// to GOT. Default offset is 0x7ff0.
// See "Global Data Symbols" in Chapter 6 in the following document:
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
- ElfSym::MipsGp = Add("_gp");
+ ElfSym::MipsGp = addAbsolute("_gp");
// On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between
// start of function and 'gp' pointer into GOT.
if (Symtab->find("_gp_disp"))
- ElfSym::MipsGpDisp = Add("_gp_disp");
+ ElfSym::MipsGpDisp = addAbsolute("_gp_disp");
// The __gnu_local_gp is a magic symbol equal to the current value of 'gp'
// pointer. This symbol is used in the code generated by .cpload pseudo-op
// in case of using -mno-shared option.
// https://sourceware.org/ml/binutils/2004-12/msg00094.html
if (Symtab->find("__gnu_local_gp"))
- ElfSym::MipsLocalGp = Add("__gnu_local_gp");
+ ElfSym::MipsLocalGp = addAbsolute("__gnu_local_gp");
}
// The Power Architecture 64-bit v2 ABI defines a TableOfContents (TOC) which
More information about the llvm-commits
mailing list