summaryrefslogtreecommitdiffstats
path: root/lld/test/ELF/linkerscript
Commit message (Collapse)AuthorAgeFilesLines
...
* Make lld actually compatible with gold in terms of filler handling.Rui Ueyama2016-08-291-5/+5
| | | | | | | | | GNU gold handles output section fillers as 32-bit values. This patch makes LLD compatible with that behavior. Differential revision: https://reviews.llvm.org/D23181 llvm-svn: 280018
* [ELF] Added test case for PROVIDE and PROVIDE_HIDDEN within sectionEugene Leviant2016-08-261-1/+8
| | | | llvm-svn: 279809
* Add support for '|' in expressions.Rafael Espindola2016-08-221-1/+1
| | | | llvm-svn: 279480
* [ELF] Define __ehdr_start symbolPetr Hosek2016-08-221-0/+11
| | | | | | | | This symbol can be used by the program to examine its own headers. Differential Revision: https://reviews.llvm.org/D23750 llvm-svn: 279452
* [ELF] - Fix for PR28976 - Corrupted section contents when using linker scriptsGeorge Rimar2016-08-192-0/+19
| | | | | | | | | | | | This is fix for PR28976. Problem was that in scanRelocs, we computed relocation offset too early for case when linkerscript was used. Patch fixes the issue delaying the calculation. Differential revision: https://reviews.llvm.org/D23655 llvm-svn: 279264
* [ELF] - Linkerscript: set correct dynamic tag entries values when LS is used.George Rimar2016-08-191-0/+28
| | | | | | | | | | | | Previously DT_PREINIT_ARRAYSZ, DT_INIT_ARRAYSZ and DT_FINI_ARRAYSZ were set to zero when lincerscript was used becase sections sizes are calculated later that were taken. Patch delays values calculation for these entries. Testcase is provided. Differential revision: https://reviews.llvm.org/D23663 llvm-svn: 279258
* [ELF] - Linkerscript: implemented SUBALIGN() command.George Rimar2016-08-191-0/+43
| | | | | | | | | | | You can force input section alignment within an output section by using SUBALIGN. The value specified overrides any alignment given by input sections, whether larger or smaller. SUBALIGN is used in many projects in the wild. Differential revision: https://reviews.llvm.org/D23063 llvm-svn: 279256
* [ELF] - Removed excessive llvm-readobj call from linkerscript-ouputformat.s. ↵George Rimar2016-08-191-1/+0
| | | | | | NFC. llvm-svn: 279236
* [ELF] Don't add input sections twice when linker script is usedEugene Leviant2016-08-181-0/+18
| | | | llvm-svn: 279036
* [ELF] Linkerscript: support assignment outside SECTIONSPetr Hosek2016-08-181-0/+26
| | | | | | | | | | | We only support assignments inside SECTIONS, but this does not match the behavior of GNU linker which also allows them outside SECTIONS. The only restriction on assignments outside SECTIONS is that they cannot reference . (they have to be absolute expressions). Differential Revision: https://reviews.llvm.org/D23598 llvm-svn: 279033
* [ELF] - linkerscript AT keyword (in output section description) implemented.George Rimar2016-08-171-0/+128
| | | | | | | | | | | | | 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-173-7/+7
| | | | | | 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/+12
| | | | | | PT_INTERP llvm-svn: 278781
* [ELF] Linkerscript: support hidden symbols assignmentsPetr Hosek2016-08-161-0/+6
| | | | | | | | | 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] Do not add start and end symbols in case they are already definedEugene Leviant2016-08-151-0/+16
| | | | llvm-svn: 278657
* [ELF] - Linkerscript: fix VA value assigned to sections when using constraints.George Rimar2016-08-121-0/+15
| | | | | | | | | | 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] - Do not use mergeable sections when LS is used.George Rimar2016-08-121-0/+28
| | | | | | | | | | | | | | | After latest changes we combine input sections with different attributes into single output section. Problem here is that regular output sections does not support adding mergeable input sections (and vise versa). Patch just temporarily disables merging for now at the same way we do for -O0 for example. This change helps for linking FreeBSD kernel. Differential revision: https://reviews.llvm.org/D23447 llvm-svn: 278555
* [ELF] - Linkerscript: reimplemented output sections constrains matching ↵George Rimar2016-08-122-16/+40
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Create only one section for a name in LinkerScript.Rui Ueyama2016-08-122-5/+3
| | | | | | | | | | | | | | 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
* [ELF] Symbol assignment within output section descriptionEugene Leviant2016-08-111-0/+38
| | | | llvm-svn: 278322
* [ELF] - Fixed section name pattern in two more testcases.George Rimar2016-08-102-2/+2
| | | | llvm-svn: 278227
* [ELF] - Fixed section name pattern in testcase.George Rimar2016-08-101-1/+1
| | | | llvm-svn: 278219
* [ELF] - Linkerscript: implement SIZEOF_HEADERS.George Rimar2016-08-101-0/+18
| | | | | | | | | | | 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
* [ELF] - Linkerscript: do not define _edata,_end,_etext if SECTIONS is used.George Rimar2016-08-081-0/+20
| | | | | | | | | | | | | | I faced that when tried to link FreeBSD kernel. It was "duplicate symbol: _edata in (internal) and (internal)" error. _data was a shared symbol that came from hack.so. At first it was replaced with DefinedRegular by the code disabled in this patch and later when script tried to define the same symbol - the error was shown. In the same situation (as given in testcase) ld defines them as UND. gold defines as ABS with zero value. Patch just disables any operations of creating these symbols if script do layout. Differential revision: https://reviews.llvm.org/D23206 llvm-svn: 277986
* Use "llvm-objdump -s" instead of hexdump command.Rui Ueyama2016-08-041-8/+8
| | | | llvm-svn: 277771
* [ELF] - Attemp to fix buildbot.George Rimar2016-08-041-1/+1
| | | | | | | http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/25733/steps/test_lld/logs/stdio Fix: removed excessive whitespace. llvm-svn: 277711
* [ELF] - Linkerscript: implemented ASSERT() keyword.George Rimar2016-08-041-0/+27
| | | | | | | | | | | | 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-042-20/+17
| | | | | | | | | | 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] - Remove trailing whitespaces. NFC.George Rimar2016-08-041-1/+1
| | | | llvm-svn: 277705
* [ELF] Linkerscript: remove repeated sections in filter()Eugene Leviant2016-08-041-2/+16
| | | | llvm-svn: 277703
* Remove buggy PROVIDE-in-output-description command.Rui Ueyama2016-08-041-20/+0
| | | | | | | | | | | | | | | | | 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 filler expression compatible with gold.Rui Ueyama2016-08-031-2/+2
| | | | | | | | | | 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
* [ELF] - Linkerscript: support all kinds of sorting (including nested).George Rimar2016-08-034-13/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+3
| | | | | | | This is an undocumented bfd feature. It is reasonable for making the scripts a bit more readable. llvm-svn: 277532
* Remove trailing whitespace.Rui Ueyama2016-07-291-1/+1
| | | | llvm-svn: 277253
* [LinkerScript] Filler can have a decimal value.Davide Italiano2016-07-291-5/+5
| | | | llvm-svn: 277222
* Don't crash if PT_TLS is empty.Rafael Espindola2016-07-291-0/+14
| | | | llvm-svn: 277202
* [ELF] - Linkerscript: implemented SIZEOF(section)George Rimar2016-07-291-0/+53
| | | | | | | | | | | | | | | 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-292-0/+75
| | | | | | | | | | | | 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: implemented filename specification.George Rimar2016-07-282-0/+43
| | | | | | | | | | | | | | | Scripts can contain something like: KEEP (*crtbegin.o(.ctors)) What means that "*crtbegin.o" is a wildcard of file to take the sections from. This is some kind of opposite to EXCLUDE_FILE and used in FreeBSD script: https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l122 Patch implements this. Differential revision: https://reviews.llvm.org/D22852 llvm-svn: 277042
* [ELF] - Linkerscript: implemented += operator.George Rimar2016-07-281-0/+21
| | | | | | | | | | | | | | | | | Sometimes += is used to move the location counter. Example from the wild is: .dbg_excpt _DBG_EXCPT_ADDR (NOLOAD) : { . += (DEFINED (_DEBUGGER) ? 0x8 : 0x0); https://github.com/chipKIT32/pic32-Arduino-USB-Bootloader-original/blob/master/boot-linkerscript.ld Patch implements it and opens way for others type of assignments (-= *= etc), though I think only += is actual to support. Differential revision: https://reviews.llvm.org/D22916 llvm-svn: 277035
* [ELF] Allows setting section for common symbols in linker scriptEugene Leviant2016-07-281-0/+49
| | | | llvm-svn: 277023
* Add support for SEGMENT_START.Rafael Espindola2016-07-282-0/+29
| | | | | | | | | | | | | | | | | | This is a bit of an odd feature. It is normally used in . = SEGMENT_START(seg, val); In bfd it evaluates to val or to the value of the corresponding -T<seg>-segment. Note that the -T<seg>-segment in bfd doesn't actually change the segment address, just the value this evaluates too, including in the default linker script. In gold the -T<seg>-segment options do change the segment address and seeing this expressions in linker scripts disables the options. For new this just always evaluates the expression to val. llvm-svn: 277014
* [ELF] - Linkerscript: ignore SORT(CONSTRUCTORS)George Rimar2016-07-281-0/+5
| | | | | | | | | | | | | | | Some scripts can contain SORT(CONSTRUCTORS) expression: https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l152 for ELF it just a nop: "When linking object file formats which do not support arbitrary sections, such as ECOFF and XCOFF, the linker will automatically recognize C++ global constructors and destructors by name. For these object file formats, the CONSTRUCTORS command tells the linker to place constructor information in the output section where the CONSTRUCTORS command appears. The CONSTRUCTORS command is ignored for other object file formats." (http://www.sourceware.org/binutils/docs-2.10/ld_3.html) So patch implements ignoring. Differential revision: https://reviews.llvm.org/D22848 llvm-svn: 276965
* [ELF/LinkerScript] Support EXCLUDE_FILE inside KEEP.Davide Italiano2016-07-273-0/+57
| | | | | | Differential Revision: https://reviews.llvm.org/D22795 llvm-svn: 276825
* [ELF] Linkerscript: symbol assignments with indentifiers on the right side ↵George Rimar2016-07-261-0/+32
| | | | | | | | | | | | | | | | of expression. In symbol assignments symbol may appear on the right-hand side of the expression: (https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l8) kernphys = CONSTANT (MAXPAGESIZE); . = kernbase + kernphys + SIZEOF_HEADERS; Patch implements that. Differential revision: https://reviews.llvm.org/D22759 llvm-svn: 276784
* [ELF] - Linkerscript: implemented ALIGN modificatior of output sections.George Rimar2016-07-261-0/+20
| | | | | | | | | | | Output section description can contain ALIGN modificator: https://sourceware.org/binutils/docs/ld/Output-Section-Description.html#Output-Section-Description Patch implements it. Differential revision: https://reviews.llvm.org/D22674 llvm-svn: 276780
* [ELF] Linkerscript: implement DATA_SEGMENT_RELRO_END.George Rimar2016-07-262-0/+79
| | | | | | | | | | | | | | | | | | | | In compare with what GNU linkers do (https://sourceware.org/binutils/docs/ld/Builtin-Functions.html), this implementation simple: Do not touch DATA_SEGMENT_ALIGN, it do what it do now - just aligns to the page boundary. Parameters of DATA_SEGMENT_RELRO_END is ignored. That should be correct as it is usually just a 24 bytes shift that allows to protect first 3 entries of got.plt with relro. (https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l146). DATA_SEGMENT_RELRO_END just aligns to the page boundary. That is what expected because all sections that are not affected by relro should be on another memory page. So at fact the difference with documented behavior is that we do not pad DATA_SEGMENT_ALIGN. 3 entries of got.plt are uncovered by relro, but functionality is simple and equal to lld behavior for case when script is not given. Differential revision: https://reviews.llvm.org/D22813 llvm-svn: 276778
* [ELF] Linkerscript: simplify DATA_SEGMENT_ALIGN evaluationGeorge Rimar2016-07-261-1/+1
| | | | | | | | | | | We can simplify the evaluation of DATA_SEGMENT_ALIGN just to simple align(). That way it will work exactly like we have in non-script case. Change was suggested by Rafael Ávila de Espíndola Differential revision: https://reviews.llvm.org/D22807 llvm-svn: 276745
* [ELF] Fix bug in test caseEugene Leviant2016-07-251-2/+2
| | | | llvm-svn: 276659
OpenPOWER on IntegriCloud