summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* Add missing REQUIRES x86 to test/COFF/icf-safe.sAzharuddin Mohammed2018-09-131-0/+1
| | | | | | | | | | | | Reviewers: ruiu, pcc Reviewed By: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51764 llvm-svn: 342145
* Fix typo in error message. NFC.Azharuddin Mohammed2018-09-131-1/+1
| | | | | | | | | | | | | | Summary: It should be "wasm-ld", not "wasm-lld". Reviewers: ruiu Reviewed By: ruiu Subscribers: aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D51767 llvm-svn: 342144
* [PDB] Emit old fpo data to the PDB file.Zachary Turner2018-09-122-110/+208
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | r342003 added support for emitting FPO data from the DEBUG_S_FRAMEDATA subsection of the .debug$S section to the PDB file. However, that is not the end of the story. FPO can end up in two different destinations in a PDB, each corresponding to a different FPO data source. The case handled by r342003 involves copying data from the DEBUG_S_FRAMEDATA subsection of the .debug$S section to the "New FPO" stream in the PDB, which is then referred to by the DBI stream. The case handled by this patch involves copying records from the .debug$F section of an object file to the "FPO" stream (or perhaps more aptly, the "Old FPO" stream) in the PDB file, which is also referred to by the DBI stream. The formats are largely similar, and the difference is mostly only visible in masm generated object files, such as some of the low-level CRT object files like memcpy. MASM doesn't appear to support writing the DEBUG_S_FRAMEDATA subsection, and instead just writes these records to the .debug$F section. Although clang-cl does not emit a .debug$F section ever, lld still needs to support it so we have good debugging for CRT functions. Differential Revision: https://reviews.llvm.org/D51958 llvm-svn: 342080
* [ELF] Revert "Also demote lazy symbols."Chih-Hung Hsieh2018-09-115-30/+41
| | | | | | | | | This reverts commit https://reviews.llvm.org/rL330869 for a regression to link Android dex2oatds. Differential Revision: https://reviews.llvm.org/D51892 llvm-svn: 342007
* [PDB] Write FPO Data to the PDB.Zachary Turner2018-09-113-12/+502
| | | | llvm-svn: 342003
* [codeview] Decode and dump FP regs from S_FRAMEPROC recordsReid Kleckner2018-09-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: There are two registers encoded in the S_FRAMEPROC flags: one for locals and one for parameters. The encoding is described by the ExpandEncodedBasePointerReg function in cvinfo.h. Two bits are used to indicate one of four possible values: 0: no register - Used when there are no variables. 1: SP / standard - Variables are stored relative to the standard SP for the ISA. 2: FP - Variables are addressed relative to the ISA frame pointer, i.e. EBP on x86. If realignment is required, parameters use this. If a dynamic alloca is used, locals will be EBP relative. 3: Alternative - Variables are stored relative to some alternative third callee-saved register. This is required to address highly aligned locals when there are dynamic stack adjustments. In this case, both the incoming SP saved in the standard FP and the current SP are at some dynamic offset from the locals. LLVM uses ESI in this case, MSVC uses EBX. Most of the changes in this patch are to pass around the CPU so that we can decode these into real, named architectural registers. Subscribers: hiraditya Differential Revision: https://reviews.llvm.org/D51894 llvm-svn: 341999
* Simplify.Rui Ueyama2018-09-112-23/+15
| | | | | | Instead of Map<StringRef, bool>, we can simply use Set<StringRef>. llvm-svn: 341948
* Style fix.Rui Ueyama2018-09-111-4/+2
| | | | llvm-svn: 341937
* [ELF] Don't emit .relr.dyn section if there are no relocsPetr Hosek2018-09-102-0/+12
| | | | | | | | This resolves PR38875. Differential Revision: https://reviews.llvm.org/D51834 llvm-svn: 341870
* [MinGW] Hook up the --require-defined option to -include:Martin Storsjo2018-09-103-0/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D51840 llvm-svn: 341846
* Buildfix for r341825Alexandre Ganea2018-09-101-3/+3
| | | | llvm-svn: 341827
* [LLD][COFF] Cleanup error messages / add more coverage testsAlexandre Ganea2018-09-107-24/+475
| | | | | | | | | | | | - Log the reason for a PDB or precompiled-OBJ load failure - Properly handle out-of-date PDB or precompiled-OBJ signature by displaying a corresponding error - Slightly change behavior on PDB failure: any subsequent load attempt from another OBJ would result in the same error message being logged - Slightly change behavior on PDB failure: retry with filename only if previous error was ENOENT ("no such file or directory") - Tests: a. for native PDB errors; b. cover all the cases above Differential Revision: https://reviews.llvm.org/D51559 llvm-svn: 341825
* Remove an effectively unused local variable.Nico Weber2018-09-101-3/+2
| | | | llvm-svn: 341823
* ReleaseNotes: update links to use httpsHans Wennborg2018-09-101-2/+2
| | | | llvm-svn: 341788
* MachO: Change getString16() back to inline functionTom Stellard2018-09-071-1/+1
| | | | | | This was accidentally changed in r341670. llvm-svn: 341672
* MachO: Fix out-of-bounds memory access in getString16Tom Stellard2018-09-071-6/+5
| | | | | | | | | | | | | | | | | | Summary: This fixes the following tests when gcc is compiled with gcc8: lld :: mach-o/do-not-emit-unwind-fde-arm64.yaml lld :: mach-o/eh-frame-relocs-arm64.yaml llvm.org/PR38096 Reviewers: lhames, kledzik, javed.absar Subscribers: kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D51547 llvm-svn: 341670
* [ELF] Check if LinkSec is nullptr when initializing SHF_LINK_ORDER sectionsFangrui Song2018-09-072-2/+20
| | | | | | | | | | | | | | Summary: This protects lld from a null pointer dereference when a faulty input file has such invalid sh_link fields. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D51743 llvm-svn: 341611
* [COFF] don't mark lazy symbols as used in regular objectsBob Haarman2018-09-063-6/+22
| | | | | | | | | | | | | | | | | | Summary: r338767 updated the COFF and wasm linker SymbolTable code to be strutured more like the ELF linker's. That inadvertedly changed the behavior of the COFF linker so that lazy symbols would be marked as used in regular objects. This change adds an overload of the insert() function, similar to the ELF linker, which does not perform that marking. Reviewers: ruiu, rnk, hans Subscribers: aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D51720 llvm-svn: 341585
* lld-link: Write an empty "repro" debug directory entry if /Brepro is passedNico Weber2018-09-052-18/+87
| | | | | | | | | | | If the coff timestamp is set to a hash, like lld-link does if /Brepro is passed, the coff spec suggests that a IMAGE_DEBUG_TYPE_REPRO entry is in the debug directory. This lets lld-link write such a section. Fixes PR38429, see bug for details. Differential Revision: https://reviews.llvm.org/D51652 llvm-svn: 341486
* When a relocation to an undefined symbol is an R_X86_64_PC32, an inputSterling Augustine2018-09-041-1/+1
| | | | | | | | | | | | section will not have an input file. Don't crash under those circumstances. Neither clang nor llvm-mc generates R_X86_64_PC32 relocations due to https://reviews.llvm.org/D43383, which makes it hard to write a test case. However, gcc does generate such relocations. I want to get a fix in now, but will figure out a way to actually exercise this code path as soon as I can. llvm-svn: 341408
* [COFF] Allow exporting all symbols from system libraries specfied with ↵Martin Storsjo2018-09-044-4/+33
| | | | | | | | | | | | | | | -wholearchive: When building a shared libc++.dll, it pulls in libc++abi.a statically with the --wholearchive flag. If such a build is done with --export-all-symbols, it's reasonable to assume that everything from that library also should be exported with the same rules as normal local object files, even though we normally avoid autoexporting things from libc++abi.a in other cases when linking a DLL (user code). Differential Revision: https://reviews.llvm.org/D51529 llvm-svn: 341403
* [DebugInfo] Common behavior for error typesAlexandre Ganea2018-08-311-4/+4
| | | | | | | | | | | | | | | Following D50807, and heading towards D50664, this intermediary change does the following: 1. Upgrade all custom Error types in llvm/trunk/lib/DebugInfo/ to use the new StringError behavior (D50807). 2. Implement std::is_error_code_enum and make_error_code() for DebugInfo error enumerations. 3. Rename GenericError -> PDBError (the file will be renamed in a subsequent commit) 4. Update custom error messages to follow the same formatting: (\w\s*)+\. 5. Keep generic "file not found" (ENOENT) errors as they are in PDB code. Previously, there used to be a custom enumeration for that purpose. 6. Remove a few extraneous LF in log() implementations. Printing LF is a responsability at a higher level, not at the error level. Differential Revision: https://reviews.llvm.org/D51499 llvm-svn: 341228
* [LLD] Add test missed from r341206. NFC.Ben Dunbobbin2018-08-311-0/+9
| | | | llvm-svn: 341207
* [LLD] Check too large offsets into merge sections earlierBen Dunbobbin2018-08-313-23/+12
| | | | | | | | | | | | | | | | | This patch moves the checking for too large offsets into merge sections earlier. Without this change the large offset generated in the added test-case will cause an assert (as it happens to be a value reserved as a "tombstone" in the DenseMap implementation) when OffsetMap is queried in getSectionPiece(). To simplify the code and avoid future mistakes I have refactored so that there is only one function that looks up offsets in the OffsetMap. Differential Revision: https://reviews.llvm.org/D51180 llvm-svn: 341206
* [ELF] [ARM] Don't mix 'ip' and 'r12' as names for the same register in ↵Martin Storsjo2018-08-311-4/+4
| | | | | | comments. NFC. llvm-svn: 341179
* [COFF] When doing automatic dll imports, replace whole .refptr.<var> chunks ↵Martin Storsjo2018-08-319-27/+99
| | | | | | | | | | | | | | | | | | | | with __imp_<var> After fixing up the runtime pseudo relocation, the .refptr.<var> will be a plain pointer with the same value as the IAT entry itself. To save a little binary size and reduce the number of runtime pseudo relocations, redirect references to the IAT entry (via the __imp_<var> symbol) itself and discard the .refptr.<var> chunk (as long as the same section chunk doesn't contain anything else than the single pointer). As there are now cases for both setting the Live variable to true and false externally, remove the accessors and setters and just make the variable public instead. Differential Revision: https://reviews.llvm.org/D51456 llvm-svn: 341175
* [PPC64] Improve a test ppc64_entry_point.sFangrui Song2018-08-311-8/+7
| | | | | | | Rename to ppc64-entry-point.s Deduplicate .text dump of little-endian big-endian llvm-svn: 341153
* Import lit.llvm after rLLD341134Fangrui Song2018-08-311-1/+1
| | | | llvm-svn: 341150
* [PPC64] Improve a test ppc64-toc-rel.sFangrui Song2018-08-312-20/+12
| | | | | | | Deduplicate dump of .text .data for little-endian and big-endian Fix a RELOCS-NE check line typo llvm-svn: 341148
* [PPC64] Remove unused -z notext from a testFangrui Song2018-08-301-2/+2
| | | | llvm-svn: 341139
* Remove LIT_SITE_CFG_IN_FOOTER, lldNico Weber2018-08-301-1/+2
| | | | | | | | | | It's always replaced with the same (short) static string, so just put that there directly. No intended behavior change. https://reviews.llvm.org/D51357 llvm-svn: 341134
* [COFF] Skip exporting artificial symbols when exporting all symbolsMartin Storsjo2018-08-302-2/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D51457 llvm-svn: 341017
* [test] Adjust a test to use CHECK-NEXT instead of CHECK-NOT. NFC.Martin Storsjo2018-08-301-6/+5
| | | | | | | | | | | Since the order and placement of the non-wanted elements might not be obvious, it feels more straightforward to hardcode the whole list with -NEXT elements (and checking for the end of the output with CHECK-EMPTY) instead of adding CHECK-NOT lines at the right places where the unwanted elements would appear if they erroneously were to included. llvm-svn: 341016
* ELF: Don't examine values of linker script symbols during ICF.Peter Collingbourne2018-08-294-2/+22
| | | | | | | | | These symbols are declared early with the same value, so they otherwise appear identical to ICF. Differential Revision: https://reviews.llvm.org/D51376 llvm-svn: 340998
* [WebAssembly] clang-format (NFC)Heejin Ahn2018-08-295-25/+27
| | | | | | | | | | | | Summary: This patch runs clang-format on all wasm-only files. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D51449 llvm-svn: 340970
* [CMake] Add an lld-test-depends targetMartin Storsjo2018-08-291-0/+3
| | | | | | | | | This builds all dependencies of lld-test/check-lld, without running the tests. This matches llvm-test-depends and clang-test-depends. Differential Revision: https://reviews.llvm.org/D51439 llvm-svn: 340943
* [COFF] Merge the .ctors, .dtors and .CRT sections into .rdata for MinGWMartin Storsjo2018-08-292-10/+20
| | | | | | | | | | | | | | | | | There's no point in keeping them as separate sections. This differs from GNU ld, which places .ctors and .dtors content in .text (implemented by a built-in linker script). But since the content only is pointers, there's no need to have it executable. GNU ld also leaves .CRT separate as its own standalone section. MSVC merges .CRT into .rdata similarly, with a directive embedded in an object file in msvcrt.lib or libcmt.lib. Differential Revision: https://reviews.llvm.org/D51414 llvm-svn: 340940
* Always add a .note.GNU-stack section if -r.Rui Ueyama2018-08-298-16/+47
| | | | | | | | | | | | With this patch, lld creates a .note.GNU_stack and adds that to an output file if it is creating a re-linkable object file (i.e. if -r is given). If we don't do this, and if you use GNU linkers as a final linker, they create an executable whose stack area is executable, which is considered pretty bad these days. Differential Revision: https://reviews.llvm.org/D51400 llvm-svn: 340902
* [ELF] Change llvm-objdump -D to -d for check lines that only inspect text ↵Fangrui Song2018-08-299-17/+17
| | | | | | | | | | | | sections Reviewers: ruiu, sfertile, syzaara, espindola Subscribers: emaste, nemanjai, arichardson, kbarton, llvm-commits Differential Revision: https://reviews.llvm.org/D51389 llvm-svn: 340890
* [PPC64] Fix DQ-form instruction handling and emit error for misalignment.Sean Fertile2018-08-284-7/+119
| | | | | | | | | | | | | Relanding r340564, original commit message: Fixes the handling of *_DS relocations used on DQ-form instructions where we were overwriting some of the extended opcode bits. Also adds an alignment check so that the user will receive a diagnostic error if the value we are writing is not properly aligned. Differential Revision: https://reviews.llvm.org/D51124 llvm-svn: 340832
* [LLD][ELF] - Simplify Call-Chain Clustering implementation a bit.George Rimar2018-08-281-16/+10
| | | | | | | | | | Looking at the current implementation and algorithm description, it does not seem we need to keep vector with all edges for each cluster and can just remember the best one. This is NFC change. Differential revision: https://reviews.llvm.org/D50609 llvm-svn: 340806
* [LLD][ELD] - Do not reject INFO output section type when used with a start ↵George Rimar2018-08-284-21/+45
| | | | | | | | | | | | | | | | | | | | address. This is https://bugs.llvm.org/show_bug.cgi?id=38625 LLD accept this: ".stack (INFO) : {", but not this: ".stack address_expression (INFO) :" The patch fixes it. Differential revision: https://reviews.llvm.org/D51027 llvm-svn: 340804
* [LLF][ELF] - Support -z global.George Rimar2018-08-284-6/+11
| | | | | | | | -z global is a flag used on Android (see D49198). Differential revision: https://reviews.llvm.org/D49374 llvm-svn: 340802
* fix comment typoNico Weber2018-08-271-1/+1
| | | | llvm-svn: 340742
* [ELF][HEXAGON] Add R_HEX_11/10/9_X supportSid Manning2018-08-272-0/+30
| | | | | | Differential Revision: https://reviews.llvm.org/D51225 llvm-svn: 340739
* Handle identifying AMDGPU bitcode filesMatt Arsenault2018-08-273-0/+27
| | | | llvm-svn: 340738
* [COFF] Support MinGW automatic dllimport of dataMartin Storsjo2018-08-2714-0/+495
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Normally, in order to reference exported data symbols from a different DLL, the declarations need to have the dllimport attribute, in order to use the __imp_<var> symbol (which contains an address to the actual variable) instead of the variable itself directly. This isn't an issue in the same way for functions, since any reference to the function without the dllimport attribute will end up as a reference to a thunk which loads the actual target function from the import address table (IAT). GNU ld, in MinGW environments, supports automatically importing data symbols from DLLs, even if the references didn't have the appropriate dllimport attribute. Since the PE/COFF format doesn't support the kind of relocations that this would require, the MinGW's CRT startup code has an custom framework of their own for manually fixing the missing relocations once module is loaded and the target addresses in the IAT are known. For this to work, the linker (originall in GNU ld) creates a list of remaining references needing fixup, which the runtime processes on startup before handing over control to user code. While this feature is rather controversial, it's one of the main features allowing unix style libraries to be used on windows without any extra porting effort. Some sort of automatic fixing of data imports is also necessary for the itanium C++ ABI on windows (as clang implements it right now) for importing vtable pointers in certain cases, see D43184 for some discussion on that. The runtime pseudo relocation handler supports 8/16/32/64 bit addresses, either PC relative references (like IMAGE_REL_*_REL32*) or absolute references (IMAGE_REL_AMD64_ADDR32, IMAGE_REL_AMD64_ADDR32, IMAGE_REL_I386_DIR32). On linking, the relocation is handled as a relocation against the corresponding IAT slot. For the absolute references, a normal base relocation is created, to update the embedded address in case the image is loaded at a different address. The list of runtime pseudo relocations contains the RVA of the imported symbol (the IAT slot), the RVA of the location the relocation should be applied to, and a size of the memory location. When the relocations are fixed at runtime, the difference between the actual IAT slot value and the IAT slot address is added to the reference, doing the right thing for both absolute and relative references. With this patch alone, things work fine for i386 binaries, and mostly for x86_64 binaries, with feature parity with GNU ld. Despite this, there are a few gotchas: - References to data from within code works fine on both x86 architectures, since their relocations consist of plain 32 or 64 bit absolute/relative references. On ARM and AArch64, references to data doesn't consist of a plain 32 or 64 bit embedded address or offset in the code. On ARMNT, it's usually a MOVW+MOVT instruction pair represented by a IMAGE_REL_ARM_MOV32T relocation, each instruction containing 16 bit of the target address), on AArch64, it's usually an ADRP+ADD/LDR/STR instruction pair with an even more complex encoding, storing a PC relative address (with a range of +/- 4 GB). This could theoretically be remedied by extending the runtime pseudo relocation handler with new relocation types, to support these instruction encodings. This isn't an issue for GCC/GNU ld since they don't support windows on ARMNT/AArch64. - For x86_64, if references in code are encoded as 32 bit PC relative offsets, the runtime relocation will fail if the target turns out to be out of range for a 32 bit offset. - Fixing up the relocations at runtime requires making sections writable if necessary, with the VirtualProtect function. In Windows Store/UWP apps, this function is forbidden. These limitations are addressed by a few later patches in lld and llvm. Differential Revision: https://reviews.llvm.org/D50917 llvm-svn: 340726
* Rename a function to follow the LLVM coding style.Rui Ueyama2018-08-276-6/+6
| | | | llvm-svn: 340716
* [COFF] Check the instructions in ARM MOV32T relocationsMartin Storsjo2018-08-272-3/+101
| | | | | | | | | | For this relocation, which applies to two consecutive instructions, it's plausible that the second instruction might not actually be the right one. Differential Revision: https://reviews.llvm.org/D50998 llvm-svn: 340715
* [ELF][HEXAGON] Add R_HEX_B13_PCREL relocation supportSid Manning2018-08-252-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D51166 llvm-svn: 340693
OpenPOWER on IntegriCloud