summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Remove unnecessary include.Rafael Espindola2015-10-131-1/+0
| | | | llvm-svn: 250161
* Use llvm::sys::path::is_absolute instead of my own.Rui Ueyama2015-10-131-5/+2
| | | | llvm-svn: 250133
* Fix test breakage on Windows.Rui Ueyama2015-10-121-1/+6
| | | | llvm-svn: 250127
* [ELF2/LinkerScript] Implement parsing of OUTPUT_ARCH() command.Davide Italiano2015-10-121-0/+10
| | | | | | Differential Revision: http://reviews.llvm.org/D13675 llvm-svn: 250115
* [ELF2/LinkerScript] Fix OUTPUT_FORMAT directive parsingDavide Italiano2015-10-121-0/+8
| | | | | | Differential Revision: http://reviews.llvm.org/D13668 llvm-svn: 250106
* Remove explicit Twine instantiation if possible.Rui Ueyama2015-10-121-1/+1
| | | | llvm-svn: 250055
* ELF2: Implement --as-needed.Rui Ueyama2015-10-111-1/+4
| | | | | | | | | | | | | | This patch adds AsNeeded and IsUsed bool fields to SharedFile. AsNeeded bit is set if the DSO is enclosed with --as-needed and --no-as-needed. IsUsed bit is off by default. When we adds a symbol to the symbol table for dynamic linking, we set its SharedFile's IsUsed bit. If AsNeeded is set but IsUsed is not set, we don't want to write that file's SO name to DT_NEEDED field. http://reviews.llvm.org/D13579 llvm-svn: 249998
* ELF2: LinkerScript: Interpret -l and = file name prefixes.Rui Ueyama2015-10-111-3/+23
| | | | | | | | In the linker script, -l and = have the same meaning as in the command line. In addition to that, if a path is not absolute, the path needs to be searched from the search paths. This patch implements them. llvm-svn: 249967
* ELF2: Do not leak MemoryBuffers.Rui Ueyama2015-10-111-8/+8
| | | | llvm-svn: 249962
* ELF2: LinkerScript: Handle INPUT as a synonym for GROUP.Rui Ueyama2015-10-111-1/+1
| | | | | | | In our name resolution algorithm, --start-group and --end-group have no special meaning. llvm-svn: 249961
* ELF2: LinkerScript: Implement INCLUDE directive.Rui Ueyama2015-10-111-0/+16
| | | | llvm-svn: 249960
* [ELF2] Implement linker script SEARCH_DIR() directive.Davide Italiano2015-10-081-0/+9
| | | | llvm-svn: 249707
* [ELF2] Add ENTRY command to the linker scriptDenis Protivensky2015-10-081-1/+13
| | | | | | | | Set ENTRY as an entry point if -e is not specified. Differential Revision: http://reviews.llvm.org/D13509 llvm-svn: 249661
* ELF2: Implement OUTPUT() linker script directive.Rui Ueyama2015-10-071-0/+12
| | | | llvm-svn: 249491
* ELF2: Define Driver::addFile() as a one-stop place to open a file.Rui Ueyama2015-10-011-6/+5
| | | | | | | | | | | | | | Opening a file and dispatching to readLinkerScript() or createFile() is a common operation. We want to use that at least from Driver and from LinkerScript. In COFF, we had the same problem. This patch resolves the problem in the same way as we did for COFF. Now, if you have a path that you want to open, just call Driver->addFile(StringRef). That function opens the file and handles that as if that were given by command line. This function is the only place we call identify_magic(). llvm-svn: 249023
* ELF2: Create LinkerScript.cpp and move code from DriverUtils to there.Rui Ueyama2015-09-301-0/+156
llvm-svn: 248920
OpenPOWER on IntegriCloud