summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* Reland r330223, "COFF: Merge .idata, .didat and .edata into .rdata by ↵Peter Collingbourne2018-04-1710-37/+44
| | | | | | | | | | | | | | | | | | | | | default.", which was reverted in r330228. In this reland I removed an unnecessary use of /debug in the test delayimports32.test and used the /pdbaltpath flag in the test pdb-publics-import.test, both of which avoid embedding absolute PDB paths in executables which could affect later RVAs. Original commit message: > COFF: Merge .idata, .didat and .edata into .rdata by default. > > This saves a little space and matches what link.exe does. > > Tested using the chromium Windows trybots: > https://chromium-review.googlesource.com/c/chromium/src/+/1014784 Differential Revision: https://reviews.llvm.org/D45737 llvm-svn: 330233
* COFF: Implement /pdbaltpath flag.Peter Collingbourne2018-04-174-21/+26
| | | | | | | | | | | I needed to revert r330223 because we were embedding an absolute PDB path in the .rdata section, which ended up being laid out before the .idata section and affecting its RVAs. This flag will let us control the embedded path. Differential Revision: https://reviews.llvm.org/D45747 llvm-svn: 330232
* Revert r330223, "COFF: Merge .idata, .didat and .edata into .rdata by default."Peter Collingbourne2018-04-1710-40/+34
| | | | | | Seems to have uncovered some sort of non-determinism on the bots. llvm-svn: 330228
* COFF: Merge .idata, .didat and .edata into .rdata by default.Peter Collingbourne2018-04-1710-34/+40
| | | | | | | | | | | This saves a little space and matches what link.exe does. Tested using the chromium Windows trybots: https://chromium-review.googlesource.com/c/chromium/src/+/1014784 Differential Revision: https://reviews.llvm.org/D45737 llvm-svn: 330223
* llvm-pdbutil: Fix an off-by-one error.Peter Collingbourne2018-04-171-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D45740 llvm-svn: 330222
* [llvm-pdbutil] Dump first section contribution for each module.Zachary Turner2018-04-171-0/+6
| | | | | | | | | | | | | | The DBI stream contains a list of module descriptors. At the beginning of each descriptor is a structure representing the first section contribution in the output file for that module. LLD currently doesn't fill out this structure at all, but link.exe does. So as a precursor to emitting this data in LLD, we first need a way to dump it so that it can be checked. This patch adds support for the dumping, and verifies via a test that LLD emits bogus information. llvm-svn: 330208
* COFF: Make SectionChunk::Relocs field an ArrayRef. NFCI.Peter Collingbourne2018-04-173-6/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D45714 llvm-svn: 330172
* Revert r329960 "Do not keep shared symbols created from garbage-collected ↵Reid Kleckner2018-04-163-35/+23
| | | | | | | | | | eliminated DSOs." This is causing large numbers of Chromium test executables to crash on shutdown. The relevant symbol seems to be __cxa_finalize, which gets removed from the dynamic symbol table for some of the support libraries. llvm-svn: 330164
* [PDB] Correctly use the target machine when writing DBI stream.Zachary Turner2018-04-161-2/+1
| | | | | | | | | Using Config->is64() will treat ARM64 as Amd64, which is incorrect. Furthermore, there are more esoteric architectures that could theoretically be encountered. Just set it directly to the machine type, which we already know anyway. llvm-svn: 330157
* Resubmit "Fix some incorrect fields in our generated PDBs."Zachary Turner2018-04-163-5/+29
| | | | | | | This fixes the failing tests. They simply hadn't been updated to match the new output resulting from this patch. llvm-svn: 330145
* Revert "Fix some incorrect fields in our generated PDBs."Zachary Turner2018-04-161-25/+1
| | | | | | | There are a couple of failing tests which slipped under my radar so I'm reverting this while I attempt to fix. llvm-svn: 330133
* Fix some incorrect fields in our generated PDBs.Zachary Turner2018-04-161-1/+25
| | | | | | | | | | | | | | | | | | Most of these are pretty trivial and obvious. Setting the toolchain version to 14.11 is perhaps a little questionable, but we've been bitten in the past where one of our version fields sidn't match MSVC's, and I definitely don't want to go through that diagnosis again as it was pretty time consuming and hard to track down. I found all of these by using llvm-pdbutil export to dump the dbi and pdb streams to a file, then using fc followed by llvm-pdbutil explain to explain the mismatched bytes. There are still some more, these are just the low hanging fruit. Differential Revision: https://reviews.llvm.org/D45276 llvm-svn: 330130
* Define InitLLVM to do common initialization all at once.Rui Ueyama2018-04-131-7/+2
| | | | | | | | | | | We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
* Reduce code duplication.Rafael Espindola2018-04-133-8/+1
| | | | | | getVA was already implemented in the base class. llvm-svn: 330036
* [ELF][MIPS] Support linking of PIE for MIPSSimon Atanasyan2018-04-133-14/+49
| | | | | | | | | | | | | | MIPS ABI requires creation of the MIPS_RLD_MAP dynamic tag for non-PIE executables only and MIPS_RLD_MAP_REL tag for both PIE and non-PIE executables. The patch skips definition of the MIPS_RLD_MAP for PIE files and defines MIPS_RLD_MAP_REL. The MIPS_RLD_MAP_REL tag stores the offset to the .rld_map section relative to the address of the tag itself. Differential Revision: https://reviews.llvm.org/D43347 llvm-svn: 329996
* Do not keep shared symbols created from garbage-collected eliminated DSOs.Rui Ueyama2018-04-123-23/+35
| | | | | | | | | | | | | | If all references to a DSO happen to be weak, and if the DSO is specified with --as-needed, the DSO is not added to DT_NEEDED. If that happens, we also need to eliminate shared symbols created from the DSO. Otherwise, they become dangling references that point to non-exsitent DSO. Fixes https://bugs.llvm.org/show_bug.cgi?id=36991 Differential Revision: https://reviews.llvm.org/D45536 llvm-svn: 329960
* [WebAssembly] Match llvm change to custom section sizeSam Clegg2018-04-123-15/+7
| | | | | | | | | | | | | | Summary: The content of custome sections no longer includes the name itself. See: https://reviews.llvm.org/D45579 Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D45580 llvm-svn: 329948
* Remove references to old SymbolBody classSam Clegg2018-04-113-5/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D45400 llvm-svn: 329846
* Rename to match an LLVM changeDavid Blaikie2018-04-111-1/+1
| | | | llvm-svn: 329841
* [ELF] - Reorder local symbols.George Rimar2018-04-114-16/+45
| | | | | | | | | | | This fixes PR36716 (https://bugs.llvm.org/show_bug.cgi?id=36716), Patch sorts local symbols to match the following order: file1, local1, hidden1, file2, local2, hidden2 ... Differential revision: https://reviews.llvm.org/D45325 llvm-svn: 329787
* [ELF] - Simplify. NFC.George Rimar2018-04-111-7/+4
| | | | llvm-svn: 329785
* Don't warn on ICFed symbols, warn on synthetic ones.Rafael Espindola2018-04-102-6/+15
| | | | | | Based on a patch for the ICF warning by Rui. llvm-svn: 329757
* [WebAssembly] Add support for custom sectionsSam Clegg2018-04-109-1/+140
| | | | | | | | | Copy user-defined custom sections into the output, concatenating sections with the same name. Differential Revision: https://reviews.llvm.org/D45340 llvm-svn: 329717
* s/LLVM_ON_WIN32/_WIN32/, lldNico Weber2018-04-102-2/+2
| | | | | | | | | | | LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. llvm-svn: 329696
* [ELF] - Do not crash when trying to order --defsym/linker script symbols.George Rimar2018-04-102-4/+20
| | | | | | | | | Currently, we crash because File is null for such symbols. Differential revision: https://reviews.llvm.org/D45440 llvm-svn: 329678
* Add a test for nested --start-group.Rui Ueyama2018-04-091-2/+5
| | | | llvm-svn: 329642
* Add --warn-backrefs to maintain compatibility with other linkersRui Ueyama2018-04-098-23/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm proposing a new command line flag, --warn-backrefs in this patch. The flag and the feature proposed below don't exist in GNU linkers nor the current lld. --warn-backrefs is an option to detect reverse or cyclic dependencies between static archives, and it can be used to keep your program compatible with GNU linkers after you switch to lld. I'll explain the feature and why you may find it useful below. lld's symbol resolution semantics is more relaxed than traditional Unix linkers. Therefore, ld.lld foo.a bar.o succeeds even if bar.o contains an undefined symbol that have to be resolved by some object file in foo.a. Traditional Unix linkers don't allow this kind of backward reference, as they visit each file only once from left to right in the command line while resolving all undefined symbol at the moment of visiting. In the above case, since there's no undefined symbol when a linker visits foo.a, no files are pulled out from foo.a, and because the linker forgets about foo.a after visiting, it can't resolve undefined symbols that could have been resolved otherwise. That lld accepts more relaxed form means (besides it makes more sense) that you can accidentally write a command line or a build file that works only with lld, even if you have a plan to distribute it to wider users who may be using GNU linkers. With --check-library-dependency, you can detect a library order that doesn't work with other Unix linkers. The option is also useful to detect cyclic dependencies between static archives. Again, lld accepts ld.lld foo.a bar.a even if foo.a and bar.a depend on each other. With --warn-backrefs it is handled as an error. Here is how the option works. We assign a group ID to each file. A file with a smaller group ID can pull out object files from an archive file with an equal or greater group ID. Otherwise, it is a reverse dependency and an error. A file outside --{start,end}-group gets a fresh ID when instantiated. All files within the same --{start,end}-group get the same group ID. E.g. ld.lld A B --start-group C D --end-group E A and B form group 0, C, D and their member object files form group 1, and E forms group 2. I think that you can see how this group assignment rule simulates the traditional linker's semantics. Differential Revision: https://reviews.llvm.org/D45195 llvm-svn: 329636
* COFF: Remove dead code. NFCI.Peter Collingbourne2018-04-091-3/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D45423 llvm-svn: 329609
* Added support for LTO options: sample_profile, new_pass_manager and ↵Rumeet Dhindsa2018-04-096-0/+62
| | | | | | | | debug_pass_manager Differential Revision: https://reviews.llvm.org/D45275 llvm-svn: 329598
* [ELF] - Simplify test case. NFC.George Rimar2018-04-091-5/+1
| | | | llvm-svn: 329563
* [ELF] - Stop setting OutSecOff too early.George Rimar2018-04-095-8/+74
| | | | | | | | | | | | | | | | | | | | | | | Currently LLD sets OutSecOff in addSection for input sections. That is a fake offset (just a rude approximation to remember the order), used for sorting SHF_LINK_ORDER sections (see resolveShfLinkOrder, compareByFilePosition). There are 2 problems with such approach: 1. We currently change and reuse Size field as a value assigned. Changing size is not good because leads to bugs. Currently, SIZEOF(.bss) for empty .bss returns 2 because we add two empty synthetic sections and increase size twice by 1. (See PR37011: https://bugs.llvm.org/show_bug.cgi?id=37011) 2. Such approach simply does not work when --symbol-ordering-file is involved, because processing of the ordering file might break the initial section order. This fixes PR37011. Differential revision: https://reviews.llvm.org/D45368 llvm-svn: 329560
* [ELF] - Fix cref.s test case.George Rimar2018-04-091-3/+4
| | | | | | | | | | | | The intention of -gc-sections flag was to check that discarded is not in the output. It should be specified in the executable command line invocation and also, the symbol must be global as local symbols are anyways not printed. Differential revision: https://reviews.llvm.org/D45159 llvm-svn: 329559
* [ELF] - Allow LLD to produce file symbols.George Rimar2018-04-097-22/+66
| | | | | | | | | | | | | This is for PR36716 and this enables emitting STT_FILE symbols. Output size affect is minor: lld binary size changes from 52,883,408 to 52,949,400 clang binary size changes from 83,136,456 to 83,219,600 Differential revision: https://reviews.llvm.org/D45261 llvm-svn: 329557
* [tests] Fix format-binary-non-ascii.s to work with Python 3 on WindowsAaron Smith2018-04-071-3/+3
| | | | | | | | | | | Some platforms interpret the pound sign as one character. Platforms that use Python 2.x actually interpret it as two characters because in the Python 2.x version of lit, the string used for the file name is a byte string and the pound sign is two bytes. Patch by Stella Stamenova! llvm-svn: 329472
* COFF: Process /merge flag as we create output sections.Peter Collingbourne2018-04-076-31/+95
| | | | | | | | With this we can merge builtin sections. Differential Revision: https://reviews.llvm.org/D45350 llvm-svn: 329471
* Avoid some temporary allocations.Rafael Espindola2018-04-061-2/+8
| | | | | | | Some system libraries have a lot of versioned symbols. When linking scylla this brings the number of malloc calls from 49154 to 37944. llvm-svn: 329453
* [ELF] Don't write to the source directory in test.Benjamin Kramer2018-04-061-2/+2
| | | | llvm-svn: 329384
* Change which file we print when a symbol cannot be ordered.Rafael Espindola2018-04-062-32/+39
| | | | | | | | | | | | Currently there are a few odd things about the warning about symbols that cannot be ordered. This patch fixes: * When there is an undefined symbol that resolves to a shared file, we were printing the location of the undefined reference. * If there are multiple comdats, we were reporting them all. llvm-svn: 329371
* COFF: Create output sections early. NFCI.Peter Collingbourne2018-04-061-126/+119
| | | | | | | | | With this, all output sections are created in one place. This will make it simpler to implement merging of builtin sections. Differential Revision: https://reviews.llvm.org/D45349 llvm-svn: 329370
* Don't ignore addend when a SHF_MERGE section is dead.Rafael Espindola2018-04-063-6/+29
| | | | | | | | This is similar to r329219, but for the entire section. Like r329219 I don't expect this to have any real impact, it is just more consistent and simpler. llvm-svn: 329367
* [WebAssembly] Remove StackPointerGlobal member variable from the driver.Rui Ueyama2018-04-051-5/+5
| | | | | | | | | Since InputGlobal makes a copy of a given object, we can use a temporary object allocated on the stack here. Differential Revision: https://reviews.llvm.org/D43924 llvm-svn: 329337
* [WebAssembly] Remove another trivial accessor.Rui Ueyama2018-04-052-11/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D43725 llvm-svn: 329336
* [ELF] Add CHECK to test/ELF/undef-start.sFangrui Song2018-04-051-2/+4
| | | | llvm-svn: 329333
* Make "Size" column in the map file one characters shorter.Rui Ueyama2018-04-054-112/+112
| | | | | | | | | Previously, "size" column is 9 characters long which is too long at least for 32-bit (because at maximum it needs 8 columns). This patch make it one column shorter than before. That's also a reasonable default for 64-bit. llvm-svn: 329317
* Fix column size in the map file.Rui Ueyama2018-04-054-112/+114
| | | | | | Size can be narrow, but LMA should be the same width as VMA. llvm-svn: 329312
* Initialize OutputOff to zero.Rafael Espindola2018-04-052-2/+11
| | | | | | | We have a dedicated Live bit, so we don't need a special value and we were not accounting for in at least one place. llvm-svn: 329307
* [ELF] Don't add NOLOAD sections to segmentEugene Leviant2018-04-052-7/+24
| | | | | | Differential revision: https://reviews.llvm.org/D45264 llvm-svn: 329281
* [ELF] - Eliminate Target::isPicRel method.George Rimar2018-04-056-28/+18
| | | | | | | | | | | | | | | | | | | | | | As was mentioned in comments for D45158, isPicRel's name does not make much sense, because what this method does is checks if we need to create the dynamic relocation or not. Instead of renaming it to something different, we can 'isPicRel' completely. We can reuse the getDynRel method. They are logically very close, getDynRel can just return R_*_NONE in case no dynamic relocation should be produced and that would simplify things and avoid functionality correlation/duplication with 'isPicRel'. The patch does this change. Differential revision: https://reviews.llvm.org/D45248 llvm-svn: 329275
* [ELF] - Reveal more information in -Map file about assignments.George Rimar2018-04-056-42/+71
| | | | | | | | | | | | | | | | | Currently, LLD print symbol assignment commands to the map file, but it does not do that for assignments that are outside of the section descriptions. Such assignments can affect the layout though. The patch implements the following: * Teaches LLD to print symbol assignments outside of section declaration. * Teaches LLD to print PROVIDE/HIDDEN/PROVIDE hidden commands. In case when symbol is not provided, nothing will be printed. Differential revision: https://reviews.llvm.org/D44894 llvm-svn: 329272
* [ELF] - Print LMA in a -Map file.George Rimar2018-04-055-78/+155
| | | | | | | | | | Currently, LLD prints VA, but not LMA in a map file. It seems can be useful to print both to reveal layout details and patch implements it. Differential revision: https://reviews.llvm.org/D44899 llvm-svn: 329271
OpenPOWER on IntegriCloud