summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Detemplate PhdrEntry. NFC.Rafael Espindola2016-12-191-2/+2
| | | | llvm-svn: 290115
* [ELF] Allow output section data commands to take expressionsMeador Inge2016-12-081-3/+3
| | | | | | | | | | | | The current implementation of the output section data store commands can only handle integer literals, but it should really handle arbitrary expressions [1]. This commit fixes that. [1] https://sourceware.org/binutils/docs-2.27/ld/Output-Section-Data.html#Output-Section-Data Differential Revision: https://reviews.llvm.org/D27561 llvm-svn: 289152
* Change the implementation of --dynamic-list to use linker script parsing.Rafael Espindola2016-12-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The feature is documented as ----------------------------- The format of the dynamic list is the same as the version node without scope and node name. See *note VERSION:: for more information. -------------------------------- And indeed qt uses a dynamic list with an 'extern "C++"' in it. With this patch we support that The change to gc-sections-shared makes us match bfd. Just because we kept bar doesn't mean it has to be in the dynamic symbol table. The changes to invalid-dynamic-list.test and reproduce.s are because of the new parser. The changes to version-script.s are the only case where we change behavior with regards to bfd, but I would like to see a mix of --version-script and --dynamic-list used in the wild before complicating the code. llvm-svn: 289082
* [ELF] Print file:line for unknown PHDR errorEugene Leviant2016-12-051-1/+2
| | | | | | Differential revision: https://reviews.llvm.org/D27335 llvm-svn: 288678
* [ELF] Print file:line for 'undefined section' errorsEugene Leviant2016-11-281-2/+4
| | | | | | Differential revision: https://reviews.llvm.org/D27108 llvm-svn: 288019
* Add comments.Rui Ueyama2016-11-211-1/+1
| | | | | | This patch rearranges code a bit to make it easy to explain. llvm-svn: 287515
* Change filler type from ArrayRef<uint8_t> to uint32_t.Rui Ueyama2016-11-191-2/+2
| | | | | | | Filler expressions in linker script "=fillexp" are always handled as 32-bit integers. Thus the new type is more natural. llvm-svn: 287445
* Omit empty parameter list.Rui Ueyama2016-11-181-1/+1
| | | | llvm-svn: 287324
* Allow SIZEOF() command on nonexistent section.Rui Ueyama2016-11-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | Linker script doesn't create a section if it has no content. So the following script doesn't create .norelocs section if it doesn't have any .rel* sections. .norelocs : { *(.rel*) } Later, if you assert that the size of .norelocs is 0, LLD printed out an error message, because it didn't allow calling SIZEOF() on nonexistent sections. This patch allows SIZEOF() on nonexistent sections, so that you can do something like this. ASSERT(SIZEOF(.norelocs), "shouldn't contain .rel sections!") Note that this behavior is compatible with GNU. Differential Revision: https://reviews.llvm.org/D26810 llvm-svn: 287257
* [ELF] Add Section() to expression objectEugene Leviant2016-11-161-11/+14
| | | | | | | | | This allows making symbols containing ADDR(section) synthetic, and defining synthetic symbols outside SECTIONS block. Differential revision: https://reviews.llvm.org/D25441 llvm-svn: 287090
* Fix program header propagation.Rafael Espindola2016-11-141-0/+1
| | | | | | | | | | Propagate program headers by walking the commands, not the sections. This allows us to propagate program headers even from sections that don't end up in the output. Fixes pr30997. llvm-svn: 286837
* Factor out removeEmptyCommands. NFC.Rafael Espindola2016-11-141-0/+1
| | | | llvm-svn: 286826
* Factor out placeOrphanSections. NFC.Rafael Espindola2016-11-141-0/+1
| | | | llvm-svn: 286824
* Make OutputSectionBase a class instead of class template.Rafael Espindola2016-11-091-5/+5
| | | | | | | | The disadvantage is that we use uint64_t instad of uint32_t for some value in 32 bit files. The advantage is a substantially simpler code, faster builds and less code duplication. llvm-svn: 286414
* Create a vector containing all input sections.Rui Ueyama2016-11-051-1/+1
| | | | | | | | | | | | | | | | Previously, we do this piece of code to iterate over all input sections. for (elf::ObjectFile<ELFT> *F : Symtab.getObjectFiles()) for (InputSectionBase<ELFT> *S : F->getSections()) It turned out that this mechanisms doesn't work well with synthetic input sections because synthetic input sections don't belong to any input file. This patch defines a vector that contains all input sections including synthetic ones. llvm-svn: 286051
* Fix some Clang-tidy modernize-use-default and Include What You Use warnings; ↵Eugene Zelenko2016-11-051-7/+23
| | | | | | | | other minor fixes. Differential revision: https://reviews.llvm.org/D26320 llvm-svn: 286030
* Add [<chars>] to the glob matcher to eliminate use of llvm::Regex.Rui Ueyama2016-11-031-15/+7
| | | | | | | | | | | | | Previously, it didn't support the character class, so we couldn't eliminate the use fo llvm::Regex. Now that it is supported, we can remove compileGlobPattern, which converts a glob pattern to a regex. This patch contains optimization for exact/prefix/suffix matches. Differential Revision: https://reviews.llvm.org/D26284 llvm-svn: 285949
* Use globMatch() instead of llvm::regex in linker scriptsEugene Leviant2016-11-031-9/+7
| | | | | | | | | This can speed up lld up to 5 times when linking applications with large number of sections and using linker script. Differential revision: https://reviews.llvm.org/D26241 llvm-svn: 285895
* The expr '.' is not absolute.Rafael Espindola2016-10-311-6/+2
| | | | | | | | | | | | | | With this patch we keep track of the fact that . is a position in the file and therefore not absolute. This allow us to compute relative relocations that involve symbol that are defined in linker scripts with '.'. This fixes https://llvm.org/bugs/show_bug.cgi?id=30406 There is still more work to track absoluteness over the various expressions, but this should unblock linking the EFI bootloader. llvm-svn: 285641
* Delay computation of IsAbsolute.Rafael Espindola2016-10-311-2/+8
| | | | | | | | | | We parse linker scripts very early, but whether an expression is absolute or not can depend on a symbol defined in a .o. Given that, we have to delay the computation of IsAbsolute. We can do that by storing an AST when parsing or by also making IsAbsolute a function like we do for the expression value. This patch implements the second option. llvm-svn: 285628
* Move IsAbsolute from SymbolAssignment to Expr.Rafael Espindola2016-10-311-5/+13
| | | | | | | | | And as a token of the new feature, make ALIGNOF always absolute. This is a step in making it possible to have non absolute symbols out of output sections. llvm-svn: 285608
* Consolidate BumpPtrAllocators.Rui Ueyama2016-10-281-2/+0
| | | | | | | | | | | Previously, we have a lot of BumpPtrAllocators, but all these allocators virtually have the same lifetime because they are not freed until the linker finishes its job. This patch aggregates them into a single allocator. Differential revision: https://reviews.llvm.org/D26042 llvm-svn: 285452
* Improve comments.Rui Ueyama2016-10-131-4/+11
| | | | llvm-svn: 284177
* [ELF] Linker script: implement LOADADDREugene Leviant2016-10-061-2/+5
| | | | | | Differential revision: https://reviews.llvm.org/D24298 llvm-svn: 283429
* [ELF] make KEEP command recognize file patternsEugene Leviant2016-10-051-1/+1
| | | | | | Differential revision: https://reviews.llvm.org/D25242 llvm-svn: 283305
* Don't error if we can't put the header in a PT_LOAD.Rafael Espindola2016-09-291-1/+1
| | | | | | | | | | If there is not sufficient address space, just give up and don't put the header in the PT_LOAD. This matches bfd behaviour and I found at least one script that depends on having a section at address 0. llvm-svn: 282750
* [ELF] - Linkerscript: implemented BYTE/SHORT/LONG/QUAD commands.George Rimar2016-09-261-2/+13
| | | | | | | | | | | | | | | | | | | The BYTE, SHORT, LONG, and QUAD commands store one, two, four, and eight bytes (respectively). After storing the bytes, the location counter is incremented by the number of bytes stored. Previously our scripts handles these commands incorrectly. For example: SECTIONS { .foo : { *(.foo.1) BYTE(0x11) ... We accepted the script above treating BYTE as input section description. These commands are used in the wild though. Differential revision: https://reviews.llvm.org/D24830 llvm-svn: 282429
* [ELF] - Linkerscript: implement DEFINED() command.George Rimar2016-09-231-0/+2
| | | | | | | | | | | | DEFINED(symbol) Return 1 if symbol is in the linker global symbol table and is defined before the statement using DEFINED in the script, otherwise return 0. Can be used to define default values for symbols. Found it in the wild. Differential revision: https://reviews.llvm.org/D24858 llvm-svn: 282245
* Handle empty sections with symbol assignments.Rafael Espindola2016-09-221-0/+1
| | | | | | Before the symbols were becoming undefined. llvm-svn: 282159
* [ELF] - Linkerscript: support complex section pattern grammar.George Rimar2016-09-211-2/+5
| | | | | | | | | | | | | | | | | | | | | | | This is PR30442. Previously we were failed to parce complex expressions like: foo : { *(SORT_BY_NAME(bar) zed) } Main idea of patch that globs and excludes can be wrapped in a SORT. There is a difference in semanics of ld/gold: ld likes: *(SORT(EXCLUDE_FILE (*file1.o) .foo.1)) gold likes: *(EXCLUDE_FILE (*file1.o) SORT(.foo.1)) Patch implements ld grammar, complex expressions like next is not a problem anymore: .abc : { *(SORT(.foo.* EXCLUDE_FILE (*file1.o) .bar.*) .bar.*) } Differential revision: https://reviews.llvm.org/D24758 llvm-svn: 282078
* Revert "Revert "Only restrict order if both sections are in the script.""Rafael Espindola2016-09-201-2/+2
| | | | | | | | | | | | | | | | | | | This reverts commit r282021, bringing back r282015. The problem was that the comparison function was not a strict weak ordering anymore, which this patch fixes. Original message: Only restrict order if both sections are in the script. This matches gold and bfd behavior and is required to handle some scripts. The script has to assume where PT_LOADs start in order to align that spot. If we don't allow section it doesn't know about to move to the middle, we can need more PT_LOADs and those will not be aligned. llvm-svn: 282035
* Remove a use of std::list.Rui Ueyama2016-09-201-4/+10
| | | | llvm-svn: 281951
* [ELF] - Fixed mistypes in comments. NFC.George Rimar2016-09-171-2/+2
| | | | llvm-svn: 281817
* Attempt to fix buildbot.Rui Ueyama2016-09-171-2/+5
| | | | llvm-svn: 281805
* Use named struct instead of unnamed std::pair.Rui Ueyama2016-09-171-1/+10
| | | | | | It is important to give members names for readability. llvm-svn: 281803
* Rename SortSectionPolicy::IgnoreConfig to None.Rui Ueyama2016-09-161-2/+2
| | | | | | Because it corresponds to SORT_NONE. None was renamed Default. llvm-svn: 281776
* Fix constraint checking in ONLY_IF_RO.Rafael Espindola2016-09-161-2/+1
| | | | | | We have to look at all the relevant input sections at once. llvm-svn: 281772
* [ELF] - Implemented --sort-section cmd line option and SORT_NONE script command.George Rimar2016-09-161-4/+3
| | | | | | | | | | | | | | | | This fixes Bug 30385 - SORT_NONE not implemented, `SORT_NONE' disables section sorting by ignoring the command line section sorting option. That is why this patch also implements --sort-section option. Description of sorting rules available at https://sourceware.org/binutils/docs/ld/Input-Section-Wildcards.html Differential revision: https://reviews.llvm.org/D24604 llvm-svn: 281771
* Recommit r281721 "[ELF] - Linkerscript: implement EXCLUDE_FILE in the middle ↵George Rimar2016-09-161-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of a input section description." With fix for 2 bots. Details about the fix performed is on a review page. Initial commit message: This is PR30387: From PR description: We fail to parse SECTIONS { foo : { *(sec0 EXCLUDE_FILE (zed1.o) sec1 EXCLUDE_FILE (zed2.o) sec2 ) } } The semantics according to bfd are: Include sec1 from every file but zed1.o Include sec2 from every file but zed2.o Include sec0 from every file Patch implements the support. Differential revision: https://reviews.llvm.org/D24650 llvm-svn: 281754
* Improve handling ASSERT outside SECTIONS blockEugene Leviant2016-09-161-3/+3
| | | | | | Differential revision: https://reviews.llvm.org/D24450 llvm-svn: 281740
* Change how we compute offsets with linker scripts.Rafael Espindola2016-09-161-3/+14
| | | | | | | | | | | | This fixes pr30367, but more importantly, it changes how we compute offsets. Now offset computation in a walk over linker script commands, like the rest of assignAddresses. IMHO this is simpler to understand and if we ever have to create multiple outputsections or chunks to change how we handle test/ELF/linkerscript/alternate-sections.s it should be easier to do it. llvm-svn: 281736
* Reverted r281721 ("[ELF] - Linkerscript: implement EXCLUDE_FILE in the ↵George Rimar2016-09-161-2/+2
| | | | | | | | | middle of a input section description."). It broke build bot: http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/27508 llvm-svn: 281723
* [ELF] - Linkerscript: implement EXCLUDE_FILE in the middle of a input ↵George Rimar2016-09-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | section description. This is PR30387: From PR description: We fail to parse SECTIONS { foo : { *(sec0 EXCLUDE_FILE (zed1.o) sec1 EXCLUDE_FILE (zed2.o) sec2 ) } } The semantics according to bfd are: Include sec1 from every file but zed1.o Include sec2 from every file but zed2.o Include sec0 from every file Patch implements the support. Differential revision: https://reviews.llvm.org/D24650 llvm-svn: 281721
* [ELF] - Linkerscript: implemented SORT_BY_INIT_PRIORITY.George Rimar2016-09-151-1/+1
| | | | | | | | | | | This is PR30386, SORT_BY_INIT_PRIORITY is a keyword can be used to sort sections by numerical value of the GCC init_priority attribute encoded in the section name. Differential revision: https://reviews.llvm.org/D24611 llvm-svn: 281646
* [ELF] Replace HasContents with HasSections. NFCEugene Leviant2016-09-141-1/+1
| | | | llvm-svn: 281449
* Simplify handling of /DISCARD/. NFC.Rafael Espindola2016-09-121-1/+1
| | | | llvm-svn: 281222
* Linker script: implement AT [ (address) ] for PHDREugene Leviant2016-09-091-0/+1
| | | | | | Differential revision: https://reviews.llvm.org/D24340 llvm-svn: 281024
* Use a protected destructor instead of a virtual one.Rafael Espindola2016-09-081-1/+3
| | | | llvm-svn: 280941
* [ELF] - Add virtual destructor to LinkerScriptBase class. NFC.George Rimar2016-09-081-0/+1
| | | | | | | | | | Absence of it caused a clang warning: warning: 'lld::elf::LinkerScriptBase' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor] At fact we don't need it here because do not destroy this object by base pointer. llvm-svn: 280916
* Linker script: implement ALIGNOFEugene Leviant2016-09-081-0/+2
| | | | | | Differential revision: https://reviews.llvm.org/D24141 llvm-svn: 280915
OpenPOWER on IntegriCloud