summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [COFF] Don't do autoexport of symbols from GNU import librariesMartin Storsjo2018-09-263-5/+51
| | | | | | | | | | This involves adding more generic list of symbol suffixes/prefixes to ignore for autoexport; adding a few other entries to these lists as well from the corresponding lists in binutils. Differential Revision: https://reviews.llvm.org/D52382 llvm-svn: 343070
* [COFF] Allow automatic dllimport from gnu import librariesMartin Storsjo2018-09-265-12/+73
| | | | | | | | | Don't assume that the IAT chunk will be a DefinedImportData, it can just as well be a DefinedRegular for gnu import libraries. Differential Revision: https://reviews.llvm.org/D52381 llvm-svn: 343069
* [WebAssembly] Add --export-default/--no-export-default optionsSam Clegg2018-09-255-2/+26
| | | | | | | | | | | | | These option control weather or not symbols marked as visibility default are exported in the output binary. By default this is true, but emscripten prefers to control the exported symbol list explicitly at link time and ignore the symbol attributes. Differential Revision: https://reviews.llvm.org/D52003 llvm-svn: 343034
* Update a --help message and add -execute-only to the man page.Rui Ueyama2018-09-252-1/+4
| | | | llvm-svn: 343032
* De-template VersionDefinitionSection. NFC.Rui Ueyama2018-09-254-51/+38
| | | | | | | | When we write a struct to a mmap'ed buffer, we usually use write16/32/64, but we didn't for VersionDefinitionSection, so we needed to template that class. llvm-svn: 343024
* Reset input section pointers to null on each linker invocation.Rui Ueyama2018-09-2517-396/+388
| | | | | | | | | | Previously, if you invoke lld's `main` more than once in the same process, the second invocation could fail or produce a wrong result due to a stale pointer values of the previous run. Differential Revision: https://reviews.llvm.org/D52506 llvm-svn: 343009
* Fix an error message. It must start with a lowercase letter.Rui Ueyama2018-09-252-2/+2
| | | | llvm-svn: 342992
* Parallelize .gdb_index string table writes.Rui Ueyama2018-09-251-1/+2
| | | | | | When we are creating a large .gdb_index, this change makes a difference. llvm-svn: 342978
* [COFF] Add support for creating range extension thunks for ARMMartin Storsjo2018-09-2512-37/+441
| | | | | | | | | | | | This is a feature that MS link.exe lacks; it currently errors out on such relocations, just like lld did before. This allows linking clang.exe for ARM - practically, any image over 16 MB will likely run into the issue. Differential Revision: https://reviews.llvm.org/D52156 llvm-svn: 342962
* [ELF] - Add -z global option to manual.George Rimar2018-09-251-0/+6
| | | | | | | This was requested during review of D49374, but for some unknown reason was not in the final commit. llvm-svn: 342954
* [WebAssembly] Move .debug_line section address of dead function outside ↵Yury Delendik2018-09-242-2/+47
| | | | | | | | | | | | | | | | | | | | | | section range Summary: Currently we are pointing all debug information that refer removed function code to the beginning of the code section (offset = 0). A debugger may want to resolve code offset to the debug information, which will collide with offsets of the live functions. Moving offsets of dead functions outside code section range. Reviewers: sbc100 Reviewed By: sbc100 Subscribers: dblaikie, ruiu, alexcrichton, dschuff, aprantl, jgravelle-google, aheejin, sunfish, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D49446 llvm-svn: 342930
* [lld-link] Generalize handling of /debug and ↵Will Wilson2018-09-246-30/+92
| | | | | | | | | | | | | /debug:{none,full,fastlink,ghash,symtab} Implement final argument precedence if multiple /debug arguments are passed on the command-line to match expected link.exe behavior. Support /debug:none and emit warning for /debug:fastlink with automatic fallback to /debug:full. Emit error if last /debug:option is unknown. Emit warning if last /debugtype:option is unknown. https://reviews.llvm.org/D50404 llvm-svn: 342894
* Correct RISC-V link in release notesEd Maste2018-09-241-1/+1
| | | | llvm-svn: 342887
* [COFF] Support linking to import libraries from GNU binutilsMartin Storsjo2018-09-219-52/+279
| | | | | | | | | | | | | | | | | | | | | | | | GNU binutils import libraries aren't the same kind of short import libraries as link.exe and LLD produce, but are a plain static library containing .idata section chunks. MSVC link.exe can successfully link to them. In order for imports from GNU import libraries to mix properly with the normal import chunks, the chunks from the existing mechanism needs to be added into named sections like .idata$2. These GNU import libraries consist of one header object, a number of object files, one for each imported function/variable, and one trailer. Within the import libraries, the object files are ordered alphabetically in this order. The chunks stemming from these libraries have to be grouped by what library they originate from and sorted, to make sure the section chunks for headers and trailers for the lists are ordered as intended. This is done on all sections named .idata$*, before adding the synthesized chunks to them. Differential Revision: https://reviews.llvm.org/D38513 llvm-svn: 342777
* Update release notes.Rui Ueyama2018-09-211-1/+9
| | | | llvm-svn: 342754
* Update release notes.Rui Ueyama2018-09-211-2/+6
| | | | llvm-svn: 342748
* Align AArch64 and i386 image base to superpageDimitry Andric2018-09-2150-825/+833
| | | | | | | | | | | | | | | | | | | Summary: As for x86_64, the default image base for AArch64 and i386 should be aligned to a superpage appropriate for the architecture. On AArch64, this is 2 MiB, on i386 it is 4 MiB. Reviewers: emaste, grimar, javed.absar, espindola, ruiu, peter.smith, srhines, rprichard Reviewed By: ruiu, peter.smith Subscribers: jfb, markj, arichardson, krytarowski, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D50297 llvm-svn: 342746
* [ELF] Use the Repl point to avoid the segfault when using ICFPetr Hosek2018-09-213-1/+69
| | | | | | | | This addresses PR38918. Differential Revision: https://reviews.llvm.org/D52202 llvm-svn: 342704
* Make a member function non-member. NFC.Rui Ueyama2018-09-201-2/+1
| | | | | | | | Non-member functions are generally preferred over member functions because it is clear that non-member functions don't depend on an internal state of an object. llvm-svn: 342695
* [WebAssembly] Add v128 value typeThomas Lively2018-09-201-0/+2
| | | | | | | | | | Reviewers: sbc100, aheejin, dschuff Subscribers: jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D52106 llvm-svn: 342690
* Rename a function. NFC.Rui Ueyama2018-09-201-2/+2
| | | | llvm-svn: 342687
* Make variable names shorter. NFC.Rui Ueyama2018-09-201-11/+10
| | | | llvm-svn: 342686
* Simplify. NFC.Rui Ueyama2018-09-201-7/+3
| | | | llvm-svn: 342685
* Add paretntheses around a C macro parameter.Rui Ueyama2018-09-201-1/+1
| | | | llvm-svn: 342673
* [ELF][HEXAGON] Set DefaultMaxPageSize to 64KSid Manning2018-09-202-50/+56
| | | | | | Update testcase to reflect the change. llvm-svn: 342662
* Fix one more test failure.Zachary Turner2018-09-201-3/+3
| | | | llvm-svn: 342660
* [PPC64] Handle ppc64le triple in getBitcodeMachineKind.Sean Fertile2018-09-202-0/+13
| | | | | | | | Enables lto and thinlto with bitcode targeting ppc64le. Differential Revision: https://reviews.llvm.org/D52265 llvm-svn: 342604
* [PPC64] Helper for offset from a function's global entry to local entry. [NFC]Sean Fertile2018-09-203-10/+41
| | | | | | | | | | | | | The PPC64 elf V2 abi defines 2 entry points for a function. There are a few places we need to calculate the offset from the global entry to the local entry and how this is done is not straight forward. This patch adds a helper function mostly for documentation purposes, explaining how the 2 entry points differ and why we choose one over the other, as well as documenting how the offsets are encoded into a functions st_other field. Differential Revision: https://reviews.llvm.org/D52231 llvm-svn: 342603
* [PPC64] Optimize redundant instructions in global access sequences.Sean Fertile2018-09-2011-8/+446
| | | | | | | | | | | | | | | | | | | The access sequence for global variables in the medium and large code models use 2 instructions to add an offset to the toc-pointer. If the offset fits whithin 16-bits then the instruction that sets the high 16 bits is redundant. This patch adds the --toc-optimize option, (on by default) and enables rewriting of 2 instruction global variable accesses into 1 when the offset from the TOC-pointer to the variable (or .got entry) fits in 16 signed bits. eg addis %r3, %r2, 0 --> nop addi %r3, %r3, -0x8000 --> addi %r3, %r2, -0x8000 This rewriting can be disabled with the --no-toc-optimize flag Differential Revision: https://reviews.llvm.org/D49237 llvm-svn: 342602
* [COFF] Fix the name mangling of a function in the autoexport exclusion listMartin Storsjo2018-09-181-1/+1
| | | | | | | The __NULL_IMPORT_DESCRIPTOR symbol has two leading underscores on architectures other than i386 as well; it is not a mangled symbol name. llvm-svn: 342448
* [COFF] Add support for delay loading DLLs for ARM64Martin Storsjo2018-09-184-3/+152
| | | | | | Differential Revision: https://reviews.llvm.org/D52190 llvm-svn: 342447
* [COFF] Fix a block with incorrect indentation. NFC.Martin Storsjo2018-09-181-3/+3
| | | | llvm-svn: 342446
* [ELF] Set Out::TlsPhdr earlier for encoding packed reloc tablesRyan Prichard2018-09-184-9/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For --pack-dyn-relocs=android, finalizeSections calls LinkerScript::assignAddresses and AndroidPackedRelocationSection::updateAllocSize in a loop, where assignAddresses lays out the ELF image, then updateAllocSize determines the size of the Android packed relocation table by encoding it. Encoding the table requires knowing the values of relocation addends. To get the addend of a TLS relocation, updateAllocSize can call getSymVA on a TLS symbol before setPhdrs has initialized Out::TlsPhdr, producing an error: <file> has an STT_TLS symbol but doesn't have an SHF_TLS section Fix the problem by initializing Out::TlsPhdr immediately after the program headers are created. The segment's p_vaddr field isn't initialized until setPhdrs, so use FirstSec->Addr, which is what setPhdrs would use. FirstSec will typically refer to the .tdata or .tbss output section, whose (tentative) address was computed by assignAddresses. Android currently avoids this problem because it uses emutls and doesn't support ELF TLS. This problem doesn't apply to --pack-dyn-relocs=relr because SHR_RELR only handles relative relocations without explicit addends or info. Fixes https://bugs.llvm.org/show_bug.cgi?id=37841. Reviewers: ruiu, pcc, chh, javed.absar, espindola Subscribers: emaste, arichardson, llvm-commits, srhines Differential Revision: https://reviews.llvm.org/D51671 llvm-svn: 342432
* [PPC64] Support relaxing R_PPC64_TLSGD16 in TlsGdtoLe relaxation.Sean Fertile2018-09-172-0/+62
| | | | | | | | | | A General-dynamic tls access can be written using a R_PPC64_TLSGD16 relocation if the target got entry is within 16 bits of the TOC-base. This patch adds support for R_PPC64_TLSGD16 by relaxing it the same as a R_PPC64_GOT_TLSGD16_LO. Differential Revision: https://reviews.llvm.org/D52055 llvm-svn: 342411
* [PPC64] Helpers for read/write an instr while relocating a half16 type. [NFC]Sean Fertile2018-09-171-16/+26
| | | | | | | | | | | | There are a growing number of places when we either want to read or write an instruction when handling a half16 relocation type. On big-endian the buffer pointer is pointing into the middle of the word we want and on little-endian it is pointing to the start of the word. These 2 helpers are to simplify reading and writing in these contexts. Differential Revision: https://reviews.llvm.org/D52115 llvm-svn: 342410
* lld-link: Also demangle undefined dllimported symbols.Nico Weber2018-09-172-3/+9
| | | | | | | | | dllimported symbols go through an import stub that's called __imp_ followed by the name the stub points to. Make that work. Differential Revision: https://reviews.llvm.org/D52145 llvm-svn: 342401
* [ELF] Use llvm::toLower instead of libc call tolowerFangrui Song2018-09-151-1/+2
| | | | | | | | | | | | | | | | | | | tolower() has some overhead because current locale is considered (though in lld the default "C" locale is used which does not matter too much). llvm::toLower is more efficient as it compiles to a compare and a conditional jump, as opposed to a libc call if tolower is used. Disregarding locale also matches gdb's behavior (gdb/minsyms.h): #define SYMBOL_HASH_NEXT(hash, c) \ ((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113) where TOLOWER (include/safe-ctype.h) is a macro that uses a lookup table under the hood which is similar to llvm::toLower. Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D52128 llvm-svn: 342342
* lld-link: Set PDB GUID to hash of PDB contents instead of to a random byte ↵Nico Weber2018-09-154-106/+69
| | | | | | | | | | | | | | | | | | | | | | | sequence. Previously, lld-link would use a random byte sequence as the PDB GUID. Instead, use a hash of the PDB file contents. To not disturb llvm-pdbutil pdb2yaml, the hash generation is an opt-in feature on InfoStreamBuilder and ldb/COFF/PDB.cpp always sets it. Since writing the PDB computes this ID which also goes in the exe, the PDB writing code now must be called before writeBuildId(). writeBuildId() for that reason is no longer included in the "Code Layout" timer. Since the PDB GUID is now a function of the PDB contents, the PDB Age is always set to 1. There was a long comment above loadExistingBuildId (now gone) about how not changing the GUID and only incrementing the age was important, but according to the discussion in PR35914 that comment was incorrect. Differential Revision: https://reviews.llvm.org/D51956 llvm-svn: 342334
* lld-link: print demangled symbol names for "undefined symbol" diagnosticsNico Weber2018-09-154-45/+32
| | | | | | | | | | | | | | | | | For this, add a few toString() calls when printing the "undefined symbol" diagnostics; toString() already does demangling on Windows hosts. Also make lld::demangleMSVC() (called by toString(Symbol*)) call LLVM's microsoftDemangle() instead of UnDecorateSymbolName() so that it works on non-Windows hosts – this makes both updating tests easier and provides a better user experience for people doing cross-links. This doesn't yet do the right thing for symbols starting with __imp_, but that can be improved in a follow-up. Differential Revision: https://reviews.llvm.org/D52104 llvm-svn: 342332
* Style fix. NFC.Rui Ueyama2018-09-141-13/+23
| | | | llvm-svn: 342300
* Rename GdbIndex.{cpp,h} -> DWARF.{cpp,h}.Rui Ueyama2018-09-144-7/+7
| | | | | | | | These files used to contain classes and functions for .gdb_index, but they are moved to SyntheticSections.{cpp,h}, so the name is now irrelevant. llvm-svn: 342299
* Revert r342297: Discard uncompressed buffer after creating .gdb_index contents.Rui Ueyama2018-09-142-10/+8
| | | | | | Looks like it broke some local builds that use -gdb-index. llvm-svn: 342298
* Discard uncompressed buffer after creating .gdb_index contents.Rui Ueyama2018-09-142-8/+10
| | | | | | | | | | | | | | Once we create .gdb_index contents, .zdebug_gnu_pub{names,types} are useless, so there's no need to keep their uncompressed data in memory. I observed that for a test case in which lld creates a 3GB .gdb_index section, the maximum resident set size reduced from 43GB to 29GB after this patch. Differential Revision: https://reviews.llvm.org/D52126 llvm-svn: 342297
* [COFF] Provide __CTOR_LIST__ and __DTOR_LIST__ symbols for MinGWMartin Storsjo2018-09-1414-43/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MinGW uses these kind of list terminator symbols for traversing the constructor/destructor lists. These list terminators are actual pointers entries in the lists, with the values 0 and (uintptr_t)-1 (instead of just symbols pointing to the start/end of the list). (This mechanism exists in both the mingw-w64 crt startup code and in libgcc; normally the mingw-w64 one is used, but a DLL build of libgcc uses the libgcc one. Therefore it's not trivial to change the mechanism without lots of cross-project synchronization and potentially invalidating some combinations of old/new versions of them.) When mingw-w64 has been used with lld so far, the CRT startup object files have so far provided these symbols, ending up with different, incompatible builds of the CRT startup object files depending on whether binutils or lld are going to be used. In order to avoid the need of different configuration of the CRT startup object files depending on what linker to be used, provide these symbols in lld instead. (Mingw-w64 checks at build time whether the linker provides these symbols or not.) This unifies this particular detail between the two linkers. This does disallow the use of the very latest lld with older versions of mingw-w64 (the configure check for the list was added recently; earlier it simply checked whether the CRT was built with gcc or clang), and requires rebuilding the mingw-w64 CRT. But the number of users of lld+mingw still is low enough that such a change should be tolerable, and unifies this aspect of the toolchains, easing interoperability between the toolchains for the future. The actual test for this feature is added in ctors_dtors_priority.s, but a number of other tests that checked absolute output addresses are updated. Differential Revision: https://reviews.llvm.org/D52053 llvm-svn: 342294
* lld: add -z interpose supportEd Maste2018-09-145-7/+18
| | | | | | | | | | | -z interpose sets the DF_1_INTERPOSE flag, marking the object as an interposer. Via FreeBSD PR 230604, linking Valgrind with lld failed. Differential Revision: https://reviews.llvm.org/D52094 llvm-svn: 342239
* [COFF] Allow embedded directives to be separated by null bytesMartin Storsjo2018-09-141-0/+46
| | | | | | | | | | | | The PE spec says that they will be separated by spaces, but link.exe handles it just fine if they are separated by null bytes as well. This adds tests to the lld repo, with the actual functional change in LLVM in SVN r342204. Differential Revision: https://reviews.llvm.org/D52014 llvm-svn: 342206
* [COFF] Avoid copying of chunk vectors. NFC.Martin Storsjo2018-09-141-1/+1
| | | | | | | | | | | | When declaring the pair variable as "auto Pair : Map", it is effectively declared as std::pair<std::pair<StringRef, uint32_t>, std::vector<Chunk *>>. This effectively does a full, shallow copy of the Chunk vector, just to be thrown away after each iteration. Differential Revision: https://reviews.llvm.org/D52051 llvm-svn: 342205
* COFF: Add support for /force:multiple optionRui Ueyama2018-09-135-7/+66
| | | | | | | | | | | Patch by Thomas Roughton. This patch adds support for linking with multiple definitions to LLD's COFF driver, in line with link.exe's /force:multiple option. Differential Revision: https://reviews.llvm.org/D50598 llvm-svn: 342191
* lld-link: For nonexisting inputs, omit follow-on diagnosticsNico Weber2018-09-132-0/+8
| | | | | | | | | | | | | | | | For lld-link missing.obj, lld-link currently prints: lld-link: error: could not open foo.obj: No such file or directory lld-link: warning: /machine is not specified. x64 is assumed lld-link: error: subsystem must be defined The 2nd and 3rd diagnostics are consequences of the input not existing and are not interesting. If input files are missing, the best thing we can do is point that out and then return. Differential Revision: https://reviews.llvm.org/D51981 llvm-svn: 342158
* [ELF] Guard --fix-cortex-a53-843419 against --just-symsPeter Smith2018-09-132-1/+23
| | | | | | | | | | | | | | If --just-syms is used the mapping symbols from the ELF file will be absolute symbols with no section. The code to process mapping symbols in --fix-cortex-a53-843419 assumes that these symbols have a defining section so a crash will result when --just-syms is used. The simple fix is to not process the symbol when it doesn't have a section. Fixes PR37971 Differential Revision: https://reviews.llvm.org/D52038 llvm-svn: 342146
OpenPOWER on IntegriCloud