summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move name lookup to script parsing time.Rafael Espindola2017-06-011-8/+24
| | | | | | | | | | | We were looking up sections by name during expression evaluation. By keeping track of forward declarations we can do the lookup during script parsing. Doing the lookup earlier will be more efficient when assignAddresses is run twice and removes two uses of OutputSections. llvm-svn: 304381
* [ELF] Use late evaluation for ALIGN in expressionPetr Hosek2017-05-301-1/+5
| | | | | | | | | | | | | | | | | | While the following expression is handled fine: PROVIDE_HIDDEN(newsym = oldsym + address); The following expression triggers an error because the expression is evaluated as absolute: PROVIDE_HIDDEN(newsym = ALIGN(oldsym, CONSTANT(MAXPAGESIZE)) + address); To avoid this error, we use late evaluation for ALIGN by making the alignment an attribute of the expression itself. Differential Revision: https://reviews.llvm.org/D33629 llvm-svn: 304185
* [ELF] - Use llvm::to_integer() instead of StringRef::getAsInteger().George Rimar2017-05-161-6/+6
| | | | | | | | | | | Switch to llvm::to_integer() everywhere in LLD instead of StringRef::getAsInteger() because API of latter is confusing. It returns true on error and false otherwise what makes reading the code incomfortable. Differential revision: https://reviews.llvm.org/D33187 llvm-svn: 303149
* Add memory ORIGIN and LENGTH expression supportRui Ueyama2017-05-091-0/+12
| | | | | | | | | | | | | | | Adds support for the ORIGIN and LENGTH linker script built in functions. ORIGIN(memory) Return the origin of the memory region LENGTH(memory) Return the length of the memory region Redo of D29775 for refactored linker script parsing. Patch by Robert Clarke Differential Revision: https://reviews.llvm.org/D32934 llvm-svn: 302564
* Rename readOutputSectionFiller parseFill.Rui Ueyama2017-04-131-10/+10
| | | | | | | | "read" is used as a prefix for functions that read tokens from input streams. This function doesn't really read anything, but just parses a given string as an integer, so rename. llvm-svn: 300281
* Fix FILL linker script command.Rui Ueyama2017-04-131-1/+0
| | | | | | | FILL command doesn't need a semicolon. Fixes https://bugs.llvm.org/show_bug.cgi?id=32657 llvm-svn: 300280
* Allow expressions in MEMORY command.Rui Ueyama2017-04-121-6/+1
| | | | | | | | | | Previously, we allowed only integers in this context. Now you can write expressions there. LLD is now able to handle the following linker, for example. MEMORY { rom (rx) : ORIGIN = (1024 * 1024) } llvm-svn: 300131
* [lld] Keep full library path in DT_NEEDED.Evgeniy Stepanov2017-04-121-6/+7
| | | | | | | | | | | | | | | | | Fixes PR32572. When (a) a library has no soname and (b) library is given on the command line with path (and not through -L/-l flags) DT_NEEDED entry for such library keeps the path as given. This behavior is consistent with gold and bfd, and is used in compiler-rt test suite. This is a second attempt after r300007 got reverted. This time relro-omagic test is changed in a way to avoid hardcoding the path to the test directory in the objdump'd binary. llvm-svn: 300011
* Revert "[lld] Keep full library path in DT_NEEDED."Evgeniy Stepanov2017-04-121-7/+6
| | | | | | This reverts commit r300007. Reason: breaks all the bots. llvm-svn: 300008
* [lld] Keep full library path in DT_NEEDED.Evgeniy Stepanov2017-04-111-6/+7
| | | | | | | | | | | | | Fixes PR32572. When (a) a library has no soname and (b) library is given on the command line with path (and not through -L/-l flags) DT_NEEDED entry for such library keeps the path as given. This behavior is consistent with gold and bfd, and is used in compiler-rt test suite. llvm-svn: 300007
* Remove big-endianness from =<fillexp> code.Rui Ueyama2017-04-111-5/+8
| | | | llvm-svn: 300005
* Return Optional<uint64_t> from readInteger instead of returning just ↵Rui Ueyama2017-04-051-38/+36
| | | | | | success/failure. llvm-svn: 299600
* Inline small functions that are used only once.Rui Ueyama2017-04-051-5/+2
| | | | llvm-svn: 299580
* Fix comments.Rui Ueyama2017-04-051-7/+13
| | | | llvm-svn: 299579
* Rename ScriptConfig::UndefinedSymbols ReferencedSymbols.Rui Ueyama2017-04-051-5/+7
| | | | | | | Symbols referenced by linker scripts are not necessarily be undefined, so the previous name didn't convey the meaining of the variable. llvm-svn: 299573
* Make readAssert() to return an AssertCommand object.Rui Ueyama2017-04-051-6/+11
| | | | llvm-svn: 299521
* Add a file comment.Rui Ueyama2017-04-051-0/+5
| | | | llvm-svn: 299520
* Simplify. NFC.Rui Ueyama2017-04-051-44/+32
| | | | | | Looks like we can use consume() in many more places. llvm-svn: 299519
* Inline leftShift and rightShift. NFC.Rui Ueyama2017-04-051-10/+2
| | | | llvm-svn: 299518
* Do not make ScriptParser class public.Rui Ueyama2017-04-051-1/+3
| | | | | | This class is used only within this file, so it can be file-local. llvm-svn: 299516
* Move the parser for the linker script to a separate file.Rui Ueyama2017-04-051-0/+1184
| | | | | | | | LinkerScript.cpp contains both the linker script processor and the linker script parser. I put both into a single file, but the file grown too large, so it's time to put them into two different files. llvm-svn: 299515
* Rename ScriptParser.{cpp,h} -> ScriptLexer.{cpp,h}.Rui Ueyama2017-02-141-203/+0
| | | | | | | These files contain a lexer, so the new names are better. The parser is in LinkerScript.{cpp,h}. llvm-svn: 295022
* Handle the case where 'local' is the name of a global in a version script:Dmitry Mikulin2017-02-071-5/+8
| | | | | | { global : local; local: *; }; llvm-svn: 294343
* Handle numbers followed by ":" in linker scripts.Rafael Espindola2017-02-031-1/+1
| | | | | | | | | | | This is a fix for Bugzilla 31813. The problem is that the tokenizer does not create a separate token for ":" unless there's white space before it. Changed it to always create a token for ":" and reworked some logic that relied on ":" being attached to some tokens like "global:" and "local:". llvm-svn: 294006
* Simplify ScriptParser.Rui Ueyama2016-12-011-15/+13
| | | | | | | | - Rename currentBuffer -> getCurrentMB to start it with verb. - Simplify containsString. - Add llvm_unreachable at end of getCurrentMB. llvm-svn: 288310
* Do not name a variable Ret which is not a return value.Rui Ueyama2016-12-011-5/+5
| | | | llvm-svn: 288309
* Make get{Line,Column}Number members of StringParser.Rui Ueyama2016-12-011-27/+31
| | | | | | This patch also renames currentLocation getCurrentLocation. llvm-svn: 288308
* Split getPos into getLineNumber and getColumnNumber.Rui Ueyama2016-12-011-30/+29
| | | | llvm-svn: 288306
* [ELF] Print file:line for 'undefined section' errorsEugene Leviant2016-11-281-0/+7
| | | | | | Differential revision: https://reviews.llvm.org/D27108 llvm-svn: 288019
* [ELF] Better error reporting for linker scriptsEugene Leviant2016-11-211-28/+55
| | | | | | Differential revision: https://reviews.llvm.org/D26795 llvm-svn: 287547
* Simplify. NFC.Rui Ueyama2016-10-211-9/+4
| | | | llvm-svn: 284806
* ELF: Implement skip() as (void)next()Justin Bogner2016-10-171-9/+1
| | | | | | Thanks to Rafael for pointing out the simplification. llvm-svn: 284407
* Rename skip(StringRef) -> consume(StringRef).Rui Ueyama2016-10-171-1/+1
| | | | | | | | skip() and skip(StringRef) were overloaded functions that have different semantics. This patch rename one of the functions to avoid function overloading. llvm-svn: 284396
* ELF: Add a skip() overload to ignore any tokenJustin Bogner2016-10-171-0/+10
| | | | | | | | | Most functions that return StringRef should check their return values, so I'm planning on marking StringRef [[nodiscard]]. This requires splitting up functions like next() that are sometimes just used for side effects. llvm-svn: 284363
* Recommit [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.George Rimar2016-09-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed code that was not checked before on windows for me, because of testcases that are disabled on that platform atm. Inital commit message: "[ELF] - Versionscript: do not treat non-wildcarded names as wildcards." Previously we incorrectly handled cases when symbol name in extern c++ tag was enclosed in quotes. Next case was treated as wildcard: GLIBCXX_3.4 { extern "C++" { "aaa*" } But it should have not. Quotes around aaa here means that we should have do exact name matching. That is PR30268 which has name with pointer is interpreted as wildcard by lld: extern "C++" { "operator delete[](void*)"; Patch fixes the issue. Differential revision: https://reviews.llvm.org/D24229 llvm-svn: 281049
* Revert r281045, it broke BB.George Rimar2016-09-091-5/+2
| | | | | | | Broken BB: http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/27211 llvm-svn: 281046
* Recommit [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.George Rimar2016-09-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed code that was not checked by testcases that are disabled on windows. Inital commit message: "[ELF] - Versionscript: do not treat non-wildcarded names as wildcards." Previously we incorrectly handled cases when symbol name in extern c++ tag was enclosed in quotes. Next case was treated as wildcard: GLIBCXX_3.4 { extern "C++" { "aaa*" } But it should have not. Quotes around aaa here means that we should have do exact name matching. That is PR30268 which has name with pointer is interpreted as wildcard by lld: extern "C++" { "operator delete[](void*)"; Patch fixes the issue. Differential revision: https://reviews.llvm.org/D24229 llvm-svn: 281045
* [ELF] - Revert r281038 to see if that unbreaks build bot.George Rimar2016-09-091-5/+2
| | | | | | http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/19703 llvm-svn: 281041
* [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.George Rimar2016-09-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | Previously we incorrectly handled cases when symbol name in extern c++ tag was enclosed in quotes. Next case was treated as wildcard: GLIBCXX_3.4 { extern "C++" { "aaa*" } But it should have not. Quotes around aaa here means that we should have do exact name matching. That is PR30268 which has name with pointer is interpreted as wildcard by lld: extern "C++" { "operator delete[](void*)"; Patch fixes the issue. Differential revision: https://reviews.llvm.org/D24229 llvm-svn: 281038
* [ELF] - Fix for: PR29093 - version script does not support [chars] wildcardsGeorge Rimar2016-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | GNU ld supports [chars] wildcards in version scripts, to match a single instance of any of the chars. Here is an extern example from libstdc++'s version script in FreeBSD: extern "C++" { ... std::locale::_[T-Za-z]*; std::[A-Zm]*; std::n[^u]*; std::nu[^m]*; std::num[^e]*; ... } Patch adds support for scripts above. This is PR29093. Differential revision: https://reviews.llvm.org/D23803 llvm-svn: 280799
* Add comments.Rui Ueyama2016-09-011-2/+4
| | | | llvm-svn: 280423
* Create Strings.cpp and move string manipulation functions to that file.Rui Ueyama2016-06-291-15/+0
| | | | llvm-svn: 274109
* [ELF] - Do not crash on unclosed quote (") in scripts.George Rimar2016-06-221-1/+1
| | | | | | | Found that during investigation of FreeBsd scripts. Unclosed quote just crashed lld. llvm-svn: 273398
* Add support for # comments.Rafael Espindola2016-06-161-1/+8
| | | | llvm-svn: 272892
* [ELF] - Implemented comparsion operators for linkerscript.George Rimar2016-04-251-1/+1
| | | | | | | | 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-2/+6
| | | | | | | | 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
* [ELF] Include Twine.h header to restore LLD build after r266524. NFCSimon Atanasyan2016-04-161-0/+1
| | | | llvm-svn: 266527
* [lld] [ELF] Add ScriptParserBase classAdhemerval Zanella2016-04-061-0/+166
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
OpenPOWER on IntegriCloud