summaryrefslogtreecommitdiffstats
path: root/lld/test/ELF/linkerscript
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't create a bogus PT_PHDR if we don't allocate the headers.Rafael Espindola2017-01-203-10/+5
| | | | llvm-svn: 292644
* [ELF] - Do not crash when assign common symbol's values in scriptGeorge Rimar2017-01-201-0/+48
| | | | | | | | | | Found that during attempts of linking linux kernel, previously we partially duplicated code from getOutputSection(), and it missed commons symbol case. Differential revision: https://reviews.llvm.org/D28903 llvm-svn: 292594
* [ELF] - Support optional comma after output section command.George Rimar2017-01-171-0/+5
| | | | | | | | | | | | | | | | | I found this when tried to link linux kernel with LLD: https://github.com/torvalds/linux/blob/master/arch/x86/entry/vdso/vdso-layout.lds.S#L86 Output section command can have optional comma at the end: .text : { *(.text*) } :text =0x90909090, It was documented about 3 years ago for binutils: https://sourceware.org/ml/binutils/2014-04/msg00045.html Differential revision: https://reviews.llvm.org/D28803 llvm-svn: 292225
* [ELF] - Fix for huge-temporary-file.sGeorge Rimar2017-01-171-1/+1
| | | | | | Removed mentioning of checks. Sorry for noise. llvm-svn: 292221
* [ELF] - Added huge-temporary-file.s testcase.George Rimar2017-01-171-0/+12
| | | | | | | | | | | | Inputs shown in that testcase previously created a huge temporarily file under 32 bits. It was fixed by D28107. During review was suggested to add a testcase even without CHECKs for documentation purposes. Patch do that. llvm-svn: 292220
* [ELF] - Move the addition of synthetics from addPredefinedSections()George Rimar2017-01-131-15/+4
| | | | | | | | | | | These were 3 last synthetics that were added in addPredefinedSections() instead of createSyntheticSections(). Now it is possible to move addition to correct common place. Also patch fixes testcase which discards .shstrtab, by restricting doing that. Differential revision: https://reviews.llvm.org/D28561 llvm-svn: 291908
* ELF: Place relro sections after non-relro sections in r/w segment.Peter Collingbourne2017-01-103-9/+9
| | | | | | | | | | | | This is in preparation for my next change, which will introduce a relro nobits section. That requires that relro sections appear at the end of the progbits part of the r/w segment so that the relro nobits section can appear contiguously. Because of the amount of churn required in the test suite, I'm making this change separately. llvm-svn: 291523
* [ELF] Allow defined symbols to be assigned from linker scriptMeador Inge2017-01-091-2/+15
| | | | | | | | This patch allows for linker scripts to assign a new value to a symbol that is already defined (either in an object file or the linker script itself). llvm-svn: 291459
* Change which input sections we concatenateRafael Espindola2017-01-052-24/+18
| | | | | | | | | | | | | | | | | | | | | After Mark's patch I was wondering what was the rationale for the ELF spec requiring us to merge only sections with matching flags and types. I tried emailing https://groups.google.com/forum/#!forum/generic-abi, but looks like my emails are not being posted (the list is probably moderated). I emailed Cary Coutant instead. Cary pointed out that the section was a late addition and didn't got the scrutiny it deserved. Given that and the problems found by implementing the letter of the standard, I propose changing lld to merge all sections with the same name and issue errors if the types or some critical flags are different. This should allow an unmodified firefox linked with lld to run. This also merges some code with the linkerscript path. llvm-svn: 291107
* [ELF] Linkerscript: print location of undefined symbol usageEugene Leviant2016-12-222-2/+2
| | | | | | Differential revision: https://reviews.llvm.org/D27194 llvm-svn: 290339
* [ELF] - Linkerscript: Fall back to search paths when INCLUDE not foundGeorge Rimar2016-12-211-0/+8
| | | | | | | | | | | | From https://sourceware.org/binutils/docs/ld/File-Commands.html: The file will be searched for in the current directory, and in any directory specified with the -L option. Patch done by Alexander Richardson. Differential revision: https://reviews.llvm.org/D27831 llvm-svn: 290247
* [ELF] - Linkerscript: Implement two argument version of ALIGN()Rui Ueyama2016-12-161-0/+22
| | | | | | | | | | Fixes http://llvm.org/PR31129 Patch by Alexander Richardson! Differential Revision: https://reviews.llvm.org/D27848 llvm-svn: 289968
* [ELF] - Accept --sort-section=xxx command form.George Rimar2016-12-161-0/+4
| | | | | | | --sort-section=xxx is the same as --sort-section xxx, was found in one of FreeBSD ports. llvm-svn: 289938
* [ELF] - Do not crash when move location counter backward.George Rimar2016-12-151-0/+9
| | | | | | | | | | | | | | | | | PR31335 shows that we do that in next case: SECTIONS { .text 0x2000 : {. = 0x100 ; *(.text) } } though documentations says that "If . is used inside a section description however, it refers to the byte offset from the start of that section, not an absolute address. " looks does not work as documented in bfd (as mentioned in comments for PR31335). Until we find out the expected behavior was suggested at least not to 'crash', what we do after trying to generate huge file. Differential revision: https://reviews.llvm.org/D27712 llvm-svn: 289782
* [ELF] Fix test case thinko from r289152Meador Inge2016-12-091-5/+1
| | | | | | | It was pointed out in a post-commit review that the tests were structured oddly. Fixed thusly. llvm-svn: 289278
* Remove `REQUIRES: shell` hack to workaround an echo issue.Rui Ueyama2016-12-094-13/+3
| | | | | | | These tests are disabled on Windows, but they seem to work just fine now, so I'll enable them. llvm-svn: 289251
* [ELF] Allow output section data commands to take expressionsMeador Inge2016-12-081-1/+46
| | | | | | | | | | | | The current implementation of the output section data store commands can only handle integer literals, but it should really handle arbitrary expressions [1]. This commit fixes that. [1] https://sourceware.org/binutils/docs-2.27/ld/Output-Section-Data.html#Output-Section-Data Differential Revision: https://reviews.llvm.org/D27561 llvm-svn: 289152
* Split linkerscript.s into small test files.Rui Ueyama2016-12-084-85/+101
| | | | | | | | | | linkerscript.s is the first test file for linker script, and at the moment it contains all tests for linker scripts. Now that test file doesn't make sense. linkerscript2.s was just badly named. Renamed searchdir.s. llvm-svn: 289148
* Print a warning message if ENTRY() symbol is not found.Rui Ueyama2016-12-081-0/+6
| | | | llvm-svn: 289146
* Use the correct MaxPageSize.Rafael Espindola2016-12-071-0/+22
| | | | | | Found by inspection. llvm-svn: 288970
* [ELF] - Teach LLD to recognize PT_OPENBSD_BOOTDATAGeorge Rimar2016-12-061-0/+7
| | | | | | | | | | | Minor patch to fix PR31288 OpenBSD commit: https://github.com/openbsd/src/commit/d39116912b9536bd77326260dc5c6e593fd4ee24 Differential revision: https://reviews.llvm.org/D27458 llvm-svn: 288832
* [ELF] Print file:line for unknown PHDR errorEugene Leviant2016-12-051-0/+10
| | | | | | Differential revision: https://reviews.llvm.org/D27335 llvm-svn: 288678
* [ELF] - Add support of proccessing of the rest allocatable synthetic ↵George Rimar2016-11-291-2/+2
| | | | | | | | | | | sections from linkerscript. This change continues what was started by D27040 Now all allocatable synthetics should be available from script side. Differential revision: https://reviews.llvm.org/D27131 llvm-svn: 288150
* [ELF] Print file:line for 'undefined section' errorsEugene Leviant2016-11-282-2/+2
| | | | | | Differential revision: https://reviews.llvm.org/D27108 llvm-svn: 288019
* Always create a PT_ARM_EXIDX if needed.Rafael Espindola2016-11-281-0/+16
| | | | | | | | | Unfortunatelly PT_ARM_EXIDX is special. There is no way to create it from linker scripts, so we have to create it even if PHDRS is used. This matches bfd and is required for the lld output to survive bfd's strip. llvm-svn: 288012
* Also skip regular symbol assignment at the start of a script.Rafael Espindola2016-11-271-0/+1
| | | | | | | | | | | | Unfortunatelly some scripts look like kernphys = ... . = .... and the expectation in that every orphan section is after the assignment. llvm-svn: 287996
* Don't put an orphan before the first . assignment.Rafael Espindola2016-11-271-0/+17
| | | | | | | | This is an horrible special case, but seems to match bfd's behaviour and is important for avoiding placing an orphan section before the expected start of the file. llvm-svn: 287994
* Create sections with just assignments as STT_NOBITS.Rafael Espindola2016-11-261-2/+2
| | | | | | | This matches the behaviour of bfd ld. Using 0 was causing problems with strip, which would remove these sections. llvm-svn: 287969
* [ELF] - Add support for access to most of synthetic sections from linkerscript.George Rimar2016-11-251-1/+1
| | | | | | | | | | | | | | | | | | This is important for cases like: .sdata : { *(.got.plt .got) ... } That was not supported before as there was no way to get access to synthetic sections from script. More details on review page. Differential revision: https://reviews.llvm.org/D27040 llvm-svn: 287913
* lld: Default image base address to 0x200000 on x86-64Ed Maste2016-11-232-11/+11
| | | | | | | | | Align to the large page size (known as a superpage or huge page). FreeBSD automatically promotes large, superpage-aligned allocations. Differential Revision: https://reviews.llvm.org/D27042 llvm-svn: 287782
* [ELF] Allow `ASSERT` in output section descriptionsMeador Inge2016-11-221-0/+10
| | | | | | | | GNU LD allows `ASSERT` commands to be in output section descriptions. Note that LD also mandates that `ASSERT` commands in this context must end with a semicolon. llvm-svn: 287677
* Remove useless newlines.Rui Ueyama2016-11-211-17/+8
| | | | llvm-svn: 287595
* Use the correct page size.Rafael Espindola2016-11-211-0/+21
| | | | | | | Config->MaxPageSize is what we use for the segment alignment, so that is the one that we have to use for placing the header. llvm-svn: 287569
* Fix address computation for headers.Rafael Espindola2016-11-211-0/+26
| | | | | | | | | | | | | | | | If the linker script has SECTIONS, the address computation is now always done in LinkerScript::assignAddresses, like for any other section. Before fixHeaders would do a tentative computation that assignAddresses would sometimes override. This patch also splits the cases where assignAddresses needs to add the headers to the first PT_LOAD and the address computation. The net effect is that we no longer create an empty page for no reason in the included test case, which matches bfd behavior. llvm-svn: 287565
* [ELF] Better error reporting for linker scriptsEugene Leviant2016-11-211-9/+49
| | | | | | Differential revision: https://reviews.llvm.org/D26795 llvm-svn: 287547
* Change the way how we print out line numbers.Rui Ueyama2016-11-212-4/+4
| | | | | | | | | | | | | | | | | | | LLD's error messages contain line numbers, function names or section names. Currently they are formatter as follows. foo.c (32): symbol 'foo' not found foo.c (function bar): symbol 'foo' not found foo.c (.text+0x1234): symbol 'foo' not found This patch changes them so that they are consistent with Clang's output. foo.c:32: symbol 'foo' not found foo.c:(function bar): symbol 'foo' not found foo.c:(.text+0x1234): symbol 'foo' not found Differential Revision: https://reviews.llvm.org/D26901 llvm-svn: 287537
* Allow use define symbols to override linker defined ones.Rafael Espindola2016-11-171-0/+17
| | | | | | | | | | | | | I hit an internal linker script that was defining _DYNAMIC instead of letting the linker do it. It turns out that both bfd and gold allow that. This is pretty easy to implement, just make the linker defined symbol weak. This should have no impact in the case where there is no user defined symbol: The visibility is hidden, which causes the output to still be local. llvm-svn: 287260
* Allow SIZEOF() command on nonexistent section.Rui Ueyama2016-11-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | Linker script doesn't create a section if it has no content. So the following script doesn't create .norelocs section if it doesn't have any .rel* sections. .norelocs : { *(.rel*) } Later, if you assert that the size of .norelocs is 0, LLD printed out an error message, because it didn't allow calling SIZEOF() on nonexistent sections. This patch allows SIZEOF() on nonexistent sections, so that you can do something like this. ASSERT(SIZEOF(.norelocs), "shouldn't contain .rel sections!") Note that this behavior is compatible with GNU. Differential Revision: https://reviews.llvm.org/D26810 llvm-svn: 287257
* Avoid accessing an end() iterator.Rafael Espindola2016-11-171-0/+5
| | | | llvm-svn: 287225
* [ELF] Add Section() to expression objectEugene Leviant2016-11-161-0/+21
| | | | | | | | | This allows making symbols containing ADDR(section) synthetic, and defining synthetic symbols outside SECTIONS block. Differential revision: https://reviews.llvm.org/D25441 llvm-svn: 287090
* Remove trailing whitespace.Rui Ueyama2016-11-151-6/+6
| | | | llvm-svn: 287009
* Fix program header propagation.Rafael Espindola2016-11-142-0/+25
| | | | | | | | | | Propagate program headers by walking the commands, not the sections. This allows us to propagate program headers even from sections that don't end up in the output. Fixes pr30997. llvm-svn: 286837
* Include version string into ".comment" section.Rui Ueyama2016-11-104-31/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds a ".comment" section to an output. The comment section contains the linker's version string. You can now find out whether a binary is created by LLD or not using objdump command like this. $ objdump -s -j .comment foo foo: file format elf64-x86-64 Contents of section .comment: 0000 00474343 3a202855 62756e74 7520342e .GCC: (Ubuntu 4. 0010 382e342d 32756275 6e747531 7e31342e 8.4-2ubuntu1~14. ... 00c0 766d2f74 72756e6b 20323835 38343629 vm/trunk 285846) 00d0 004c696e 6b65723a 204c4c44 20342e30 .Linker: LLD 4.0 00e0 2e302028 7472756e 6b203238 36343036 .0 (trunk 286406 00f0 2900 ). Compilers emits .comment section as well, so the output contains both compiler and linker information. Alternative considered: I first tried to add a SHT_NOTE section because GNU gold does that. A NOTE section starts with a header which contains content type. It turned out that ld.gold sets type NT_GNU_GOLD_VERSION to their NOTE section. So the NOTE type is only for GNU gold (surprise!) Next, I tried to create ".linker-version" section. However, it seems that reusing the existing ".comment" section is better because 1) other tools already know about .comment section and is able to strip it and 2) the result contans not only linker info but also compiler info. Differential Revision: https://reviews.llvm.org/D26487 llvm-svn: 286496
* [ELF] Test case update (orphan.s)Eugene Leviant2016-11-081-0/+7
| | | | llvm-svn: 286226
* [ELF] Heuristic for placing orphan sectionEugene Leviant2016-11-082-1/+30
| | | | | | Differential revision: https://reviews.llvm.org/D25325 llvm-svn: 286225
* Rewrite CommonInputSection as a synthetic input section.Rui Ueyama2016-11-051-3/+8
| | | | | | | | | | | | A CommonInputSection is a section containing all common symbols. That was an input section but was abstracted in a different way than the synthetic input sections because it was written before the synthetic input section was invented. This patch rewrites CommonInputSection as a synthetic input section so that it behaves better with other sections. llvm-svn: 286053
* Remove string table offsets from tests.Rui Ueyama2016-11-011-1/+1
| | | | | | <N> where "foo (<N>)" is the offset of string "foo" in the string table. llvm-svn: 285751
* The expr '.' is not absolute.Rafael Espindola2016-10-313-2/+55
| | | | | | | | | | | | | | With this patch we keep track of the fact that . is a position in the file and therefore not absolute. This allow us to compute relative relocations that involve symbol that are defined in linker scripts with '.'. This fixes https://llvm.org/bugs/show_bug.cgi?id=30406 There is still more work to track absoluteness over the various expressions, but this should unblock linking the EFI bootloader. llvm-svn: 285641
* Delay computation of IsAbsolute.Rafael Espindola2016-10-311-1/+23
| | | | | | | | | | We parse linker scripts very early, but whether an expression is absolute or not can depend on a symbol defined in a .o. Given that, we have to delay the computation of IsAbsolute. We can do that by storing an AST when parsing or by also making IsAbsolute a function like we do for the expression value. This patch implements the second option. llvm-svn: 285628
* Simple numeric constants are absolute.Rafael Espindola2016-10-311-0/+10
| | | | llvm-svn: 285621
OpenPOWER on IntegriCloud