summaryrefslogtreecommitdiffstats
path: root/lld/test/ELF/linkerscript
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] Don't create empty output section for unreferenced PROVIDEsJames Henderson2018-07-031-0/+30
| | | | | | | | | | | | | | | | | | | | LLD removes empty output sections otherwise specified in the linker script. Prior to this change however, if section descriptions included ANY kind of symbol assignment, then the consequent output section would not be removed, even if the assignment was marked with PROVIDE and not actually triggered (i.e. the symbol was never referenced). This change modifies the isDiscarable function to ignore such directives when determining whether a section should be discarded, in keeping with bfd's behaviour. Symbol assignments that do result in a symbol definition will continue to result in a kept section (this is not actually the same as bfd's behaviour, but it is simpler, and probably makes more sense). Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D48771 llvm-svn: 336184
* [ELF] - Revert huge-temporary-file.s changed in r336129George Rimar2018-07-031-1/+1
| | | | | | | | | | | | | | | | Comment in the test case says that: ## This inputs previously created a 4gb temporarily file under 32 bit ## configuration. Issue was fixed. There is no clean way to check that from here. ## This testcase added for documentation purposes. The intention of the test was to create such huge file in case if our code will be broken again. And currently it documents we do not create huge outputs. r336129 changed -o to /dev/null and broke the intentions of the test case. llvm-svn: 336179
* [ELF] Fix other tests after r336129Fangrui Song2018-07-025-9/+9
| | | | llvm-svn: 336136
* [ELF] Replace unused output filenames with /dev/null in testsFangrui Song2018-07-0220-27/+27
| | | | | | Post commit review at rLLD335992 llvm-svn: 336129
* [ELF] - Linker script: add tests for checking malformed numbers parsing.George Rimar2018-06-291-2/+17
| | | | | | | | | | | | | | Previoulsy we had no test that covered malfolmed numbers with 'H', 'K' and 'M' suffixes, so the following lines were uncovered: https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L996 https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L1003 https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L1008 Patch fixes that. llvm-svn: 335979
* [ELF] - Implement linker script OVERLAYs.George Rimar2018-06-273-0/+60
| | | | | | | | | | | | | | | | | | This is PR36768. Linker script OVERLAYs are described in 4.6.9. Overlay Description of the spec: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/sections.html They are used to allow output sections which have different LMAs but the same VAs and used for embedded programming. Currently, LLD restricts overlapping of sections and that seems to be the most desired behaviour for defaults. My thoughts about possible approaches for PR36768 are on the bug page, this patch implements OVERLAY keyword and allows VAs overlapping for sections that within the overlay. Differential revision: https://reviews.llvm.org/D44780 llvm-svn: 335714
* [ELF] Make non-writable non-executable PROGBITS sections closer to .textFangrui Song2018-06-2612-27/+23
| | | | | | | | | | | | This generalizes the old heuristic placing SHT_DYNSYM SHT_DYNSTR first in the readonly SHF_ALLOC segment. Reviewers: espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D48406 llvm-svn: 335674
* [ELF] Assign RF_EXEC rank even if --no-rosegment or SECTIONS command is usedFangrui Song2018-06-2621-49/+51
| | | | | | | | | | | | | | | | | Summary: Currently when --no-rosegment is specified or a linker script with SECTIONS command is used, .rodata (A) .text (AX) are assigned the same rank and .rodata may be placed after .text . This increases the gap between .text and .bss and can cause pc-relative relocation overflow (e.g. gcc crtbegin.o crtbegin.S have R_X86_64_PC32 relocation from .text to .bss). This patch makes SingleRoRx affect only segment layout, not section layout. As a consequence, .rodata will be placed before .text regardless of SingleRoRx. Reviewers: espindola, ruiu, grimar, echristo, javed.absar Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D48405 llvm-svn: 335627
* [ELF] Fix sort-non-script.sFangrui Song2018-06-251-1/+1
| | | | llvm-svn: 335499
* [ELF] Change test files for style consistency. NFCFangrui Song2018-06-255-27/+27
| | | | | | | | | * Move `REQUIRES:` line to the top * llvm-mc ... -o %t -> llvm-mc ... -o %t.o * Don't check "TEXT" "DATA" columns (they are bfd-style names that do not fit into llvm well) in llvm-objdump output llvm-svn: 335498
* [ELF] readobj -elf-output-style=GNU -> readelfFangrui Song2018-06-257-11/+10
| | | | | | Style change for consistency. NFC llvm-svn: 335494
* [ELF] Change llvm-objdump output for D48472: TEXT DATA -> TEXTFangrui Song2018-06-2311-20/+20
| | | | | | | | | | Reviewers: jyknight, Bigcheese, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D48473 llvm-svn: 335404
* [lld] Add REQUIRES: x86 where needed to testsJoel Jones2018-06-064-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | If building lld without x86 support, tests that require that support should be treated as unsupported, not errors. Tested using: 1. cmake '-DLLVM_TARGETS_TO_BUILD=AArch64;X86' make check-lld => Expected Passes : 1406 Unsupported Tests : 287 2. cmake '-DLLVM_TARGETS_TO_BUILD=AArch64' make check-lld => Expected Passes : 410 Unsupported Tests : 1283 Patch by Joel Jones Differential Revision: https://reviews.llvm.org/D47748 llvm-svn: 334095
* Make ALIGN work with -r in linker scriptsRui Ueyama2018-05-171-0/+21
| | | | | | | | | | | | Patch by Mark Kettenis. Make ALIGN work in linker scripts used with the -r option. This works in GNU ld (ld.bfd) and is used to generate the "random gap" object for linking the OpenBSD kernel. Differential Revision: https://reviews.llvm.org/D46839 llvm-svn: 332656
* [lld] Mitigate relocation overflow [part 1 of 2].Han Shen2018-05-1520-48/+74
| | | | | | | | | | | This CL places .dynsym and .dynstr at the beginning of SHF_ALLOC sections. We do this to mitigate the possibility that huge .dynsym and .dynstr sections placed between ro-data and text sections cause relocation overflow. Differential Revision: https://reviews.llvm.org/D45788 llvm-svn: 332374
* [ELF] - Revert of: r332038, r332054, r332060, r332061, r332062, r332063George Rimar2018-05-1120-74/+48
| | | | | | | | | | | This reverts "Mitigate relocation overflow [part 1 of 2]." and the following commits which were trying to fix the bots. At the moment of r332082, bots are still failing and we need to find the reason of test case breakages first of all. http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/17042/steps/test/logs/stdio http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/29845/steps/test/logs/stdio llvm-svn: 332085
* Mitigate relocation overflow [part 1 of 2].Han Shen2018-05-1020-48/+74
| | | | | | | | | | | | This CL is to mitigate R_X86_64_PC32 relocation overflow problems for huge binaries that has near 4G allocated sections. By examining those binaries, there're 2 issues contributes to the problem: 1). huge ".dynsym" and ".dynstr" stands in the way between .rodata and .text 2). _init_array_start/end are placed at 0 if no ".init_array" presents, this causes .text relocation against them become more prone to overflow. This CL addresses 1st problem (the 2nd will be addressed in another CL.) by assigning a smaller sortrank to .dynsym and .dynstr thus they no longer stand in between. llvm-svn: 332038
* Add a CIE with length 0 unconditionally.Fangrui Song2018-05-083-3/+3
| | | | | | | | | | | | Summary: This is not technically required, but glibc unwind-dw2-fde.c classify_object_over_fdes expects there is a CIE record length 0 as a terminator. Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D46566 llvm-svn: 331708
* [ELF] - Eliminate the AssertCommand.George Rimar2018-04-251-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, LLD supports ASSERT as a separate command. We support two forms now. Assign expression-form: . = ASSERT(0x100) (old GNU ld required it and some scripts in the wild are still using something like . = ASSERT((_end - _text <= (512 * 1024 * 1024)), "kernel image bigger than KERNEL_IMAGE_SIZE"); Nowadays above is not a mandatory form and command-like form is commonly used: ASSERT(<expr>, "text); The return value of the ASSERT is Dot. That was implemented in D30171. It looks like (2) is just a short version of (1) then. GNU ld does *not* list ASSERT as a SECTIONS command: https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS Given above we probably can change ASSERT to be an assignment to Dot. That makes the rest of the code much simpler. Patch do that. Differential revision: https://reviews.llvm.org/D45434 llvm-svn: 330814
* [ELF] - Do not crash when trying to order --defsym/linker script symbols.George Rimar2018-04-101-0/+16
| | | | | | | | | Currently, we crash because File is null for such symbols. Differential revision: https://reviews.llvm.org/D45440 llvm-svn: 329678
* [ELF] - Simplify test case. NFC.George Rimar2018-04-091-5/+1
| | | | llvm-svn: 329563
* [ELF] - Stop setting OutSecOff too early.George Rimar2018-04-092-0/+58
| | | | | | | | | | | | | | | | | | | | | | | Currently LLD sets OutSecOff in addSection for input sections. That is a fake offset (just a rude approximation to remember the order), used for sorting SHF_LINK_ORDER sections (see resolveShfLinkOrder, compareByFilePosition). There are 2 problems with such approach: 1. We currently change and reuse Size field as a value assigned. Changing size is not good because leads to bugs. Currently, SIZEOF(.bss) for empty .bss returns 2 because we add two empty synthetic sections and increase size twice by 1. (See PR37011: https://bugs.llvm.org/show_bug.cgi?id=37011) 2. Such approach simply does not work when --symbol-ordering-file is involved, because processing of the ordering file might break the initial section order. This fixes PR37011. Differential revision: https://reviews.llvm.org/D45368 llvm-svn: 329560
* Make "Size" column in the map file one characters shorter.Rui Ueyama2018-04-052-54/+54
| | | | | | | | | Previously, "size" column is 9 characters long which is too long at least for 32-bit (because at maximum it needs 8 columns). This patch make it one column shorter than before. That's also a reasonable default for 64-bit. llvm-svn: 329317
* Fix column size in the map file.Rui Ueyama2018-04-052-54/+54
| | | | | | Size can be narrow, but LMA should be the same width as VMA. llvm-svn: 329312
* [ELF] Don't add NOLOAD sections to segmentEugene Leviant2018-04-051-6/+23
| | | | | | Differential revision: https://reviews.llvm.org/D45264 llvm-svn: 329281
* [ELF] - Reveal more information in -Map file about assignments.George Rimar2018-04-052-22/+38
| | | | | | | | | | | | | | | | | Currently, LLD print symbol assignment commands to the map file, but it does not do that for assignments that are outside of the section descriptions. Such assignments can affect the layout though. The patch implements the following: * Teaches LLD to print symbol assignments outside of section declaration. * Teaches LLD to print PROVIDE/HIDDEN/PROVIDE hidden commands. In case when symbol is not provided, nothing will be printed. Differential revision: https://reviews.llvm.org/D44894 llvm-svn: 329272
* [ELF] - Print LMA in a -Map file.George Rimar2018-04-053-13/+83
| | | | | | | | | | Currently, LLD prints VA, but not LMA in a map file. It seems can be useful to print both to reveal layout details and patch implements it. Differential revision: https://reviews.llvm.org/D44899 llvm-svn: 329271
* [ELF] - Check that output sections fit in address space.George Rimar2018-04-033-1/+27
| | | | | | | | | | Added checks to test that we do not produce output where VA of sections overruns the address space available. Differential revision: https://reviews.llvm.org/D43820 llvm-svn: 329063
* [ELF] - Linkerscript: support MIN and MAX.George Rimar2018-03-281-0/+4
| | | | | | | | | | | | | | Sample for the OVERLAY command from the spec (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/sections.html) uses MAX command that we do not support currently: . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1)); This patch implements support for MIN and MAX. Differential revision: https://reviews.llvm.org/D44734 llvm-svn: 328696
* This is PR36799.George Rimar2018-03-261-0/+58
| | | | | | | | | | | | | | | | Currently, we might have a bug with scripts like below: .foo : ALIGN(8) { *(.foo) } > ram because do not expand the memory region when doing ALIGN. This might result in file range overlaps. The patch fixes the issue. Differential revision: https://reviews.llvm.org/D44730 llvm-svn: 328479
* [ELF] - Do not ignore discarding of .rela.plt/.rela.dyn, allow doing custom ↵George Rimar2018-03-242-0/+26
| | | | | | | | | | | | | | | | | | | | | | layout for them. Currently when we build input sections list in linker script we ignore all rel[a] sections. That was done to support scripts like .rela.dyn : { *(.rela.data) } for emit relocs. Though as a result following scripts were also silently ignored: /DISCARD/ : { *(.rela.plt) /DISCARD/ : { *(.rela.dyn) and we produced output with this sections. That is not ideal. The solution this patch suggests is simple: do not ignore synthetic rel[a] sections. That way we can enable common discarding logic for them and report a proper error. Differential revision: https://reviews.llvm.org/D41640 llvm-svn: 328419
* [ELF] - Another fix for "LLD crashes with --emit-relocs when trying to ↵George Rimar2018-03-231-0/+13
| | | | | | | | | | | | | | | proccess .eh_frame" This fixes PR36367 which is about segfault when --emit-relocs is used together with .eh_frame sections which happens because of reordering of regular and .rel[a] sections. Path changes loop that iterates over input sections to create relocation target sections first. Differential revision: https://reviews.llvm.org/D44679 llvm-svn: 328299
* Fix linker script operator precedence.Rui Ueyama2018-03-151-0/+4
| | | | | | | | | | | "&" should have higher priority than "|" [1]. Previously, they had the same priority. [1] https://sourceware.org/binutils/docs/ld/Operators.html Differential Revision: https://reviews.llvm.org/D43880 llvm-svn: 327684
* [ELF] - Simplify test case. NFCI.George Rimar2018-03-151-2/+1
| | | | llvm-svn: 327614
* [ELF] - Show data and assignment commands in the map file.George Rimar2018-03-151-0/+38
| | | | | | | | | Patch teaches LLD to print BYTE/SHORT/LONG/QUAD and location move commands to the map file. Differential revision: https://reviews.llvm.org/D44004 llvm-svn: 327612
* [ELF] - Convert overlapping-sections.s testcase to x86 and cleanup.George Rimar2018-03-141-85/+27
| | | | | | | | | | | | | | | Patch do the following changes: * Test case was converted from MIPS to x86. * Removed part of the test checking we are able to produce a valid output. Since we do that already in other tests, this one's intention should be only to check we are still able to report overlaps and/or produce broken output with overlaps. Differential revision: https://reviews.llvm.org/D44438 llvm-svn: 327480
* [ELF} - Fix build bots.George Rimar2018-03-132-2/+2
| | | | llvm-svn: 327419
* [ELF] - Fix mistype in comment. NFC.George Rimar2018-03-131-1/+1
| | | | llvm-svn: 327417
* [ELF] - Rename test cases to *.test.George Rimar2018-03-1328-0/+0
| | | | | | This is a follow-up for r327410. llvm-svn: 327416
* [ELF] - Represent tests as linker scripts instead of asm.George Rimar2018-03-1328-200/+232
| | | | | | | | | This follows recently started direction and sometimes allows to fully get rid from `echo` calls. I'll rename changed files to *.test in a follow-up. llvm-svn: 327410
* [ELF] - Implement INSERT BEFORE.George Rimar2018-03-133-3/+32
| | | | | | | | | | | This finishes PR35877. INSERT BEFORE used similar to INSERT AFTER, it inserts sections before the given target section. Differential revision: https://reviews.llvm.org/D44380 llvm-svn: 327378
* [ELF] - Fix wrong "REQUIRES" in test.George Rimar2018-03-131-1/+1
| | | | | | Its a follow up for r327374 to fix BB. llvm-svn: 327377
* [ELF] - Restrict section offsets that exceeds file size.George Rimar2018-03-132-0/+28
| | | | | | | | | | | | | | | | | This is part of PR36515. With some linkerscripts it is possible to get file offset overlaps and overflows. Currently LLD checks overlaps in checkNoOverlappingSections(). And also we allow broken output with --no-inhibit-exec. Problem is that sometimes final offset of sections is completely broken and we calculate output file size wrong and might crash. Patch implements check to verify that there is no output section which offset exceeds file size. Differential revision: https://reviews.llvm.org/D43819 llvm-svn: 327376
* [ELF] - Drop special flags for empty output sections.George Rimar2018-03-131-0/+21
| | | | | | | | | | | | | | | | This fixes PR36598. LLD currently crashes when we have empty output section with SHF_LINK_ORDER flag. This might happen if we place an empty synthetic section in the linker script, but keep output section alive with the use of additional symbol, for example. The patch fixes the issue by dropping all special flags for empty sections. Differential revision: https://reviews.llvm.org/D44376 llvm-svn: 327374
* [ELF] - Change consume()->expect() in INSERT AFTER parsing.George Rimar2018-03-121-0/+6
| | | | | | | | AFTER keyword is mandatory and consume() was used by mistake here. We accepted broken script before this patch, testcase shows the issue. llvm-svn: 327260
* [ELF] - Support "INSERT AFTER" statement.George Rimar2018-03-083-0/+44
| | | | | | | | | | | | | | | | | | | | This implements INSERT AFTER in a following way: During reading scripts it collects all insert statements. After we done and read all files it inserts statements into script commands list. With that: * Rest of code does know nothing about INSERT. * Approach is straightforward and have no visible limitations. * It is also easy to support INSERT BEFORE (was seen in clang code once). * Should work for PR35877 and similar cases. Cons: * It assumes we have "main" scripts that describes sections. Differential revision: https://reviews.llvm.org/D43468 llvm-svn: 327003
* [ELF] - Adjust rangeToString to report ranges in a different format.George Rimar2018-03-071-10/+10
| | | | | | | | | | | | | It was raised during the review of D43819. LLD usually use [X, Y] for reporting ranges, like below: "relocation R_386_16 out of range: 65536 is not in [0, 65535]" Patch changes rangeToString() to do the same. Differential revision: https://reviews.llvm.org/D44207 llvm-svn: 326918
* [ELF] - Recommit r326892,r326893 "[ELF] - Report LMA region overflows."George Rimar2018-03-071-0/+16
| | | | | | | | | | | | With fix: add missing "RUN:" prefix to test case. Original commit message: We do not report LMA region overflows currently. Both GNU linkers do that. The patch implements it. Differential revision: https://reviews.llvm.org/D44094 llvm-svn: 326895
* [ELF] - Revert r326892, r326893.George Rimar2018-03-071-16/+0
| | | | | | | Bots are still unhappy: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/26259 llvm-svn: 326894
* [ELF] - Fix build bot after r326892 "[ELF] - Report LMA region overflows."George Rimar2018-03-071-1/+0
| | | | | | Removed excessive line from testcase. llvm-svn: 326893
OpenPOWER on IntegriCloud