summaryrefslogtreecommitdiffstats
path: root/lld/ELF/MapFile.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make it possible to redirect not only errs() but also outs()Rui Ueyama2019-11-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change is for those who use lld as a library. Context: https://reviews.llvm.org/D70287 This patch adds a new parmeter to lld::*::link() so that we can pass an raw_ostream object representing stdout. Previously, lld::*::link() took only an stderr object. Justification for making stdoutOS and stderrOS mandatory: I wanted to make link() functions to take stdout and stderr in that order. However, if we change the function signature from bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stderrOS = llvm::errs()); to bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS = llvm::outs(), raw_ostream &stderrOS = llvm::errs()); , then the meaning of existing code that passes stderrOS silently changes (stderrOS would be interpreted as stdoutOS). So, I chose to make existing code not to compile, so that developers can fix their code. Differential Revision: https://reviews.llvm.org/D70292
* [ELF] Wrap things in `namespace lld { namespace elf {`, NFCFangrui Song2019-10-071-5/+7
| | | | | | | | | | | This makes it clear `ELF/**/*.cpp` files define things in the `lld::elf` namespace and simplifies `elf::foo` to `foo`. Reviewed By: atanasyan, grimar, ruiu Differential Revision: https://reviews.llvm.org/D68323 llvm-svn: 373885
* Fight a bit against global initializers. NFC.Benjamin Kramer2019-08-221-2/+2
| | | | llvm-svn: 369695
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-1/+1
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* [Coding style change] Rename variables so that they start with a lowercase ↵Rui Ueyama2019-07-101-112/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | letter This patch is mechanically generated by clang-llvm-rename tool that I wrote using Clang Refactoring Engine just for creating this patch. You can see the source code of the tool at https://reviews.llvm.org/D64123. There's no manual post-processing; you can generate the same patch by re-running the tool against lld's code base. Here is the main discussion thread to change the LLVM coding style: https://lists.llvm.org/pipermail/llvm-dev/2019-February/130083.html In the discussion thread, I proposed we use lld as a testbed for variable naming scheme change, and this patch does that. I chose to rename variables so that they are in camelCase, just because that is a minimal change to make variables to start with a lowercase letter. Note to downstream patch maintainers: if you are maintaining a downstream lld repo, just rebasing ahead of this commit would cause massive merge conflicts because this patch essentially changes every line in the lld subdirectory. But there's a remedy. clang-llvm-rename tool is a batch tool, so you can rename variables in your downstream repo with the tool. Given that, here is how to rebase your repo to a commit after the mass renaming: 1. rebase to the commit just before the mass variable renaming, 2. apply the tool to your downstream repo to mass-rename variables locally, and 3. rebase again to the head. Most changes made by the tool should be identical for a downstream repo and for the head, so at the step 3, almost all changes should be merged and disappear. I'd expect that there would be some lines that you need to merge by hand, but that shouldn't be too many. Differential Revision: https://reviews.llvm.org/D64121 llvm-svn: 365595
* ELF: Add basic partition data structures and behaviours.Peter Collingbourne2019-05-291-2/+2
| | | | | | | | | | | | | | This change causes us to read partition specifications from partition specification sections and split output sections into partitions according to their reachability from partition entry points. This is only the first step towards a full implementation of partitions. Later changes will add additional synthetic sections to each partition so that they can be loaded independently. Differential Revision: https://reviews.llvm.org/D60353 llvm-svn: 361925
* ELF: Remove a comparison against In.EhFrame. NFCI.Peter Collingbourne2019-05-231-4/+5
| | | | | | | | This won't work once we have multiple .eh_frame sections. Differential Revision: https://reviews.llvm.org/D62280 llvm-svn: 361556
* Use llvm::stable_sortFangrui Song2019-04-231-4/+2
| | | | | | | | | Make some small adjustment while touching the code: make parameters const, use less_first(), etc. Differential Revision: https://reviews.llvm.org/D60989 llvm-svn: 358943
* Replace `typedef A B` with `using B = A`. NFC.Rui Ueyama2019-04-011-1/+1
| | | | | | | | I did this using Perl. Differential Revision: https://reviews.llvm.org/D60003 llvm-svn: 357372
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [ELF] - (-Map file) Implement printing of LMA for assignments outside of ↵George Rimar2018-12-061-3/+4
| | | | | | | | | | | | | section declarations. This was a missing piece. We started to print LMAs and information about assignments, but did not do that for assignments outside of section declarations yet. The patch implements it. Differential revision: https://reviews.llvm.org/D45314 llvm-svn: 348468
* Reset input section pointers to null on each linker invocation.Rui Ueyama2018-09-251-2/+2
| | | | | | | | | | 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
* [ELF] - Change dyn_cast to cast. NFC.George Rimar2018-07-021-1/+1
| | | | | | | | This is followup for r335958. Thanks to Rui for noticing. llvm-svn: 336082
* [ELF] - Remove dead code.George Rimar2018-06-291-3/+0
| | | | | | | | | | | | I do not think this code was ever alive, because the following code says we can have OutputSection and SymbolAssignment cases only. We already handle both of them. https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L502 FWIW, it is dead in the LLD code coverage reports I am running either. llvm-svn: 335958
* Replace SharedSymbols with Defined when creating copy relocations.Rafael Espindola2018-04-261-29/+14
| | | | | | | | | | | | | 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
* [ELF] - Never use std::sort.George Rimar2018-04-241-2/+3
| | | | | | | | | | | | | | | 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
* 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
* [ELF] - Reveal more information in -Map file about assignments.George Rimar2018-04-051-2/+16
| | | | | | | | | | | | | | | | | 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-051-11/+18
| | | | | | | | | | 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
* Do not show alignment 0 because that is equivalent to 1.Rui Ueyama2018-04-041-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D44991 llvm-svn: 329233
* [ELF] - Cleanup. NFCI.George Rimar2018-04-041-1/+1
| | | | | | | | | Rename field, added comments. This is splitted from the D44894. Requested to be committed as independent cleanup. llvm-svn: 329162
* Add a SectionBase::getVA helper. NFC.Rafael Espindola2018-03-241-2/+1
| | | | | | There were a few too many places duplicating this. llvm-svn: 328402
* [ELF] - Show data and assignment commands in the map file.George Rimar2018-03-151-7/+25
| | | | | | | | | Patch teaches LLD to print BYTE/SHORT/LONG/QUAD and location move commands to the map file. Differential revision: https://reviews.llvm.org/D44004 llvm-svn: 327612
* [ELF] Add .eh_frame pieces to map fileRui Ueyama2018-03-141-0/+42
| | | | | | | | | This patch is a simplified version of https://reviews.llvm.org/D42960 written by Andrew Ng. Differential Revision: https://reviews.llvm.org/D44168 llvm-svn: 327574
* Implement --cref.Rui Ueyama2018-03-141-0/+49
| | | | | | | | | | | | | | This is an option to print out a table of symbols and filenames. The output format of this option is the same as GNU, so that it can be processed by the same scripts as before after migrating from GNU to lld. This option is mildly useful; we can live without it. But it is pretty convenient sometimes, and it can be implemented in 50 lines of code, so I think lld should support this option. Differential Revision: https://reviews.llvm.org/D44336 llvm-svn: 327565
* Rename Indent{1,2} -> Indent{8,16}.Rui Ueyama2018-03-071-4/+4
| | | | llvm-svn: 326912
* Do not create temporary strings just to print out spaces. NFC.Rui Ueyama2018-03-061-4/+5
| | | | llvm-svn: 326841
* Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.Rui Ueyama2018-02-281-1/+1
| | | | | | | | | This should resolve the issue that lld build fails in some hosts that uses case-insensitive file system. Differential Revision: https://reviews.llvm.org/D43788 llvm-svn: 326339
* [ELF] - Introduce getInputSections() helper.George Rimar2018-02-221-11/+5
| | | | | | | | | | | We sometimes need to iterate over input sections for a given output section. It is not very convinent because we have to iterate over section descriptions. Patch introduces getInputSections helper, it simplifies things. Differential revision: https://reviews.llvm.org/D43574 llvm-svn: 325763
* Remove some includes from InputFiles.h.Rafael Espindola2017-12-091-0/+1
| | | | | | | They were not used in InputFiles.h and it was getting too easy to add circular includes. llvm-svn: 320256
* [ELF] - Show .plt symbols in -Map output.George Rimar2017-12-061-3/+9
| | | | | | | | | | As mentioned in PR35471, shared functions for which .plt entry address is used shows up in bfd's map files. Patch teaches LLD to do the same. Differential revision: https://reviews.llvm.org/D40839 llvm-svn: 319879
* Recommit r319747 "[ELF] - Show copy relocated symbols in a --Map file output."George Rimar2017-12-051-16/+25
| | | | | | | | | | | | | | | With fix: Specify -soname for input dso to fix up the .dynstr section size in different environments. Original commit message: As mentioned in PR35471, copied symbols did not show in --Map output. Patch fixes that. Differential revision: https://reviews.llvm.org/D40785 llvm-svn: 319769
* [ELF] - Revert r319747 "[ELF] - Show copy relocated symbols in a --Map file ↵George Rimar2017-12-051-25/+16
| | | | | | | | | | | | | | output.". It broke bots: http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/15570/steps/test_lld/logs/stdio http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/10930/steps/check-lld%20asan/logs/stdio http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/16336/steps/test%20lld/logs/stdio According to outputs, .dynstr section has different sizes for some reason. llvm-svn: 319749
* [ELF] - Show copy relocated symbols in a --Map file output.George Rimar2017-12-051-16/+25
| | | | | | | | | As mentioned in PR35471, copied symbols did not show in --Map output. Patch fixes that. Differential revision: https://reviews.llvm.org/D40785 llvm-svn: 319747
* Use Symbol::File directly.Rafael Espindola2017-11-291-1/+1
| | | | | | | We are already paying the cost of storing a InputFile in every Symbol, so use it uniformly. llvm-svn: 319378
* Simplify. NFC.Rafael Espindola2017-11-291-2/+1
| | | | llvm-svn: 319370
* ELF: Merge DefinedRegular and Defined.Peter Collingbourne2017-11-061-2/+2
| | | | | | | | | Now that DefinedRegular is the only remaining derived class of Defined, we can merge the two classes. Differential Revision: https://reviews.llvm.org/D39667 llvm-svn: 317448
* Rename SymbolBody -> SymbolRui Ueyama2017-11-031-1/+1
| | | | | | | | | | | | | Now that we have only SymbolBody as the symbol class. So, "SymbolBody" is a bit strange name now. This is a mechanical change generated by perl -i -pe s/SymbolBody/Symbol/g $(git grep -l SymbolBody lld/ELF lld/COFF) nd clang-format-diff. Differential Revision: https://reviews.llvm.org/D39459 llvm-svn: 317370
* Do not handle DefinedCommon symbols in the MapFile writer.Rui Ueyama2017-10-281-15/+4
| | | | | | | | Because of r314495 which converts DefinedCommon symbols to DefinedRegular symbols, common symbols are no longer reachable to the MapFile writer. So the code to handle common symbols is now dead. llvm-svn: 316846
* Pass symbol attributes instead of ElfSym to Shared symbol ctor.Rui Ueyama2017-10-281-12/+6
| | | | | | | This change allows us to use less templates for Shared symbol and the functions that deals with shared symbols. llvm-svn: 316841
* [lld] Move Threads to CommonBob Haarman2017-10-131-1/+2
| | | | | | | | | | | | | | | | Summary: This will allow using the functionality from other linkers. It is also a prerequisite for sharing the error logging code. Reviewers: ruiu Reviewed By: ruiu Subscribers: emaste, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D38822 llvm-svn: 315725
* Rename Commands -> SectionCommands.Rui Ueyama2017-10-111-1/+1
| | | | | | | | | | "Commands" was ambiguous because in the linker script, everything is a command. We used to handle only SECTIONS commands, and at the time, it might make sense to call them the commands, but it is no longer the case. We handle not only SECTIONS but also MEMORY, PHDRS, VERSION, etc., and they are all commands. llvm-svn: 315409
* [ELF] - Introduce std::vector<InputFile *> global arrays.George Rimar2017-09-191-1/+1
| | | | | | | | | | | | This patch removes lot of static Instances arrays from different input file classes and introduces global arrays for access instead. Similar to arrays we have for InputSections/OutputSectionCommands. It allows to iterate over input files in a non-templated code. Differential revision: https://reviews.llvm.org/D35987 llvm-svn: 313619
* Currently lld creates a single section to collect all commons. There is no wayDmitry Mikulin2017-09-081-3/+3
| | | | | | | | | | | | | | | to separate commons based on file name patterns. The following linker script construct does not work because commons are allocated before section placement is done and the only synthesized BssSection that holds all commons has no file associated with it: SECTIONS { .common_0 : { *file0.o(COMMON) }} This patch changes the allocation of commons to create a section per common symbol and let the section logic do the layout. Differential revision: https://reviews.llvm.org/D37489 llvm-svn: 312796
* [ELF] - Fixing buildbot.George Rimar2017-08-111-1/+1
| | | | | | http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/11517/steps/build_Lld/logs/stdio llvm-svn: 310705
* [ELF] - Do not omit common symbols when -Map is given.George Rimar2017-08-111-20/+29
| | | | | | | | | | | This is PR33886, previously we did not output common symbols to map, patch fixes that. Differential revision: https://reviews.llvm.org/D36466 llvm-svn: 310703
* Move File from SymbolBody to Symbol.Rafael Espindola2017-08-041-1/+1
| | | | | | | | | | | | | With this Symbol has the same size as before, but DefinedRegular goes from 72 to 64 bytes. I also find this a bit easier to read. There are fewer places initializing File for example. This has a small but measurable speed improvement on all tests (1% max). llvm-svn: 310142
* Simplify. NFC.Rafael Espindola2017-08-041-4/+4
| | | | llvm-svn: 310090
* [ELF] - Cleanup MapFile.cpp. NFC.George Rimar2017-07-281-12/+9
| | | | | | | * Removed redundant templating. * Added missing `static` keyword. llvm-svn: 309376
OpenPOWER on IntegriCloud