summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a test. NFC.Rafael Espindola2018-04-261-0/+29
| | | | | | This would have fund a bug in a patch I am working on. llvm-svn: 330925
* Simplify. NFC.Rui Ueyama2018-04-261-9/+9
| | | | llvm-svn: 330892
* [COFF] more informative "broken object file" diagnosticsBob Haarman2018-04-251-5/+4
| | | | | | | | | | | | | | | | | | Summary: When a symbol refers to a special section or a section that doesn't exist, lld would fatal with "broken object file". This change gives a different message for each scenario, and includes the name of the file, name of the symbol, and the section being referred to. Reviewers: pcc, ruiu Reviewed By: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46090 llvm-svn: 330883
* Remove unused features from StringRefZ and move it to Symbols.h.Rui Ueyama2018-04-252-41/+22
| | | | | | Differential Revision: https://reviews.llvm.org/D46087 llvm-svn: 330879
* Pack symbols a bit more.Rafael Espindola2018-04-253-26/+36
| | | | | | | | | | | | | | | | | | | | | | | | | Before this patch: Symbol 56 Defined 80 Undefined 56 SharedSymbol 88 LazyArchive 72 LazyObject 56 With this patch Symbol 48 Defined 72 Undefined 48 SharedSymbol 80 LazyArchive 64 LazyObject 48 The result is that peak allocation when linking chromium (according to heaptrack) goes from 578 to 568 MB. llvm-svn: 330874
* Also demote lazy symbols.Rafael Espindola2018-04-253-21/+24
| | | | | | | This is not a big simplification right now, but the special cases for lazy symbols have been a common source of bugs in the past. llvm-svn: 330869
* [COFF] Don't set the tsaware bit on DLLsHans Wennborg2018-04-252-1/+6
| | | | | | | | It doesn't apply to DLLs, and link.exe doesn't set it. Differential Revision: https://reviews.llvm.org/D46077 llvm-svn: 330868
* [ELF] - Eliminate the AssertCommand.George Rimar2018-04-254-55/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, LLD supports ASSERT as a separate command. We support two forms now. Assign expression-form: . = ASSERT(0x100) (old GNU ld required it and some scripts in the wild are still using something like . = ASSERT((_end - _text <= (512 * 1024 * 1024)), "kernel image bigger than KERNEL_IMAGE_SIZE"); Nowadays above is not a mandatory form and command-like form is commonly used: ASSERT(<expr>, "text); The return value of the ASSERT is Dot. That was implemented in D30171. It looks like (2) is just a short version of (1) then. GNU ld does *not* list ASSERT as a SECTIONS command: https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS Given above we probably can change ASSERT to be an assignment to Dot. That makes the rest of the code much simpler. Patch do that. Differential revision: https://reviews.llvm.org/D45434 llvm-svn: 330814
* Bring r329960 back.Rafael Espindola2018-04-253-62/+50
| | | | | | | | | | | | | | | | | | | | The fix is to copy Used when replacing the symbol. Original message: Do not keep shared symbols created from garbage-collected eliminated DSOs. 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: 330788
* [COFF] create MemoryBuffers without requiring NUL terminatorsBob Haarman2018-04-241-3/+7
| | | | | | | | | | | | | | | | | | | | Summary: In a number of places in the COFF linker, we were calling MemoryBuffer::getFile() with default parameters. This causes LLVM to NUL-terminate the buffers, which can prevent them from being memory mapped. Since we operate on binary and do not use NUL as an indicator of the end of the file content, this change causes us to not require the NUL terminator anymore. Reviewers: ruiu, pcc Reviewed By: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45909 llvm-svn: 330786
* Style fix.Rui Ueyama2018-04-241-3/+3
| | | | llvm-svn: 330785
* Add a test. NFC.Rafael Espindola2018-04-241-0/+21
| | | | | | This would have found the issue in r329960. llvm-svn: 330784
* [WebAssembly] Match llvm-side change to reloc section headerSam Clegg2018-04-241-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D45795 llvm-svn: 330750
* [ELF] - Never use std::sort.George Rimar2018-04-244-19/+20
| | | | | | | | | | | | | | | It turns out we should not use the std::sort anymore. r327219 added a new wrapper llvm::sort (D39245). When EXPENSIVE_CHECKS is defined, it shuffles the input container and that helps to find non-deterministic ordering. Patch changes code to use llvm::sort and std::stable_sort instead of std::sort Differential revision: https://reviews.llvm.org/D45969 llvm-svn: 330702
* [ELF] - Refactor lazy symbol duplicated code.George Rimar2018-04-242-29/+25
| | | | | | | | | | | Our code for LazyObject and LazyArchive duplicates. This patch extracts the common part to remove the duplication. Differential revision: https://reviews.llvm.org/D45516 llvm-svn: 330701
* [COFF] Alias /DEBUG:FULL to /DEBUGZachary Turner2018-04-231-0/+1
| | | | | | | | | | | | | | With MSVC linker, /DEBUG is an alias of /DEBUG:FASTLINK, and if you don't want /DEBUG:FASTLINK you have to explicitly specify /DEBUG:FULL. LLD doesn't support /DEBUG:FASTLINK, and so our standard /DEBUG option is what MSVC calls /DEBUG:FULL. To provide command line compatibility with MSVC, we should also support /DEBUG:FULL, and since it's the same as what LLD already does for /DEBUG, just alias it. llvm-svn: 330647
* Remove duplicate "error:" from an error message.Rui Ueyama2018-04-233-8/+8
| | | | | | | This patch also simplifies the code a bit which wasn't committed in https://reviews.llvm.org/r330600. llvm-svn: 330644
* [PPC64] Fix toc restore nops offset for V2 ABIZaara Syeda2018-04-237-66/+122
| | | | | | | | | | The PPC64 V2 ABI restores the toc base by loading from an offset of 24 from r1. This patch fixes the offset and updates the testcases from V1 to V2. It also issues an error when a nop is missing after a call to an external function. Differential Revision: https://reviews.llvm.org/D45892 llvm-svn: 330600
* [ELF] - Simplify. NFC.George Rimar2018-04-231-5/+3
| | | | llvm-svn: 330597
* [ELF] Swap argument names: use Old to refer to original symbol and New for ↵Fangrui Song2018-04-201-4/+4
| | | | | | | | | | | | incoming one Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D45905 llvm-svn: 330491
* Fix nullptr passed to memcpy in lld/COFF/Chunks.cppBob Haarman2018-04-201-1/+2
| | | | | | | | | | | | | | | | Summary: ubsan found that we sometimes pass nullptr to memcpy in SectionChunk::writeTo(). This change adds a check that avoids that. Reviewers: ruiu Reviewed By: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45789 llvm-svn: 330490
* COFF: Document /pdbaltpath.Peter Collingbourne2018-04-201-1/+1
| | | | llvm-svn: 330488
* Use /pdbaltpath to avoid a path length dependency.Peter Collingbourne2018-04-201-3/+3
| | | | llvm-svn: 330485
* COFF: Merge .xdata into .rdata by default.Peter Collingbourne2018-04-204-28/+25
| | | | | | Differential Revision: https://reviews.llvm.org/D45804 llvm-svn: 330484
* COFF: Merge .bss into .data by default.Peter Collingbourne2018-04-206-41/+14
| | | | | | Differential Revision: https://reviews.llvm.org/D45803 llvm-svn: 330483
* Add -z {combreloc,copyreloc,noexecstack,lazy,relro,text}.Rui Ueyama2018-04-208-12/+45
| | | | | | Differential Revision: https://reviews.llvm.org/D45902 llvm-svn: 330482
* COFF: Preserve section type when processing /section flag.Peter Collingbourne2018-04-205-5/+15
| | | | | | | | It turns out that we were dropping this before. Differential Revision: https://reviews.llvm.org/D45802 llvm-svn: 330481
* COFF: Use (name, output characteristics) as a key when grouping input ↵Peter Collingbourne2018-04-206-31/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sections into output sections. This is what link.exe does and lets us avoid needing to worry about merging output characteristics while adding input sections to output sections. With this change we can't process /merge in the same way as before because sections with different output characteristics can still be merged into one another. So this change moves the processing of /merge to just before we assign addresses. In the case where there are multiple output sections with the same name, link.exe only merges the first section with the source name into the first section with the target name, and we do the same. At the same time I also implemented transitive merging (which means that /merge:.c=.b /merge:.b=.a merges both .c and .b into .a). This isn't quite enough though because link.exe has a special case for .CRT in 32-bit mode: it processes sections whose output characteristics are DATA | R | W as though the output characteristics were DATA | R (so that they get merged into things like constructor lists in the expected way). Chromium has a few such sections, and it turns out that those sections were causing the problem that resulted in r318699 (merge .xdata into .rdata) being reverted: because of the previous permission merging semantics, the .CRT sections were causing the entire .rdata section to become writable, which caused the SEH runtime to crash because it apparently requires .xdata to be read-only. This change also implements the same special case. This should unblock being able to merge .xdata into .rdata by default, as well as .bss into .data, both of which will be done in followups. Differential Revision: https://reviews.llvm.org/D45801 llvm-svn: 330479
* Under some scenarios, the current directory isn't writableSterling Augustine2018-04-201-1/+1
| | | | | | during a test. Set the output path to avoid that problem. llvm-svn: 330464
* [LLD/PDB] Remove improper assert.Zachary Turner2018-04-201-1/+0
| | | | | | | | It's possible to have an empty object file, for example if you just compile an empty .c file. This file won't have any sections so asserting that a file has chunks is definitely wrong. llvm-svn: 330461
* [LLD/PDB] Emit first section contribution for DBI Module Descriptor.Zachary Turner2018-04-202-34/+49
| | | | | | | | | | | | | | | | Part of the DBI stream is a list of variable length structures describing each module that contributes to the final executable. One member of this structure is a section contribution entry that describes the first section contribution in the output file for the given module. We have been leaving this structure unpopulated until now, so with this patch it is now filled out correctly. Differential Revision: https://reviews.llvm.org/D45832 llvm-svn: 330457
* [WebAssembly] Implement -print-gc-sections, to better test GC of globalsNicholas Wilson2018-04-206-14/+137
| | | | | | Differential Revision: https://reviews.llvm.org/D44311 llvm-svn: 330456
* [WebAssembly] Implement GC for importsNicholas Wilson2018-04-206-17/+187
| | | | | | Differential Revision: https://reviews.llvm.org/D44313 llvm-svn: 330454
* [WebAssembly] Implement --print-gc-sections for synthetic functionsNicholas Wilson2018-04-205-9/+27
| | | | | | | | | | Enables cleaning up confusion between which name variables are mangled and which are unmangled, and --print-gc-sections then excersises and tests that. Differential Revision: https://reviews.llvm.org/D44440 llvm-svn: 330449
* [ELF] --warn-backrefs: use the same GroupId for object files in the same ↵Fangrui Song2018-04-204-3/+25
| | | | | | | | | | | | --{start,end}-lib Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D45849 llvm-svn: 330443
* Fix trap instruction on pp64.Rafael Espindola2018-04-202-4/+6
| | | | | | | The test was passing on a big endian host, but just because od with x4 was compensating for it. llvm-svn: 330386
* [ELF] Increase NextGroupId with --end-groupFangrui Song2018-04-194-2/+9
| | | | | | | | | | Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D45846 llvm-svn: 330379
* [WebAssembly] Fix bug where reloc addends were written as unsignedSam Clegg2018-04-192-1/+20
| | | | | | | | | | | Relocation addends can be negative so should be written as signed LEBs. This bug meant that writing value between 64 and 128 would be incorrectly interpreted as negative by the object file readers. Differential Revision: https://reviews.llvm.org/D45825 llvm-svn: 330374
* Add a test. NFC.Rafael Espindola2018-04-191-0/+33
| | | | | | | We have relatively few tests on the contents of non alloc sections. This one would have found a bug in a patch I am working on. llvm-svn: 330369
* COFF: Remove OutputSection::getPermissions() and getCharacteristics().Peter Collingbourne2018-04-194-10/+8
| | | | | | | | All callers can just access the header directly. Differential Revision: https://reviews.llvm.org/D45800 llvm-svn: 330367
* COFF: Rename Chunk::getPermissions to getOutputCharacteristics.Peter Collingbourne2018-04-196-14/+14
| | | | | | | | | | In an upcoming change I will need to make a distinction between section type (code, data, bss) and permissions. The term that I use for both of these things is "output characteristics". Differential Revision: https://reviews.llvm.org/D45799 llvm-svn: 330361
* Define InputSection::getOffset inline.Rafael Espindola2018-04-192-2/+4
| | | | | | | This is much simpler than the other section types and there are many places where the section type is statically know. llvm-svn: 330350
* Simplify Repl handling.Rafael Espindola2018-04-192-5/+6
| | | | | | | | | | Now that we don't ICF synthetic sections, we can go back to the old logic on whose responsibility it is to check Repl. The idea is that Sec->something() will not check Repl. It is the responsibility of the caller to find the correct Sec. llvm-svn: 330346
* Simplify getOffset for synthetic sections.Rafael Espindola2018-04-194-6/+10
| | | | | | | | | | We had a single symbol using -1 with a synthetic section. It is simpler to just update its value. This is not a big will by itself, but will allow having a simple getOffset for InputSeciton. llvm-svn: 330340
* Rename MergeInputSection::getOffset.Rafael Espindola2018-04-192-6/+7
| | | | | | | Unlike the getOffset in the base class, this one computes the offset in the parent synthetic section, not the final output section. llvm-svn: 330339
* Simplify. NFC.Rafael Espindola2018-04-191-1/+3
| | | | | | | | Using getOffset is here was a bit of an overkill. This is being written and has relocations. This implies it is a .eh_frame or regular section. llvm-svn: 330307
* Don't call getOffset twice. NFC.Rafael Espindola2018-04-191-2/+3
| | | | | | Just a bit faster. llvm-svn: 330306
* [COFF] Mark images with no exception handlers for /safesehReid Kleckner2018-04-183-7/+64
| | | | | | | | | | | | | | | | | Summary: DLLs and executables with no exception handlers need to be marked with IMAGE_DLL_CHARACTERISTICS_NO_SEH, even if they have a load config. Discovered here when building Chromium with LLD on Windows: https://crbug.com/833951 Reviewers: ruiu, mstorsjo Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45778 llvm-svn: 330300
* COFF: Friendlier undefined symbol errors.Peter Collingbourne2018-04-1710-9/+315
| | | | | | | | | | | | | | | Summary: This change does three things: - Try to find the file and line number of an undefined symbol reference by reading codeview debug info. - Try to find the name of the function or global variable with the undefined symbol reference by searching the object file's symbol table. - Prints the information in the same style as the ELF linker. Differential Revision: https://reviews.llvm.org/D45467 llvm-svn: 330235
* [ELF] Add profile guided section layoutMichael J. Spencer2018-04-1713-19/+693
| | | | | | | | | | | | | | | | | This adds profile guided layout using the Call-Chain Clustering (C³) heuristic from https://research.fb.com/wp-content/uploads/2017/01/cgo2017-hfsort-final1.pdf . RFC: [llvm-dev] [RFC] Profile guided section layout http://lists.llvm.org/pipermail/llvm-dev/2017-June/114178.html Pass `--call-graph-ordering-file <file>` to read a call graph profile where each line has the format: <from symbol> <to symbol> <call count> Differential Revision: https://reviews.llvm.org/D36351 llvm-svn: 330234
OpenPOWER on IntegriCloud