1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

Vendor import of lld release_90 branch r369369:

https://llvm.org/svn/llvm-project/lld/branches/release_90@369369
This commit is contained in:
Dimitry Andric 2019-08-20 21:35:55 +00:00
parent f1e1c239e3
commit 1e52e898a3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/lld/dist-release_90/; revision=351312
svn path=/vendor/lld/lld-release_90-r369369/; revision=351313; tag=vendor/lld/lld-release_90-r369369
4 changed files with 74 additions and 6 deletions

View File

@ -184,8 +184,10 @@ void LinkerDriver::addBuffer(std::unique_ptr<MemoryBuffer> mb,
if (wholeArchive) {
std::unique_ptr<Archive> file =
CHECK(Archive::create(mbref), filename + ": failed to parse archive");
Archive *archive = file.get();
make<std::unique_ptr<Archive>>(std::move(file)); // take ownership
for (MemoryBufferRef m : getArchiveMembers(file.get()))
for (MemoryBufferRef m : getArchiveMembers(archive))
addArchiveBuffer(m, "<whole-archive>", filename, 0);
return;
}

View File

@ -762,6 +762,28 @@ void Writer::locateImportTables() {
}
}
// Return whether a SectionChunk's suffix (the dollar and any trailing
// suffix) should be removed and sorted into the main suffixless
// PartialSection.
static bool shouldStripSectionSuffix(SectionChunk *sc, StringRef name) {
// On MinGW, comdat groups are formed by putting the comdat group name
// after the '$' in the section name. For .eh_frame$<symbol>, that must
// still be sorted before the .eh_frame trailer from crtend.o, thus just
// strip the section name trailer. For other sections, such as
// .tls$$<symbol> (where non-comdat .tls symbols are otherwise stored in
// ".tls$"), they must be strictly sorted after .tls. And for the
// hypothetical case of comdat .CRT$XCU, we definitely need to keep the
// suffix for sorting. Thus, to play it safe, only strip the suffix for
// the standard sections.
if (!config->mingw)
return false;
if (!sc || !sc->isCOMDAT())
return false;
return name.startswith(".text$") || name.startswith(".data$") ||
name.startswith(".rdata$") || name.startswith(".pdata$") ||
name.startswith(".xdata$") || name.startswith(".eh_frame$");
}
// Create output section objects and add them to OutputSections.
void Writer::createSections() {
// First, create the builtin sections.
@ -807,10 +829,7 @@ void Writer::createSections() {
continue;
}
StringRef name = c->getSectionName();
// On MinGW, comdat groups are formed by putting the comdat group name
// after the '$' in the section name. Such a section name suffix shouldn't
// imply separate alphabetical sorting of those section chunks though.
if (config->mingw && sc && sc->isCOMDAT())
if (shouldStripSectionSuffix(sc, name))
name = name.split('$').first;
PartialSection *pSec = createPartialSection(name,
c->getOutputCharacteristics());
@ -1076,6 +1095,13 @@ Optional<coff_symbol16> Writer::createSymbol(Defined *def) {
}
}
// Symbols that are runtime pseudo relocations don't point to the actual
// symbol data itself (as they are imported), but points to the IAT entry
// instead. Avoid emitting them to the symbol table, as they can confuse
// debuggers.
if (def->isRuntimePseudoReloc)
return None;
StringRef name = def->getName();
if (name.size() > COFF::NameSize) {
sym.Name.Offset.Zeroes = 0;

View File

@ -3177,11 +3177,23 @@ static bool isDuplicateArmExidxSec(InputSection *prev, InputSection *cur) {
// The .ARM.exidx table must be sorted in ascending order of the address of the
// functions the table describes. Optionally duplicate adjacent table entries
// can be removed. At the end of the function the ExecutableSections must be
// can be removed. At the end of the function the executableSections must be
// sorted in ascending order of address, Sentinel is set to the InputSection
// with the highest address and any InputSections that have mergeable
// .ARM.exidx table entries are removed from it.
void ARMExidxSyntheticSection::finalizeContents() {
if (script->hasSectionsCommand) {
// The executableSections and exidxSections that we use to derive the
// final contents of this SyntheticSection are populated before the
// linker script assigns InputSections to OutputSections. The linker script
// SECTIONS command may have a /DISCARD/ entry that removes executable
// InputSections and their dependent .ARM.exidx section that we recorded
// earlier.
auto isDiscarded = [](const InputSection *isec) { return !isec->isLive(); };
llvm::erase_if(executableSections, isDiscarded);
llvm::erase_if(exidxSections, isDiscarded);
}
// Sort the executable sections that may or may not have associated
// .ARM.exidx sections by order of ascending address. This requires the
// relative positions of InputSections to be known.

View File

@ -28,6 +28,15 @@ ELF Improvements
``$ ld.lld --call-shared`` now prints
``unknown argument '--call-shared', did you mean '--call_shared'``.
* lld now supports replacing ``JAL`` with ``JALX`` instructions in case
of MIPS - microMIPS cross-mode jumps.
* lld now creates LA25 thunks for MIPS R6 code.
* Put MIPS-specific .reginfo, .MIPS.options, and .MIPS.abiflags sections
into corresponding PT_MIPS_REGINFO, PT_MIPS_OPTIONS, and PT_MIPS_ABIFLAGS
segments.
* ...
COFF Improvements
@ -53,6 +62,14 @@ COFF Improvements
* Several speed and memory usage improvements.
* Range extension thunks are now created for ARM64, if needed
* lld-link now supports resource object files created by GNU windres and
MS cvtres, not only llvm-cvtres
* The generated thunks for delayimports now share the majority of code
among thunks, significantly reducing the overhead of using delayimport
* ...
MinGW Improvements
@ -62,6 +79,17 @@ MinGW Improvements
terminators for the sections such as .eh_frame properly, fixing
DWARF exception handling with libgcc and gcc's crtend.o.
* lld now also handles DWARF unwind info generated by GCC, when linking
with libgcc
* Many more GNU ld options are now supported, which e.g. allows the lld
MinGW frontend to be called by GCC
* PDB output can be requested without manually specifying the PDB file
name, with the new option ``-pdb=`` with an empty value to the option.
(The old existing syntax ``-pdb <filename>`` was more cumbersome to use
with an empty parameter value.)
MachO Improvements
------------------