summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Handle empty dynamic lists.Rafael Espindola2017-09-081-0/+1
| | | | llvm-svn: 312820
* If --dynamic-list is given, only those symbols are preemptible.Rafael Espindola2017-09-081-2/+15
| | | | | | | | | | | | | This allows combining --dynamic-list and version scripts too. The version script controls which symbols are visible, and --dynamic-list controls which of those are preemptible. Unlike previous versions, undefined symbols are still considered preemptible, which was the issue breaking the cfi tests. This fixes pr34053. llvm-svn: 312806
* [ELF] - Linkerscript: implement REGION_ALIAS.George Rimar2017-09-081-7/+24
| | | | | | | | | | | | REGION_ALIAS(alias, region) Alias names can be added to existing memory regions created with the MEMORY command. Each name corresponds to at most one memory region. Differential revision: https://reviews.llvm.org/D37477 llvm-svn: 312777
* Revert "Revert "Revert r311468: If --dynamic-list is given, only those ↵Rafael Espindola2017-09-081-15/+2
| | | | | | | | | | symbols are preemptible"" This reverts commit r312757. Evgenii Stepanov reports that it broke some tests. llvm-svn: 312771
* Revert "Revert r311468: If --dynamic-list is given, only those symbols are ↵Rafael Espindola2017-09-071-2/+15
| | | | | | | | | | | | | | preemptible" If --dynamic-list is given, only those symbols are preemptible. This allows combining --dynamic-list and version scripts too. The version script controls which symbols are visible, and --dynamic-list controls which of those are preemptible. This fixes pr34053. llvm-svn: 312757
* Detect linker script INCLUDE cycles.Rui Ueyama2017-09-061-0/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D37524 llvm-svn: 312656
* Add a comment.Rui Ueyama2017-09-061-0/+1
| | | | llvm-svn: 312655
* Revert r311468: If --dynamic-list is given, only those symbols are preemptibleRui Ueyama2017-08-221-15/+2
| | | | | | This reverts commit r311468 because it broke some CFI bots. llvm-svn: 311497
* If --dynamic-list is given, only those symbols are preemptibleRui Ueyama2017-08-221-2/+15
| | | | | | | | | | | | | | | | | Patch by Rafael Espíndola. This is PR34053. The implementation is a bit of a hack, given the precise location where IsPreemtible is set, it cannot be used from SymbolTable::handleAnonymousVersion. I could add another method to SymbolTable if you think that would be better. Differential Revision: https://reviews.llvm.org/D36499 llvm-svn: 311468
* [ELF, LinkerScript] Support ! operator in linker script.Hafiz Abid Qadeer2017-08-101-0/+4
| | | | | | | | | | | | | | Summary: This small patch adds the support for ! operator in linker scripts. Reviewers: ruiu, rafael Reviewed By: ruiu Subscribers: meadori, grimar, emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D36451 llvm-svn: 310607
* [ELF] - Remove ScriptLexer::Error field and check ErrorCount instead.George Rimar2017-08-041-18/+18
| | | | | | | | | | | | D35945 introduces change when there is useless to check Error flag in few places, but ErrorCount must be checked instead. But then we probably can just check ErrorCount always. That should simplify things. Patch do that. Differential revision: https://reviews.llvm.org/D36266 llvm-svn: 310046
* [ELF] - Do not segfault if linkerscript tries to access Target too early.George Rimar2017-08-031-10/+22
| | | | | | | | | | | | | | Following possible scripts triggered accessing to Target when it was not yet initialized (was nullptr). MEMORY { name : ORIGIN = DATA_SEGMENT_RELRO_END; } MEMORY { name : ORIGIN = CONSTANT(COMMONPAGESIZE); } Patch errors out instead. Differential revision: https://reviews.llvm.org/D36140 llvm-svn: 309953
* [ELF] - Do not crash when ALIGN/DATA_SEGMENT_ALIGN expression used with zero ↵George Rimar2017-07-281-3/+7
| | | | | | | | | | | | | value. Previously we would crash when tried to ALIGN(0). Patch uses value 1 instead in this case, that looks to be consistent with GNU linkers and reasonable and simple behavior itself. Differential revision: https://reviews.llvm.org/D35942 llvm-svn: 309372
* Merge OutputSectionCommand and OutputSection.Rafael Espindola2017-07-271-18/+14
| | | | | | | | | | | | | This is a bit of a hack, but it is *so* convenient. Now that we create synthetic linker scripts when none is provided, we always have to handle paired OutputSection and OutputsectionCommand and keep a mapping from one to the other. This patch simplifies things by merging them and creating what used to be OutputSectionCommands really early. llvm-svn: 309311
* [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
OpenPOWER on IntegriCloud