summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF, LinkerScript] Memory region name parsing fixMeador Inge2017-07-261-0/+2
| | | | | | | | | | | | | | | | | This patch fixes a small issue with respect to how memory region names are parsed on output section descriptions. For example, consider: .text : { *(.text) } > rom That can also be written like: .text : { *(.text) } >rom The latter form is accepted by GNU LD and is fairly common. Differential Revision: https://reviews.llvm.org/D35920 llvm-svn: 309191
* [ELF] Align the value if needed when computing the expressionPetr Hosek2017-07-201-2/+4
| | | | | | | | | Also add the test cases for the addition and subtraction both for the relative and absolute case. Differential Revision: https://reviews.llvm.org/D35346 llvm-svn: 308692
* Add the --chroot option for --reproduce.Rui Ueyama2017-07-201-1/+1
| | | | | | | | | | | | | | | Summary: If the linker is invoked with `--chroot /foo` and `/bar/baz.o`, it tries to read the file from `/foo/bar/baz.o`. This feature is useful when you are dealing with files created by the --reproduce option. Reviewers: grimar Subscribers: llvm-commits, emaste Differential Revision: https://reviews.llvm.org/D35517 llvm-svn: 308646
* Move feature-specific functions out of Strings.cpp.Rui Ueyama2017-07-131-0/+10
| | | | | | | | Functions declared in Strings.h should provide generic string operations for the linker, but some of them are too specific to some features. This patch moves them to the location where they are used. llvm-svn: 307949
* [ELF] Extract temporary state used in assignAddresses()Peter Smith2017-07-071-2/+1
| | | | | | | | | | | | | | | | | | The assignAddresses() function accumulates state in the LinkerScript that prevents it from being called multiple times. This change moves the state into a separate structure AddressState that is created at the start of the function and disposed of at the end. CurAddressState is used rather than passing a reference to the state as a parameter to the functions used by assignAddresses(). This is because the getSymbolValue function needs to be executed in the context of AddressState but it is stored in ScriptParser when AddressState is not available. The AddressState is also used in a limited context by processCommands() Differential Revision: https://reviews.llvm.org/D34345 llvm-svn: 307367
* Fix a bug in output section directive.Rui Ueyama2017-06-081-15/+32
| | | | | | | | | | Previously, it couldn't parse SECTIONS .text (0x1000) : { *(.text) } because "(" was interpreted as the begining of the "(NOLOAD)" directive. llvm-svn: 305006
* [ELF] - Linkerscript: implement NOLOAD section type.George Rimar2017-06-071-4/+14
| | | | | | | | | | | | | | | This is PR32351 Each output section may have a type. The type is a keyword in parentheses. (https://sourceware.org/binutils/docs/ld/Output-Section-Type.html#Output-Section-Type) This patch support only one type, it is NOLOAD. If output section has such type, we force it to be SHT_NOBITS. More details are available on a review page. Differential revision: https://reviews.llvm.org/D33647 llvm-svn: 304925
* [ELF] - Linkerscript: improved error reporting.George Rimar2017-06-071-6/+8
| | | | | | | | | | | | | | | | When linking linux kernel LLD currently reports next errors: ld: error: unable to evaluate expression: input section .head.text has no output section assigned ld: error: At least one side of the expression must be absolute ld: error: At least one side of the expression must be absolute That does not provide file/line information and overall looks unclear. Patch adds location information to ExprValue and that allows to provide more clear error messages. Differential revision: https://reviews.llvm.org/D33943 llvm-svn: 304881
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-1/+1
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* 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
OpenPOWER on IntegriCloud