summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.h
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - Linkerscript: add InputSectionDescription command to LS parser.George Rimar2016-07-211-22/+13
| | | | | | | | | | | | | | This adds InputSectionDescription command to represent the input section declaration. This leads to next cleanup: SectionRule removed. ScriptConfiguration::Sections mamber removed. LinkerScript<ELFT>::getOutputSection() removed. Differential revision: https://reviews.llvm.org/D22617 llvm-svn: 276283
* [ELF] Support FLAGS attribute in program header definitionEugene Leviant2016-07-211-0/+1
| | | | llvm-svn: 276260
* [ELF] - Linkerscript: remove excessive ScriptConfiguration::Filler fieldGeorge Rimar2016-07-211-3/+0
| | | | | | | | | Previously OutputSectionCommand::Filler was introduced, but unused. Patch fixes that. Differential revision: https://reviews.llvm.org/D22615 llvm-svn: 276253
* [ELF] - Initial support of tree-style linker script implemented.George Rimar2016-07-211-7/+28
| | | | | | | | | | | Approach uses LLVM-style RTTI for representing the linker script commands in a form of tree for future simplification of parsing. Core idea and code sample belongs to Rui Ueyama. Differential revision: https://reviews.llvm.org/D22604 llvm-svn: 276243
* Simplify output section ownership.Rui Ueyama2016-07-201-2/+3
| | | | | | | | | This patch simplifies output section management by making Factory class have ownership of sections that creates. Differential Revision: https://reviews.llvm.org/D22575 llvm-svn: 276141
* Removed trailing whitespaces. NFC.George Rimar2016-07-201-2/+2
| | | | llvm-svn: 276126
* [ELF] Create output sections in LinkerScript classEugene Leviant2016-07-201-0/+5
| | | | llvm-svn: 276121
* Fix build with gcc 6.Rafael Espindola2016-07-191-1/+1
| | | | llvm-svn: 275972
* [ELF] Minimal PHDRS parser and section to segment assignment supportEugene Leviant2016-07-191-0/+17
| | | | llvm-svn: 275965
* Merge SymbolAssignmentKind and ExprKind.Rui Ueyama2016-07-151-1/+1
| | | | | | | | | In a linker script, `.` is a special symbol indicating a counter. Previously, we had two expression types, ExprKind and SymbolAssignmentKind for `.` and all the other symbol names, respectively. But we could merge them because the former is a special case of the latter. llvm-svn: 275527
* [ELF] Support for symbol assignment in linker scripts within SECTIONS {} blockEugene Leviant2016-07-121-2/+3
| | | | llvm-svn: 275158
* Create Strings.cpp and move string manipulation functions to that file.Rui Ueyama2016-06-291-2/+0
| | | | llvm-svn: 274109
* Rename matchStr -> globMatch.Rui Ueyama2016-06-291-1/+1
| | | | llvm-svn: 274103
* [ELF] Support for wildcard in version scripts.Davide Italiano2016-06-291-0/+2
| | | | | | | | | | | | | | | Example: VERSION_1.0 { global: foo*; local: *; } now correctly matches all the symbols which name starts with `foo`. Differential Revision: http://reviews.llvm.org/D21732 llvm-svn: 274091
* Removed another dead code. NFC.George Rimar2016-05-041-3/+0
| | | | llvm-svn: 268505
* [ELF] - Removed dead declarations. NFC.George Rimar2016-04-251-5/+0
| | | | llvm-svn: 267381
* Move uintX_t typedef to the class definition. NFC.Rui Ueyama2016-04-221-1/+3
| | | | | | Now it is doable because LinkerScript is a template class. llvm-svn: 267212
* Recommitted r267132 "[ELF] - implemented ternary operator for linkerscript ↵George Rimar2016-04-221-0/+1
| | | | | | | | | | | | | | | | | | | | | expressions" With fix: removed redundant Dot parameter. Original commit message: [ELF] - implemented ternary operator for linkerscript expressions Patch implements ternary operator for linkerscript expressions. Like: SECTIONS { . = 0x1 ? 0x2 : 0x3; ... } Differential revision: http://reviews.llvm.org/D19332 llvm-svn: 267140
* Revert r267132 as it broke buildbot.George Rimar2016-04-221-1/+0
| | | | llvm-svn: 267134
* [ELF] - implemented ternary operator for linkerscript expressionsGeorge Rimar2016-04-221-0/+1
| | | | | | | | | | | | | | Patch implements ternary operator for linkerscript expressions. Like: SECTIONS { . = 0x1 ? 0x2 : 0x3; ... } Differential revision: http://reviews.llvm.org/D19332 llvm-svn: 267132
* Inline SectionRule::match.Rui Ueyama2016-04-221-4/+1
| | | | | | This short function was used only once and didn't provide much value. llvm-svn: 267086
* ELF: Make the special variable "." as a LinkerScript class member.Rui Ueyama2016-04-221-1/+8
| | | | | | | | I will eventually make `evaluate` function a usual parse function rather than a function that works on a separate token list. This is the first step toward that. llvm-svn: 267083
* ELF: Change how to handle KEEP linker script command.Rui Ueyama2016-04-211-5/+6
| | | | | | | | | | | | | | | | | | You can instruct the linker to not discard sections even if they are unused and --gc-sections option is given. The linker script command for doing that is KEEP. The syntax is KEEP(foo) where foo is a section name. KEEP commands are written in SECTIONS command, so you can specify the order of sections *and* which sections will be kept. Each sub-command in SECTIONS command are translated into SectionRule object. Previously, each SectionRule has `Keep` bit. However, if you think about it, this hid information in too deep in elements of a list. Semantically, KEEP commands aren't really related to SECTIONS subcommands. We can keep the section list for KEEP in a separate list. This patch does that. llvm-svn: 267065
* ELF: Change the return type of getSectionOrder.Rui Ueyama2016-04-211-1/+1
| | | | | | Also changed the function name and added comments. llvm-svn: 267044
* [ELF] - Make LinkerScript::getSectionOrder private. NFC.George Rimar2016-04-211-1/+1
| | | | llvm-svn: 266979
* [ELF] - Use ArrayRef instead of std::vector& for LinkerScript module. NFC.George Rimar2016-04-211-1/+1
| | | | llvm-svn: 266978
* [ELF] - Get rid of SectionOrder array.George Rimar2016-04-211-3/+1
| | | | | | | | | | | SectionOrder vector was a part of LinkerScript class. It can be removed because Commands vector contains the same information and SectiorOrder is just a subset. Differential revision: http://reviews.llvm.org/D19171 llvm-svn: 266974
* ELF: Template LinkerScript class.Rui Ueyama2016-04-201-23/+30
| | | | | | | | | | | | | | | | | | | | | Originally, linker scripts were basically an alternative way to specify options to the command line options. But as we add more features to hanlde symbols and sections, many member functions needed to be templated. Now most the members are templated. It is probably time to template the entire class. Previously, LinkerScript is an executor of the linker script as well as a storage of linker script configurations. This is not suitable to template the class because when we are reading linker script files, we don't know the ELF type yet, so we can't instantiate ELF-templated classes. In this patch, I defined a new class, ScriptConfiguration, to store linker script configurations. ScriptParser writes parse results to it, and LinkerScript uses them. Differential Revision: http://reviews.llvm.org/D19302 llvm-svn: 266908
* ELF: Add +, -, *, / and & to SECTIONS linker script command.Rui Ueyama2016-04-191-1/+0
| | | | | | | | | | | | | | | This patch is based heavily on George Rimor's patch http://reviews.llvm.org/D19221. In the linker script, you can write expressions to compute addresses. Currently we only support "+" operator. This adds a few more operators. Since this patch adds * and /, we need to handle operator precedences properly. I implemented that using the operator-precedence grammar. Differential Revision: http://reviews.llvm.org/D19237 llvm-svn: 266798
* Updated comment. NFC.George Rimar2016-04-191-2/+2
| | | | llvm-svn: 266727
* Rename LocationNode -> SectionsCommand.Rui Ueyama2016-04-181-4/+4
| | | | | | | | They are called sections-command in the doc, so it is nice to keep it consistent with it. https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS llvm-svn: 266668
* Refactor LinkerScript::assignAddresses. NFC.Rui Ueyama2016-04-181-2/+0
| | | | llvm-svn: 266666
* Recommitted 266457 with fix:George Rimar2016-04-161-0/+22
| | | | | | | | | | | | | | | | | | | | * Do script driven layout only if SECTIONS section exist. Initial commit message: [ELF] - Implemented basic location counter support. This patch implements location counter support. It also separates assign addresses for sections to assignAddressesScript() if it scipt exists. Main testcase is test/ELF/linkerscript-locationcounter.s, It contains some work with location counter. It is basic now. Implemented location counter assignment and '+' operations. Patch by myself with LOTS of comments and design suggestions from Rui Ueyama. Differential revision: http://reviews.llvm.org/D18499 llvm-svn: 266526
* Revert r266457: "[ELF] - Implemented basic location counter support."Rui Ueyama2016-04-151-22/+0
| | | | | | | This reverts commit r266457 as it breaks "hello world" both on Linux and FreeBSD. llvm-svn: 266485
* [ELF] - Implemented basic location counter support.George Rimar2016-04-151-0/+22
| | | | | | | | | | | | | | This patch implements location counter support. It also separates assign addresses for sections to assignAddressesScript() if it scipt exists. Main testcase is test/ELF/linkerscript-locationcounter.s, It contains some work with location counter. It is basic now. Implemented location counter assignment and '+' operations. Patch by myself with LOTS of comments and design suggestions from Rui Ueyama. Differential revision: http://reviews.llvm.org/D18499 llvm-svn: 266457
* ELF: Remove OutSection class and use a map instead.Rui Ueyama2016-02-281-8/+5
| | | | | | | It is easier to handle section filler data separately rather than merging with section names. llvm-svn: 262175
* Rename elf2 to elf.Rafael Espindola2016-02-281-2/+2
| | | | llvm-svn: 262159
* [ELF] - Implemented linkerscript sections padding.George Rimar2016-02-261-2/+9
| | | | | | | | | | | | | | | BSD linker scripts contain special cases to add NOP padding to code sections. Syntax is next: .init: { KEEP (*(.init)) } =0x90909090 (0x90 is NOP) This patch implements that functionality. llvm-svn: 262020
* [ELF] - Linkerscript KEEP command.George Rimar2016-02-231-1/+8
| | | | | | | | | | | When link-time garbage collection is in use (-gc-sections), it is often useful to mark sections that should not be eliminated. This is accomplished by surrounding an input section's wildcard entry with KEEP(). Patch implements that command. Differential revision: http://reviews.llvm.org/D17242 llvm-svn: 261616
* ELF: Add wildcard pattern matching to SECTIONS linker script command.Rui Ueyama2016-02-121-5/+20
| | | | | | | | | | | | | | | | | | | | Each rule in SECTIONS commands is something like ".foo *(.baz.*)", which instructs the linker to collect all sections whose name matches ".baz.*" from all files and put them into .foo section. Previously, we didn't recognize the wildcard character. This patch adds that feature. Performance impact is a bit concerning because a linker script can contain hundreds of SECTIONS rules, and doing pattern matching against each rule would be too expensive. We could merge all patterns into single DFA so that it takes O(n) to the input size. However, it is probably too much at this moment -- we don't know whether the performance of pattern matching matters or not. So I chose to implement the simplest algorithm in this patch. I hope this simple pattern matcher is sufficient. llvm-svn: 260745
* ELF: Remove use of MapVector from LinkerScript.Rui Ueyama2016-02-121-6/+5
| | | | | | We don't have to use a MapVector here. Instead, just std::vector suffices. llvm-svn: 260724
* ELF: Remove readLinkerScript and define LinkerScript::read instead.Rui Ueyama2016-02-111-0/+8
| | | | llvm-svn: 260598
* ELF: Create LinkerScript class to move code out of Writer.Rui Ueyama2016-02-111-0/+45
Previously, we had code for linker scripts in Writer. This patch separates that as LinkerScript class. The class provides a few functions to query linker scripts and is also a container of some linker-script-specific information. Hopefully, Writer will only implement the default behavior and let the new class handle gotchas regarding linker scripts. llvm-svn: 260591
OpenPOWER on IntegriCloud