summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a comment. NFC.Rafael Espindola2018-04-261-0/+5
| | | | llvm-svn: 330967
* Replace SharedSymbols with Defined when creating copy relocations.Rafael Espindola2018-04-268-81/+63
| | | | | | | | | | | | | This is slightly simpler to read IMHO. Now if a symbol has a position in the file, it is Defined. The main motivation is that with this a SharedSymbol doesn't need a section, which reduces the size of SymbolUnion. With this the peak allocation when linking chromium goes from 568.1 to 564.2 MB. llvm-svn: 330966
* Simplify processRelocAux.Rafael Espindola2018-04-261-17/+19
| | | | | | | | | | | It returns a different Expr only in the case of creating a function symbol pointing to its plt entry. We can just add a call to addPltEntry to avoid that and return void. With this patch further simplifications of how we handle copy relocations are possible. llvm-svn: 330960
* Delete GotPltIndex.Rafael Espindola2018-04-263-4/+5
| | | | | | | | | It was always an offset of PltIndex. This doesn't reduce the size of the structures, but makes it easier to do so in a followup patch. llvm-svn: 330953
* Simplify. NFC.Rui Ueyama2018-04-261-9/+9
| | | | llvm-svn: 330892
* Remove unused features from StringRefZ and move it to Symbols.h.Rui Ueyama2018-04-251-8/+22
| | | | | | Differential Revision: https://reviews.llvm.org/D46087 llvm-svn: 330879
* Pack symbols a bit more.Rafael Espindola2018-04-252-26/+33
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ELF] - Eliminate the AssertCommand.George Rimar2018-04-253-52/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-251-0/+18
| | | | | | | | | | | | | | | | | | | | 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
* [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
* Remove duplicate "error:" from an error message.Rui Ueyama2018-04-231-6/+6
| | | | | | | 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-231-2/+6
| | | | | | | | | | 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
* Add -z {combreloc,copyreloc,noexecstack,lazy,relro,text}.Rui Ueyama2018-04-203-8/+19
| | | | | | Differential Revision: https://reviews.llvm.org/D45902 llvm-svn: 330482
* [ELF] --warn-backrefs: use the same GroupId for object files in the same ↵Fangrui Song2018-04-202-3/+12
| | | | | | | | | | | | --{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-201-1/+2
| | | | | | | 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-193-2/+4
| | | | | | | | | | Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D45846 llvm-svn: 330379
* 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
* [ELF] Add profile guided section layoutMichael J. Spencer2018-04-179-19/+355
| | | | | | | | | | | | | | | | | 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
* Revert r329960 "Do not keep shared symbols created from garbage-collected ↵Reid Kleckner2018-04-161-13/+0
| | | | | | | | | | 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
* 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-132-2/+15
| | | | | | | | | | | | | | 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-121-0/+13
| | | | | | | | | | | | | | 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
* Remove references to old SymbolBody classSam Clegg2018-04-111-2/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D45400 llvm-svn: 329846
* [ELF] - Reorder local symbols.George Rimar2018-04-112-7/+26
| | | | | | | | | | | 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-101-1/+4
| | | | | | Based on a patch for the ICF warning by Rui. llvm-svn: 329757
* s/LLVM_ON_WIN32/_WIN32/, lldNico Weber2018-04-101-1/+1
| | | | | | | | | | | 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-101-4/+4
| | | | | | | | | Currently, we crash because File is null for such symbols. Differential revision: https://reviews.llvm.org/D45440 llvm-svn: 329678
* Add --warn-backrefs to maintain compatibility with other linkersRui Ueyama2018-04-097-23/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Added support for LTO options: sample_profile, new_pass_manager and ↵Rumeet Dhindsa2018-04-094-0/+23
| | | | | | | | debug_pass_manager Differential Revision: https://reviews.llvm.org/D45275 llvm-svn: 329598
* [ELF] - Stop setting OutSecOff too early.George Rimar2018-04-093-8/+16
| | | | | | | | | | | | | | | | | | | | | | | 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] - Allow LLD to produce file symbols.George Rimar2018-04-091-1/+1
| | | | | | | | | | | | | 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
* 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
* Change which file we print when a symbol cannot be ordered.Rafael Espindola2018-04-061-26/+34
| | | | | | | | | | | | 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
* Don't ignore addend when a SHF_MERGE section is dead.Rafael Espindola2018-04-062-6/+2
| | | | | | | | 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
* Make "Size" column in the map file one characters shorter.Rui Ueyama2018-04-051-4/+4
| | | | | | | | | 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-051-4/+6
| | | | | | Size can be narrow, but LMA should be the same width as VMA. llvm-svn: 329312
* Initialize OutputOff to zero.Rafael Espindola2018-04-051-1/+1
| | | | | | | 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-051-1/+1
| | | | | | 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-054-20/+33
| | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud