summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - Formatted comment, fixed mistype. NFC.George Rimar2018-03-121-3/+2
| | | | llvm-svn: 327280
* [ELF] - Removed excessive lookup. NFC.George Rimar2018-03-121-3/+2
| | | | llvm-svn: 327272
* [ELF] - Change consume()->expect() in INSERT AFTER parsing.George Rimar2018-03-121-1/+1
| | | | | | | | 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
* For most Targets the _GLOBAL_OFFSET_TABLE_ symbol is expected to be atPeter Smith2018-03-118-13/+28
| | | | | | | | | | | | | | | | | | the start of the .got.plt section so that _GLOBAL_OFFSET_TABLE_[0] = reserved value that is by convention the address of the dynamic section. Previously we had defined _GLOBAL_OFFSET_TABLE_ as either the start or end of the .got section with the intention that the .got.plt section would follow the .got. However this does not always hold with the current default section ordering so _GLOBAL_OFFSET_TABLE_[0] may not be consistent with the reserved first entry of the .got.plt. X86, X86_64, Arm and AArch64 will use the .got.plt. Mips and Power use .got Fixes PR36555 Differential Revision: https://reviews.llvm.org/D44259 llvm-svn: 327248
* [ELF] Add elf64lppc emulation.Fangrui Song2018-03-091-0/+1
| | | | | | | | Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D44264 llvm-svn: 327177
* [ELF] Convert {read,write}*be to endianness-aware read/write.Fangrui Song2018-03-094-45/+66
| | | | | | | | Subscribers: emaste, nemanjai, arichardson, kbarton, llvm-commits Differential Revision: https://reviews.llvm.org/D44227 llvm-svn: 327156
* ELF: Do not create multiple thunks for the same virtual address.Peter Collingbourne2018-03-092-10/+17
| | | | | | | | | | This avoids creating multiple thunks for symbols with aliases or which belong to ICF'd sections. This patch reduces the size of Chromium for Android by 260KB (0.8% of .text). Differential Revision: https://reviews.llvm.org/D44284 llvm-svn: 327154
* [ELF] - Fix crash relative to SHF_LINK_ORDER sections.George Rimar2018-03-083-12/+14
| | | | | | | | | | | | | | | | | Our code assumes all input sections in an output SHF_LINK_ORDER section has SHF_LINK_ORDER flag. We do not check that and that can cause a crash. That happens because we call std::stable_sort(Sections.begin(), Sections.end(), compareByFilePosition);, where compareByFilePosition predicate does not expect to see null when calls getLinkOrderDep. The same might happen when sections refer to non-regular sections. Test cases demonstrate the issues, patch fixes them. Differential revision: https://reviews.llvm.org/D44193 llvm-svn: 327006
* [ELF] - Support "INSERT AFTER" statement.George Rimar2018-03-084-1/+43
| | | | | | | | | | | | | | | | | | | | 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
* Return early. NFC.Rui Ueyama2018-03-081-0/+1
| | | | | | | | We don't need to handle an object file having more than one symbol table, so as soon as we find the first one, we can process it and then return from the function. llvm-svn: 326977
* Simplify LazyobjFile and readElfSymbols.Rui Ueyama2018-03-082-48/+35
| | | | | | | | | | addElfSymbols and readJustSymbolsFile still has duplicate code, but I didn't come up with a good idea to eliminate them. Since this patch is an improvement, I'm sending this for review. Differential Revision: https://reviews.llvm.org/D44187 llvm-svn: 326972
* Use exact uint32_t for uint32_t ELF field. NFC.Rui Ueyama2018-03-073-3/+3
| | | | llvm-svn: 326934
* Initialize a member in C++11 style. NFC.Rui Ueyama2018-03-072-4/+2
| | | | llvm-svn: 326933
* [ELF] - Adjust rangeToString to report ranges in a different format.George Rimar2018-03-071-1/+1
| | | | | | | | | | | | | 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
* Revert r326911: Improve --warn-symbol-ordering.Rui Ueyama2018-03-071-25/+18
| | | | | | This reverts commit r326911 because it was committed by accident. llvm-svn: 326914
* Rename Indent{1,2} -> Indent{8,16}.Rui Ueyama2018-03-071-4/+4
| | | | llvm-svn: 326912
* Improve --warn-symbol-ordering.Rui Ueyama2018-03-071-18/+25
| | | | | | | | | | | | | | | | Summary: I originally tried to simplify code and then noticed that lld doesn't do what it tells to the user by warn(). It says "unable to order discarded symbol" but it actually can for sections eliminated by ICF. With this patch, lld doesn't sort such sections. Reviewers: jhenderson, rafael Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D44180 llvm-svn: 326911
* [ELF] Prevent crash when reporting errors if debug line cannot be parsedJames Henderson2018-03-071-0/+2
| | | | | | | | | | | | | LLD uses the debug info and debug line sections to determine the location of e.g. references to undefined symbols, when producing error messages. In the event that debug info was present, but debug line parsing failed for some reason, then a nullptr would end up being dereferenced by the location-lookup code. Differential Revision: https://reviews.llvm.org/D44205 Reviewers: grimar llvm-svn: 326899
* [ELF] - Recommit r326892,r326893 "[ELF] - Report LMA region overflows."George Rimar2018-03-071-2/+2
| | | | | | | | | | | | 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-2/+2
| | | | | | | 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] - Report LMA region overflows.George Rimar2018-03-071-2/+2
| | | | | | | | | 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: 326892
* [ELF] - Allow discarding .hash and .gnu.hash from linker script.George Rimar2018-03-071-0/+8
| | | | | | | | | Currently, LLD segfaults when linker script attempts to discard one of the hash sections. This patch fixes that. Differential revision: https://reviews.llvm.org/D44012 llvm-svn: 326891
* Do not create temporary strings just to print out spaces. NFC.Rui Ueyama2018-03-061-4/+5
| | | | llvm-svn: 326841
* Implement --just-symbols.Rui Ueyama2018-03-064-0/+52
| | | | | | Differential Revision: https://reviews.llvm.org/D39348 llvm-svn: 326835
* Improve duplicated version handling.Rafael Espindola2018-03-061-2/+3
| | | | | | | | | | | | It looks like the problem that caused us to originally warn instead of error was that of a symbol being assigned to the same version twice. Now we don't warn if a symbol is assigned to the same version twice, but error if it is assigned to multiple. This fixes pr28342. llvm-svn: 326813
* Remove redundant casts.Rui Ueyama2018-03-051-2/+2
| | | | llvm-svn: 326753
* [ELF] - Support moving location counter when MEMORY is used.George Rimar2018-03-052-29/+25
| | | | | | | | | | | | | | | | We do not expand memory region correctly for following scripts: .foo.1 : { *(.foo.1) . += 0x1000; } > ram Patch generalizes expanding of output sections and memory regions in one place and fixes the issue. Differential revision: https://reviews.llvm.org/D43999 llvm-svn: 326688
* [ELF] - Report location for div/mod by zero.George Rimar2018-03-051-19/+20
| | | | | | | | | | | "division by zero" or "modulo by zero" are not very informative errors and even probably confusing as does not let to know that error is coming from linker script. Patch adds location reporting. Differential revision: https://reviews.llvm.org/D43934 llvm-svn: 326686
* Simplify. NFC.Rafael Espindola2018-03-032-7/+1
| | | | | | | Since r321982 we don't set VersionId in scanShlibUndefined, which makes InVersionScript redundant. llvm-svn: 326641
* [ELF] - Report error when memory region is overflowed by data commands.George Rimar2018-03-021-12/+15
| | | | | | | | | | | | | | | | | | LLD can not catch a memory area overflow when using a data command. If we have the script below: .foo : { *(.foo) BYTE(0x1) } > ram where BYTE overflows the ram region, we do not report it currently. Patch fixes that. Differential revision: https://reviews.llvm.org/D43948 llvm-svn: 326545
* Accept both `--foo bar` and `--foo=bar` styles options.Rui Ueyama2018-03-012-16/+14
| | | | | | | | | GNU linkers by convention supports both `--foo bar` and `--foo=bar` styles for all long options that take arguments. Differential Revision: https://reviews.llvm.org/D43972 llvm-svn: 326506
* Set DF_TEXTREL to executables that need text relocations.Rui Ueyama2018-03-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: If an executable needs text relocations, it should be marked as such so that the loader can prepare for text relocations. We currently create a dummy segment with DT_TEXTREL for that purpose. Generic ABI as of 2000 [1] mentioned that "Its [DT_TEXTREL's] use has been superseded by the DF_TEXTREL flag". However, it's actually not superseded even after 18 years. OpenBSD and musl recognize only DT_TEXTREL. So we still need to set both. [1] http://www.sco.com/developers/gabi/2000-07-17/ch5.dynamic.html Reviewers: rafael Subscribers: emaste, llvm-commits, arichardson Differential Revision: https://reviews.llvm.org/D43920 llvm-svn: 326503
* Don't ingoned --enable-new-dtags.Rafael Espindola2018-03-011-1/+2
| | | | llvm-svn: 326498
* Don't allocate a header bellow address 0.Rafael Espindola2018-03-011-4/+18
| | | | | | | | | | | | With the current code if the script has a PHDRS we always obey and try to allocate a header. This can cause Min - HeaderSize to underflow. It looks like bfd actually prints an error for this case. With this patch we do the same. Found while looking at pr36515. llvm-svn: 326441
* [ELF] - Don't crash on broken MEMORY declaration.George Rimar2018-03-011-3/+7
| | | | | | | | | | | LLD crashes with broken scripts shown in testcase, because fails to read memory regon name and accesses MemoryRegions's element which is nullptr. Patch fixes it. Differential revision: https://reviews.llvm.org/D43866 llvm-svn: 326431
* [ELF] - Do not remove empty sections that use symbols in expressions.George Rimar2018-03-013-5/+9
| | | | | | | | | | | | | | | This is PR36515. Currenly if we have a script like .debug_info 0 : { *(.debug_info) }, we would not remove this section and keep it in the output. That does not work, because it is common case for debug sections to have a zero address expression. Patch changes behavior so that we remove only sections that do not use symbols in its expressions. Differential revision: https://reviews.llvm.org/D43863 llvm-svn: 326430
* Do not create multiple NOTE segments.Rui Ueyama2018-03-011-10/+18
| | | | | | | | | | | Previously, we didn't try to make effort to put .note sections next to each other in the output file, so two .note sections were likely to be stored to two separate NOTE segments. That's undesirable because we should create as few segments as possible in general. Differential Revision: https://reviews.llvm.org/D43858 llvm-svn: 326410
* Simplify removing empty output sections.Rafael Espindola2018-03-014-32/+30
| | | | | | | With this the meaning of the Live bit in output sections is clear: we have at some point added a input section into it. llvm-svn: 326401
* Add "%" operator to the linker script.Rui Ueyama2018-02-281-1/+10
| | | | | | | | This patch improves compatibility with GNU linkers. Differential Revision: https://reviews.llvm.org/D43883 llvm-svn: 326348
* Inline a trivial function. NFC.Rui Ueyama2018-02-281-5/+1
| | | | llvm-svn: 326347
* Simplify. NFC.Rafael Espindola2018-02-281-3/+3
| | | | llvm-svn: 326344
* Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.Rui Ueyama2018-02-2816-149/+13
| | | | | | | | | This should resolve the issue that lld build fails in some hosts that uses case-insensitive file system. Differential Revision: https://reviews.llvm.org/D43788 llvm-svn: 326339
* [ELF] Process linker scripts deeper when declaring symbols.Igor Kudrin2018-02-281-14/+33
| | | | | | | | We should process symbols inside output section declarations the same way as top-level ones. Differential Revision: https://reviews.llvm.org/D43008 llvm-svn: 326305
* Add `--dynamic-linker=foo` as an alias for `--dynamic-linker foo`.Rui Ueyama2018-02-271-0/+1
| | | | | | This patch fixes a minor compatibility issue with ld.gold and ld.bfd. llvm-svn: 326243
* Put undefined symbols from shared libraries in the symbol table.Rafael Espindola2018-02-276-46/+4
| | | | | | | With the recent fixes these symbols have more in common than not with regular undefined symbols. llvm-svn: 326242
* Fix gcc warning.Rafael Espindola2018-02-271-1/+2
| | | | | | Should fix the build in some bots. llvm-svn: 326209
* Add support for SHF_ARM_PURECODE.Rafael Espindola2018-02-271-3/+11
| | | | | | | Now we don't mark a PT_LOAD as readable if all its sections are SHF_ARM_PURECODE. llvm-svn: 326207
* [ELF] - Format, fix mistype. NFC.George Rimar2018-02-271-3/+2
| | | | llvm-svn: 326198
* [ELF] - Fix case of using both --icf and --symbol-ordering-file together.George Rimar2018-02-271-1/+1
| | | | | | | | | | | | | Imagine that we have sections A, B, C, where A == C and symbol ordering file containing symbols: symC, symB, symA Previously because of ICF it was possible that final order would be B, A or B, C. That violates order specified in ordering file. Patch changes that. Differential revision: https://reviews.llvm.org/D43234 llvm-svn: 326179
* [ELF] Create and export symbols provided by a linker script if they ↵Igor Kudrin2018-02-275-12/+22
| | | | | | | | | | | referenced by DSOs. It should be possible to resolve undefined symbols in dynamic libraries using symbols defined in a linker script. Differential Revision: https://reviews.llvm.org/D43011 llvm-svn: 326176
OpenPOWER on IntegriCloud