summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* ELF: Remove use of MapVector from LinkerScript.Rui Ueyama2016-02-121-16/+12
| | | | | | 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-2/+2
| | | | llvm-svn: 260598
* ELF: Create LinkerScript class to move code out of Writer.Rui Ueyama2016-02-111-29/+53
| | | | | | | | | | | | 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
* Re-submit ELF: Report multiple errors from the driver.Rui Ueyama2016-02-021-1/+1
| | | | | | This reverts r259395 which reverted r259143. llvm-svn: 259572
* ELF: Do not use fatal in LinkerScript.cpp.Rui Ueyama2016-02-021-22/+56
| | | | | | | | | | | | This patch adds "Error" field to LinkerScript class. That field is false by default, and set to true if there is a syntax error in an input file. The linker script parser is a recursive-descedent parser. Each function returns if Error is true -- so that eventually the whole parser returns to a caller. http://reviews.llvm.org/D16667 llvm-svn: 259557
* Revert r259143, it broke check-lld on Windows (see PR26388).Nico Weber2016-02-011-1/+1
| | | | llvm-svn: 259395
* ELF: Report multiple errors from the driver.Rui Ueyama2016-01-291-1/+1
| | | | | | | | | This patch let the driver keep going until it parses all command line options. http://reviews.llvm.org/D16645 llvm-svn: 259143
* ELF: Rename error -> fatal and redefine error as a non-noreturn function.Rui Ueyama2016-01-281-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In many situations, we don't want to exit at the first error even in the process model. For example, it is better to report all undefined symbols rather than reporting the first one that the linker picked up randomly. In order to handle such errors, we don't need to wrap everything with ErrorOr (thanks for David Blaikie for pointing this out!) Instead, we can set a flag to record the fact that we found an error and keep it going until it reaches a reasonable checkpoint. This idea should be applicable to other places. For example, we can ignore broken relocations and check for errors after visiting all relocs. In this patch, I rename error to fatal, and introduce another version of error which doesn't call exit. That function instead sets HasError to true. Once HasError becomes true, it stays true, so that we know that there was an error if it is true. I think introducing a non-noreturn error reporting function is by itself a good idea, and it looks to me that this also provides a gradual path towards lld-as-a-library (or at least embed-lld-to-your-program) without sacrificing code readability with lots of ErrorOr's. http://reviews.llvm.org/D16641 llvm-svn: 259069
* Fix bug in handling of quoted linker script tokens and update tests to use it.Pete Cooper2016-01-221-1/+1
| | | | | | | | | | | | | There was an off by one error because the StringRef.substr functions second argument is a length, not the end index. Also updated a few ELF files which failed when run on Jenkins with paths including the @ character. This is often used in Jenkins for shared workspace plugin. Reviewed by Rui Ueyama llvm-svn: 258583
* Remove unnecessary `lld::`.Rui Ueyama2016-01-061-1/+1
| | | | llvm-svn: 256970
* [ELF] Lookup INPUT argument in the current directorySimon Atanasyan2015-11-261-0/+2
| | | | | | | | | | | | | If an argument of the INPUT directive is a regular path, linker should lookup it in the current folder first. The fix does not contain any test cases because I think it is not a good idea to pollute a current folder (which in general might be arbitrary) by test files. Differential Revision: http://reviews.llvm.org/D15027 llvm-svn: 254178
* [ELF] Reapply r254031 - LinkerScript: lookup absolute paths under sysrootSimon Atanasyan2015-11-261-3/+23
| | | | | | | | | | | | | | | In case a sysroot prefix is configured, and the filename starts with the '/' character, and the script being processed was located inside the sysroot prefix, the file's name will be looked for in the sysroot prefix. Otherwise, the linker falls to the common lookup scheme. It is slightly modified version of the commit r254031. The problem of the initial commit was in the `is_absolute` call. On Windows 'C:\' is absolute path but we do not need to find it under sysroot. In this patch linker looks up a path under sysroot only if the paths starts with '/' character. llvm-svn: 254135
* Follow-up to r254049; remove function I missed in the revert.Hans Wennborg2015-11-251-9/+0
| | | | llvm-svn: 254052
* Revert r254031: "ELF2: LinkerScript: lookup absolute paths under sysroot"Hans Wennborg2015-11-251-11/+3
| | | | | | | | | | | | | | | | The test fails on Windows: Command 34: "ld.lld" "-o" "D:\src\llvm\build.release\tools\lld\test\ELF\Output\l inkerscript.s.tmp2" "D:\src\llvm\build.release\tools\lld\test\ELF\Output\linkers cript.s.tmp.dir/xyz.script" "--sysroot=D:\src\llvm\build.release\tools\lld\test\ ELF\Output\linkerscript.s.tmp.dir" Command 34 Result: 1 Command 34 Output: Command 34 Stderr: Unable to find /libxyz.a llvm-svn: 254049
* ELF2: Factor out isUnderSysroot from readLinkerScript. NFC.Rui Ueyama2015-11-241-7/+10
| | | | llvm-svn: 254032
* ELF2: LinkerScript: lookup absolute paths under sysrootSimon Atanasyan2015-11-241-3/+17
| | | | | | | | | | | | | In case a sysroot prefix is configured, and the filename starts with the '/' character, and the script being processed was located inside the sysroot prefix, the file's name will be looked for in the sysroot prefix. Otherwise, the linker falls to the common lookup scheme. https://www.sourceware.org/binutils/docs-2.24/ld/File-Commands.html Differential Revision: http://reviews.llvm.org/D14916 llvm-svn: 254031
* [ELF2] SECTIONS command basic supportDenis Protivensky2015-11-121-1/+36
| | | | | | | | | | * determine output section by input section name * discard input sections * order output sections accordingly Differential Revision: http://reviews.llvm.org/D14140 llvm-svn: 252868
* [ELF2] - Linker script EXTERN command implemented.George Rimar2015-10-191-0/+13
| | | | | | | | The reason of collecting all undefines in vector is that during reading files we already need to have Symtab created. Or like was done in that patch - to put undefines from scripts somewhere to delay Symtab.addUndefinedOpt() call. Differential Revision: http://reviews.llvm.org/D13870 llvm-svn: 250711
* [ELF2/Linkerscript] Skip semicolon in linker directives parsing.Davide Italiano2015-10-131-0/+2
| | | | | | | | | The documentation says: "You may separate commands using semicolons", so they seem to be optional. Differential Revision: http://reviews.llvm.org/D13703 llvm-svn: 250223
* ELF2: Add comments.Rui Ueyama2015-10-131-1/+1
| | | | llvm-svn: 250215
OpenPOWER on IntegriCloud