summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove a use of template to make code less abstracted.Rui Ueyama2018-10-091-19/+26
| | | | | | | Sometimes, code that is a bit longer but doesn't use template is easier to understand than code that uses template. llvm-svn: 344072
* Fix lld test.Zachary Turner2018-10-091-19/+0
| | | | | | | I removed this output from the dumper because it was non-portable, but I didn't update the test which checked the output. llvm-svn: 344066
* lld-link: attempt to fix tests on Windows after r344061.Nico Weber2018-10-091-1/+1
| | | | llvm-svn: 344065
* Add an entry to the release notes.Rui Ueyama2018-10-091-0/+3
| | | | llvm-svn: 344062
* lld-link: Use /pdbsourcepath: for more places when present.Nico Weber2018-10-092-20/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | /pdbsourcepath: was added in https://reviews.llvm.org/D48882 to make it possible to have relative paths in the debug info that clang-cl writes. lld-link then makes the paths absolute at link time, which debuggers require. This way, clang-cl's output is independent of the absolute path of the build directory, which is useful for cacheability in distcc-like systems. This patch extends /pdbsourcepath: (if passed) to also be used for: 1. The "cwd" stored in the env block in the pdb is /pdbsourcepath: if present 2. The "exe" stored in the env block in the pdb is made absolute relative to /pdbsourcepath: instead of the cwd 3. The "pdb" stored in the env block in the pdb is made absolute relative to /pdbsourcepath: instead of the cwd 4. For making absolute paths to .obj files referenced from the pdb /pdbsourcepath: is now useful in three scenarios (the first one already working before this change): 1. When building with full debug info, passing the real build dir to /pdbsourcepath: allows having clang-cl's output to be independent of the build directory path. This patch effectively doesn't change behavior for this use case (assuming the cwd is the build dir). 2. When building without compile-time debug info but linking with /debug, a fake fixed /pdbsourcepath: can be passed to get symbolized stacks while making the pdb and exe independent of the current build dir. For this two work, lld-link needs to be invoked with relative paths for the lld-link invocation itself (for "exe"), for the pdb output name, the exe output name (for "pdb"), and the obj input files, and no absolute path must appear on the link command (for "cmd" in the pdb's env block). Since no full debug info is present, it doesn't matter that the absolute path doesn't exist on disk -- we only get symbols in stacks. 3. When building production builds with full debug info that don't have local changes, and that get source indexed and their pdbs get uploaded to a symbol server. /pdbsourcepath: again makes the build output independent of the current directory, and the fixed path passed to /pdbsourcepath: can be given the source indexing transform so that it gets mapped to a repository path. This has the same requirements as 2. This patch also makes it possible to create PDB files containing Windows-style absolute paths when cross-compiling on a POSIX system. Differential Revision: https://reviews.llvm.org/D53021 llvm-svn: 344061
* lld-link: Implement support for %_PDB% and %_EXT% for /pdbaltpath:.Nico Weber2018-10-083-0/+160
| | | | | | | | | | Warn that references to regular env vars are ignored. Fixes PR38940. Differential Revision: https://reviews.llvm.org/D52942 llvm-svn: 344003
* Fix a broken buildbot.Rui Ueyama2018-10-081-1/+1
| | | | llvm-svn: 343983
* Avoid unnecessary buffer allocation and memcpy for compressed sections.Rui Ueyama2018-10-0815-87/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we uncompress all compressed sections before doing anything. That works, and that is conceptually simple, but that could results in a waste of CPU time and memory if uncompressed sections are then discarded or just copied to the output buffer. In particular, if .debug_gnu_pub{names,types} are compressed and if no -gdb-index option is given, we wasted CPU and memory because we uncompress them into newly allocated bufers and then memcpy the buffers to the output buffer. That temporary buffer was redundant. This patch changes how to uncompress sections. Now, compressed sections are uncompressed lazily. To do that, `Data` member of `InputSectionBase` is now hidden from outside, and `data()` accessor automatically expands an compressed buffer if necessary. If no one calls `data()`, then `writeTo()` directly uncompresses compressed data into the output buffer. That eliminates the redundant memory allocation and redundant memcpy. This patch significantly reduces memory consumption (20 GiB max RSS to 15 Gib) for an executable whose .debug_gnu_pub{names,types} are in total 5 GiB in an uncompressed form. Differential Revision: https://reviews.llvm.org/D52917 llvm-svn: 343979
* [ELF][HEXAGON] Add R_HEX_GOT_16_X supportSid Manning2018-10-082-1/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D52909 llvm-svn: 343972
* [llvm-nm] Write "no symbol" output to stderrPetr Hosek2018-10-051-1/+1
| | | | | | | | | | This matches the output of binutils' nm and ensures that any scripts or tools that use nm and expect empty output in case there no symbols don't break. Differential Revision: https://reviews.llvm.org/D52943 llvm-svn: 343887
* [COFF] Do MinGW specific entry/subsystem inferenceMartin Storsjo2018-10-053-0/+68
| | | | | | | | | | | | | | | | | | | | ld.bfd doesn't do any inference of subsystem; unless the windows subsystem is specified, the console subsystem is used. For the console subsystem, the entry point is called mainCRTStartup, regardless of whether the the user code entry point is main or wmain. The same goes for the windows subsystem, where the entry point always is WinMainCRTStartup, for both WinMain and wWinMain in user code. One detail that we don't emulate, is that if the inferred entry point is undefined, ld.bfd silently just sets the entry point to the start of the image. And if an explicit entry point is set, but it is undefined, the link still succeeds but the linker warns about the entry point not being found. Differential Revision: https://reviews.llvm.org/D52931 llvm-svn: 343879
* [docs] Mention some notable feature in the release notesMartin Storsjo2018-10-051-0/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D52908 llvm-svn: 343878
* [COFF] Cope with GCC produced weak aliases referring to comdat functionsMartin Storsjo2018-10-054-0/+89
| | | | | | | | | | | | For certain cases of inline functions written to comdat sections, GCC 5.x produces a weak symbol in addition, which would end up undefined in some cases. This no longer seems to happen with GCC 6.x or newer though. Differential Revision: https://reviews.llvm.org/D52602 llvm-svn: 343877
* [LLD][COFF] Fix ordering of CRT global initializers in COMDAT sectionsAlexandre Ganea2018-10-056-6/+192
| | | | | | | | | | (patch by Benoit Rousseau) This patch fixes a bug where the global variable initializers were sometimes not invoked in the correct order when it involved a C++ template instantiation. Differential Revision: https://reviews.llvm.org/D52749 llvm-svn: 343847
* ReleaseNotes: remove superfluous 's' in 'can promotes'Ed Maste2018-10-041-1/+1
| | | | llvm-svn: 343820
* [ELF][HEXAGON] Add support for GOT relocations.Sid Manning2018-10-045-15/+41
| | | | | | | | | | | | | The GOT is referenced through the symbol _GLOBAL_OFFSET_TABLE_ . The relocation added calculates the offset into the global offset table for the entry of a symbol. In order to get the correct TargetVA I needed to create an new relocation expression, HEXAGON_GOT. It does Sym.getGotVA() - In.GotPlt->getVA(). Differential Revision: https://reviews.llvm.org/D52744 llvm-svn: 343784
* [ELF] - Simplify. NFCI.George Rimar2018-10-041-4/+2
| | | | | | Assign the `Link` to parent directly. llvm-svn: 343762
* Use std::make_pair rather than brace initialization.Matt Morehouse2018-10-041-2/+2
| | | | | | | r343732 broke the Windows bot. Seems like the compiler on that bot doesn't like brace initialization. llvm-svn: 343749
* [ELF] Fix typo. NFCShoaib Meenai2018-10-041-1/+1
| | | | llvm-svn: 343748
* [ELF] Fix crash on invalid undefined local symbolsShoaib Meenai2018-10-033-9/+75
| | | | | | | | | | | | | | | | | | | | r320770 made LLD handle invalid DSOs where local symbols were found in the global part of the symbol table. Unfortunately, it didn't handle the case where those local symbols were also undefined, and r326242 exposed an assertion failure in that case. Just warn on that case instead of crashing, by moving the local binding check before the undefined symbol addition. The input file for the test is crafted by hand, since I don't know of any tool that would produce such a broken DSO. I also don't understand what it even means for a symbol to be undefined but have STB_LOCAL binding - I don't think that combination makes any sense - but we have found broken DSOs of this nature that we were linking against. I've included detailed instructions on how to produce the DSO in the test. Differential Revision: https://reviews.llvm.org/D52815 llvm-svn: 343745
* [llvm-nm] Update lld tests based on changed llvm-nm outputJordan Rupprecht2018-10-031-1/+2
| | | | llvm-svn: 343743
* [WebAssembly] Refactor use of signaturesDerek Schuff2018-10-034-22/+23
| | | | | | | | Update use of WebAssemblySignature to go along with D52580 Differential Revision: https://reviews.llvm.org/D52622 llvm-svn: 343734
* Minor refacotring of Relocations.cpp. NFC.Rui Ueyama2018-10-031-44/+67
| | | | | | | | This patch splits ThunkCreator::mergeThunks into two smaller functions. Also adds blank lines to various places so that the code doesn't look too dense. llvm-svn: 343732
* [PPC64] Test documenting toc-restore after interposable recursive call. [NFC]Sean Fertile2018-10-031-0/+52
| | | | | | | | | A test verifying that toc restores are properly inserted following recursive calls, as well as briefly describing why they are needed. Differential Revision: https://reviews.llvm.org/D52564 llvm-svn: 343729
* [PPC64] Add test documenting toc-restore when linking with -Bsymbolic. [NFC]Sean Fertile2018-10-032-0/+82
| | | | | | Differential Revision: https://reviews.llvm.org/D52523 llvm-svn: 343728
* [COFF] Cope with weak aliases produced by GNU toolsMartin Storsjo2018-10-034-1/+61
| | | | | | | | | | | | | | | When GNU tools create a weak alias, they produce a strong symbol named .weak.<weaksymbol>.<relatedstrongsymbol>. GNU ld allows many such weak alternatives for the same weak symbol, and the linker picks the first one encountered. This can't be reproduced by assembling from .s files, since llvm-mc produces symbols named .weak.<weaksymbol>.default in these cases. Differential Revision: https://reviews.llvm.org/D52601 llvm-svn: 343704
* lld-link: Several tweaks to default entry point selection.Nico Weber2018-10-033-18/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Three related changes: 1. link.exe uses the presence of main and wmain to decide if it should call mainCRTStartup or wmainCRTStartup, even if /nodefaultlib is passed. For compatibility, remove FindMain logic. 2. Default to the non-wide entrypoint if main is not found. This has two effects: 2a. In normal links, lld-link now prints lld-link: error: undefined symbol: _main >>> referenced by f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:78 >>> libcmt.lib(exe_main.obj):("int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)) >>> referenced by f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283 >>> libcmt.lib(exe_main.obj):("int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)) instead of lld-link: error: entry point must be defined This is arguably a better error message, since it now mentions that _main is missing. (This matches link.exe's diagnostic in this case.) 2b. With /nodefautlib, we now default to mainCRTStartup if no main() is present, again matching link.exe. This makes r337407 obsolete. This means if you have a cc file containing both mainCRTStartup and wmainCRTStartup and you pass /nodefaultlib /subsystem:console, lld-link will now call mainCRTStartup, matching link.exe 3. Print a warning if both main and wmain are present, similar to link.exe's LNK4067. Differential Revision: https://reviews.llvm.org/D52832 llvm-svn: 343698
* [ELF] - Fix BB after r343668George Rimar2018-10-031-1/+2
| | | | | | | | | This stops testing the value of .rela.plt section offset. Also makes _start global to eliminate 'cannot find entry symbol _start' warning. llvm-svn: 343669
* [ELF] - Do not forget to include to .dymsym symbols that were converted to ↵George Rimar2018-10-032-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Defined. This is the fix for "Bug 39104 - LLD links incorrect ELF executable if version script contains "local: *;" (https://bugs.llvm.org/show_bug.cgi?id=39104). The issue happens when we have non-PIC program call to function in a shared library. (for example, the PR above has R_X86_64_PC32 relocation against __libc_start_main) LLD converts symbol to Defined in that case with the use of replaceWithDefined() The issue is that after above we create a broken relocation because do not include the symbol into .dynsym. That happens when the version script is used because we treat the symbol as STB_LOCAL if the following condition match: VersionId == VER_NDX_LOCAL && isDefined() and do not include it to .dynsym because of that. Patch fixes the issue. Differential revision: https://reviews.llvm.org/D52724 llvm-svn: 343668
* [LLD] - Do not crash when reporting errors when .debug_line_str (DWARF5) is usedGeorge Rimar2018-10-033-0/+140
| | | | | | | | | | | | | | | | | | Imagine we have the following code: int foo(); int main() { return foo(); } It will crash if you try to compile it with `clang -O0 -gdwarf-5 test.cpp -o test -g -fuse-ld=lld` The crash happens inside the LLVM DWARF parser because LLD does not provide the .debug_line_str section. At the same time for correct parsing and reporting, we anyways need to provide this section from our side. The patch fixes the issue. llvm-svn: 343667
* Introduce a flag to warn when ifunc symbols are used with text relocations.Ali Tamur2018-10-026-3/+72
| | | | | | | | | | | | | | | | | Summary: This patch adds a new flag, --warn-ifunc-textrel, to work around a glibc bug. When a code with ifunc symbols is used to produce an object file with text relocations, lld always succeeds. However, if that object file is linked using an old version of glibc, the resultant binary just crashes with segmentation fault when it is run (The bug is going to be corrected as of glibc 2.19). Since there is no way to tell beforehand what library the object file will be linked against in the future, there does not seem to be a fool-proof way for lld to give an error only in cases where the binary will crash. So, with this change (dated 2018-09-25), lld starts to give a warning, contingent on a new command line flag that does not have a gnu counter part. The default value for --warn-ifunc-textrel is false, so lld behaviour will not change unless the user explicitly asks lld to give a warning. Users that link with a glibc library with version 2.19 or newer, or does not use ifunc symbols, or does not generate object files with text relocations do not need to take any action. Other users may consider to start passing warn-ifunc-textrel to lld to get early warnings. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: grimar, MaskRay, markj, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D52430 llvm-svn: 343628
* [NFC][BUG-FIX][ARM] Add missing data symbolDiogo N. Sampaio2018-10-021-3/+6
| | | | | | | | | | llvm rL343594: [ARM] Emmit data symbol for constant pool data fixed a bug that ommited required data symbols. Such change breaked a test case in lld: test/ELF/arm-thunk-largesection.s llvm-svn: 343604
* [ELF] Read the call graph profile from object files.Michael J. Spencer2018-10-025-0/+109
| | | | | | | | | | This uses the call graph profile embedded in the object files to construct the call graph. This is read from a SHT_LLVM_CALL_GRAPH_PROFILE (0x6fff4c02) section as (uint32_t, uint32_t, uint64_t) tuples as (from symbol index, to symbol index, weight). Differential Revision: https://reviews.llvm.org/D45850 llvm-svn: 343552
* [ELF] [HEXAGON] Add support for PLT_B22_PCREL and HEX_32_PCRELSid Manning2018-10-012-13/+25
| | | | | | | | Update testcase. Differential Revision: https://reviews.llvm.org/D52734 llvm-svn: 343515
* Add an explanation about cross linking.Rui Ueyama2018-10-011-2/+17
| | | | | | Differential Revision: https://reviews.llvm.org/D52567 llvm-svn: 343495
* Fix typo in LLD man pageJames Henderson2018-10-011-1/+1
| | | | llvm-svn: 343449
* [COFF] In MinGW mode, ignore relocations against a discarded sectionMartin Storsjo2018-09-303-1/+111
| | | | | | | | | | | | | | When GCC produces a jump table as part of a comdat function, the jump table itself is produced as plain non-comdat rdata section. When linked with ld.bfd, all of those rdata sections are kept, with relocations unchanged in the sections that refer to discarded comdat sections. This has been observed with at least GCC 5.x and 7.x. Differential Revision: https://reviews.llvm.org/D52600 llvm-svn: 343422
* [LLD][COFF] Fix pdb loading when the path points to a removable deviceAlexandre Ganea2018-09-281-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D52666 llvm-svn: 343366
* [WebAssembly] Preserve function signatures during LTOSam Clegg2018-09-283-7/+38
| | | | | | | | | | | | | | | | | | | With LTO when and undefined function (with a known signature) in replaced by a defined bitcode function we were loosing the signature information (since bitcode functions don't have signatures). With this change we preserve the original signature from the undefined function and verify that the post LTO compiled function has the correct signature. This change improves the error handling in the case where there is a signature mismatch with a function defined in a bitcode file. Differential Revision: https://reviews.llvm.org/D50721 llvm-svn: 343340
* [ELF][HEXAGON] Add support for dynamic librariesSid Manning2018-09-284-5/+75
| | | | | | | | | Write out the PLT header and stub. Hexagon uses RELA relocations. Differential Revision: https://reviews.llvm.org/D52317 llvm-svn: 343320
* [WebAssembly] Add --[no]-export-dynamic to replace --export-defaultSam Clegg2018-09-2719-56/+64
| | | | | | | | | | | | | | | | | | | | | | | | In a very recent change I introduced a --no-export-default flag but after conferring with others it seems that this feature already exists in gnu GNU ld and lld in the form the --export-dynamic flag which is off by default. This change replaces export-default with export-dynamic and also changes the default to match the traditional linker behaviour. Now, by default, only the entry point is exported. If other symbols are required by the embedder then --export-dynamic or --export can be used to export all visibility hidden symbols or individual symbols respectively. This change touches a lot of tests that were relying on symbols being exported by default. I imagine it will also effect many users but do think the change is worth it match of the traditional behaviour and flag names. Differential Revision: https://reviews.llvm.org/D52587 llvm-svn: 343265
* [COFF] Add missing Requires x86 to fix buildbotPeter Smith2018-09-271-0/+1
| | | | | | | | | Add REQUIRES: x86 to pdb-debug-f.s as this is causing the Arm and AArch64 buildbots to fail as they do not have the x86 backend. Differential Revision: https://reviews.llvm.org/D52606 llvm-svn: 343196
* [WebAssembly] Update Config member to match command line optionSam Clegg2018-09-274-8/+8
| | | | | | | | Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D50976 llvm-svn: 343157
* Revert "[WebAssembly] Update docs"Sam Clegg2018-09-272-84/+18
| | | | | | | | | | This change reverts rL343155. It broke the builtbot, even though it works for me locally: http://lab.llvm.org:8011/builders/lld-sphinx-docs/builds/26336 Must be a sphinx version issue I guess. llvm-svn: 343156
* [WebAssembly] Update docsSam Clegg2018-09-272-18/+84
| | | | | | Differential Revision: https://reviews.llvm.org/D52048 llvm-svn: 343155
* [ELF] llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)Fangrui Song2018-09-263-24/+19
| | | | | | | | | | | | Summary: The convenience wrapper in STLExtras is available since rL342102. Reviewers: ruiu, espindola Subscribers: emaste, arichardson, mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D52569 llvm-svn: 343146
* Allow later -z name=<int> args to override earlier argsRyan Prichard2018-09-262-1/+4
| | | | | | | | | | | | | | | | | | Summary: lld already gives later -z options precedence in getZFlag(). This matches the behavior of ld.bfd and ld.gold, where later options override earlier ones. (I tested with -z max-page-size and -z stack-size.) Reviewers: ruiu, espindola, grimar Reviewed By: ruiu, grimar Subscribers: grimar, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D52526 llvm-svn: 343145
* [AArch64] Fix range check of R_AARCH64_TLSLE_ADD_TPREL_HI12Ryan Prichard2018-09-262-2/+19
| | | | | | | | | | | | | | | | | | | | | | | Summary: An AArch64 LE relocation is a positive ("variant 1") offset. This relocation is used to write the upper 12 bits of a 24-bit offset into an add instruction: add x0, x0, :tprel_hi12:v1 The comment in the ARM docs for R_AARCH64_TLSLE_ADD_TPREL_HI12 is: "Set an ADD immediate field to bits [23:12] of X; check 0 <= X < 2^24." Reviewers: javed.absar, espindola, ruiu, peter.smith, zatrazz Reviewed By: ruiu Subscribers: emaste, arichardson, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D52525 llvm-svn: 343144
* [ELF][test] Use llvm-readelf's short option -r instead of -relocations and ↵Fangrui Song2018-09-269-31/+31
| | | | | | | | | | | | | | remove ignored --wide Reviewers: ruiu, sfertile, espindola Reviewed By: ruiu Subscribers: jsji, emaste, nemanjai, arichardson, kbarton, llvm-commits Differential Revision: https://reviews.llvm.org/D52124 llvm-svn: 343135
* [ELF] - Do not fail on R_*_NONE relocations when parsing the debug info.George Rimar2018-09-2616-2/+81
| | | | | | | | | | | | | | | | | This is https://bugs.llvm.org//show_bug.cgi?id=38919. Currently, LLD may report "unsupported relocation target while parsing debug info" when parsing the debug information. At the same time LLD does that for zeroed R_X86_64_NONE relocations, which obviously has "invalid" targets. The nature of R_*_NONE relocation assumes them should be ignored. This patch teaches LLD to stop reporting the debug information parsing errors for them. Differential revision: https://reviews.llvm.org/D52408 llvm-svn: 343078
OpenPOWER on IntegriCloud