summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.h
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - Linkerscript: simplify access to templated methods from parser.George Rimar2016-09-081-4/+15
| | | | | | | | | 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
* Support ABSOLUE keyword in symbol assignmentsEugene Leviant2016-09-071-2/+4
| | | | | | | | | | | | This patch allows making section defined symbols absolute: .foo : { begin_foo = ABSOLUTE(.); *(.foo) } Differential revision: https://reviews.llvm.org/D24135 llvm-svn: 280788
* [ELF] - Use std::regex instead of hand written logic in elf::globMatch()George Rimar2016-09-021-5/+9
| | | | | | | | | | 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
* Eliminate LayoutInputSection classEugene Leviant2016-09-011-3/+2
| | | | | | | | | | 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
* [ELF] Linkerscript: define symbols outside SECTIONSPetr Hosek2016-08-311-0/+3
| | | | | | | | | 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
* Delete unnecessary template.Rafael Espindola2016-08-311-1/+1
| | | | llvm-svn: 280237
* [ELF] - Remove VersionScriptParser class and move the members to ScriptParserGeorge Rimar2016-08-311-0/+2
| | | | | | | | | 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
* [ELF] - Linkerscript: implemented ADDR command.George Rimar2016-08-301-0/+1
| | | | | | | | | | | 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] - Linkerscript: implemented SUBALIGN() command.George Rimar2016-08-191-0/+1
| | | | | | | | | | | 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] - Linkerscript: removed duplicate forward declarations, regrouped. NFC.George Rimar2016-08-181-4/+1
| | | | llvm-svn: 279060
* [ELF] - linkerscript AT keyword (in output section description) implemented.George Rimar2016-08-171-0/+2
| | | | | | | | | | | | | The linker will normally set the LMA equal to the VMA. You can change that by using the AT keyword. The expression lma that follows the AT keyword specifies the load address of the section. Patch implements this keyword. Differential revision: https://reviews.llvm.org/D19272 llvm-svn: 278911
* [ELF] Ignore .interp section in case linker script specifies PHDRS without ↵Eugene Leviant2016-08-161-0/+1
| | | | | | PT_INTERP llvm-svn: 278781
* [ELF] - Linkerscript: reimplemented output sections constrains matching ↵George Rimar2016-08-121-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | functionality. Previously filtering that was used worked incorrectly. For example for next script it would just remove both sections completely: SECTIONS { . = 0x1000; .aaa : ONLY_IF_RW { *(.aaa.*) } . = 0x2000; .aaa : ONLY_IF_RO { *(.aaa.*) } } Patch fixes above issues and adds testcase showing the issue. Testcase is a subset of FreeBSD script which has: .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } ... .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } Differential revision: https://reviews.llvm.org/D23326 llvm-svn: 278486
* Rename getSizeOfHeaders -> getHeaderSize.Rui Ueyama2016-08-121-1/+1
| | | | | | | We have getSectionSize for SIZEOF command. So, I think getHeaderSize is a better name for SIZEOF_HEADERS. llvm-svn: 278470
* Create only one section for a name in LinkerScript.Rui Ueyama2016-08-121-0/+3
| | | | | | | | | | | | | | Previously, we created two or more output sections if there are input sections with the same name but with different attributes. That is a wrong behavior. This patch fixes the issue. One thing we need to do is to merge output section attributes. Currently, we create an output section based on the first input section's attributes. This may make a wrong output section attributes. What we need to do is to bitwise-OR attributes. We'll do it in a follow-up patch. llvm-svn: 278461
* Allocate LayoutInputSections using SpecificBumpPtrAllocator.Rui Ueyama2016-08-121-0/+5
| | | | llvm-svn: 278453
* Split LinkerScript<ELFT>::createSections.Rui Ueyama2016-08-121-0/+2
| | | | | | Also avoid to use a lambda that is called only once. llvm-svn: 278445
* [ELF] Symbol assignment within output section descriptionEugene Leviant2016-08-111-4/+0
| | | | llvm-svn: 278322
* [ELF] - Linkerscript: implement SIZEOF_HEADERS.George Rimar2016-08-101-0/+1
| | | | | | | | | | | SIZEOF_HEADERS - Return the size in bytes of the output file’s headers. It is is a feature used in FreeBsd script, for example. There is a discussion on PR28688 page about it. Differential revision: https://reviews.llvm.org/D23165 llvm-svn: 278204
* Split InputSectionDescription::Sort into SortInner and SortOuter.Rui Ueyama2016-08-041-2/+3
| | | | | | | | | | | | | | | | | Summary: The comparator function to compare input sections as instructed by SORT command was a bit too complicated because it needed to handle four different cases. This patch split it into two function calls. This patch also simplifies the parser. Reviewers: grimar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23140 llvm-svn: 277780
* Remove redundant argument.Rafael Espindola2016-08-041-6/+5
| | | | | | But always set Script<ELFT>::X->OutputSections. llvm-svn: 277720
* [ELF] - Linkerscript: implemented ASSERT() keyword.George Rimar2016-08-041-1/+8
| | | | | | | | | | | | ASSERT(exp, message) Ensure that exp is non-zero. If it is zero, then exit the linker with an error code, and print message. ASSERT is useful and was seen in few projects in the wild. Differential revision: https://reviews.llvm.org/D22912 llvm-svn: 277710
* Revert 277594, it caused PR28827Nico Weber2016-08-031-2/+3
| | | | llvm-svn: 277599
* Remove redundant argument.Rafael Espindola2016-08-031-3/+2
| | | | llvm-svn: 277594
* [ELF] - Linkerscript: support all kinds of sorting (including nested).George Rimar2016-08-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we supported only sorting by name. When there are nested section sorting commands in linker script, there can be at most 1 level of nesting for section sorting commands. SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard section pattern)). It will sort the input sections by name first, then by alignment if 2 sections have the same name. SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section pattern)). It will sort the input sections by alignment first, then by name if 2 sections have the same alignment. SORT_BY_NAME (SORT_BY_NAME (wildcard section pattern)) is treated the same as SORT_ BY_NAME (wildcard section pattern). SORT_BY_ALIGNMENT (SORT_BY_ALIGNMENT (wildcard section pattern)) is treated the same as SORT_BY_ALIGNMENT (wildcard section pattern). All other nested section sorting commands are invalid. Patch implements that all above. Differential revision: https://reviews.llvm.org/D23019 llvm-svn: 277583
* [ELF] - Linkerscript: implemented SIZEOF(section)George Rimar2016-07-291-4/+5
| | | | | | | | | | | | | | | SIZEOF(section) Return the size in bytes of the named section, if that section has been allocated. SIZEOF(section) often used in scripts. Few examples from the wild: https://github.com/chipKIT32/pic32-Arduino-USB-Bootloader-original/blob/master/boot-linkerscript.ld https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/gba_cart.ld Patch implements it. Differential revision: https://reviews.llvm.org/D22915 llvm-svn: 277165
* Remove dead declaration.Rui Ueyama2016-07-291-1/+0
| | | | llvm-svn: 277159
* [ELF] - Linkerscript: Implemented SORT command.George Rimar2016-07-291-0/+1
| | | | | | | | | | | | When the SORT keyword is used, the linker will sort the files or sections into ascending order by name before placing them in the output file. It is used in FreeBSD script: https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l139 This is PR28689. Differential revision: https://reviews.llvm.org/D22749 llvm-svn: 277153
* Add comments.Rui Ueyama2016-07-291-1/+7
| | | | llvm-svn: 277116
* Remove `Ignore` flag from SymbolAssignment class.Rui Ueyama2016-07-291-2/+2
| | | | | | | | | | | | | Previously, Ignore flag is set if we don't want to assign a value to symbols. It happens if a symbol assingment is in PROVIDE() and there's already a symbol with the same name. The previous code had a subtle but that we assume that the existing symbol is an absolute symbol even if it is not. This patch fixes the issue by always overwriting an absolute symbol. llvm-svn: 277115
* Rename DoLayout -> HasContents. NFC.Rui Ueyama2016-07-291-1/+1
| | | | llvm-svn: 277102
* [ELF] - Linkerscript: implemented filename specification.George Rimar2016-07-281-1/+2
| | | | | | | | | | | | | | | Scripts can contain something like: KEEP (*crtbegin.o(.ctors)) What means that "*crtbegin.o" is a wildcard of file to take the sections from. This is some kind of opposite to EXCLUDE_FILE and used in FreeBSD script: https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l122 Patch implements this. Differential revision: https://reviews.llvm.org/D22852 llvm-svn: 277042
* Make CommonInputSection singleton class.Rui Ueyama2016-07-281-4/+2
| | | | | | | | | All other singleton instances are accessible globally. CommonInputSection shouldn't be an exception. Differential Revision: https://reviews.llvm.org/D22935 llvm-svn: 277034
* [ELF] Allows setting section for common symbols in linker scriptEugene Leviant2016-07-281-2/+5
| | | | llvm-svn: 277023
* [ELF/LinkerScript] Support EXCLUDE_FILE inside KEEP.Davide Italiano2016-07-271-2/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D22795 llvm-svn: 276825
* [ELF] - Linkerscript: implemented ALIGN modificatior of output sections.George Rimar2016-07-261-0/+1
| | | | | | | | | | | Output section description can contain ALIGN modificator: https://sourceware.org/binutils/docs/ld/Output-Section-Description.html#Output-Section-Description Patch implements it. Differential revision: https://reviews.llvm.org/D22674 llvm-svn: 276780
* Split getPhdrsIndices. NFC.Rui Ueyama2016-07-261-0/+1
| | | | llvm-svn: 276717
* Split LinkerScript::createSections into small functions.Rui Ueyama2016-07-251-0/+5
| | | | | | | | | | | createSections function is getting longer, so it is time to split it into small functions. The reason why the function is long is because it has deeply nested for-loops. This patch constructs temporary data to reduce nesting level. Differential Revision: https://reviews.llvm.org/D22786 llvm-svn: 276706
* Make ConstraintKind an enum class.Rui Ueyama2016-07-251-2/+2
| | | | llvm-svn: 276697
* Re-commit "Split LinkerScript::createSections".Rui Ueyama2016-07-251-0/+3
| | | | | | Re-commit r276543 with a fix for buildbots. llvm-svn: 276693
* [ELF] - Linkerscript: implemented output section [address] attribute.George Rimar2016-07-251-0/+1
| | | | | | | | | | | | | | | | Output section description in SECTIONS looks like that: section [address] [(type)] : ... { ... } Patch implements support of address atribute. Differential revision: https://reviews.llvm.org/D22689 llvm-svn: 276619
* Simplify. NFC.Rui Ueyama2016-07-241-1/+1
| | | | llvm-svn: 276586
* Make readExpr return an Expr object instead of a vector of tokens.Rui Ueyama2016-07-241-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we handled an expression as a vector of tokens. In other words, an expression was a vector of uncooked raw StringRefs. When we need a value of an expression, we used ExprParser to run the expression. The separation was needed essentially because parse time is too early to evaluate an expression. In order to evaluate an expression, we need to finalize section sizes. Because linker script parsing is done at very early stage of the linking process, we can't evaluate expressions while parsing. The above mechanism worked fairly well, but there were a few drawbacks. One thing is that we sometimes have to parse the same expression more than once in order to find the end of the expression. In some contexts, linker script expressions have no clear end marker. So, we needed to recognize balanced expressions and ternary operators. The other is poor error reporting. Since expressions are parsed basically twice, and some information that is available at the first stage is lost in the second stage, it was hard to print out apprpriate error messages. This patch fixes the issues with a new approach. Now the expression parsing is integrated into ScriptParser. ExprParser class is removed. Expressions are represented as lambdas instead of vectors of tokens. Lambdas captures information they need to run themselves when they are created. In this way, ends of expressions are naturally detected, and errors are handled in the usual way. This patch also reduces the amount of code. Differential Revision: https://reviews.llvm.org/D22728 llvm-svn: 276574
* Rollback r276538 and r276540 to unbreak asan bot.Rui Ueyama2016-07-241-3/+0
| | | | llvm-svn: 276543
* Split LinkerScript::createSections.Rui Ueyama2016-07-241-0/+3
| | | | | | | | createSections is getting longer, so it is probably time to split. Differential Revision: https://reviews.llvm.org/D22730 llvm-svn: 276538
* Remove Phdr typedef.Rui Ueyama2016-07-231-3/+3
| | | | | | I don't think this typedef contributes to readability. llvm-svn: 276525
* Make a pure function a non-member file-scoped function.Rui Ueyama2016-07-231-1/+0
| | | | llvm-svn: 276524
* [ELF] Support PROVIDE and PROVIDE_HIDDEN inside SECTIONSEugene Leviant2016-07-221-0/+4
| | | | llvm-svn: 276398
* [ELF/LinkerScript] Support ONLY_IF_{RO, RW} directive.Davide Italiano2016-07-221-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D22660 llvm-svn: 276384
* [ELF] - Cleanup of LinkerScript<ELFT>::assignAddresses()George Rimar2016-07-211-0/+1
| | | | | | | | | | LinkerScript<ELFT>::assignAddresses is becoming larger and looks it can be good time for splitting. I expect to can more SectionsCommand's there, and dispatching some of them separatelly can help to keep method smaller either. Differential revision: https://reviews.llvm.org/D22506 llvm-svn: 276300
OpenPOWER on IntegriCloud