summaryrefslogtreecommitdiff
path: root/lld
AgeCommit message (Collapse)Author
2018-06-23[ELF] Change llvm-objdump output for D48472: TEXT DATA -> TEXTFangrui Song
Reviewers: jyknight, Bigcheese, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D48473
2018-06-22[ELF] - ICF: test we do not merge sections which relocations differs only in ↵George Rimar
addend. This is to test the following `return false` line which was uncovered by our tests earlier: https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L255
2018-06-22Revert "[WebAssembly] Error on mismatched function signature in final output"Sam Clegg
This caused a lot of issues on the WebAssembly waterfall. In particular, until with the signature of `main`. We probably want a better solution for main before we re-land. Reverts rL335192
2018-06-22[ELF] - Repair (re-enable) few ICF test cases.George Rimar
--verbose is not used to report ICF sections since r324755, --print-icf-sections is used instead. These tests were at fact disabled since that time.
2018-06-22[ELF] - ICF: Add 2 more test cases.George Rimar
These test cases covers the following condition: https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L243 It was uncovered by our tests. I was able to delete the whole `if` and no test failed.
2018-06-22[ELF] - ICF: remove excessive check. NFC.George Rimar
Change removes the excessive comparsion of the relocation arrays sizes. This code was dead, because at the higer level, equalsConstant function contains the following check: `A->NumRelocations != B->NumRelocations` where NumRelocations contains the size of the relocations array. So removed check did the same job twice. This was found with use of code coverage analysis.
2018-06-22[ELF] - Change how we handle suplicate -wrap. [NFC]George Rimar
This avoids doing llvm::sort and std::unique for -wrap options. I think it is more clean way.
2018-06-21[WebAssembly] Only mark non-hidden symbols as live if they are also definedSam Clegg
Previously we were also marking undefined symbols (i.e. imports) as live. Differential Revision: https://reviews.llvm.org/D48299
2018-06-21[WebAssembly] Error on mismatched function signature in final outputSam Clegg
During symbol resolution, emit warnings for function signature mismatches. During GC, if any mismatched symbol is marked as live then generate an error. This means that we only error out if the mismatch is written to the final output. i.e. if we would generate an invalid wasm file. Differential Revision: https://reviews.llvm.org/D48394
2018-06-20[WebAssembly] Minor cleanup to test inputs. NFC.Sam Clegg
Update load-undefined.test such that it doesn't rely on ret32 and ret64 having default visibility. Split out from: https://reviews.llvm.org/D48394 Differential Revision: https://reviews.llvm.org/D48403
2018-06-20[WebAssembly] Update function signature mismatch error message. NFC.Sam Clegg
We don't start our error messages with capital letters. Split out from https://reviews.llvm.org/D48394 Differential Revision: https://reviews.llvm.org/D48400
2018-06-20[ELF][MIPS] Fill a primary-GOT as much as possibleSimon Atanasyan
While building a Global Offset Table try to fill the primary GOT as much as possible because the primary GOT can be accessed in the most effective way. If it is not possible, try to fill the last GOT in the multi-GOT list, and finally create a new GOT if both attempts failed.
2018-06-20[ELF] Support -z initfirstFangrui Song
Summary: glibc uses this option to link libpthread.so glibc/nptl/Makefile: LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst Reviewers: ruiu, echristo, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D48329
2018-06-19[ELF][MIPS] Temporarily mark failed MIPS tests as XFAIL.Simon Atanasyan
microMIPS 64-bit is unsupported by LLVM starting from r335057. But such code can be generated by GCC. Mark failed test cases as XFAIL while decide to drop microMIPS 64-bit support from LLD too or use binary inputs for the test.
2018-06-18[ELF] Uniquify --wrap list.Fangrui Song
Summary: For --wrap foo --wrap foo, bfd/gold wrap the symbol only once but LLD would rotate it twice. Reviewers: ruiu, espindola Subscribers: emaste, arichardson, mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D48298
2018-06-18[ELF] - Simplify the conflict-variable-linkage-name.s test case. [NFC]George Rimar
This is a follow up requested during post commit review for "[lld] r333880 - [ELF] - Also use DW_AT_linkage_name when gathering information about variables for error messages." It removes checking of the input objects since it is really excessive.
2018-06-18Update copyright year to 2018.Paul Robinson
2018-06-16[ELF] Pass callables by function_refBenjamin Kramer
No need to create a heavyweight std::function if it's not stored. No functionality change intended.
2018-06-15[ELF][MIPS] Fix stable_sort predicate to satisfy strict-ordering ↵Simon Atanasyan
requirement. NFC Fix for PR37785.
2018-06-14Fix wasm responsefile lld test on WindowsReid Kleckner
2018-06-14[COFF] Fix /wholearchive: to do libpath search againReid Kleckner
Fixes https://crbug.com/852882
2018-06-14[ELF][MIPS] Replace calls to MapVector::find by MapVector::lookup. NFCSimon Atanasyan
2018-06-13[ELF][X86_64] Use R_GOTREL_FROM_END instead of R_GOTREL for R_X86_64_GOTOFF64Fangrui Song
Summary: R_X86_64_GOTOFF64: S + A - GOT R_X86_64_GOTPC{32,64}: GOT + A - P (R_GOTONLY_PC_FROM_END) R_X86_64_GOTOFF64 should use R_GOTREL_FROM_END so that in conjunction with R_X86_64_GOTPC{32,64}, the `GOT` term is neutralized. This also matches the handling of R_386_GOTOFF (S + A - GOT). Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D48095
2018-06-13Remove needless bitwise-AND.Rui Ueyama
Because applyMask ignores upper bits, we don't need to mask them.
2018-06-13Make a function non-member because it doesn't depend on any class.Rui Ueyama
2018-06-13Apply clang-format.Rui Ueyama
2018-06-13[Darwin] Do not error on '-lto_library' optionBrian Gesiak
Summary: Any invocation of `clang -fuse-ld=lld` that results in a link command on a macOS host currently fails, because the Darwin lld driver does not recognize the `-lto_library` option that Clang passes it. Fix the error by having the Darwin driver ignore the option. The Clang driver's macOS toolchain is written such that it will always pass the `-lto_library` option to the linker invocation on a macOS host. And although the DarwinLdDriver is written to ignore any unknown arguments, because `-lto_library` begins with `-l`, the DarwinLdDriver interprets it as a library search command, for a library named "to_library". When the DarwinLdDriver is unable to find a library specified via `-l`, it exits with a hard error. This causes any invocation of `clang -fuse-ld=lld` that results in a link command on a macOS host to fail with an error. To fix the issue, I considered two alternatives: 1. Modify the Clang Darwin toolchain to only pass `-lto_library` if lld is *not* being used. lld doesn't support LTO on Darwin anyway, so it can't use the option. However, I opted against this because, if and when lld *does* support LTO on Darwin, I'll have to make another commit to Clang in order to get it to pass the option to lld again. 2. Modify the Darwin lld driver to ignore the `-lto_library` option. Just in case users may take this to mean LTO is supported, I also added a warning. If and when lld supports LTO on Darwin, the same commit that adds support for this option can remove the warning. Option (2) seemed better to me, and is the rationale behind this commit. Test Plan: check-lld Reviewers: ruiu, smeenai, pcc Reviewed By: smeenai Subscribers: JDevlieghere, pcc, mehdi_amini, inglorion, steven_wu, llvm-commits Differential Revision: https://reviews.llvm.org/D47994
2018-06-13Add Hexagon SupportSid Manning
Differential Revision: https://reviews.llvm.org/D47791
2018-06-13[WebAssembly] Fix broken build due to missing attributes.incAaron Smith
WebAssembly depends on attributes.h which includes attributes.inc. Unless cmake explicitly specifies this dependency, the .inc file is sometimes generated after the build tries to use it. Patch by Stella Stamenova
2018-06-13Use shorter names for #lo, #hi, #ha, etc. NFC.Rui Ueyama
Since these functions are file-local, the new names shouldn't be ambiguous. Differential Revision: https://reviews.llvm.org/D48093
2018-06-12Fix /WholeArchive bug.Rui Ueyama
`lld-link foo.lib /wholearchive:foo.lib` should work the same way as `lld-link /wholearchive:foo.lib foo.lib`. Previously, /wholearchive in the former case was ignored. Differential Revision: https://reviews.llvm.org/D47565
2018-06-12[COFF] Fix crash when emitting symbol tables with GCShoaib Meenai
When running with linker GC (`-opt:ref`), defined imported symbols that are referenced but then dropped by GC end up with their `Location` member being nullptr, which means `getChunk()` returns nullptr for them and attempting to call `getChunk()->getOutputSection()` causes a crash from the nullptr dereference. Check for `getChunk()` being nullptr and bail out early to avoid the crash. Differential Revision: https://reviews.llvm.org/D48092
2018-06-12Handle R_X86_64_GOTOFF64.Rui Ueyama
R_X86_64_GOTOFF64 is a relocation type to set to a distance betwween a symbol and the beginning of the .got section. Previously, we always created a dynamic relocation for the relocation type even though it can be resolved at link-time. Creating a dynamic relocation for R_X86_64_GOTOFF64 caused link failure for some programs that do have a relocation of the type in a .text section, as text relocations are prohibited in most configurations. Differential Revision: https://reviews.llvm.org/D48058
2018-06-12[ELF][PPC64] Support R_PPC64_DTPREL64 which may be emitted in .rela.debug_addrFangrui Song
2018-06-12[ELF] Support R_X86_64_GOTPC{32,64}Fangrui Song
Reviewers: ruiu, grimar, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D47098
2018-06-12Refactor ExecuteAndWait to take StringRefs.Zachary Turner
This simplifies some code which had StringRefs to begin with, and makes other code more complicated which had const char* to begin with. In the end, I think this makes for a more idiomatic and platform agnostic API. Not all platforms launch process with null terminated c-string arrays for the environment pointer and argv, but the api was designed that way because it allowed easy pass-through for posix-based platforms. There's a little additional overhead now since on posix based platforms we'll be takign StringRefs which were constructed from null terminated strings and then copying them to null terminate them again, but from a readability and usability standpoint of the API user, I think this API signature is strictly better.
2018-06-12Fix -DBUILD_SHARED_LIBS=1 buildSam Clegg
This was broken in rL334466
2018-06-12[ELF][MIPS] Fix TLS GOT entries for local symbols in shared librariesAlexander Richardson
Summary: Previously LLD would not add any dynamic relocations and write a module index of 1 which is not correct for the shared library case. This can happen when a thread-local global variable is marked as local with a version script. With this change I am now able to link all of the FreeBSD base system for MIPS64 with LLD. Differential Revision: https://reviews.llvm.org/D48002
2018-06-12[Darwin] Use errorHandler from liblldCommonBrian Gesiak
Summary: Error handling in liblldCore and the Darwin toolchain prints to an output stream. A TODO in the project explained that a diagnostics interface resembling Clang's should be added. For now, the simple diagnostics interface defined in liblldCommon seems like an improvement. It prints colors when they're available, uses locks for thread-safety, and abstracts away the `"error: "` and newline literal strings that litter the Darwin toolchain code. To use the liblldCommon error handler, a link dependency is added to the liblldDriver library. Test Plan: 1. check-lld 2. Invoke `ld64.lld -r` in a terminal that supports color output. Confirm that "ld64.lld: error: -arch not specified and could not be inferred" is output, and that the "error:" is colored red! Reviewers: ruiu, smeenai Reviewed By: ruiu Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D47998
2018-06-12[PPC64] Support R_PPC64_DTPREL relocations.Sean Fertile
Patch adds support for most of the dynamic thread pointer based relocations for local-dynamic tls. The HIGH and HIGHA versions are missing becuase they are not supported by the llvm integrated assembler yet.
2018-06-11AMDGPU/LLD: Handle R_AMDGPU_REL64 relocationKonstantin Zhuravlyov
Requires r334443 from llvm Differential Revision: https://reviews.llvm.org/D47734
2018-06-11[ELF] Fix copy relocation when two symbols share the same Symbol instance.Fangrui Song
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).
2018-06-11[ELF] Pass a pointer to InputFile to the getRelocTargetVA to escape ↵Simon Atanasyan
dereferencing of nullptr. NFC
2018-06-11[ELF][MIPS] Multi-GOT implementationSimon Atanasyan
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
2018-06-09Fix build broken by r334341.Rui Ueyama
2018-06-09Remove a dead variable.Rui Ueyama
2018-06-08[PPC64] Add support for local-exec TLS modelZaara Syeda
This patch adds the relocations needed support the local-exec TLS model: R_PPC64_TPREL16 R_PPC64_TPREL16_HA R_PPC64_TPREL16_LO R_PPC64_TPREL16_HI R_PPC64_TPREL16_DS R_PPC64_TPREL16_LO_DS R_PPC64_TPREL16_HIGHER R_PPC64_TPREL16_HIGHERA R_PPC64_TPREL16_HIGHEST R_PPC64_TPREL16_HIGHESTA Differential Revision: https://reviews.llvm.org/D47598
2018-06-08Expand comments.Rui Ueyama
2018-06-07[WebAssembly] Add --export-all flagSam Clegg
This causes all symbols to be exported in the final wasm binary even if they were not compiled with default visibility. This feature is useful for the emscripten toolchain that has a corresponding EXPORT_ALL feature which allows the JS code to interact with all C function. Differential Revision: https://reviews.llvm.org/D47806
2018-06-07[COFF] report file containing unsupported relocationBob Haarman
Summary: When reporting an unsupported relocation type, let's also report the file we encountered it in to aid diagnosis. Reviewers: ruiu, rnk Reviewed By: rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45911