authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-10 13:10:12-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-10 13:10:12-04:00
log016a59e3a155894412ccf3d98fe6ac1054243d06
treebb71096f2dad14d3389dca10d48302cc55700792
parent185cb1327806f073b91218ff2fd6f21d95060c00
signaturelock-open Commit is signed but in an unrecognized format.

update embedded LLD to 9.0.0rc4


33 files changed, 555 insertions(+), 190 deletions(-)

deps/lld/CMakeLists.txt-1
...@@ -56,7 +56,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)...@@ -56,7 +56,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
56 include(HandleLLVMOptions)56 include(HandleLLVMOptions)
5757
58 if(LLVM_INCLUDE_TESTS)58 if(LLVM_INCLUDE_TESTS)
59 set(Python_ADDITIONAL_VERSIONS 2.7)
60 include(FindPythonInterp)59 include(FindPythonInterp)
61 if(NOT PYTHONINTERP_FOUND)60 if(NOT PYTHONINTERP_FOUND)
62 message(FATAL_ERROR61 message(FATAL_ERROR
deps/lld/COFF/Config.h+1
...@@ -189,6 +189,7 @@ struct Configuration {...@@ -189,6 +189,7 @@ struct Configuration {
189 // Used for /thinlto-object-suffix-replace:189 // Used for /thinlto-object-suffix-replace:
190 std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace;190 std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace;
191191
192 uint64_t align = 4096;
192 uint64_t imageBase = -1;193 uint64_t imageBase = -1;
193 uint64_t fileAlign = 512;194 uint64_t fileAlign = 512;
194 uint64_t stackReserve = 1024 * 1024;195 uint64_t stackReserve = 1024 * 1024;
deps/lld/COFF/Driver.cpp+32-8
...@@ -36,6 +36,7 @@...@@ -36,6 +36,7 @@
36#include "llvm/Option/Option.h"36#include "llvm/Option/Option.h"
37#include "llvm/Support/Debug.h"37#include "llvm/Support/Debug.h"
38#include "llvm/Support/LEB128.h"38#include "llvm/Support/LEB128.h"
39#include "llvm/Support/MathExtras.h"
39#include "llvm/Support/Path.h"40#include "llvm/Support/Path.h"
40#include "llvm/Support/Process.h"41#include "llvm/Support/Process.h"
41#include "llvm/Support/TarWriter.h"42#include "llvm/Support/TarWriter.h"
...@@ -270,13 +271,12 @@ void LinkerDriver::addArchiveBuffer(MemoryBufferRef mb, StringRef symName,...@@ -270,13 +271,12 @@ void LinkerDriver::addArchiveBuffer(MemoryBufferRef mb, StringRef symName,
270}271}
271272
272void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,273void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
273 StringRef symName,274 const Archive::Symbol &sym,
274 StringRef parentName) {275 StringRef parentName) {
275276
276 auto reportBufferError = [=](Error &&e,277 auto reportBufferError = [=](Error &&e, StringRef childName) {
277 StringRef childName) {
278 fatal("could not get the buffer for the member defining symbol " +278 fatal("could not get the buffer for the member defining symbol " +
279 symName + ": " + parentName + "(" + childName + "): " +279 toCOFFString(sym) + ": " + parentName + "(" + childName + "): " +
280 toString(std::move(e)));280 toString(std::move(e)));
281 };281 };
282282
...@@ -287,7 +287,8 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,...@@ -287,7 +287,8 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
287 reportBufferError(mbOrErr.takeError(), check(c.getFullName()));287 reportBufferError(mbOrErr.takeError(), check(c.getFullName()));
288 MemoryBufferRef mb = mbOrErr.get();288 MemoryBufferRef mb = mbOrErr.get();
289 enqueueTask([=]() {289 enqueueTask([=]() {
290 driver->addArchiveBuffer(mb, symName, parentName, offsetInArchive);290 driver->addArchiveBuffer(mb, toCOFFString(sym), parentName,
291 offsetInArchive);
291 });292 });
292 return;293 return;
293 }294 }
...@@ -295,15 +296,16 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,...@@ -295,15 +296,16 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
295 std::string childName = CHECK(296 std::string childName = CHECK(
296 c.getFullName(),297 c.getFullName(),
297 "could not get the filename for the member defining symbol " +298 "could not get the filename for the member defining symbol " +
298 symName);299 toCOFFString(sym));
299 auto future = std::make_shared<std::future<MBErrPair>>(300 auto future = std::make_shared<std::future<MBErrPair>>(
300 createFutureForFile(childName));301 createFutureForFile(childName));
301 enqueueTask([=]() {302 enqueueTask([=]() {
302 auto mbOrErr = future->get();303 auto mbOrErr = future->get();
303 if (mbOrErr.second)304 if (mbOrErr.second)
304 reportBufferError(errorCodeToError(mbOrErr.second), childName);305 reportBufferError(errorCodeToError(mbOrErr.second), childName);
305 driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)), symName,306 driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)),
306 parentName, /* OffsetInArchive */ 0);307 toCOFFString(sym), parentName,
308 /*OffsetInArchive=*/0);
307 });309 });
308}310}
309311
...@@ -1053,6 +1055,12 @@ void LinkerDriver::maybeExportMinGWSymbols(const opt::InputArgList &args) {...@@ -1053,6 +1055,12 @@ void LinkerDriver::maybeExportMinGWSymbols(const opt::InputArgList &args) {
1053 });1055 });
1054}1056}
10551057
1058static const char *libcallRoutineNames[] = {
1059#define HANDLE_LIBCALL(code, name) name,
1060#include "llvm/IR/RuntimeLibcalls.def"
1061#undef HANDLE_LIBCALL
1062};
1063
1056void LinkerDriver::link(ArrayRef<const char *> argsArr) {1064void LinkerDriver::link(ArrayRef<const char *> argsArr) {
1057 // Needed for LTO.1065 // Needed for LTO.
1058 InitializeAllTargetInfos();1066 InitializeAllTargetInfos();
...@@ -1421,6 +1429,13 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {...@@ -1421,6 +1429,13 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
1421 for (auto *arg : args.filtered(OPT_section))1429 for (auto *arg : args.filtered(OPT_section))
1422 parseSection(arg->getValue());1430 parseSection(arg->getValue());
14231431
1432 // Handle /align
1433 if (auto *arg = args.getLastArg(OPT_align)) {
1434 parseNumbers(arg->getValue(), &config->align);
1435 if (!isPowerOf2_64(config->align))
1436 error("/align: not a power of two: " + StringRef(arg->getValue()));
1437 }
1438
1424 // Handle /aligncomm1439 // Handle /aligncomm
1425 for (auto *arg : args.filtered(OPT_aligncomm))1440 for (auto *arg : args.filtered(OPT_aligncomm))
1426 parseAligncomm(arg->getValue());1441 parseAligncomm(arg->getValue());
...@@ -1748,6 +1763,15 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {...@@ -1748,6 +1763,15 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
1748 u->weakAlias = symtab->addUndefined(to);1763 u->weakAlias = symtab->addUndefined(to);
1749 }1764 }
17501765
1766 // If any inputs are bitcode files, the LTO code generator may create
1767 // references to library functions that are not explicit in the bitcode
1768 // file's symbol table. If any of those library functions are defined in a
1769 // bitcode file in an archive member, we need to arrange to use LTO to
1770 // compile those archive members by adding them to the link beforehand.
1771 if (!BitcodeFile::instances.empty())
1772 for (const char *s : libcallRoutineNames)
1773 symtab->addLibcall(s);
1774
1751 // Windows specific -- if __load_config_used can be resolved, resolve it.1775 // Windows specific -- if __load_config_used can be resolved, resolve it.
1752 if (symtab->findUnderscore("_load_config_used"))1776 if (symtab->findUnderscore("_load_config_used"))
1753 addUndefined(mangle("_load_config_used"));1777 addUndefined(mangle("_load_config_used"));
deps/lld/COFF/Driver.h+1-1
...@@ -72,7 +72,7 @@ public:...@@ -72,7 +72,7 @@ public:
72 void parseDirectives(InputFile *file);72 void parseDirectives(InputFile *file);
7373
74 // Used by ArchiveFile to enqueue members.74 // Used by ArchiveFile to enqueue members.
75 void enqueueArchiveMember(const Archive::Child &c, StringRef symName,75 void enqueueArchiveMember(const Archive::Child &c, const Archive::Symbol &sym,
76 StringRef parentName);76 StringRef parentName);
7777
78 MemoryBufferRef takeBuffer(std::unique_ptr<MemoryBuffer> mb);78 MemoryBufferRef takeBuffer(std::unique_ptr<MemoryBuffer> mb);
deps/lld/COFF/InputFiles.cpp+4-4
...@@ -85,16 +85,16 @@ void ArchiveFile::parse() {...@@ -85,16 +85,16 @@ void ArchiveFile::parse() {
85}85}
8686
87// Returns a buffer pointing to a member file containing a given symbol.87// Returns a buffer pointing to a member file containing a given symbol.
88void ArchiveFile::addMember(const Archive::Symbol *sym) {88void ArchiveFile::addMember(const Archive::Symbol &sym) {
89 const Archive::Child &c =89 const Archive::Child &c =
90 CHECK(sym->getMember(),90 CHECK(sym.getMember(),
91 "could not get the member for symbol " + sym->getName());91 "could not get the member for symbol " + toCOFFString(sym));
9292
93 // Return an empty buffer if we have already returned the same buffer.93 // Return an empty buffer if we have already returned the same buffer.
94 if (!seen.insert(c.getChildOffset()).second)94 if (!seen.insert(c.getChildOffset()).second)
95 return;95 return;
9696
97 driver->enqueueArchiveMember(c, sym->getName(), getName());97 driver->enqueueArchiveMember(c, sym, getName());
98}98}
9999
100std::vector<MemoryBufferRef> getArchiveMembers(Archive *file) {100std::vector<MemoryBufferRef> getArchiveMembers(Archive *file) {
deps/lld/COFF/InputFiles.h+1-1
...@@ -96,7 +96,7 @@ public:...@@ -96,7 +96,7 @@ public:
96 // Enqueues an archive member load for the given symbol. If we've already96 // Enqueues an archive member load for the given symbol. If we've already
97 // enqueued a load for the same archive member, this function does nothing,97 // enqueued a load for the same archive member, this function does nothing,
98 // which ensures that we don't load the same member more than once.98 // which ensures that we don't load the same member more than once.
99 void addMember(const Archive::Symbol *sym);99 void addMember(const Archive::Symbol &sym);
100100
101private:101private:
102 std::unique_ptr<Archive> file;102 std::unique_ptr<Archive> file;
deps/lld/COFF/SymbolTable.cpp+16-4
...@@ -179,7 +179,7 @@ void SymbolTable::loadMinGWAutomaticImports() {...@@ -179,7 +179,7 @@ void SymbolTable::loadMinGWAutomaticImports() {
179 log("Loading lazy " + l->getName() + " from " + l->file->getName() +179 log("Loading lazy " + l->getName() + " from " + l->file->getName() +
180 " for automatic import");180 " for automatic import");
181 l->pendingArchiveLoad = true;181 l->pendingArchiveLoad = true;
182 l->file->addMember(&l->sym);182 l->file->addMember(l->sym);
183 }183 }
184}184}
185185
...@@ -363,13 +363,13 @@ Symbol *SymbolTable::addUndefined(StringRef name, InputFile *f,...@@ -363,13 +363,13 @@ Symbol *SymbolTable::addUndefined(StringRef name, InputFile *f,
363 if (auto *l = dyn_cast<Lazy>(s)) {363 if (auto *l = dyn_cast<Lazy>(s)) {
364 if (!s->pendingArchiveLoad) {364 if (!s->pendingArchiveLoad) {
365 s->pendingArchiveLoad = true;365 s->pendingArchiveLoad = true;
366 l->file->addMember(&l->sym);366 l->file->addMember(l->sym);
367 }367 }
368 }368 }
369 return s;369 return s;
370}370}
371371
372void SymbolTable::addLazy(ArchiveFile *f, const Archive::Symbol sym) {372void SymbolTable::addLazy(ArchiveFile *f, const Archive::Symbol &sym) {
373 StringRef name = sym.getName();373 StringRef name = sym.getName();
374 Symbol *s;374 Symbol *s;
375 bool wasInserted;375 bool wasInserted;
...@@ -382,7 +382,7 @@ void SymbolTable::addLazy(ArchiveFile *f, const Archive::Symbol sym) {...@@ -382,7 +382,7 @@ void SymbolTable::addLazy(ArchiveFile *f, const Archive::Symbol sym) {
382 if (!u || u->weakAlias || s->pendingArchiveLoad)382 if (!u || u->weakAlias || s->pendingArchiveLoad)
383 return;383 return;
384 s->pendingArchiveLoad = true;384 s->pendingArchiveLoad = true;
385 f->addMember(&sym);385 f->addMember(sym);
386}386}
387387
388void SymbolTable::reportDuplicate(Symbol *existing, InputFile *newFile) {388void SymbolTable::reportDuplicate(Symbol *existing, InputFile *newFile) {
...@@ -505,6 +505,18 @@ Symbol *SymbolTable::addImportThunk(StringRef name, DefinedImportData *id,...@@ -505,6 +505,18 @@ Symbol *SymbolTable::addImportThunk(StringRef name, DefinedImportData *id,
505 return nullptr;505 return nullptr;
506}506}
507507
508void SymbolTable::addLibcall(StringRef name) {
509 Symbol *sym = findUnderscore(name);
510 if (!sym)
511 return;
512
513 if (Lazy *l = dyn_cast<Lazy>(sym)) {
514 MemoryBufferRef mb = l->getMemberBuffer();
515 if (identify_magic(mb.getBuffer()) == llvm::file_magic::bitcode)
516 addUndefined(sym->getName());
517 }
518}
519
508std::vector<Chunk *> SymbolTable::getChunks() {520std::vector<Chunk *> SymbolTable::getChunks() {
509 std::vector<Chunk *> res;521 std::vector<Chunk *> res;
510 for (ObjFile *file : ObjFile::instances) {522 for (ObjFile *file : ObjFile::instances) {
deps/lld/COFF/SymbolTable.h+2-1
...@@ -83,7 +83,7 @@ public:...@@ -83,7 +83,7 @@ public:
83 Symbol *addAbsolute(StringRef n, uint64_t va);83 Symbol *addAbsolute(StringRef n, uint64_t va);
8484
85 Symbol *addUndefined(StringRef name, InputFile *f, bool isWeakAlias);85 Symbol *addUndefined(StringRef name, InputFile *f, bool isWeakAlias);
86 void addLazy(ArchiveFile *f, const Archive::Symbol sym);86 void addLazy(ArchiveFile *f, const Archive::Symbol &sym);
87 Symbol *addAbsolute(StringRef n, COFFSymbolRef s);87 Symbol *addAbsolute(StringRef n, COFFSymbolRef s);
88 Symbol *addRegular(InputFile *f, StringRef n,88 Symbol *addRegular(InputFile *f, StringRef n,
89 const llvm::object::coff_symbol_generic *s = nullptr,89 const llvm::object::coff_symbol_generic *s = nullptr,
...@@ -97,6 +97,7 @@ public:...@@ -97,6 +97,7 @@ public:
97 Symbol *addImportData(StringRef n, ImportFile *f);97 Symbol *addImportData(StringRef n, ImportFile *f);
98 Symbol *addImportThunk(StringRef name, DefinedImportData *s,98 Symbol *addImportThunk(StringRef name, DefinedImportData *s,
99 uint16_t machine);99 uint16_t machine);
100 void addLibcall(StringRef name);
100101
101 void reportDuplicate(Symbol *existing, InputFile *newFile);102 void reportDuplicate(Symbol *existing, InputFile *newFile);
102103
deps/lld/COFF/Symbols.cpp+18-4
...@@ -20,18 +20,23 @@ using namespace llvm::object;...@@ -20,18 +20,23 @@ using namespace llvm::object;
2020
21using namespace lld::coff;21using namespace lld::coff;
2222
23namespace lld {
24
23static_assert(sizeof(SymbolUnion) <= 48,25static_assert(sizeof(SymbolUnion) <= 48,
24 "symbols should be optimized for memory usage");26 "symbols should be optimized for memory usage");
2527
26// Returns a symbol name for an error message.28// Returns a symbol name for an error message.
27std::string lld::toString(coff::Symbol &b) {29static std::string demangle(StringRef symName) {
28 if (config->demangle)30 if (config->demangle)
29 if (Optional<std::string> s = lld::demangleMSVC(b.getName()))31 if (Optional<std::string> s = demangleMSVC(symName))
30 return *s;32 return *s;
31 return b.getName();33 return symName;
34}
35std::string toString(coff::Symbol &b) { return demangle(b.getName()); }
36std::string toCOFFString(const Archive::Symbol &b) {
37 return demangle(b.getName());
32}38}
3339
34namespace lld {
35namespace coff {40namespace coff {
3641
37StringRef Symbol::getName() {42StringRef Symbol::getName() {
...@@ -113,5 +118,14 @@ Defined *Undefined::getWeakAlias() {...@@ -113,5 +118,14 @@ Defined *Undefined::getWeakAlias() {
113 return d;118 return d;
114 return nullptr;119 return nullptr;
115}120}
121
122MemoryBufferRef Lazy::getMemberBuffer() {
123 Archive::Child c =
124 CHECK(sym.getMember(),
125 "could not get the member for symbol " + toCOFFString(sym));
126 return CHECK(c.getMemoryBufferRef(),
127 "could not get the buffer for the member defining symbol " +
128 toCOFFString(sym));
129}
116} // namespace coff130} // namespace coff
117} // namespace lld131} // namespace lld
deps/lld/COFF/Symbols.h+10-1
...@@ -21,6 +21,14 @@...@@ -21,6 +21,14 @@
21#include <vector>21#include <vector>
2222
23namespace lld {23namespace lld {
24
25std::string toString(coff::Symbol &b);
26
27// There are two different ways to convert an Archive::Symbol to a string:
28// One for Microsoft name mangling and one for Itanium name mangling.
29// Call the functions toCOFFString and toELFString, not just toString.
30std::string toCOFFString(const coff::Archive::Symbol &b);
31
24namespace coff {32namespace coff {
2533
26using llvm::object::Archive;34using llvm::object::Archive;
...@@ -257,6 +265,8 @@ public:...@@ -257,6 +265,8 @@ public:
257265
258 static bool classof(const Symbol *s) { return s->kind() == LazyKind; }266 static bool classof(const Symbol *s) { return s->kind() == LazyKind; }
259267
268 MemoryBufferRef getMemberBuffer();
269
260 ArchiveFile *file;270 ArchiveFile *file;
261271
262private:272private:
...@@ -429,7 +439,6 @@ void replaceSymbol(Symbol *s, ArgT &&... arg) {...@@ -429,7 +439,6 @@ void replaceSymbol(Symbol *s, ArgT &&... arg) {
429}439}
430} // namespace coff440} // namespace coff
431441
432std::string toString(coff::Symbol &b);
433} // namespace lld442} // namespace lld
434443
435#endif444#endif
deps/lld/COFF/Writer.cpp+9-4
...@@ -626,6 +626,9 @@ void Writer::run() {...@@ -626,6 +626,9 @@ void Writer::run() {
626626
627 writeMapFile(outputSections);627 writeMapFile(outputSections);
628628
629 if (errorCount())
630 return;
631
629 ScopedTimer t2(diskCommitTimer);632 ScopedTimer t2(diskCommitTimer);
630 if (auto e = buffer->commit())633 if (auto e = buffer->commit())
631 fatal("failed to write the output file: " + toString(std::move(e)));634 fatal("failed to write the output file: " + toString(std::move(e)));
...@@ -1205,9 +1208,11 @@ void Writer::assignAddresses() {...@@ -1205,9 +1208,11 @@ void Writer::assignAddresses() {
1205 sizeOfHeaders +=1208 sizeOfHeaders +=
1206 config->is64() ? sizeof(pe32plus_header) : sizeof(pe32_header);1209 config->is64() ? sizeof(pe32plus_header) : sizeof(pe32_header);
1207 sizeOfHeaders = alignTo(sizeOfHeaders, config->fileAlign);1210 sizeOfHeaders = alignTo(sizeOfHeaders, config->fileAlign);
1208 uint64_t rva = pageSize; // The first page is kept unmapped.
1209 fileSize = sizeOfHeaders;1211 fileSize = sizeOfHeaders;
12101212
1213 // The first page is kept unmapped.
1214 uint64_t rva = alignTo(sizeOfHeaders, config->align);
1215
1211 for (OutputSection *sec : outputSections) {1216 for (OutputSection *sec : outputSections) {
1212 if (sec == relocSec)1217 if (sec == relocSec)
1213 addBaserels();1218 addBaserels();
...@@ -1237,10 +1242,10 @@ void Writer::assignAddresses() {...@@ -1237,10 +1242,10 @@ void Writer::assignAddresses() {
1237 sec->header.SizeOfRawData = rawSize;1242 sec->header.SizeOfRawData = rawSize;
1238 if (rawSize != 0)1243 if (rawSize != 0)
1239 sec->header.PointerToRawData = fileSize;1244 sec->header.PointerToRawData = fileSize;
1240 rva += alignTo(virtualSize, pageSize);1245 rva += alignTo(virtualSize, config->align);
1241 fileSize += alignTo(rawSize, config->fileAlign);1246 fileSize += alignTo(rawSize, config->fileAlign);
1242 }1247 }
1243 sizeOfImage = alignTo(rva, pageSize);1248 sizeOfImage = alignTo(rva, config->align);
12441249
1245 // Assign addresses to sections in MergeChunks.1250 // Assign addresses to sections in MergeChunks.
1246 for (MergeChunk *mc : MergeChunk::instances)1251 for (MergeChunk *mc : MergeChunk::instances)
...@@ -1309,7 +1314,7 @@ template <typename PEHeaderTy> void Writer::writeHeader() {...@@ -1309,7 +1314,7 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
1309 pe->MinorLinkerVersion = 0;1314 pe->MinorLinkerVersion = 0;
13101315
1311 pe->ImageBase = config->imageBase;1316 pe->ImageBase = config->imageBase;
1312 pe->SectionAlignment = pageSize;1317 pe->SectionAlignment = config->align;
1313 pe->FileAlignment = config->fileAlign;1318 pe->FileAlignment = config->fileAlign;
1314 pe->MajorImageVersion = config->majorImageVersion;1319 pe->MajorImageVersion = config->majorImageVersion;
1315 pe->MinorImageVersion = config->minorImageVersion;1320 pe->MinorImageVersion = config->minorImageVersion;
deps/lld/ELF/Arch/PPC.cpp+11-2
...@@ -190,6 +190,13 @@ bool PPC::inBranchRange(RelType type, uint64_t src, uint64_t dst) const {...@@ -190,6 +190,13 @@ bool PPC::inBranchRange(RelType type, uint64_t src, uint64_t dst) const {
190RelExpr PPC::getRelExpr(RelType type, const Symbol &s,190RelExpr PPC::getRelExpr(RelType type, const Symbol &s,
191 const uint8_t *loc) const {191 const uint8_t *loc) const {
192 switch (type) {192 switch (type) {
193 case R_PPC_NONE:
194 return R_NONE;
195 case R_PPC_ADDR16_HA:
196 case R_PPC_ADDR16_HI:
197 case R_PPC_ADDR16_LO:
198 case R_PPC_ADDR32:
199 return R_ABS;
193 case R_PPC_DTPREL16:200 case R_PPC_DTPREL16:
194 case R_PPC_DTPREL16_HA:201 case R_PPC_DTPREL16_HA:
195 case R_PPC_DTPREL16_HI:202 case R_PPC_DTPREL16_HI:
...@@ -227,7 +234,9 @@ RelExpr PPC::getRelExpr(RelType type, const Symbol &s,...@@ -227,7 +234,9 @@ RelExpr PPC::getRelExpr(RelType type, const Symbol &s,
227 case R_PPC_TPREL16_HI:234 case R_PPC_TPREL16_HI:
228 return R_TLS;235 return R_TLS;
229 default:236 default:
230 return R_ABS;237 error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) +
238 ") against symbol " + toString(s));
239 return R_NONE;
231 }240 }
232}241}
233242
...@@ -319,7 +328,7 @@ void PPC::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {...@@ -319,7 +328,7 @@ void PPC::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {
319 break;328 break;
320 }329 }
321 default:330 default:
322 error(getErrorLocation(loc) + "unrecognized relocation " + toString(type));331 llvm_unreachable("unknown relocation");
323 }332 }
324}333}
325334
deps/lld/ELF/Arch/PPC64.cpp+20-2
...@@ -532,6 +532,21 @@ void PPC64::relaxTlsIeToLe(uint8_t *loc, RelType type, uint64_t val) const {...@@ -532,6 +532,21 @@ void PPC64::relaxTlsIeToLe(uint8_t *loc, RelType type, uint64_t val) const {
532RelExpr PPC64::getRelExpr(RelType type, const Symbol &s,532RelExpr PPC64::getRelExpr(RelType type, const Symbol &s,
533 const uint8_t *loc) const {533 const uint8_t *loc) const {
534 switch (type) {534 switch (type) {
535 case R_PPC64_NONE:
536 return R_NONE;
537 case R_PPC64_ADDR16:
538 case R_PPC64_ADDR16_DS:
539 case R_PPC64_ADDR16_HA:
540 case R_PPC64_ADDR16_HI:
541 case R_PPC64_ADDR16_HIGHER:
542 case R_PPC64_ADDR16_HIGHERA:
543 case R_PPC64_ADDR16_HIGHEST:
544 case R_PPC64_ADDR16_HIGHESTA:
545 case R_PPC64_ADDR16_LO:
546 case R_PPC64_ADDR16_LO_DS:
547 case R_PPC64_ADDR32:
548 case R_PPC64_ADDR64:
549 return R_ABS;
535 case R_PPC64_GOT16:550 case R_PPC64_GOT16:
536 case R_PPC64_GOT16_DS:551 case R_PPC64_GOT16_DS:
537 case R_PPC64_GOT16_HA:552 case R_PPC64_GOT16_HA:
...@@ -554,6 +569,7 @@ RelExpr PPC64::getRelExpr(RelType type, const Symbol &s,...@@ -554,6 +569,7 @@ RelExpr PPC64::getRelExpr(RelType type, const Symbol &s,
554 return R_PPC64_CALL_PLT;569 return R_PPC64_CALL_PLT;
555 case R_PPC64_REL16_LO:570 case R_PPC64_REL16_LO:
556 case R_PPC64_REL16_HA:571 case R_PPC64_REL16_HA:
572 case R_PPC64_REL16_HI:
557 case R_PPC64_REL32:573 case R_PPC64_REL32:
558 case R_PPC64_REL64:574 case R_PPC64_REL64:
559 return R_PC;575 return R_PC;
...@@ -607,7 +623,9 @@ RelExpr PPC64::getRelExpr(RelType type, const Symbol &s,...@@ -607,7 +623,9 @@ RelExpr PPC64::getRelExpr(RelType type, const Symbol &s,
607 case R_PPC64_TLS:623 case R_PPC64_TLS:
608 return R_TLSIE_HINT;624 return R_TLSIE_HINT;
609 default:625 default:
610 return R_ABS;626 error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) +
627 ") against symbol " + toString(s));
628 return R_NONE;
611 }629 }
612}630}
613631
...@@ -870,7 +888,7 @@ void PPC64::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {...@@ -870,7 +888,7 @@ void PPC64::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {
870 write64(loc, val - dynamicThreadPointerOffset);888 write64(loc, val - dynamicThreadPointerOffset);
871 break;889 break;
872 default:890 default:
873 error(getErrorLocation(loc) + "unrecognized relocation " + toString(type));891 llvm_unreachable("unknown relocation");
874 }892 }
875}893}
876894
deps/lld/ELF/InputFiles.cpp+2-2
...@@ -1144,7 +1144,7 @@ void ArchiveFile::fetch(const Archive::Symbol &sym) {...@@ -1144,7 +1144,7 @@ void ArchiveFile::fetch(const Archive::Symbol &sym) {
1144 Archive::Child c =1144 Archive::Child c =
1145 CHECK(sym.getMember(), toString(this) +1145 CHECK(sym.getMember(), toString(this) +
1146 ": could not get the member for symbol " +1146 ": could not get the member for symbol " +
1147 sym.getName());1147 toELFString(sym));
11481148
1149 if (!seen.insert(c.getChildOffset()).second)1149 if (!seen.insert(c.getChildOffset()).second)
1150 return;1150 return;
...@@ -1153,7 +1153,7 @@ void ArchiveFile::fetch(const Archive::Symbol &sym) {...@@ -1153,7 +1153,7 @@ void ArchiveFile::fetch(const Archive::Symbol &sym) {
1153 CHECK(c.getMemoryBufferRef(),1153 CHECK(c.getMemoryBufferRef(),
1154 toString(this) +1154 toString(this) +
1155 ": could not get the buffer for the member defining symbol " +1155 ": could not get the buffer for the member defining symbol " +
1156 sym.getName());1156 toELFString(sym));
11571157
1158 if (tar && c.getParent()->isThin())1158 if (tar && c.getParent()->isThin())
1159 tar->append(relativeToRoot(CHECK(c.getFullName(), this)), mb.getBuffer());1159 tar->append(relativeToRoot(CHECK(c.getFullName(), this)), mb.getBuffer());
deps/lld/ELF/Symbols.cpp+18-11
...@@ -42,6 +42,20 @@ Defined *ElfSym::relaIpltEnd;...@@ -42,6 +42,20 @@ Defined *ElfSym::relaIpltEnd;
42Defined *ElfSym::riscvGlobalPointer;42Defined *ElfSym::riscvGlobalPointer;
43Defined *ElfSym::tlsModuleBase;43Defined *ElfSym::tlsModuleBase;
4444
45// Returns a symbol for an error message.
46static std::string demangle(StringRef symName) {
47 if (config->demangle)
48 if (Optional<std::string> s = demangleItanium(symName))
49 return *s;
50 return symName;
51}
52namespace lld {
53std::string toString(const Symbol &b) { return demangle(b.getName()); }
54std::string toELFString(const Archive::Symbol &b) {
55 return demangle(b.getName());
56}
57} // namespace lld
58
45static uint64_t getSymVA(const Symbol &sym, int64_t &addend) {59static uint64_t getSymVA(const Symbol &sym, int64_t &addend) {
46 switch (sym.kind()) {60 switch (sym.kind()) {
47 case Symbol::DefinedKind: {61 case Symbol::DefinedKind: {
...@@ -250,12 +264,13 @@ void Symbol::fetch() const {...@@ -250,12 +264,13 @@ void Symbol::fetch() const {
250}264}
251265
252MemoryBufferRef LazyArchive::getMemberBuffer() {266MemoryBufferRef LazyArchive::getMemberBuffer() {
253 Archive::Child c = CHECK(267 Archive::Child c =
254 sym.getMember(), "could not get the member for symbol " + sym.getName());268 CHECK(sym.getMember(),
269 "could not get the member for symbol " + toELFString(sym));
255270
256 return CHECK(c.getMemoryBufferRef(),271 return CHECK(c.getMemoryBufferRef(),
257 "could not get the buffer for the member defining symbol " +272 "could not get the buffer for the member defining symbol " +
258 sym.getName());273 toELFString(sym));
259}274}
260275
261uint8_t Symbol::computeBinding() const {276uint8_t Symbol::computeBinding() const {
...@@ -331,14 +346,6 @@ void elf::maybeWarnUnorderableSymbol(const Symbol *sym) {...@@ -331,14 +346,6 @@ void elf::maybeWarnUnorderableSymbol(const Symbol *sym) {
331 report(": unable to order discarded symbol: ");346 report(": unable to order discarded symbol: ");
332}347}
333348
334// Returns a symbol for an error message.
335std::string lld::toString(const Symbol &b) {
336 if (config->demangle)
337 if (Optional<std::string> s = demangleItanium(b.getName()))
338 return *s;
339 return b.getName();
340}
341
342static uint8_t getMinVisibility(uint8_t va, uint8_t vb) {349static uint8_t getMinVisibility(uint8_t va, uint8_t vb) {
343 if (va == STV_DEFAULT)350 if (va == STV_DEFAULT)
344 return vb;351 return vb;
deps/lld/ELF/Symbols.h+5-1
...@@ -33,7 +33,11 @@ class Undefined;...@@ -33,7 +33,11 @@ class Undefined;
33} // namespace elf33} // namespace elf
3434
35std::string toString(const elf::Symbol &);35std::string toString(const elf::Symbol &);
36std::string toString(const elf::InputFile *);36
37// There are two different ways to convert an Archive::Symbol to a string:
38// One for Microsoft name mangling and one for Itanium name mangling.
39// Call the functions toCOFFString and toELFString, not just toString.
40std::string toELFString(const elf::Archive::Symbol &);
3741
38namespace elf {42namespace elf {
3943
deps/lld/ELF/Writer.cpp+14-12
...@@ -2230,25 +2230,27 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {...@@ -2230,25 +2230,27 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
2230// same with its virtual address modulo the page size, so that the loader can2230// same with its virtual address modulo the page size, so that the loader can
2231// load executables without any address adjustment.2231// load executables without any address adjustment.
2232static uint64_t computeFileOffset(OutputSection *os, uint64_t off) {2232static uint64_t computeFileOffset(OutputSection *os, uint64_t off) {
2233 // File offsets are not significant for .bss sections. By convention, we keep
2234 // section offsets monotonically increasing rather than setting to zero.
2235 if (os->type == SHT_NOBITS)
2236 return off;
2237
2238 // If the section is not in a PT_LOAD, we just have to align it.
2239 if (!os->ptLoad)
2240 return alignTo(off, os->alignment);
2241
2242 // The first section in a PT_LOAD has to have congruent offset and address2233 // The first section in a PT_LOAD has to have congruent offset and address
2243 // module the page size.2234 // module the page size.
2244 OutputSection *first = os->ptLoad->firstSec;2235 if (os->ptLoad && os->ptLoad->firstSec == os) {
2245 if (os == first) {2236 uint64_t alignment =
2246 uint64_t alignment = std::max<uint64_t>(os->alignment, config->maxPageSize);2237 std::max<uint64_t>(os->ptLoad->p_align, config->maxPageSize);
2247 return alignTo(off, alignment, os->addr);2238 return alignTo(off, alignment, os->addr);
2248 }2239 }
22492240
2241 // File offsets are not significant for .bss sections other than the first one
2242 // in a PT_LOAD. By convention, we keep section offsets monotonically
2243 // increasing rather than setting to zero.
2244 if (os->type == SHT_NOBITS)
2245 return off;
2246
2247 // If the section is not in a PT_LOAD, we just have to align it.
2248 if (!os->ptLoad)
2249 return alignTo(off, os->alignment);
2250
2250 // If two sections share the same PT_LOAD the file offset is calculated2251 // If two sections share the same PT_LOAD the file offset is calculated
2251 // using this formula: Off2 = Off1 + (VA2 - VA1).2252 // using this formula: Off2 = Off1 + (VA2 - VA1).
2253 OutputSection *first = os->ptLoad->firstSec;
2252 return first->offset + os->addr - first->addr;2254 return first->offset + os->addr - first->addr;
2253}2255}
22542256
deps/lld/docs/ReleaseNotes.rst+165-35
...@@ -5,18 +5,15 @@ lld 9.0.0 Release Notes...@@ -5,18 +5,15 @@ lld 9.0.0 Release Notes
5.. contents::5.. contents::
6 :local:6 :local:
77
8.. warning::
9 These are in-progress notes for the upcoming LLVM 9.0.0 release.
10 Release notes for previous releases can be found on
11 `the Download Page <https://releases.llvm.org/download.html>`_.
12
13Introduction8Introduction
14============9============
1510
16This document contains the release notes for the lld linker, release 9.0.0.11lld is a high-performance linker that supports ELF (Unix), COFF
17Here we describe the status of lld, including major improvements12(Windows), Mach-O (macOS), MinGW and WebAssembly. lld is
18from the previous release. All lld releases may be downloaded13command-line-compatible with GNU linkers and Microsoft link.exe and is
19from the `LLVM releases web site <https://llvm.org/releases/>`_.14significantly faster than the system default linkers.
15
16lld 9 has lots of feature improvements and bug fixes.
2017
21Non-comprehensive list of changes in this release18Non-comprehensive list of changes in this release
22=================================================19=================================================
...@@ -27,50 +24,187 @@ ELF Improvements...@@ -27,50 +24,187 @@ ELF Improvements
27* ld.lld now has typo suggestions for flags:24* ld.lld now has typo suggestions for flags:
28 ``$ ld.lld --call-shared`` now prints25 ``$ ld.lld --call-shared`` now prints
29 ``unknown argument '--call-shared', did you mean '--call_shared'``.26 ``unknown argument '--call-shared', did you mean '--call_shared'``.
27 (`r361518 <https://reviews.llvm.org/rL361518>`_)
28
29* ``--allow-shlib-undefined`` and ``--no-allow-shlib-undefined``
30 options are added. ``--no-allow-shlib-undefined`` is the default for
31 executables.
32 (`r352826 <https://reviews.llvm.org/rL352826>`_)
33
34* ``-nmagic`` and ``-omagic`` options are fully supported.
35 (`r360593 <https://reviews.llvm.org/rL360593>`_)
36
37* Segment layout has changed. PT_GNU_RELRO, which was previously
38 placed in the middle of readable/writable PT_LOAD segments, is now
39 placed at the beginning of them. This change permits lld-produced
40 ELF files to be read correctly by GNU strip older than 2.31, which
41 has a bug to discard a PT_GNU_RELRO in the former layout.
42
43* ``-z common-page-size`` is supported.
44 (`r360593 <https://reviews.llvm.org/rL360593>`_)
45
46* Diagnostics messages have improved. A new flag ``--vs-diagnostics``
47 alters the format of diagnostic output to enable source hyperlinks
48 in Microsoft Visual Studio IDE.
49
50* Linker script compatibility with GNU BFD linker has generally improved.
51
52* The clang ``--dependent-library`` form of autolinking is supported.
53
54 This feature is added to implement the Windows-style autolinking for
55 Unix. On Unix, in order to use a library, you usually have to
56 include a header file provided by the library and then explicitly
57 link the library with the linker ``-l`` option. On Windows, header
58 files usually contain pragmas that list needed libraries. Compilers
59 copy that information to object files, so that linkers can
60 automatically link needed libraries. ``--dependent-library`` is
61 added for implementing that Windows semantics on Unix.
62 (`r360984 <https://reviews.llvm.org/rL360984>`_)
63
64* AArch64 BTI and PAC are supported.
65 (`r362793 <https://reviews.llvm.org/rL362793>`_)
3066
31* lld now supports replacing ``JAL`` with ``JALX`` instructions in case67* lld now supports replacing ``JAL`` with ``JALX`` instructions in case
32 of MIPS - microMIPS cross-mode jumps.68 of MIPS-microMIPS cross-mode jumps.
69 (`r354311 <https://reviews.llvm.org/rL354311>`_)
3370
34* lld now creates LA25 thunks for MIPS R6 code.71* lld now creates LA25 thunks for MIPS R6 code.
72 (`r354312 <https://reviews.llvm.org/rL354312>`_)
3573
36* Put MIPS-specific .reginfo, .MIPS.options, and .MIPS.abiflags sections74* Put MIPS-specific .reginfo, .MIPS.options, and .MIPS.abiflags sections
37 into corresponding PT_MIPS_REGINFO, PT_MIPS_OPTIONS, and PT_MIPS_ABIFLAGS75 into corresponding PT_MIPS_REGINFO, PT_MIPS_OPTIONS, and PT_MIPS_ABIFLAGS
38 segments.76 segments.
3977
40* ...78* The quality of RISC-V and PowerPC ports have greatly improved. Many
79 applications can now be linked by lld. PowerPC64 is now almost
80 production ready.
81
82* The Linux kernel for arm32_7, arm64, ppc64le and x86_64 can now be
83 linked by lld.
84
85* x86-64 TLSDESC is supported.
86 (`r361911 <https://reviews.llvm.org/rL361911>`_,
87 `r362078 <https://reviews.llvm.org/rL362078>`_)
88
89* DF_STATIC_TLS flag is set for i386 and x86-64 when needed.
90 (`r353293 <https://reviews.llvm.org/rL353293>`_,
91 `r353378 <https://reviews.llvm.org/rL353378>`_)
92
93* The experimental partitioning feature is added to allow a program to
94 be split into multiple pieces.
95
96 The feature allows you to semi-automatically split a single program
97 into multiple ELF files called "partitions". Since all partitions
98 share the same memory address space and don't use PLT/GOT, split
99 programs run as fast as regular programs.
100
101 With the mechanism, you can start a program only with a "main"
102 partition and load remaining partitions on-demand. For example, you
103 can split a web browser into a main partition and a PDF reader
104 sub-partition and load the PDF reader partition only when a user
105 tries to open a PDF file.
106
107 See `the documentation <Partitions.html>`_ for more information.
108
109* If "-" is given as an output filename, lld writes the final result
110 to the standard output. Previously, it created a file "-" in the
111 current directory.
112 (`r351852 <https://reviews.llvm.org/rL351852>`_)
113
114* ``-z ifunc-noplt`` option is added to reduce IFunc function call
115 overhead in a freestanding environment such as the OS kernel.
116
117 Functions resolved by the IFunc mechanism are usually dispatched via
118 PLT and thus slower than regular functions because of the cost of
119 indirection. With ``-z ifunc-noplt``, you can eliminate it by doing
120 text relocations at load-time. You need a special loader to utilize
121 this feature. This feature is added for the FreeBSD kernel but can
122 be used by any operating systems.
123 (`r360685 <https://reviews.llvm.org/rL360685>`_)
124
125* ``--undefined-glob`` option is added. The new option is an extension
126 to ``--undefined`` to take a glob pattern instead of a single symbol
127 name.
128 (`r363396 <https://reviews.llvm.org/rL363396>`_)
129
41130
42COFF Improvements131COFF Improvements
43-----------------132-----------------
44133
45* Like the ELF driver, lld-link now has typo suggestions for flags.134* Like the ELF driver, lld-link now has typo suggestions for flags.
135 (`r361518 <https://reviews.llvm.org/rL361518>`_)
46136
47* lld-link now correctly reports duplicate symbol errors for obj files137* lld-link now correctly reports duplicate symbol errors for object
48 that were compiled with /Gy.138 files that were compiled with ``/Gy``.
139 (`r352590 <https://reviews.llvm.org/rL352590>`_)
49140
50* lld-link now correctly reports duplicate symbol errors when several res141* lld-link now correctly reports duplicate symbol errors when several
51 input files define resources with the same type, name, and language.142 resource (.res) input files define resources with the same type,
52 This can be demoted to a warning using ``/force:multipleres``.143 name and language. This can be demoted to a warning using
144 ``/force:multipleres``.
145 (`r359829 <https://reviews.llvm.org/rL359829>`_)
146
147* lld-link now rejects more than one resource object input files,
148 matching link.exe. Previously, lld-link would silently ignore all
149 but one. If you hit this: Don't pass resource object files to the
150 linker, instead pass res files to the linker directly. Don't put
151 resource files in static libraries, pass them on the command line.
152 (`r359749 <https://reviews.llvm.org/rL359749>`_)
53153
54* Having more than two ``/natvis:`` now works correctly; it used to not154* Having more than two ``/natvis:`` now works correctly; it used to not
55 work for larger binaries before.155 work for larger binaries before.
156 (`r327895 <https://reviews.llvm.org/rL327895>`_)
56157
57* Undefined symbols are now printed only in demangled form. Pass158* Undefined symbols are now printed only in demangled form. Pass
58 ``/demangle:no`` to see raw symbol names instead.159 ``/demangle:no`` to see raw symbol names instead.
59160 (`r355878 <https://reviews.llvm.org/rL355878>`_)
60* The following flags have been added: ``/functionpadmin``, ``/swaprun:``,
61 ``/threads:no``
62161
63* Several speed and memory usage improvements.162* Several speed and memory usage improvements.
64163
65* Range extension thunks are now created for ARM64, if needed
66
67* lld-link now supports resource object files created by GNU windres and164* lld-link now supports resource object files created by GNU windres and
68 MS cvtres, not only llvm-cvtres165 MS cvtres, not only llvm-cvtres.
69166
70* The generated thunks for delayimports now share the majority of code167* The generated thunks for delayimports now share the majority of code
71 among thunks, significantly reducing the overhead of using delayimport168 among thunks, significantly reducing the overhead of using delayimport.
169 (`r365823 <https://reviews.llvm.org/rL365823>`_)
170
171* ``IMAGE_REL_ARM{,64}_REL32`` relocations are supported.
172 (`r352325 <https://reviews.llvm.org/rL352325>`_)
173
174* Range extension thunks for AArch64 are now supported, so lld can
175 create large executables for Windows/ARM64.
176 (`r352929 <https://reviews.llvm.org/rL352929>`_)
177
178* The following flags have been added:
179 ``/functionpadmin`` (`r354716 <https://reviews.llvm.org/rL354716>`_),
180 ``/swaprun:`` (`r359192 <https://reviews.llvm.org/rL359192>`_),
181 ``/threads:no`` (`r355029 <https://reviews.llvm.org/rL355029>`_),
182 ``/filealign`` (`r361634 <https://reviews.llvm.org/rL361634>`_)
183
184WebAssembly Improvements
185------------------------
186
187* Imports from custom module names are supported.
188 (`r352828 <https://reviews.llvm.org/rL352828>`_)
189
190* Symbols that are in llvm.used are now exported by default.
191 (`r353364 <https://reviews.llvm.org/rL353364>`_)
192
193* Initial support for PIC and dynamic linking has landed.
194 (`r357022 <https://reviews.llvm.org/rL357022>`_)
195
196* wasm-ld now add ``__start_``/``__stop_`` symbols for data sections.
197 (`r361236 <https://reviews.llvm.org/rL361236>`_)
198
199* wasm-ld now doesn't report an error on archives without a symbol index.
200 (`r364338 <https://reviews.llvm.org/rL364338>`_)
201
202* The following flags have been added:
203 ``--emit-relocs`` (`r361635 <https://reviews.llvm.org/rL361635>`_),
204 ``--wrap`` (`r361639 <https://reviews.llvm.org/rL361639>`_),
205 ``--trace`` and ``--trace-symbol``
206 (`r353264 <https://reviews.llvm.org/rL353264>`_).
72207
73* ...
74208
75MinGW Improvements209MinGW Improvements
76------------------210------------------
...@@ -80,22 +214,18 @@ MinGW Improvements...@@ -80,22 +214,18 @@ MinGW Improvements
80 DWARF exception handling with libgcc and gcc's crtend.o.214 DWARF exception handling with libgcc and gcc's crtend.o.
81215
82* lld now also handles DWARF unwind info generated by GCC, when linking216* lld now also handles DWARF unwind info generated by GCC, when linking
83 with libgcc217 with libgcc.
84
85* Many more GNU ld options are now supported, which e.g. allows the lld
86 MinGW frontend to be called by GCC
87218
88* PDB output can be requested without manually specifying the PDB file219* PDB output can be requested without manually specifying the PDB file
89 name, with the new option ``-pdb=`` with an empty value to the option.220 name, with the new option ``-pdb=`` with an empty value to the option.
90 (The old existing syntax ``-pdb <filename>`` was more cumbersome to use221 (The old existing syntax ``-pdb <filename>`` was more cumbersome to use
91 with an empty parameter value.)222 with an empty parameter value.)
92223
93MachO Improvements224* ``--no-insert-timestamp`` option is added as an alias to ``/timestamp:0``.
94------------------225 (`r353145 <https://reviews.llvm.org/rL353145>`_)
95
96* Item 1.
97226
98WebAssembly Improvements227* Many more GNU ld options are now supported, which e.g. allows the lld
99------------------------228 MinGW frontend to be called by GCC.
100229
101* ...230* The following options are added: ``--exclude-all-symbols``,
231 ``--appcontainer``, ``--undefined``
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp+1
...@@ -621,6 +621,7 @@ void ArchHandler_x86_64::applyFixupFinal(...@@ -621,6 +621,7 @@ void ArchHandler_x86_64::applyFixupFinal(
621 // Fall into llvm_unreachable().621 // Fall into llvm_unreachable().
622 break;622 break;
623 }623 }
624 llvm_unreachable("invalid x86_64 Reference Kind");
624}625}
625626
626void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,627void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,
deps/lld/test/COFF/Inputs/libcall-archive.ll created+6
...@@ -0,0 +1,6 @@
1target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
2target triple = "i686-unknown-windows"
3
4define void @memcpy() {
5 ret void
6}
deps/lld/test/COFF/Inputs/libcall-archive.s created+2
...@@ -0,0 +1,2 @@
1.globl ___sync_val_compare_and_swap_8
2___sync_val_compare_and_swap_8:
deps/lld/test/COFF/align.s created+45
...@@ -0,0 +1,45 @@
1# RUN: yaml2obj < %s > %t.obj
2# RUN: lld-link /out:%t.exe /entry:main /align:32 %t.obj
3# RUN: llvm-readobj --file-headers %t.exe | FileCheck %s
4
5# CHECK: SectionAlignment: 32
6
7--- !COFF
8header:
9 Machine: IMAGE_FILE_MACHINE_AMD64
10 Characteristics: []
11sections:
12 - Name: .text
13 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
14 Alignment: 4096
15 SectionData: 0000000000000000
16 Relocations:
17 - VirtualAddress: 0
18 SymbolName: __ImageBase
19 Type: IMAGE_REL_AMD64_ADDR64
20symbols:
21 - Name: .text
22 Value: 0
23 SectionNumber: 1
24 SimpleType: IMAGE_SYM_TYPE_NULL
25 ComplexType: IMAGE_SYM_DTYPE_NULL
26 StorageClass: IMAGE_SYM_CLASS_STATIC
27 SectionDefinition:
28 Length: 8
29 NumberOfRelocations: 1
30 NumberOfLinenumbers: 0
31 CheckSum: 0
32 Number: 0
33 - Name: main
34 Value: 0
35 SectionNumber: 1
36 SimpleType: IMAGE_SYM_TYPE_NULL
37 ComplexType: IMAGE_SYM_DTYPE_NULL
38 StorageClass: IMAGE_SYM_CLASS_EXTERNAL
39 - Name: __ImageBase
40 Value: 0
41 SectionNumber: 0
42 SimpleType: IMAGE_SYM_TYPE_NULL
43 ComplexType: IMAGE_SYM_DTYPE_NULL
44 StorageClass: IMAGE_SYM_CLASS_EXTERNAL
45...
deps/lld/test/COFF/libcall-archive.ll created+22
...@@ -0,0 +1,22 @@
1; REQUIRES: x86
2; RUN: rm -f %t.a
3; RUN: llvm-as -o %t.obj %s
4; RUN: llvm-as -o %t2.obj %S/Inputs/libcall-archive.ll
5; RUN: llvm-mc -filetype=obj -triple=i686-unknown-windows -o %t3.obj %S/Inputs/libcall-archive.s
6; RUN: llvm-ar rcs %t.a %t2.obj %t3.obj
7; RUN: lld-link -out:%t.exe -subsystem:console -entry:start -safeseh:no -lldmap:- %t.obj %t.a | FileCheck %s
8
9; CHECK-NOT: ___sync_val_compare_and_swap_8
10; CHECK: _start
11; CHECK: _memcpy
12
13target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
14target triple = "i686-unknown-windows"
15
16define void @start(i8* %a, i8* %b) {
17entry:
18 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* %b, i64 1024, i1 false)
19 ret void
20}
21
22declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1)
deps/lld/test/COFF/multiple-resource-objs.test+2
...@@ -1,7 +1,9 @@...@@ -1,7 +1,9 @@
1# RUN: llvm-cvtres /out:%t_resource.obj %S/Inputs/resource.res1# RUN: llvm-cvtres /out:%t_resource.obj %S/Inputs/resource.res
2# RUN: llvm-cvtres /out:%t_id.obj %S/Inputs/id.res2# RUN: llvm-cvtres /out:%t_id.obj %S/Inputs/id.res
3# RUN: rm -f %t.exe
3# RUN: not lld-link /out:%t.exe /dll /noentry %t_id.obj %t_resource.obj 2>&1 | \4# RUN: not lld-link /out:%t.exe /dll /noentry %t_id.obj %t_resource.obj 2>&1 | \
4# RUN: FileCheck --check-prefix=TWOOBJ %s5# RUN: FileCheck --check-prefix=TWOOBJ %s
6# RUN: not test -f %t.exe
57
6TWOOBJ: error: {{.*}}_resource.obj: more than one resource obj file not allowed, already got {{.*}}_id.obj8TWOOBJ: error: {{.*}}_resource.obj: more than one resource obj file not allowed, already got {{.*}}_id.obj
79
deps/lld/test/COFF/thin-archive.s+6-2
...@@ -11,14 +11,18 @@...@@ -11,14 +11,18 @@
11# RUN: FileCheck --allow-empty %s11# RUN: FileCheck --allow-empty %s
12# RUN: lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe 2>&1 | \12# RUN: lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe 2>&1 | \
13# RUN: FileCheck --allow-empty %s13# RUN: FileCheck --allow-empty %s
14# RUN: lld-link /entry:main %t.main.obj /wholearchive:%t_thin.lib /out:%t.exe 2>&1 | \
15# RUN: FileCheck --allow-empty %s
1614
17# RUN: rm %t.lib.obj15# RUN: rm %t.lib.obj
18# RUN: lld-link /entry:main %t.main.obj %t.lib /out:%t.exe 2>&1 | \16# RUN: lld-link /entry:main %t.main.obj %t.lib /out:%t.exe 2>&1 | \
19# RUN: FileCheck --allow-empty %s17# RUN: FileCheck --allow-empty %s
18# RUN: not lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe 2>&1 | \
19# RUN: FileCheck --check-prefix=NOOBJ %s
20# RUN: not lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe \
21# RUN: /demangle:no 2>&1 | FileCheck --check-prefix=NOOBJNODEMANGLE %s
2022
21# CHECK-NOT: error: could not get the buffer for the member defining23# CHECK-NOT: error: could not get the buffer for the member defining
24# NOOBJ: error: could not get the buffer for the member defining symbol int __cdecl f(void): {{.*}}.lib({{.*}}.lib.obj):
25# NOOBJNODEMANGLE: error: could not get the buffer for the member defining symbol ?f@@YAHXZ: {{.*}}.lib({{.*}}.lib.obj):
2226
23 .text27 .text
2428
deps/lld/test/ELF/archive-thin-missing-member.s+8-6
...@@ -8,17 +8,19 @@...@@ -8,17 +8,19 @@
8# RUN: rm %t.o8# RUN: rm %t.o
99
10# Test error when loading symbols from missing thin archive member.10# Test error when loading symbols from missing thin archive member.
11# RUN: not ld.lld %t-no-syms.a -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR111# RUN: not ld.lld --entry=_Z1fi %t-no-syms.a -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR1
12# ERR1: {{.*}}-no-syms.a: could not get the buffer for a child of the archive: '{{.*}}.o': {{[Nn]}}o such file or directory12# ERR1: {{.*}}-no-syms.a: could not get the buffer for a child of the archive: '{{.*}}.o': {{[Nn]}}o such file or directory
1313
14# Test error when thin archive has symbol table but member is missing.14# Test error when thin archive has symbol table but member is missing.
15# RUN: not ld.lld -m elf_amd64_fbsd %t-syms.a -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR215# RUN: not ld.lld --entry=_Z1fi -m elf_amd64_fbsd %t-syms.a -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2
16# ERR2: {{.*}}-syms.a: could not get the buffer for the member defining symbol _start: '{{.*}}.o': {{[Nn]}}o such file or directory16# ERR2: {{.*}}-syms.a: could not get the buffer for the member defining symbol f(int): '{{.*}}.o': {{[Nn]}}o such file or directory
17# RUN: not ld.lld --entry=_Z1fi --no-demangle -m elf_amd64_fbsd %t-syms.a -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2MANGLE
18# ERR2MANGLE: {{.*}}-syms.a: could not get the buffer for the member defining symbol _Z1fi: '{{.*}}.o': {{[Nn]}}o such file or directory
1719
18# Test error when thin archive is linked using --whole-archive but member is missing.20# Test error when thin archive is linked using --whole-archive but member is missing.
19# RUN: not ld.lld --whole-archive %t-syms.a -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR321# RUN: not ld.lld --entry=_Z1fi --whole-archive %t-syms.a -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR3
20# ERR3: {{.*}}-syms.a: could not get the buffer for a child of the archive: '{{.*}}.o': {{[Nn]}}o such file or directory22# ERR3: {{.*}}-syms.a: could not get the buffer for a child of the archive: '{{.*}}.o': {{[Nn]}}o such file or directory
2123
22.global _start24.global _Z1fi
23_start:25_Z1fi:
24 nop26 nop
deps/lld/test/ELF/basic-ppc64.s+6-6
...@@ -35,7 +35,7 @@...@@ -35,7 +35,7 @@
35// CHECK-NEXT: Version: 135// CHECK-NEXT: Version: 1
36// CHECK-NEXT: Entry: 0x1000036// CHECK-NEXT: Entry: 0x10000
37// CHECK-NEXT: ProgramHeaderOffset: 0x4037// CHECK-NEXT: ProgramHeaderOffset: 0x40
38// CHECK-NEXT: SectionHeaderOffset: 0x200F838// CHECK-NEXT: SectionHeaderOffset: 0x30098
39// CHECK-NEXT: Flags [ (0x2)39// CHECK-NEXT: Flags [ (0x2)
40// CHECK-NEXT: 0x240// CHECK-NEXT: 0x2
41// CHECK-NEXT: ]41// CHECK-NEXT: ]
...@@ -178,7 +178,7 @@...@@ -178,7 +178,7 @@
178// CHECK-NEXT: SHF_WRITE (0x1)178// CHECK-NEXT: SHF_WRITE (0x1)
179// CHECK-NEXT: ]179// CHECK-NEXT: ]
180// CHECK-NEXT: Address: 0x30000180// CHECK-NEXT: Address: 0x30000
181// CHECK-NEXT: Offset: 0x20060181// CHECK-NEXT: Offset: 0x30000
182// CHECK-NEXT: Size: 0182// CHECK-NEXT: Size: 0
183// CHECK-NEXT: Link: 0183// CHECK-NEXT: Link: 0
184// CHECK-NEXT: Info: 0184// CHECK-NEXT: Info: 0
...@@ -194,7 +194,7 @@...@@ -194,7 +194,7 @@
194// CHECK-NEXT: SHF_STRINGS (0x20)194// CHECK-NEXT: SHF_STRINGS (0x20)
195// CHECK-NEXT: ]195// CHECK-NEXT: ]
196// CHECK-NEXT: Address: 0x0196// CHECK-NEXT: Address: 0x0
197// CHECK-NEXT: Offset: 0x20060197// CHECK-NEXT: Offset: 0x30000
198// CHECK-NEXT: Size: 8198// CHECK-NEXT: Size: 8
199// CHECK-NEXT: Link: 0199// CHECK-NEXT: Link: 0
200// CHECK-NEXT: Info: 0200// CHECK-NEXT: Info: 0
...@@ -211,7 +211,7 @@...@@ -211,7 +211,7 @@
211// CHECK-NEXT: Flags [ (0x0)211// CHECK-NEXT: Flags [ (0x0)
212// CHECK-NEXT: ]212// CHECK-NEXT: ]
213// CHECK-NEXT: Address: 0x0213// CHECK-NEXT: Address: 0x0
214// CHECK-NEXT: Offset: 0x20068214// CHECK-NEXT: Offset: 0x30008
215// CHECK-NEXT: Size: 48215// CHECK-NEXT: Size: 48
216// CHECK-NEXT: Link: 10216// CHECK-NEXT: Link: 10
217// CHECK-NEXT: Info: 2217// CHECK-NEXT: Info: 2
...@@ -233,7 +233,7 @@...@@ -233,7 +233,7 @@
233// CHECK-NEXT: Flags [ (0x0)233// CHECK-NEXT: Flags [ (0x0)
234// CHECK-NEXT: ]234// CHECK-NEXT: ]
235// CHECK-NEXT: Address: 0x0235// CHECK-NEXT: Address: 0x0
236// CHECK-NEXT: Offset: 0x20098236// CHECK-NEXT: Offset: 0x30038
237// CHECK-NEXT: Size: 84237// CHECK-NEXT: Size: 84
238// CHECK-NEXT: Link: 0238// CHECK-NEXT: Link: 0
239// CHECK-NEXT: Info: 0239// CHECK-NEXT: Info: 0
...@@ -255,7 +255,7 @@...@@ -255,7 +255,7 @@
255// CHECK-NEXT: Flags [ (0x0)255// CHECK-NEXT: Flags [ (0x0)
256// CHECK-NEXT: ]256// CHECK-NEXT: ]
257// CHECK-NEXT: Address: 0x0257// CHECK-NEXT: Address: 0x0
258// CHECK-NEXT: Offset: 0x200EC258// CHECK-NEXT: Offset: 0x3008C
259// CHECK-NEXT: Size: 10259// CHECK-NEXT: Size: 10
260// CHECK-NEXT: Link: 0260// CHECK-NEXT: Link: 0
261// CHECK-NEXT: Info: 0261// CHECK-NEXT: Info: 0
deps/lld/test/ELF/linkerscript/nobits-offset.s+16-9
...@@ -2,17 +2,24 @@...@@ -2,17 +2,24 @@
2# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o2# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3# RUN: echo "SECTIONS { \3# RUN: echo "SECTIONS { \
4# RUN: .sec1 (NOLOAD) : { . += 1; } \4# RUN: .sec1 (NOLOAD) : { . += 1; } \
5# RUN: .text : { *(.text) } \5# RUN: .bss : { *(.bss) } \
6# RUN: };" > %t.script6# RUN: };" > %t.script
7# RUN: ld.lld %t.o -T %t.script -o %t7# RUN: ld.lld %t.o -T %t.script -o %t
8# RUN: llvm-readelf --sections %t | FileCheck %s8# RUN: llvm-readelf -S -l %t | FileCheck %s
99
10# We used to misalign section offsets if the first section in a10## If a SHT_NOBITS section is the only section of a PT_LOAD segment,
11# PT_LOAD was SHT_NOBITS.11## p_offset will be set to the sh_offset field of the section. Check we align
12## sh_offset to sh_addr modulo max-page-size, so that p_vaddr=p_offset (mod
13## p_align).
1214
13# CHECK: [ 2] .text PROGBITS 0000000000000010 001010 000010 00 AX 0 0 1615# CHECK: Name Type Address Off Size ES Flg Lk Inf Al
16# CHECK: .bss NOBITS 0000000000000400 001400 000001 00 WA 0 0 1024
1417
15.global _start18# CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
16_start:19# CHECK: LOAD 0x001400 0x0000000000000400 0x0000000000000400 0x000000 0x000001 RW 0x1000
17 nop20
18.p2align 421# CHECK: 00 .bss
22
23.bss
24.p2align 10
25.byte 0
deps/lld/test/ELF/nmagic.s created+23
...@@ -0,0 +1,23 @@
1# REQUIRES: x86
2# Verify that .rodata is aligned to a 8 byte boundary.
3
4# RUN: llvm-mc -filetype=obj -triple=i386 %s -o %t.o
5# RUN: ld.lld %t.o -o %t.exe -n -Ttext 0
6# RUN: llvm-readelf --section-headers %t.exe | FileCheck %s
7
8# CHECK: [ 0] NULL 00000000 000000 000000 00 0 0 0
9# CHECK: [ 1] .text PROGBITS 00000000 0000d4 000001 00 AX 0 0 4
10# CHECK: [ 2] .rodata PROGBITS 00000008 0000d8 000008 00 A 0 0 8
11# CHECK: [ 3] .comment PROGBITS 00000000 0000e0 000008 01 MS 0 0 1
12# CHECK: [ 4] .symtab SYMTAB 00000000 0000e8 000020 10 6 1 4
13# CHECK: [ 5] .shstrtab STRTAB 00000000 000108 000032 00 0 0 1
14# CHECK: [ 6] .strtab STRTAB 00000000 00013a 000008 00 0 0 1
15
16.globl _start
17.text
18_start:
19 ret
20
21.rodata
22.align 8
23.quad 42
deps/lld/test/ELF/nobits-offset.s created+21
...@@ -0,0 +1,21 @@
1# REQUIRES: aarch64
2# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
3# RUN: ld.lld %t.o -o %t
4# RUN: llvm-readelf -S -l %t | FileCheck %s
5
6## If a SHT_NOBITS section is the only section of a PT_LOAD segment,
7## p_offset will be set to the sh_offset field of the section. Check we align
8## sh_offset to sh_addr modulo max-page-size, so that p_vaddr=p_offset (mod
9## p_align).
10
11# CHECK: Name Type Address Off Size ES Flg Lk Inf Al
12# CHECK: .bss NOBITS 0000000000210000 010000 000001 00 WA 0 0 4096
13
14# CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
15# CHECK: LOAD 0x010000 0x0000000000210000 0x0000000000210000 0x000000 0x000001 RW 0x10000
16
17# CHECK: 02 .bss
18
19.bss
20.p2align 12
21.byte 0
deps/lld/test/ELF/ppc64-reloc-rel.s created+58
...@@ -0,0 +1,58 @@
1# REQUIRES: ppc
2
3# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
4# RUN: ld.lld %t.o --defsym=foo=rel16+0x8000 -o %t
5# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
6# RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=REL %s
7# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SEC %s
8# RUN: llvm-readelf -x .eh_frame %t | FileCheck --check-prefix=HEX %s
9
10.section .R_PPC64_REL14,"ax",@progbits
11# FIXME This does not produce a relocation
12 beq 1f
131:
14# CHECK-LABEL: Disassembly of section .R_PPC64_REL14:
15# CHECK: bt 2, .+4
16
17.section .R_PPC64_REL16,"ax",@progbits
18.globl rel16
19rel16:
20 li 3, foo-rel16-1@ha # R_PPC64_REL16_HA
21 li 3, foo-rel16@ha
22 li 4, foo-rel16+0x7fff@h # R_PPC64_REL16_HI
23 li 4, foo-rel16+0x8000@h
24 li 5, foo-rel16-1@l # R_PPC64_REL16_LO
25 li 5, foo-rel16@l
26# CHECK-LABEL: Disassembly of section .R_PPC64_REL16:
27# CHECK: li 3, 0
28# CHECK-NEXT: li 3, 1
29# CHECK-NEXT: li 4, 0
30# CHECK-NEXT: li 4, 1
31# CHECK-NEXT: li 5, 32767
32# CHECK-NEXT: li 5, -32768
33
34.section .R_PPC64_REL24,"ax",@progbits
35 b rel16
36# CHECK-LABEL: Disassembly of section .R_PPC64_REL24:
37# CHECK: b .+67108840
38
39.section .REL32_AND_REL64,"ax",@progbits
40 .cfi_startproc
41 .cfi_personality 148, rel64
42 nop
43 .cfi_endproc
44rel64:
45 li 3, 0
46# REL: .rela.eh_frame {
47# REL-NEXT: 0x12 R_PPC64_REL64 .REL32_AND_REL64 0x4
48# REL-NEXT: 0x28 R_PPC64_REL32 .REL32_AND_REL64 0x0
49# REL-NEXT: }
50
51# SEC: .REL32_AND_REL64 PROGBITS 0000000010010020
52
53## CIE Personality Address: 0x10010020-(0x10000168+2)+4 = 0xfeba
54## FDE PC Begin: 0x10010020-(0x10000178+8) = 0xfea0
55# HEX: section '.eh_frame':
56# HEX-NEXT: 0x10000158
57# HEX-NEXT: 0x10000168 {{....}}bafe 00000000
58# HEX-NEXT: 0x10000178 {{[0-9a-f]+}} {{[0-9a-f]+}} a0fe0000
deps/lld/test/ELF/ppc64-relocs.s+9-72
...@@ -18,16 +18,9 @@ _start:...@@ -18,16 +18,9 @@ _start:
18 li 3,4218 li 3,42
19 sc19 sc
2020
21.section .rodata,"a",@progbits21.section .toc,"aw",@progbits
22 .p2align 2
23.LJTI0_0:
24 .long .LBB0_2-.LJTI0_0
25
26.section .toc,"aw",@progbits
27.L1:22.L1:
28.quad 22, 37, 89, 4723 .quad 22, 37, 89, 47
29.LC0:
30 .tc .LJTI0_0[TC],.LJTI0_0
3124
32.section .R_PPC64_TOC16_LO_DS,"ax",@progbits25.section .R_PPC64_TOC16_LO_DS,"ax",@progbits
33 ld 1, .L1@toc@l(2)26 ld 1, .L1@toc@l(2)
...@@ -53,91 +46,47 @@ _start:...@@ -53,91 +46,47 @@ _start:
53# CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_HA:46# CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_HA:
54# CHECK: 10010018: addis 1, 2, 047# CHECK: 10010018: addis 1, 2, 0
5548
56.section .R_PPC64_REL24,"ax",@progbits
57 b 1f
581:
59
60# CHECK-LABEL: Disassembly of section .R_PPC64_REL24:
61# CHECK: 1001001c: b .+4
62
63.section .R_PPC64_REL14,"ax",@progbits
64 beq 1f
651:
66
67# CHECK-LABEL: Disassembly of section .R_PPC64_REL14:
68# CHECK: 10010020: bt 2, .+4
69
70.section .R_PPC64_ADDR16_LO,"ax",@progbits49.section .R_PPC64_ADDR16_LO,"ax",@progbits
71 li 1, .Lfoo@l50 li 1, .Lfoo@l
7251
73# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_LO:52# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_LO:
74# CHECK: 10010024: li 1, 053# CHECK: li 1, 0
7554
76.section .R_PPC64_ADDR16_HI,"ax",@progbits55.section .R_PPC64_ADDR16_HI,"ax",@progbits
77 li 1, .Lfoo@h56 li 1, .Lfoo@h
7857
79# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HI:58# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HI:
80# CHECK: 10010028: li 1, 409759# CHECK: li 1, 4097
8160
82.section .R_PPC64_ADDR16_HA,"ax",@progbits61.section .R_PPC64_ADDR16_HA,"ax",@progbits
83 li 1, .Lfoo@ha62 li 1, .Lfoo@ha
8463
85# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HA:64# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HA:
86# CHECK: 1001002c: li 1, 409765# CHECK: li 1, 4097
8766
88.section .R_PPC64_ADDR16_HIGHER,"ax",@progbits67.section .R_PPC64_ADDR16_HIGHER,"ax",@progbits
89 li 1, .Lfoo@higher68 li 1, .Lfoo@higher
9069
91# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHER:70# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHER:
92# CHECK: 10010030: li 1, 071# CHECK: li 1, 0
9372
94.section .R_PPC64_ADDR16_HIGHERA,"ax",@progbits73.section .R_PPC64_ADDR16_HIGHERA,"ax",@progbits
95 li 1, .Lfoo@highera74 li 1, .Lfoo@highera
9675
97# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHERA:76# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHERA:
98# CHECK: 10010034: li 1, 077# CHECK: li 1, 0
9978
100.section .R_PPC64_ADDR16_HIGHEST,"ax",@progbits79.section .R_PPC64_ADDR16_HIGHEST,"ax",@progbits
101 li 1, .Lfoo@highest80 li 1, .Lfoo@highest
10281
103# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHEST:82# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHEST:
104# CHECK: 10010038: li 1, 083# CHECK: li 1, 0
10584
106.section .R_PPC64_ADDR16_HIGHESTA,"ax",@progbits85.section .R_PPC64_ADDR16_HIGHESTA,"ax",@progbits
107 li 1, .Lfoo@highesta86 li 1, .Lfoo@highesta
10887
109# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHESTA:88# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHESTA:
110# CHECK: 1001003c: li 1, 089# CHECK: li 1, 0
111
112.section .R_PPC64_REL32, "ax",@progbits
113 addis 5, 2, .LC0@toc@ha
114 ld 5, .LC0@toc@l(5)
115.LBB0_2:
116 add 3, 3, 4
117
118# DATALE: '.rodata':
119# DATALE: 0x100001c8 80fe0000
120
121# DATABE: '.rodata':
122# DATABE: 0x100001c8 0000fe80
123
124# Address of rodata + value stored at rodata entry
125# should equal address of LBB0_2.
126# 0x10000190 + 0xfeb4 = 0x10010044
127# CHECK-LABEL: Disassembly of section .R_PPC64_REL32:
128# CHECK: 10010040: addis 5, 2, 0
129# CHECK: 10010044: ld 5, -32736(5)
130# CHECK: 10010048: add 3, 3, 4
131
132.section .R_PPC64_REL64, "ax",@progbits
133 .cfi_startproc
134 .cfi_personality 148, __foo
135 li 0, 1
136 li 3, 55
137 sc
138 .cfi_endproc
139__foo:
140 li 3,0
14190
142.section .R_PPC64_TOC,"a",@progbits91.section .R_PPC64_TOC,"a",@progbits
143 .quad .TOC.@tocbase92 .quad .TOC.@tocbase
...@@ -150,15 +99,3 @@ __foo:...@@ -150,15 +99,3 @@ __foo:
15099
151# DATABE-LABEL: section '.R_PPC64_TOC':100# DATABE-LABEL: section '.R_PPC64_TOC':
152# DATABE: 00000000 10028000101# DATABE: 00000000 10028000
153
154# Check that the personality (relocated by R_PPC64_REL64) in the .eh_frame
155# equals the address of __foo.
156# 0x100001ea + 0xfe6e = 0x10010058
157# DATALE: section '.eh_frame':
158# DATALE: 0x100001e8 {{....}}6efe
159
160# DATABE: section '.eh_frame':
161# DATABE: 0x100001e8 {{[0-9a-f]+ [0-9a-f]+}} fe6e{{....}}
162
163# CHECK: __foo
164# CHECK-NEXT: 10010058: li 3, 0
deps/lld/test/ELF/relocation-copy-align-common.s+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15# CHECK-NEXT: SHF_WRITE15# CHECK-NEXT: SHF_WRITE
16# CHECK-NEXT: ]16# CHECK-NEXT: ]
17# CHECK-NEXT: Address: 0x20300017# CHECK-NEXT: Address: 0x203000
18# CHECK-NEXT: Offset: 0x20B018# CHECK-NEXT: Offset: 0x3000
19# CHECK-NEXT: Size: 1619# CHECK-NEXT: Size: 16
20# CHECK-NEXT: Link: 020# CHECK-NEXT: Link: 0
21# CHECK-NEXT: Info: 021# CHECK-NEXT: Info: 0