summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - Linkerscript: implemented SORT_BY_INIT_PRIORITY.George Rimar2016-09-151-0/+8
| | | | | | | | | | | 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
* Check the return of getInteger.Rafael Espindola2016-09-151-1/+2
| | | | llvm-svn: 281608
* Handle arbitrary expressions in DATA_SEGMENT_RELRO_END.Rafael Espindola2016-09-141-1/+1
| | | | llvm-svn: 281521
* Move helper function higher in the file. NFCRafael Espindola2016-09-141-26/+26
| | | | | | This just makes a followup patch easier to read. llvm-svn: 281482
* [ELF] Replace HasContents with HasSections. NFCEugene Leviant2016-09-141-2/+2
| | | | llvm-svn: 281449
* Simplify InputFile ownership management.Rui Ueyama2016-09-141-5/+2
| | | | | | | | | | | | | | | | | | | | Previously, all input files were owned by the symbol table. Files were created at various places, such as the Driver, the lazy symbols, or the bitcode compiler, and the ownership of new files was transferred to the symbol table using std::unique_ptr. All input files were then free'd when the symbol table is freed which is on program exit. I think we don't have to transfer ownership just to free all instance at once on exit. In this patch, all instances are automatically collected to a vector and freed on exit. In this way, we no longer have to use std::unique_ptr. Differential Revision: https://reviews.llvm.org/D24493 llvm-svn: 281425
* Enable merging of SHF_MERGE sections with linker scripts.Rafael Espindola2016-09-131-1/+32
| | | | | | | | | This also fixes the related problem of non SHF_MERGE sections with different flags not being merged. Fixes pr30355. llvm-svn: 281338
* Refactor duplicated code. NFC.Rafael Espindola2016-09-131-11/+11
| | | | llvm-svn: 281329
* Delete dead code.Rafael Espindola2016-09-131-3/+0
| | | | | | We already handle this is createSections. llvm-svn: 281320
* Simplify handling of /DISCARD/. NFC.Rafael Espindola2016-09-121-10/+7
| | | | llvm-svn: 281222
* Recommit [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.George Rimar2016-09-091-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed code that was not checked before on windows for me, because of testcases that are disabled on that platform atm. Inital commit message: "[ELF] - Versionscript: do not treat non-wildcarded names as wildcards." Previously we incorrectly handled cases when symbol name in extern c++ tag was enclosed in quotes. Next case was treated as wildcard: GLIBCXX_3.4 { extern "C++" { "aaa*" } But it should have not. Quotes around aaa here means that we should have do exact name matching. That is PR30268 which has name with pointer is interpreted as wildcard by lld: extern "C++" { "operator delete[](void*)"; Patch fixes the issue. Differential revision: https://reviews.llvm.org/D24229 llvm-svn: 281049
* Revert r281045, it broke BB.George Rimar2016-09-091-15/+8
| | | | | | | Broken BB: http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/27211 llvm-svn: 281046
* Recommit [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.George Rimar2016-09-091-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed code that was not checked by testcases that are disabled on windows. Inital commit message: "[ELF] - Versionscript: do not treat non-wildcarded names as wildcards." Previously we incorrectly handled cases when symbol name in extern c++ tag was enclosed in quotes. Next case was treated as wildcard: GLIBCXX_3.4 { extern "C++" { "aaa*" } But it should have not. Quotes around aaa here means that we should have do exact name matching. That is PR30268 which has name with pointer is interpreted as wildcard by lld: extern "C++" { "operator delete[](void*)"; Patch fixes the issue. Differential revision: https://reviews.llvm.org/D24229 llvm-svn: 281045
* [ELF] - Revert r281038 to see if that unbreaks build bot.George Rimar2016-09-091-13/+6
| | | | | | http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/19703 llvm-svn: 281041
* [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.George Rimar2016-09-091-6/+13
| | | | | | | | | | | | | | | | | | | | | | Previously we incorrectly handled cases when symbol name in extern c++ tag was enclosed in quotes. Next case was treated as wildcard: GLIBCXX_3.4 { extern "C++" { "aaa*" } But it should have not. Quotes around aaa here means that we should have do exact name matching. That is PR30268 which has name with pointer is interpreted as wildcard by lld: extern "C++" { "operator delete[](void*)"; Patch fixes the issue. Differential revision: https://reviews.llvm.org/D24229 llvm-svn: 281038
* Linker script: implement AT [ (address) ] for PHDREugene Leviant2016-09-091-1/+9
| | | | | | Differential revision: https://reviews.llvm.org/D24340 llvm-svn: 281024
* Fix bug in -nostdlib.Rui Ueyama2016-09-081-1/+2
| | | | | | | We still have to skip a token inside SEARCH_DIR() when -nostdlib is specified. Previuosly, we didn't skip it, so it caused a parse error. llvm-svn: 281001
* Reduce templating. NFC.Rafael Espindola2016-09-081-11/+7
| | | | llvm-svn: 280986
* Compute section names only once.Rafael Espindola2016-09-081-3/+3
| | | | | | | | This simplifies error handling as there is now only one place in the code that needs to consider the possibility that the name is corrupted. Before we would do it in every access. llvm-svn: 280937
* Linker script: implement ALIGNOFEugene Leviant2016-09-081-0/+16
| | | | | | Differential revision: https://reviews.llvm.org/D24141 llvm-svn: 280915
* [ELF] - Apply clang-format to LinkerScript.cpp, NFC.George Rimar2016-09-081-17/+15
| | | | llvm-svn: 280911
* [ELF] - Linkerscript: simplify access to templated methods from parser.George Rimar2016-09-081-76/+16
| | | | | | | | | Previous way of accessing templated methods was a bit bulky, Patch introduces small interface based solution. Differential revision: https://reviews.llvm.org/D23872 llvm-svn: 280910
* [ELF] - Linkerscript: create multiple output sections for inputs with ↵George Rimar2016-09-071-40/+40
| | | | | | | | | | | | | | | different attributes. Previously we combined sections by name if linkerscript was used. For that we had to disable SHF_MERGE handling temporarily, but then found that implementing it properly will require additional complexity layers like subsections or something. At the same time looks we can live with multiple output sections approach for now. That patch do this change. Differential revision: https://reviews.llvm.org/D24127 llvm-svn: 280801
* Support ABSOLUE keyword in symbol assignmentsEugene Leviant2016-09-071-22/+47
| | | | | | | | | | | | This patch allows making section defined symbols absolute: .foo : { begin_foo = ABSOLUTE(.); *(.foo) } Differential revision: https://reviews.llvm.org/D24135 llvm-svn: 280788
* Simplify a boolean expression by using the De Morgan's law.Rui Ueyama2016-09-061-1/+1
| | | | llvm-svn: 280766
* Add a comment.Rui Ueyama2016-09-061-0/+4
| | | | llvm-svn: 280724
* [ELF] - Linkerscript: implemented FILL command as alias for =fillexprGeorge Rimar2016-09-061-8/+16
| | | | | | | | | Patch implements FILL just as alias for =fillexpr. This allows to make implementation much shorted and simpler than D24186. Differential revision: https://reviews.llvm.org/D24227 llvm-svn: 280708
* [ELF] PR30221 - linker script expression parser does not accept '~'Simon Atanasyan2016-09-021-0/+15
| | | | | | | | | | | The patch adds support for both '-' and '~' unary expressions. Also it brings support for signed numbers is expressions. https://llvm.org/bugs/show_bug.cgi?id=30221 Differential revision: https://reviews.llvm.org/D24128 llvm-svn: 280546
* [ELF] - Use std::regex instead of hand written logic in elf::globMatch()George Rimar2016-09-021-29/+16
| | | | | | | | | | Use std::regex instead of hand written matcher. Patch based on code and ideas of Rui Ueyama. Differential revision: https://reviews.llvm.org/D23829 llvm-svn: 280544
* Add -nostdlib.Rui Ueyama2016-09-021-1/+2
| | | | llvm-svn: 280528
* Dispatch without hash table lookup.Rui Ueyama2016-09-021-19/+25
| | | | | | | | | | | Cmd used to be the single central place to dispatch. It is not longer the case because we have a logic for readProvideOrAssignment(). This patch removes the hash table so that evrything is in a single function. This is slightly verbose but should improve readability. Differential Revision: https://reviews.llvm.org/D24200 llvm-svn: 280524
* Add comments.Rui Ueyama2016-09-021-0/+4
| | | | llvm-svn: 280515
* [ELF] - Linkerscript: add support for suffixes in numbers.George Rimar2016-09-021-8/+29
| | | | | | | | | | | | | | Both bfd and gold accept: foo = 1K; bar = 1M; zed = 1H; And lowercase forms: k, m, h. Patch adds support for that. Differential revision: https://reviews.llvm.org/D24194 llvm-svn: 280494
* Eliminate LayoutInputSection classEugene Leviant2016-09-011-68/+42
| | | | | | | | | | Previously we used LayoutInputSection class to correctly assign symbols defined in linker script. This patch removes it and uses pointer to preceding input section in SymbolAssignment class instead. Differential revision: https://reviews.llvm.org/D23661 llvm-svn: 280348
* Linker script: support VERSION command.Rui Ueyama2016-08-311-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: VERSION commands define symbol versions. The grammar of the commnad is as follows VERSION { version-script-commands } where version-script-commands is [ name ] { version-definitions }. Note that we already support version-script-commands because it is being used for version script command. This patch is based on George's patch https://reviews.llvm.org/D23609 Reviewers: grimar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24089 llvm-svn: 280284
* [ELF] Linkerscript: define symbols outside SECTIONSPetr Hosek2016-08-311-4/+18
| | | | | | | | | Symbol assignments outside of SECTIONS command need to be created even when SECTIONS command is not used. Differential Revision: https://reviews.llvm.org/D23751 llvm-svn: 280252
* [ELF] - Remove VersionScriptParser class and move the members to ScriptParserGeorge Rimar2016-08-311-4/+97
| | | | | | | | | Patch removes VersionScriptParser class and moves the members to ScriptParser It opens road for implementation of VERSION linkerscript command. Differential revision: https://reviews.llvm.org/D23774 llvm-svn: 280212
* Allow adding start/end symbols to any sectionEugene Leviant2016-08-311-4/+37
| | | | | | | | | Allows adding start and/or end symbols to special output sections, like .eh_frame_hdr, which aren't lists of regular input sections. Differential revision: https://reviews.llvm.org/D23716 llvm-svn: 280205
* [ELF] - Linkerscript: implemented ADDR command.George Rimar2016-08-301-0/+31
| | | | | | | | | | | ADDR(section) Return the absolute address (the VMA) of the named section. Used in the wild, eg.: https://searchcode.com/file/53617342/arch/x86/kernel/vmlinux.lds.S Differential revision: https://reviews.llvm.org/D23913 llvm-svn: 280070
* [ELF] - Fix for: bug 29115 - linkerscript does not support non-wildcard ↵George Rimar2016-08-301-13/+13
| | | | | | | | | | | | | | | filename spec. FreeBSD/mips script has non-wildcard filename specifications: .text : { start.o(.text*) Patch adds support for that, this is PR29115. Differential revision: https://reviews.llvm.org/D23839 llvm-svn: 280069
* Make lld actually compatible with gold in terms of filler handling.Rui Ueyama2016-08-291-10/+10
| | | | | | | | | GNU gold handles output section fillers as 32-bit values. This patch makes LLD compatible with that behavior. Differential revision: https://reviews.llvm.org/D23181 llvm-svn: 280018
* Add support for '|' in expressions.Rafael Espindola2016-08-221-0/+3
| | | | llvm-svn: 279480
* Do not add .interp, .dynamic nor .eh_frame_hdr to segments just by type.Rui Ueyama2016-08-221-21/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: We previously added these output sections to segments just by type. Therefore, if there's a PHDRS command like this PHDRS { headers PT_PHDR PHDRS; interp PT_INTERP; } SECTIONS { . = SIZEOF_HEADERS; .interp : { *(.interp) } :text } then .interp was added to "interp" segment even though the linker is not instructed to do so by SECTIONS command. This patch removes the default behavior to simplify. Differential Revision: https://reviews.llvm.org/D23702 llvm-svn: 279414
* [ELF] - Give automatically generated __start_* and __stop_* symbols default ↵George Rimar2016-08-191-2/+2
| | | | | | | | | | | | | | | | visibility. This patch is opposite to D19024, which made this symbols to be hidden by default. Unfortunately FreeBSD loader wants to see start_set_modmetadata_set/stop_set_modmetadata_set in the dynamic symbol table. They were not placed there because had hidden visibility. Patch makes them to have default visibility again. Differential revision: https://reviews.llvm.org/D23552 llvm-svn: 279262
* [ELF] - Linkerscript: implemented SUBALIGN() command.George Rimar2016-08-191-1/+8
| | | | | | | | | | | You can force input section alignment within an output section by using SUBALIGN. The value specified overrides any alignment given by input sections, whether larger or smaller. SUBALIGN is used in many projects in the wild. Differential revision: https://reviews.llvm.org/D23063 llvm-svn: 279256
* [ELF] Don't add input sections twice when linker script is usedEugene Leviant2016-08-181-1/+2
| | | | llvm-svn: 279036
* [ELF] Linkerscript: support assignment outside SECTIONSPetr Hosek2016-08-181-0/+2
| | | | | | | | | | | We only support assignments inside SECTIONS, but this does not match the behavior of GNU linker which also allows them outside SECTIONS. The only restriction on assignments outside SECTIONS is that they cannot reference . (they have to be absolute expressions). Differential Revision: https://reviews.llvm.org/D23598 llvm-svn: 279033
* Merge readAt and readAlign.Rui Ueyama2016-08-171-28/+14
| | | | | | Now that they are identical. llvm-svn: 278953
* [ELF] - Linkerscript: make readAt() signature to be consistent with others ↵George Rimar2016-08-171-4/+5
| | | | | | read*(). NFC. llvm-svn: 278931
* Attemp to fix linux build bot after r278911 ("[ELF] - linkerscript AT ↵George Rimar2016-08-171-1/+1
| | | | | | | | keyword (in output section description) implemented.") http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/26289/steps/build_Lld/logs/stdio llvm-svn: 278914
OpenPOWER on IntegriCloud