summaryrefslogtreecommitdiffstats
path: root/lld/test/ELF/Inputs
Commit message (Collapse)AuthorAgeFilesLines
...
* [LLD] Update split stack support to handle more generic prologues. Improve ↵Jordan Rupprecht2018-08-021-0/+10
| | | | | | | | | | error handling. Add test file for better code-coverage. Update tests to be more complete. Submitting patch on behalf of saugustine. Differential Revision: https://reviews.llvm.org/D49926 llvm-svn: 338750
* [LLD][ELF] - ICF: Check we do not fold sections which relocations reffering ↵George Rimar2018-07-311-0/+3
| | | | | | | | | | | to absolute symbols with a different values. This adds a test for the following uncovered piece of code: https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L263 Without that lines we would crash. llvm-svn: 338379
* [ELF][ARM] Implement support for Tag_ABI_VFP_argsPeter Smith2018-07-314-0/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Tag_ABI_VFP_args build attribute controls the procedure call standard used for floating point parameters on ARM. The values are: 0 - Base AAPCS (FP Parameters passed in Core (Integer) registers 1 - VFP AAPCS (FP Parameters passed in FP registers) 2 - Toolchain specific (Neither Base or VFP) 3 - Compatible with all (No use of floating point parameters) If the Tag_ABI_VFP_args build attribute is missing it has an implicit value of 0. We use the attribute in two ways: - Detect a clash in calling convention between Base, VFP and Toolchain. we follow ld.bfd's lead and do not error if there is a clash between an implicit Base AAPCS caused by a missing attribute. Many projects including the hard-float (VFP AAPCS) version of glibc contain assembler files that do not use floating point but do not have Tag_ABI_VFP_args. - Set the EF_ARM_ABI_FLOAT_SOFT or EF_ARM_ABI_FLOAT_HARD ELF header flag for Base or VFP AAPCS respectively. This flag is used by some ELF loaders. References: - Addenda to, and Errata in, the ABI for the ARM Architecture for Tag_ABI_VFP_args - Elf for the ARM Architecture for ELF header flags Fixes PR36009 Differential Revision: https://reviews.llvm.org/D49993 llvm-svn: 338377
* [ELF][MIPS] Fix primary GOT sometimes overflowing by one or two wordsSimon Atanasyan2018-07-241-0/+8
| | | | | | | | | | | | | | | | If we fail to merge a secondary GOT with the primary GOT but so far only one merged GOT has been created (the primary one), the final element in MergedGots is the primary GOT. Thus we should not try to merge with this final element passing IsPrimary=false, since this will ignore the fact that the destination GOT does in fact need a header, and those extra two entries can be enough to allow the merge to incorrectly occur. Instead we should check for this case before attempting the second merge. Patch by James Clarke. Differential revision: https://reviews.llvm.org/D49422 llvm-svn: 337810
* [ELF] Check eh_frame_hdr overflow with PC offsets instead of PC absolute ↵Fangrui Song2018-07-201-0/+25
| | | | | | | | | | | | addresses Reviewers: grimar, ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D49607 llvm-svn: 337610
* ELF: Implement --icf=safe using address-significance tables.Peter Collingbourne2018-07-181-0/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D48146 llvm-svn: 337429
* Implement framework for linking split-stack object files, and x86_64 support.Sterling Augustine2018-07-171-0/+16
| | | | llvm-svn: 337332
* Also search BitcodeFiles for exclude-lib symbolsYi Kong2018-07-111-0/+3
| | | | | | | | Archives created with ThinLTO are bitcodes, they also need to be searched for excluded symbols. Differential Revision: https://reviews.llvm.org/D48857 llvm-svn: 336826
* [ELF] - Add a test case for relocation pointing to deduplicated COMDAT.George Rimar2018-07-041-0/+6
| | | | | | | | | | | | ELF spec doesn't allow a relocation to point to a deduplicated COMDAT section. Unfortunately this happens in practice (e.g. .eh_frame) We have a code in MarkLive.cpp for that and it was uncovered by any test case: https://github.com/llvm-mirror/lld/blob/master/ELF/MarkLive.cpp#L199 Patch adds a test. llvm-svn: 336259
* [ELF][MIPS] Use llvm-mc to generate test case input file. NFCSimon Atanasyan2018-07-031-0/+0
| | | | llvm-svn: 336201
* Add Hexagon SupportSid Manning2018-06-131-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D47791 llvm-svn: 334637
* [ELF] Fix copy relocation when two symbols share the same Symbol instance.Fangrui Song2018-06-111-0/+11
| | | | | | | | | | In glibc libc.so.6, the multiple versions of sys_errlist share the same Symbol instance. When sys_errlist is copy relocated, we would replace SharedSymbol with Defined in the first iteration of the following loop: for (SharedSymbol *Sym : getSymbolsAt<ELFT>(SS)) Then in the second iteration, we think the symbol (which has been changed to Defined) is still SharedSymbol and screw up (the address ends up in the `Size` field). llvm-svn: 334432
* [ELF][MIPS] Multi-GOT implementationSimon Atanasyan2018-06-112-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Almost all entries inside MIPS GOT are referenced by signed 16-bit index. Zero entry lies approximately in the middle of the GOT. So the total number of GOT entries cannot exceed ~16384 for 32-bit architecture and ~8192 for 64-bit architecture. This limitation makes impossible to link rather large application like for example LLVM+Clang. There are two workaround for this problem. The first one is using the -mxgot compiler's flag. It enables using a 32-bit index to access GOT entries. But each access requires two assembly instructions two load GOT entry index to a register. Another workaround is multi-GOT. This patch implements it. Here is a brief description of multi-GOT for detailed one see the following link https://dmz-portal.mips.com/wiki/MIPS_Multi_GOT. If the sum of local, global and tls entries is less than 64K only single got is enough. Otherwise, multi-got is created. Series of primary and multiple secondary GOTs have the following layout: ``` - Primary GOT Header Local entries Global entries Relocation only entries TLS entries - Secondary GOT Local entries Global entries TLS entries ... ``` All GOT entries required by relocations from a single input file entirely belong to either primary or one of secondary GOTs. To reference GOT entries each GOT has its own _gp value points to the "middle" of the GOT. In the code this value loaded to the register which is used for GOT access. MIPS 32 function's prologue: ``` lui v0,0x0 0: R_MIPS_HI16 _gp_disp addiu v0,v0,0 4: R_MIPS_LO16 _gp_disp ``` MIPS 64 function's prologue: ``` lui at,0x0 14: R_MIPS_GPREL16 main ``` Dynamic linker does not know anything about secondary GOTs and cannot use a regular MIPS mechanism for GOT entries initialization. So we have to use an approach accepted by other architectures and create dynamic relocations R_MIPS_REL32 to initialize global entries (and local in case of PIC code) in secondary GOTs. But ironically MIPS dynamic linker requires GOT entries and correspondingly ordered dynamic symbol table entries to deal with dynamic relocations. To handle this problem relocation-only section in the primary GOT contains entries for all symbols referenced in global parts of secondary GOTs. Although the sum of local and normal global entries of the primary got should be less than 64K, the size of the primary got (including relocation-only entries can be greater than 64K, because parts of the primary got that overflow the 64K limit are used only by the dynamic linker at dynamic link-time and not by 16-bit gp-relative addressing at run-time. The patch affects common LLD code in the following places: - Added new hidden -mips-got-size flag. This flag required to set low maximum size of a single GOT to be able to test the implementation using small test cases. - Added InputFile argument to the getRelocTargetVA function. The same symbol referenced by GOT relocation from different input file might be allocated in different GOT. So result of relocation depends on the file. - Added new ctor to the DynamicReloc class. This constructor records settings of dynamic relocation which used to adjust address of 64kb page lies inside a specific output section. With the patch LLD is able to link all LLVM+Clang+LLD applications and libraries for MIPS 32/64 targets. Differential revision: https://reviews.llvm.org/D31528 llvm-svn: 334390
* Correct aligment computation for shared object symbols.Han Shen2018-06-063-0/+17
| | | | | | | | | | The original computation for shared object symbol alignment is wrong when st_value equals 0. It is very unusual for dso symbols to have st_value equal 0. But when it happens, it causes obscure run time bugs. Differential Revision: https://reviews.llvm.org/D47602 llvm-svn: 334135
* [PPC64] Add support for initial-exec TLS modelZaara Syeda2018-06-011-0/+20
| | | | | | | | | | | | | This patch adds the relocations needed support the initial-exec TLS model: R_PPC64_GOT_TPREL16_HA R_PPC64_GOT_TPREL16_LO_DS R_PPC64_GOT_TPREL16_DS R_PPC64_GOT_TPREL16_HI R_PPC64_TLS Differential Revision: https://reviews.llvm.org/D47455 llvm-svn: 333769
* [ELF] Do not error for missing version when symbol has local version.Peter Smith2018-05-141-0/+9
| | | | | | | | | | | | | If a symbol with an undefined version in a DSO is not going to be exported into the dynamic symbol table then do not give an error message for the missing version. This can happen with the --exclude-libs option which implicitly gives all symbols in a static library the local version. This matches the behavior of ld.gold and is exploited by the Bionic dynamic linker on Arm. Differential Revision: https://reviews.llvm.org/D43126 llvm-svn: 332224
* [ELF] Rework debug line parsing to use llvm::Error and callbacks (LLD-side)James Henderson2018-05-101-1/+91
| | | | | | | | | | | | | | Reviewed by: ruiu, grimar, espindola Differential Revision: https://reviews.llvm.org/D44562 Summary: r331971 changes the debug line parser interface to report LLVM errors in an interface that different executables can use, rather than always being printed directly as warnings to stderr. This change allows LLD to make use of the new interface and call its own warning methods to report problems. llvm-svn: 331972
* [ELF][MIPS] Fix calculation of GP relative relocations in case of ↵Simon Atanasyan2018-05-082-0/+0
| | | | | | | | | | | | | | | | | | | relocatable output Some MIPS relocations depend on "gp" value. By default, this value has 0x7ff0 offset from a .got section. But relocatable files produced by a compiler or a linker might redefine this default value and we have to use it for a calculation of the relocation result. When we generate EXE or DSO it's trivial. Generating a relocatable output is more difficult case because the linker does calculate relocations in this case and cannot store individual "gp" values used by each input object file. As a workaround we add the "gp" value to the relocation addend. This fixes https://llvm.org/pr31149 Differential revision: https://reviews.llvm.org/D45972 llvm-svn: 331772
* [PPC64] Remove support for ELF V1 ABI in LLDZaara Syeda2018-05-042-22/+13
| | | | | | | | | | | The current support for V1 ABI in LLD is incomplete. This patch removes V1 ABI support and changes the default behavior to V2 ABI, issuing an error when using the V1 ABI. It also updates the testcases to V2 and removes any V1 specific tests. Differential Revision: https://reviews.llvm.org/D46316 llvm-svn: 331529
* [PPC64] Add offset to local entry point when calling functions without pltZaara Syeda2018-04-272-0/+51
| | | | | | | | | | | | | | PPC64 V2 ABI describes two entry points to a function. The global entry point sets up the TOC base pointer. When calling a local function, the call should branch to the local entry point rather than the global entry point. Section 3.4.1 describes using the 3 most significant bits of the st_other field to find out how many instructions there are between the local and global entry point. This patch adds the correct offset required to branch to the local entry point of a function. Differential Revision: https://reviews.llvm.org/D45729 llvm-svn: 331046
* [PPC64] Fix toc restore nops offset for V2 ABIZaara Syeda2018-04-231-0/+14
| | | | | | | | | | The PPC64 V2 ABI restores the toc base by loading from an offset of 24 from r1. This patch fixes the offset and updates the testcases from V1 to V2. It also issues an error when a nop is missing after a call to an external function. Differential Revision: https://reviews.llvm.org/D45892 llvm-svn: 330600
* Inline a small test file.Rui Ueyama2018-04-031-1/+0
| | | | llvm-svn: 329124
* [PPC64] Write plt stubs for ElfV2 abiSean Fertile2018-04-021-0/+14
| | | | | | | | Add the default version of a plt stub for the V2 Elf abi. Differential Revision: https://reviews.llvm.org/D44850 llvm-svn: 329004
* Re-implement --just-symbols as a regular object file.Rui Ueyama2018-03-301-9/+0
| | | | | | | | | | | | I tried a few different designs to find a way to implement it without too much hassle and settled down with this. Unlike before, object files given as arguments for --just-symbols are handled as object files, with an exception that their section tables are handled as if they were all null. Differential Revision: https://reviews.llvm.org/D42025 llvm-svn: 328852
* ELF: Add support for short thunks on ARM.Peter Collingbourne2018-03-292-0/+17
| | | | | | | | | | | A short thunk uses a direct branch (b or b.w) instruction, and is used when the target has the same thumbness as the thunk and is within direct branch range (32MB for ARM, 16MB for Thumb-2). Reduces the size of Chromium for Android's .text section by around 160KB. Differential Revision: https://reviews.llvm.org/D44963 llvm-svn: 328846
* Fix PR36793.Rafael Espindola2018-03-231-0/+24
| | | | | | | With this patch lld will iterate over compile units to find the line tables instead of assuming there is only one at offset 0. llvm-svn: 328284
* Make the debug info in some tests more realistic.Rafael Espindola2018-03-222-0/+42
| | | | | | | | | | | | | | | | | | | Currently lld just parses the .debug_line section assuming that there is only one compile unit. That assumption is false (PR36793). I have a patch that changes lld to iterate over the compile units and parse the portions of the .debug_line they point to (which fixes PR36793). A problem is that we will then need a compiler unit pointing to .debug_line for lld to see it. It seems like bfd has the same restriction. This patch updates existing tests to add a minimal compile unit so that they still work with PR36793 fixed. llvm-svn: 328215
* [ELF] Add .eh_frame pieces to map fileRui Ueyama2018-03-141-0/+2
| | | | | | | | | This patch is a simplified version of https://reviews.llvm.org/D42960 written by Andrew Ng. Differential Revision: https://reviews.llvm.org/D44168 llvm-svn: 327574
* Error instead of producing broken binary.Rafael Espindola2018-03-141-0/+4
| | | | | | | | This "fixes" PR36678 by just producing an error when we find a case where we would produce an plt entry that used ebx but ebx would not be set. llvm-svn: 327542
* [ELF] Prevent crash when reporting errors if debug line cannot be parsedJames Henderson2018-03-071-0/+44
| | | | | | | | | | | | | 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
* Implement --just-symbols.Rui Ueyama2018-03-061-0/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D39348 llvm-svn: 326835
* Rename a test file and fix indentation.Rui Ueyama2018-03-011-0/+0
| | | | llvm-svn: 326504
* AMDGPU/LLD: Remove the use of binary file from one of the AMDGPU testsKonstantin Zhuravlyov2018-02-161-0/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D43413 llvm-svn: 325404
* ELF: Stop collecting a list of symbols in ArchiveFile.Peter Collingbourne2018-02-161-0/+2
| | | | | | | | | | | | There seems to be no reason to collect this list of symbols. Also fix a bug where --exclude-libs would apply to all symbols that appear in an archive's symbol table, even if the relevant archive member was not added to the link. Differential Revision: https://reviews.llvm.org/D43369 llvm-svn: 325380
* [ELF] Add warnings for various symbols that cannot be orderedJames Henderson2018-02-142-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | There are a number of different situations when symbols are requested to be ordered in the --symbol-ordering-file that cannot be ordered for some reason. To assist with identifying these symbols, and either tidying up the order file, or the inputs, a number of warnings have been added. As some users may find these warnings unhelpful, due to how they use the symbol ordering file, a switch has also been added to disable these warnings. The cases where we now warn are: * Entries in the order file that don't correspond to any symbol in the input * Undefined symbols * Absolute symbols * Symbols imported from shared objects * Symbols that are discarded, due to e.g. --gc-sections or /DISCARD/ linker script sections * Multiple of the same entry in the order file Reviewed by: rafael, ruiu Differential Revision: https://reviews.llvm.org/D42475 llvm-svn: 325125
* Remove 'z' in .zdebug when decompressing a section.Rui Ueyama2018-02-121-4/+4
| | | | | | | | | | | When decompressing a compressed debug section, we drop SHF_COMPRESSED flag but we didn't drop "z" in ".zdebug" section name. This patch does that for consistency. This change also fixes the issue that .zdebug_gnu_pubnames are not dropped when we are creating a .gdb_index section. llvm-svn: 324949
* [ELF][MIPS] Ignore incorrect version definition index for _gp_disp symbolSimon Atanasyan2018-02-072-0/+14
| | | | | | | | | | | | MIPS BFD linker puts _gp_disp symbol into DSO files and assigns zero version definition index to it. This value means 'unversioned local symbol' while _gp_disp is a section global symbol. We have to handle this bug in the LLD because BFD linker is used for building MIPS toolchain libraries. Differential revision: https://reviews.llvm.org/D42486 llvm-svn: 324467
* [ELF] Add --print-icf-sections flagJames Henderson2018-02-011-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | Currently ICF information is output through stderr if the "--verbose" flag is used. This differs to Gold for example, which uses an explicit flag to output this to stdout. This commit adds the "--print-icf-sections" and "--no-print-icf-sections" flags and changes the output message format for clarity and consistency with "--print-gc-sections". These messages are still output to stderr if using the verbose flag. However to avoid intermingled message output to console, this will not occur when the "--print-icf-sections" flag is used. Existing tests have been modified to expect the new message format from stderr. Patch by Owen Reynolds. Differential Revision: https://reviews.llvm.org/D42375 Reviewers: ruiu, rafael Reviewed by: llvm-svn: 323976
* Don't mark a shared library as needed because of a lazy symbol.Rafael Espindola2018-01-231-0/+3
| | | | | | Fixes PR36029. llvm-svn: 323221
* Fix another case we used the wrong visibility.Rafael Espindola2018-01-161-0/+1
| | | | | | In here too we want the computed output visibility. llvm-svn: 322586
* Add an extra test. NFC.Rafael Espindola2018-01-161-0/+2
| | | | | | | Without this all test would pass if the visibility checks were removed from SymbolTable::addShared and SymbolTable::addUndefined. llvm-svn: 322583
* Fix another case we were using the wrong visibility.Rafael Espindola2018-01-161-0/+2
| | | | llvm-svn: 322580
* Rename --icf-data and add a corresponding flag for functions.Rafael Espindola2018-01-102-0/+12
| | | | | | | | | | When we have --icf=safe we should be able to define --icf=all as a shorthand for --icf=safe --ignore-function-address-equality. For now --ignore-function-address-equality is used only to control access to non preemptable symbols in shared libraries. llvm-svn: 322152
* [ELF] Compress debug sections after assignAddresses and support custom layoutJames Henderson2018-01-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, in r320472, I moved the calculation of section offsets and sizes for compressed debug sections into maybeCompress, which happens before assignAddresses, so that the compression had the required information. However, I failed to take account of relocations that patch such sections. This had two effects: 1. A race condition existed when a debug section referred to a different debug section (see PR35788). 2. References to symbols in non-debug sections would be patched incorrectly. This is because the addresses of such symbols are not calculated until after assignAddresses (this was a partial regression caused by r320472, but they could still have been broken before, in the event that a custom layout was used in a linker script). assignAddresses does not need to know about the output section size of non-allocatable sections, because they do not affect the value of Dot. This means that there is no longer a reason not to support custom layout of compressed debug sections, as far as I'm aware. These two points allow for delaying when maybeCompress can be called, removing the need for the loop I previously added to calculate the section size, and therefore the race condition. Furthermore, by delaying, we fix the issues of relocations getting incorrect symbol values, because they have now all been finalized. llvm-svn: 321986
* [ELF] Only scan executables for shlib undefined symbolsShoaib Meenai2017-12-301-0/+4
| | | | | | | | | | | | | | | | | | | | If using a version script with a `local: *` in it, symbols in shared libraries will still get default visibility if another shared library on the link line has an undefined reference to the symbol. This is quite surprising. Neither bfd nor gold have this behavior when linking a shared library, and none of LLD's tests fail without this behavior, so it seems safe to limit scanShlibUndefined to executables. As far as executables are concerned, gold doesn't do any automatic default visibility marking, and bfd issues a link error about a shared library having a reference to a hidden symbol rather than silently giving that symbol default visibility. I think bfd's behavior here is preferable to LLD's, but that's something to be considered in a follow-up. Differential Revision: https://reviews.llvm.org/D41524 llvm-svn: 321578
* Allow copy relocation with -z notext.Rafael Espindola2017-12-281-0/+5
| | | | | | | | | | This makes adjustExpr a bit simpler too IMHO. It seems that some of the complication around relocation processing is that we are trying to create copy relocations too early. It seems we could handle a few simple cases first and continue. llvm-svn: 321507
* Don't try to preempt protected symbols with -z notext.Rafael Espindola2017-12-271-0/+5
| | | | | | I will send a followup patch removing the FIXME this patch adds. llvm-svn: 321499
* Allow relocations in rw sections to create plt entries.Rafael Espindola2017-12-241-0/+4
| | | | | | | | | | | If a relocation cannot be implemented by the dynamic linker and the section is rw, allow creating a plt entry to use as the function address as if the section was ro. This matches bfd and gold. It also matches our behavior with -z notext. llvm-svn: 321430
* [ELF] - Allow using PLT relocations when "-z notext" is given.George Rimar2017-12-231-0/+10
| | | | | | | | | | | | | | | This is part of PR35720. Currently LLD allows dynamic relocations against text when -z notext is given. Though for non-PIC relocations like R_X86_64_PC32 that does not work, we produce "relocation R_X86_64_PC32 cannot be used against shared object;" error because they may overflow in runtime. Solution implemented is to use PLT for them. Differential revision: https://reviews.llvm.org/D41541 llvm-svn: 321400
* Fix crash on invalid.Rafael Espindola2017-12-141-0/+0
| | | | | | | We would fail an assert if a shared library had a local symbol after sh_info. llvm-svn: 320667
OpenPOWER on IntegriCloud