summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ELF] - Implemented comparsion operators for linkerscript.George Rimar2016-04-251-7/+25
| | | | | | | | Patch adds support of <,>,!=,==,>=,<= operators. Differential revision: http://reviews.llvm.org/D19419 llvm-svn: 267382
* Use ScriptParserBase features to parse linker script expressions.Rui Ueyama2016-04-231-71/+59
| | | | | | | | Previously, we have re-implemented utility functions such as `expect` or `next` in LinkerScript.cpp. This patch reuses the existing implementation that is in ScriptParser.cpp. llvm-svn: 267255
* Devirtualize ScriptParserBase. NFC.Rui Ueyama2016-04-221-1/+1
| | | | | | | | | | | ScriptParserBase class is a container of collection of various methods to parse linker script-ish text. It had a virtual method `run` to run the parser. But we don't have to enforce its descendents to implement that. It's up to them. This patch removes pure virtual function `run`. llvm-svn: 267246
* Inline getInteger as it's too short to be a function. NFC.Rui Ueyama2016-04-221-10/+4
| | | | llvm-svn: 267219
* Update a comment for r267145.Rui Ueyama2016-04-221-1/+2
| | | | llvm-svn: 267218
* Move uintX_t typedef to the class definition. NFC.Rui Ueyama2016-04-221-2/+0
| | | | | | Now it is doable because LinkerScript is a template class. llvm-svn: 267212
* [ELF] - Implemented linkerscript ALIGN commandGeorge Rimar2016-04-221-0/+8
| | | | | | | | | | | | ALIGN(exp) Return the location counter (.) aligned to the next exp boundary. (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/expressions.html) Patch implements this command. This fixes PR27406. Differential revision: http://reviews.llvm.org/D19364 llvm-svn: 267145
* Recommitted r267132 "[ELF] - implemented ternary operator for linkerscript ↵George Rimar2016-04-221-0/+14
| | | | | | | | | | | | | | | | | | | | | 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-14/+0
| | | | llvm-svn: 267134
* [ELF] - implemented ternary operator for linkerscript expressionsGeorge Rimar2016-04-221-0/+14
| | | | | | | | | | | | | | 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-5/+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-21/+22
| | | | | | | | 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-17/+24
| | | | | | | | | | | | | | | | | | 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-6/+10
| | | | | | Also changed the function name and added comments. llvm-svn: 267044
* [ELF] - Use ArrayRef instead of std::vector& for LinkerScript module. NFC.George Rimar2016-04-211-3/+3
| | | | llvm-svn: 266978
* [ELF] - Get rid of SectionOrder array.George Rimar2016-04-211-10/+16
| | | | | | | | | | | 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
* Define and use a utility function. NFC.Rui Ueyama2016-04-201-7/+16
| | | | llvm-svn: 266914
* ELF: Redefine parseExpr to parse an expression. NFC.Rui Ueyama2016-04-201-9/+12
| | | | | | | | | Previously the function reads an operator and the rest of the expressions. This patch makes it to actually parse an expression which starts with a primary pexression followed by other expressions concatenated with operators. llvm-svn: 266912
* ELF: Template LinkerScript class.Rui Ueyama2016-04-201-57/+41
| | | | | | | | | | | | | | | | | | | | | 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
* Make a function file-scoped.Rui Ueyama2016-04-191-1/+1
| | | | llvm-svn: 266816
* Attempt to fix buildbot.Rui Ueyama2016-04-191-1/+1
| | | | llvm-svn: 266799
* ELF: Add +, -, *, / and & to SECTIONS linker script command.Rui Ueyama2016-04-191-17/+97
| | | | | | | | | | | | | | | 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
* Rename LocationNode -> SectionsCommand.Rui Ueyama2016-04-181-10/+10
| | | | | | | | 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
* Remove redundant curly braces.Rui Ueyama2016-04-181-3/+3
| | | | llvm-svn: 266667
* Refactor LinkerScript::assignAddresses. NFC.Rui Ueyama2016-04-181-24/+22
| | | | llvm-svn: 266666
* Recommitted 266457 with fix:George Rimar2016-04-161-2/+129
| | | | | | | | | | | | | | | | | | | | * 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-129/+2
| | | | | | | 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-2/+129
| | | | | | | | | | | | | | 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
* [lld] [ELF] Add ScriptParserBase classAdhemerval Zanella2016-04-061-166/+4
| | | | | | | | This patch add a base script tokenizer class to decouple parsing from linker script handling. The idea is to use this base class on dynamic list parsing (--dynamic-list option). No functionality added. llvm-svn: 265600
* [ELF] - Teach linkerscript error handler to show full script line and column ↵George Rimar2016-04-061-0/+21
| | | | | | | | | | | | | | | marker on error. When error, this adds the text line of script to the output and a marks exact incorrect token under it: line 1: <error text here> UNKNOWN_TAG { ^ Differential revision: http://reviews.llvm.org/D18699 llvm-svn: 265523
* Include line number in error message for linker scripts.Rui Ueyama2016-03-301-2/+13
| | | | | | | This patch is based on http://reviews.llvm.org/D18545 written by George Rimar. llvm-svn: 264878
* Fix spelling.Rui Ueyama2016-03-131-2/+2
| | | | llvm-svn: 263358
* Recommit of r263252, [ELF] - Change all messages to lowercase to be consistent.George Rimar2016-03-121-4/+4
| | | | | | | | | | | | | | | | | | | | | which was reverted because included unrelative changes by mistake. Original commit message: [ELF] - Change all messages to lowercase to be consistent. That is directly opposite to http://reviews.llvm.org/D18045, which was reverted. This patch changes all messages to start from lowercase letter if they were not before. That is done to be consistent with clang. Differential revision: http://reviews.llvm.org/D18085 llvm-svn: 263337
* Revert r263252: "[ELF] - Change all messages to lowercase to be consistent."Rui Ueyama2016-03-111-4/+4
| | | | | | This reverts commit r263252 because the change contained unrelated changes. llvm-svn: 263272
* [ELF] - Change all messages to lowercase to be consistent.George Rimar2016-03-111-4/+4
| | | | | | | | | | | | | | That is directly opposite to http://reviews.llvm.org/D18045, which was reverted. This patch changes all messages to start from lowercase letter if they were not before. That is done to be consistent with clang. Differential revision: http://reviews.llvm.org/D18085 llvm-svn: 263252
* This reverts the r263125George Rimar2016-03-111-7/+7
| | | | | | | | | | | | | | | | | | | | It was discussed to make all messages be lowercase to be consistent with clang. (also reverts the r263128 which fixed build bot fail after r263125) Original commit message: [ELF] - Consistent spelling for error/warning messages Previously error and warnings were not consistent in lld. Some of them started from lowercase letter, others from uppercase. Also there was one or two which had a dot at the end. This patch changes all messages to start from uppercase letter if they were not before. Differential revision: http://reviews.llvm.org/D18045 llvm-svn: 263240
* [ELF] - Consistent spelling for error/warning messagesGeorge Rimar2016-03-101-7/+7
| | | | | | | | | | | | Previously error and warnings were not consistent in lld. Some of them started from lowercase letter, others from uppercase. Also there was one or two which had a dot at the end. This patch changes all messages to start from uppercase letter if they were not before. Differential revision: http://reviews.llvm.org/D18045 llvm-svn: 263125
* Revert "ELF: Add /lib and /usr/lib as default search paths."Rafael Espindola2016-03-081-3/+1
| | | | | | | | | | | | | | | It was causing errors like /lib/libc.so.6 is incompatible with elf_x86_64 when linking on Fedora. Every system has different default paths. It seems better to just trust the driver to pass the correct -L options. This reverts commit 262910. llvm-svn: 262941
* ELF: Add /lib and /usr/lib as default search paths.Rui Ueyama2016-03-081-1/+3
| | | | | | | GNU ld and gold have these paths as default search paths. If you don't want these directories, pass -nostdlib. llvm-svn: 262910
* ELF: Remove OutSection class and use a map instead.Rui Ueyama2016-02-281-16/+14
| | | | | | | It is easier to handle section filler data separately rather than merging with section names. llvm-svn: 262175
* Simplify. NFC.Rui Ueyama2016-02-281-6/+5
| | | | llvm-svn: 262174
* Rename elf2 to elf.Rafael Espindola2016-02-281-4/+4
| | | | llvm-svn: 262159
* [ELF] - Implemented linkerscript sections padding.George Rimar2016-02-261-7/+53
| | | | | | | | | | | | | | | 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
* Remove redundant template instantiations.Rui Ueyama2016-02-261-5/+0
| | | | | | | This class is used only in this translation unit, so no need to instantiate them explicitly. llvm-svn: 261951
* [ELF] - replaced std::function with raw pointers in LinkerScript.cppGeorge Rimar2016-02-241-20/+21
| | | | | | | | Change as was proposed by David Blaikie. Differential revision: http://reviews.llvm.org/D17499 llvm-svn: 261729
* [ELF] - Teach input section wildcard patterns to recognize '?' meta character.George Rimar2016-02-241-3/+4
| | | | | | | | | | | `?' - matches any single character https://sourceware.org/binutils/docs/ld/Input-Section-Wildcards.html This is used in linker scripts. Differential revision: http://reviews.llvm.org/D17290 llvm-svn: 261726
* [ELF] - Linkerscript KEEP command.George Rimar2016-02-231-7/+37
| | | | | | | | | | | 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
* Attemp to heal windows buildbotGeorge Rimar2016-02-191-10/+10
| | | | | | http://lab.llvm.org:8011/builders/sanitizer-windows/builds/17414 llvm-svn: 261322
* [ELF] - Minor refactor of LinkerScript fileGeorge Rimar2016-02-191-23/+20
| | | | | | | | | * Else-ifs in ScriptParser::run() replaced with std::function + map * Reordered members of ScriptParser Differential revision: http://reviews.llvm.org/D17256 llvm-svn: 261317
* ELF: Add wildcard pattern matching to SECTIONS linker script command.Rui Ueyama2016-02-121-5/+54
| | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud