summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - linkerscript AT keyword (in output section description) implemented.George Rimar2016-08-171-0/+18
| | | | | | | | | | | | | The linker will normally set the LMA equal to the VMA. You can change that by using the AT keyword. The expression lma that follows the AT keyword specifies the load address of the section. Patch implements this keyword. Differential revision: https://reviews.llvm.org/D19272 llvm-svn: 278911
* [ELF] Set MAXPAGESIZE to 2MiB on x86-64 to match bfd and gold.Michael J. Spencer2016-08-171-1/+3
| | | | | | The FreeBSD kernel relies on this behavior to not overwrite the boot loader. llvm-svn: 278889
* [ELF] Ignore .interp section in case linker script specifies PHDRS without ↵Eugene Leviant2016-08-161-0/+9
| | | | | | PT_INTERP llvm-svn: 278781
* [ELF] Linkerscript: support hidden symbols assignmentsPetr Hosek2016-08-161-5/+7
| | | | | | | | | This add support for HIDDEN command which can be used to define a symbol that will be hidden and won't be exported. Differential Revision: https://reviews.llvm.org/D23534 llvm-svn: 278770
* [ELF] Linkerscript: fix bug in assignOffsets (check Sym for non-null)Eugene Leviant2016-08-151-2/+4
| | | | llvm-svn: 278663
* [ELF] - Linkerscript: fix VA value assigned to sections when using constraints.George Rimar2016-08-121-10/+26
| | | | | | | | | | Previously we searched output section by name to assign VA. That did not work in the case when multiple output sections with different constraints were defined in script. Testcase shows the possible issue scenario, patch fixes the issue. Differential revision: https://reviews.llvm.org/D23451 llvm-svn: 278561
* [ELF] - Remove excessive loop in LinkerScript<ELFT>::assignAddresses()George Rimar2016-08-121-26/+26
| | | | | | | | | | After 278461 "Create only one section for a name in LinkerScript." this loop is excessive. Patch also reorders code slightly to use early return. Differential revision: https://reviews.llvm.org/D23442 llvm-svn: 278554
* [ELF] - Linkerscript: reimplemented output sections constrains matching ↵George Rimar2016-08-121-38/+19
| | | | | | | | | | | | | | | | | | | | | | | | | functionality. Previously filtering that was used worked incorrectly. For example for next script it would just remove both sections completely: SECTIONS { . = 0x1000; .aaa : ONLY_IF_RW { *(.aaa.*) } . = 0x2000; .aaa : ONLY_IF_RO { *(.aaa.*) } } Patch fixes above issues and adds testcase showing the issue. Testcase is a subset of FreeBSD script which has: .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } ... .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } Differential revision: https://reviews.llvm.org/D23326 llvm-svn: 278486
* Rename getSizeOfHeaders -> getHeaderSize.Rui Ueyama2016-08-121-8/+8
| | | | | | | We have getSectionSize for SIZEOF command. So, I think getHeaderSize is a better name for SIZEOF_HEADERS. llvm-svn: 278470
* Early continue. NFC.Rui Ueyama2016-08-121-11/+14
| | | | llvm-svn: 278465
* Simplify LinkerScript<ELFT>::createSections.Rui Ueyama2016-08-121-16/+11
| | | | | | | | | Previously, we were setting LayoutInputSection's OutputSection member in createSections. Because when we create LayoutInputSectinos, we don't know the output section for them, so we backfilled the member in the function. This patch moves the code to backfill it to assignOffsets. llvm-svn: 278464
* Remove excessive parentheses.Rui Ueyama2016-08-121-1/+1
| | | | llvm-svn: 278462
* Create only one section for a name in LinkerScript.Rui Ueyama2016-08-121-78/+62
| | | | | | | | | | | | | | Previously, we created two or more output sections if there are input sections with the same name but with different attributes. That is a wrong behavior. This patch fixes the issue. One thing we need to do is to merge output section attributes. Currently, we create an output section based on the first input section's attributes. This may make a wrong output section attributes. What we need to do is to bitwise-OR attributes. We'll do it in a follow-up patch. llvm-svn: 278461
* Allocate LayoutInputSections using SpecificBumpPtrAllocator.Rui Ueyama2016-08-121-20/+14
| | | | llvm-svn: 278453
* Remove OutputSectionBuilder::finalize.Rui Ueyama2016-08-121-15/+4
| | | | | | | | The reason why we had to assign offsets only to sections that don't contain layout sections were unclear. It turned out that we can live without it. llvm-svn: 278449
* Remove useless local variable.Rui Ueyama2016-08-121-3/+2
| | | | llvm-svn: 278446
* Split LinkerScript<ELFT>::createSections.Rui Ueyama2016-08-121-24/+33
| | | | | | Also avoid to use a lambda that is called only once. llvm-svn: 278445
* Replace a variadic forwarding template function with less complex ones.Rui Ueyama2016-08-111-26/+28
| | | | llvm-svn: 278439
* Make class hierarchy more shallow.Rui Ueyama2016-08-111-3/+4
| | | | | | | LayoutInputSection is a dummy class and does not need any features that the actual implementation (InputSection class) provides. llvm-svn: 278430
* Remove trailing whitespace.Rui Ueyama2016-08-111-1/+1
| | | | llvm-svn: 278420
* Add comments.Rui Ueyama2016-08-111-1/+12
| | | | llvm-svn: 278408
* [ELF] Symbol assignment within output section descriptionEugene Leviant2016-08-111-72/+201
| | | | llvm-svn: 278322
* [ELF] - Linkerscript: implement SIZEOF_HEADERS.George Rimar2016-08-101-1/+23
| | | | | | | | | | | SIZEOF_HEADERS - Return the size in bytes of the output file’s headers. It is is a feature used in FreeBsd script, for example. There is a discussion on PR28688 page about it. Differential revision: https://reviews.llvm.org/D23165 llvm-svn: 278204
* Remove unreachable `return`. NFC.Rui Ueyama2016-08-091-1/+0
| | | | llvm-svn: 278096
* Remove isOutputDynamic and use Out<ELFT>::DynSymTab instead.Rui Ueyama2016-08-091-1/+1
| | | | | | | This patch is to not instantiate DynSymTab and DynStrTab if the output is not a dynamic output. llvm-svn: 278095
* Simplify. NFC.Rui Ueyama2016-08-051-19/+8
| | | | llvm-svn: 277794
* Move invariants outside of a lambda. NFC.Rui Ueyama2016-08-051-3/+3
| | | | llvm-svn: 277791
* Make combine() non-member function.Rui Ueyama2016-08-051-35/+34
| | | | | | Because this function depends only on its arguments. llvm-svn: 277790
* Split InputSectionDescription::Sort into SortInner and SortOuter.Rui Ueyama2016-08-041-42/+41
| | | | | | | | | | | | | | | | | Summary: The comparator function to compare input sections as instructed by SORT command was a bit too complicated because it needed to handle four different cases. This patch split it into two function calls. This patch also simplifies the parser. Reviewers: grimar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23140 llvm-svn: 277780
* Remove redundant argument.Rafael Espindola2016-08-041-10/+6
| | | | | | But always set Script<ELFT>::X->OutputSections. llvm-svn: 277720
* [ELF] - Linkerscript: implemented ASSERT() keyword.George Rimar2016-08-041-0/+28
| | | | | | | | | | | | ASSERT(exp, message) Ensure that exp is non-zero. If it is zero, then exit the linker with an error code, and print message. ASSERT is useful and was seen in few projects in the wild. Differential revision: https://reviews.llvm.org/D22912 llvm-svn: 277710
* [ELF] - Linkerscript: Fixed SORT_BY_ALIGNMENT sorting order.George Rimar2016-08-041-2/+2
| | | | | | | | | | According to spec: "SORT_BY_ALIGNMENT will sort sections into descending order by alignment before placing them in the output file" Previously they were sorted into ascending order. llvm-svn: 277706
* [ELF] Linkerscript: remove repeated sections in filter()Eugene Leviant2016-08-041-12/+12
| | | | llvm-svn: 277703
* Remove buggy PROVIDE-in-output-description command.Rui Ueyama2016-08-041-9/+3
| | | | | | | | | | | | | | | | | With the previous change, it is now obvious that readProvide in this context appended new commands to a wrong command list. It was mistakenly adding new commands to the top level. Thus, all commands inside output section descriptions were interpreted as they were written on top level. PROVIDE command naturally requires symbol assignment support in the output section description. We don't have that one yet. I removed the implementation because there's no way to fix it now. We can resurrect the test once we support the symbol assignment (with a modification to detect errors that we failed to find as described.) llvm-svn: 277687
* Make ScriptParser::read* functions more functional style.Rui Ueyama2016-08-041-53/+53
| | | | | | | | | | | | Previously, many read* functions created new command objects and add them directly to the top-level data structure. This is not work for some commands because some commands, such as the assignment, can appear inside and outside of the output section description. This patch is to not append objects to the top-level data structure. Callers are now responsible to do that. llvm-svn: 277686
* Make filler expression compatible with gold.Rui Ueyama2016-08-031-7/+8
| | | | | | | | | | Previously, a decimal filler expression is interpreted as a byte value. Gold on the other hand use it as a 32-bit big-endian value. This patch fixes the compatibility issue. Differential Revision: https://reviews.llvm.org/D23142 llvm-svn: 277680
* Create only one vector instead of two.Rui Ueyama2016-08-031-8/+10
| | | | | | | In this for-loop, we append elements from one vector to another, which is a bit inefficient. llvm-svn: 277653
* Revert 277594, it caused PR28827Nico Weber2016-08-031-4/+5
| | | | llvm-svn: 277599
* Remove redundant argument.Rafael Espindola2016-08-031-5/+4
| | | | llvm-svn: 277594
* [ELF] - Linkerscript: support all kinds of sorting (including nested).George Rimar2016-08-031-10/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we supported only sorting by name. When there are nested section sorting commands in linker script, there can be at most 1 level of nesting for section sorting commands. SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard section pattern)). It will sort the input sections by name first, then by alignment if 2 sections have the same name. SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section pattern)). It will sort the input sections by alignment first, then by name if 2 sections have the same alignment. SORT_BY_NAME (SORT_BY_NAME (wildcard section pattern)) is treated the same as SORT_ BY_NAME (wildcard section pattern). SORT_BY_ALIGNMENT (SORT_BY_ALIGNMENT (wildcard section pattern)) is treated the same as SORT_BY_ALIGNMENT (wildcard section pattern). All other nested section sorting commands are invalid. Patch implements that all above. Differential revision: https://reviews.llvm.org/D23019 llvm-svn: 277583
* Support expressions inside FLAGS.Rafael Espindola2016-08-021-1/+3
| | | | | | | This is an undocumented bfd feature. It is reasonable for making the scripts a bit more readable. llvm-svn: 277532
* [LinkerScript] Filler can have a decimal value.Davide Italiano2016-07-291-5/+11
| | | | llvm-svn: 277222
* [ELF] - Linkerscript: implemented SIZEOF(section)George Rimar2016-07-291-13/+42
| | | | | | | | | | | | | | | SIZEOF(section) Return the size in bytes of the named section, if that section has been allocated. SIZEOF(section) often used in scripts. Few examples from the wild: https://github.com/chipKIT32/pic32-Arduino-USB-Bootloader-original/blob/master/boot-linkerscript.ld https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/gba_cart.ld Patch implements it. Differential revision: https://reviews.llvm.org/D22915 llvm-svn: 277165
* [ELF] - Linkerscript: Implemented SORT command.George Rimar2016-07-291-6/+32
| | | | | | | | | | | | When the SORT keyword is used, the linker will sort the files or sections into ascending order by name before placing them in the output file. It is used in FreeBSD script: https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l139 This is PR28689. Differential revision: https://reviews.llvm.org/D22749 llvm-svn: 277153
* [ELF] - Linkerscript: make addSection() global function instead lambda. NFC.George Rimar2016-07-291-13/+16
| | | | llvm-svn: 277150
* [ELF] - Update comment. NFC.George Rimar2016-07-291-4/+1
| | | | llvm-svn: 277147
* Remove `continue` at end of a for-loop.Rui Ueyama2016-07-291-3/+1
| | | | llvm-svn: 277122
* Split readOutputSectionDescription.Rui Ueyama2016-07-291-8/+12
| | | | llvm-svn: 277121
* Remove `Ignore` flag from SymbolAssignment class.Rui Ueyama2016-07-291-21/+17
| | | | | | | | | | | | | Previously, Ignore flag is set if we don't want to assign a value to symbols. It happens if a symbol assingment is in PROVIDE() and there's already a symbol with the same name. The previous code had a subtle but that we assume that the existing symbol is an absolute symbol even if it is not. This patch fixes the issue by always overwriting an absolute symbol. llvm-svn: 277115
* Rename DoLayout -> HasContents. NFC.Rui Ueyama2016-07-291-1/+1
| | | | llvm-svn: 277102
OpenPOWER on IntegriCloud