summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement R_X86_64_16.Rafael Espindola2017-02-134-0/+25
| | | | | | It is used by qemu. llvm-svn: 294965
* Create only one section symbol per section.Rafael Espindola2017-02-117-21/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Unfortunately some consumers of our .o files produced with -r expect only one section symbol per section. That is true of at least of go's own linker. Combining them is a somewhat convoluted process. We have to create a symbol for every section since we don't know which ones will be needed. The relocation sections also have to be written first to handle the Elf_Rel addend. I did consider a completely different approach: We could remove the -r special case of relocation sections when reading. We would instead have a copyRelocs function that is used instead of scanRelocs. It would create a DynamicReloc for each relocation and a RelocationSection for each input relocation section. A complication of such change is that DynamicReloc would have to take a section index and a input section instead of a symbol since with -emit-relocs some DynamicReloc would hold relocations referring to the dynamic symbol table and other to the static symbol table. That would be a pretty big change, and if we do it it is probably better to do it as a refactoring. llvm-svn: 294816
* Relax tests a bit.Rafael Espindola2017-02-102-7/+7
| | | | | | The values being tested were not relevant to the test. llvm-svn: 294776
* [CMake] Fix pthread handling for out-of-tree buildsEric Fiselier2017-02-104-4/+4
| | | | | | | | | | | | | | | LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects to correctly link the threading library when needed. Unfortunately `PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed and therefore can't be used when configuring out-of-tree builds. This causes such builds to fail since `pthread` isn't being correctly linked. This patch attempts to fix that problem by renaming and exporting `LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB` because It seemed likely to cause collisions with downstream users of `LLVMConfig.cmake`. llvm-svn: 294690
* added missing "savetemps/" in test/COFF/savetemps.llBob Haarman2017-02-091-1/+1
| | | | llvm-svn: 294664
* Don't try to link to the 4.0 release notesHans Wennborg2017-02-091-0/+2
| | | | llvm-svn: 294659
* list paths explicitly instead of using * inBob Haarman2017-02-091-14/+18
| | | | | | | | | | | | test/COFF/savetemps.ll Reviewers: dyung, ruiu Reviewed By: dyung, ruiu Differential Revision: https://reviews.llvm.org/D29788 llvm-svn: 294643
* Handle gcing user created metadata.Rafael Espindola2017-02-092-0/+41
| | | | | | In particular, this should allow us to gc unused asan metadata. llvm-svn: 294592
* [ELF] Refactor PltSection and IPltSection into PltSection [NFC]Peter Smith2017-02-093-75/+40
| | | | | | | | | | | | Much of the code in PltSection and IPltSection is similar, we identify the IPlt by a HeaderSize of 0 and alter our behaviour in the member functions appropriately: -Iplt does not have a header -Iplt always follows after the Plt Differential Revision: https://reviews.llvm.org/D29664 llvm-svn: 294579
* [ELF] Use synthetic section to hold copy relocationPeter Smith2017-02-095-27/+45
| | | | | | | | | | | | | | When we need a copy relocation we create a synthetic SHT_NOBITS section that contains the right amount of ZI and assign it to either .bss or .rel.ro.bss as appropriate. This allows the dynamic relocation to be placed on the InputSection, removing the last case where a dynamic relocation is stored as an offset from the OutputSection. This has the side effect that we can run assignOffsets() after scanRelocs() without losing the additional ZI needed for the copy relocations. Differential Revision: https://reviews.llvm.org/D29637 llvm-svn: 294577
* [test] Fix zlib cond when building stand-alone, clean upMichal Gorny2017-02-083-9/+14
| | | | | | | | | | | | | | | Fix the test zlib conditional to use LLVM_ENABLE_ZLIB value when building stand-alone. The HAVE_LIBZ is not available when performing a stand-alone build. Since the zlib support is a feature of the underlying LLVM library, it exports the actual status as the final value of LLVM_ENABLE_ZLIB in LLVMConfig. While at it, canonicalize the boolean value into 0/1 and remove unused CMake definitions (most likely copied from clang). Differential Revision: https://reviews.llvm.org/D29340 llvm-svn: 294508
* [test] Use LLD-specific binary&library dirs when building stand-aloneMichal Gorny2017-02-082-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use both LLD- and LLVM-specific binary&library directories when LLD is being built stand-alone. This ensures that the freshly built tools and libraries are found and used correctly. Without this patch, the test suite uses LLVM_TOOLS_DIR and LLVM_LIBS_DIR to locate lld, and set PATH and LD_LIBRARY_PATH. When doing a stand-alone builds, these variables represent the installed LLVM. As a result, tests either fail due to missing lld executables/libraries or use an earlier installed LLD version rather than the one being built. To solve this, an additional LLD_TOOLS_DIR and LLD_LIBS_DIR variables are added that are populated using LLVM_*_OUTPUT_INTDIR. Those variables are populated with directories used to output built executables and libraries. In stand-alone builds, they represent the directories used by LLD. In integrated builds, they have the same values as LLVM_*_DIR and therefore using them does not harm. The new variables are prepended to PATH and LD_LIBRARY_PATH to ensure that freshly built binaries are preferred over potentially earlier installed ones. Furthermore, the resulting PATH is used to locate tools for substitutions since the search includes both tools built as part of LLD and of LLVM. Differential Revision: https://reviews.llvm.org/D29335 llvm-svn: 294507
* Attempt to fix lld-x86_64-win7 bot.Rui Ueyama2017-02-081-2/+2
| | | | | | | | | The test is failing on the bot because "/subsystem:console" was truncated for some reason. I don't know why that is happening on that machine (it is not reproducible on my Windows machine). In this patch, I'm trying to tame it by making the output shorter. llvm-svn: 294502
* [COFF] added support for /lldsavetempsBob Haarman2017-02-085-3/+54
| | | | | | | | | | | | | | Summary: This adds an option to save temporary files generated during link-time optimization. This can be useful for debugging. Reviewers: ruiu, pcc Reviewed By: ruiu, pcc Subscribers: mehdi_amini Differential Revision: https://reviews.llvm.org/D29518 llvm-svn: 294498
* Recommit r294464 "[ELF] - Added partial support for --emit-relocs (no ↵George Rimar2017-02-088-8/+134
| | | | | | | | | | | | | | | | | | | | | | --gc-section case, no /DISCARD/ support) #3" with temporarily file name fix in testcase. Original commit message: -q, --emit-relocs - Generate relocations in output Simplest implementation: * no GC case, * no "/DISCARD/" linkerscript command support. This patch is extracted from D28612 / D29636, Relative to PR31579. Differential revision: https://reviews.llvm.org/D29663 llvm-svn: 294469
* Reverted r294464 "[ELF] - Added partial support for --emit-relocs (no ↵George Rimar2017-02-088-134/+8
| | | | | | | | | --gc-section case, no /DISCARD/ support) #3" Broked build bot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/5835/steps/test/logs/stdio llvm-svn: 294466
* [ELF] - Added partial support for --emit-relocs (no --gc-section case, no ↵George Rimar2017-02-088-8/+134
| | | | | | | | | | | | | | | | | | /DISCARD/ support) #3 -q, --emit-relocs - Generate relocations in output Simplest implementation: * no GC case, * no "/DISCARD/" linkerscript command support. This patch is extracted from D28612 / D29636, Relative to PR31579. Differential revision: https://reviews.llvm.org/D29663 llvm-svn: 294464
* Revert "Simplify symbol computation for non alloc sections."Rafael Espindola2017-02-082-4/+11
| | | | | | | This reverts commit r294346. Looks like it regressed the build of magenta. llvm-svn: 294460
* [ELF] - Linkerscript - fix handling of OUTPUT_ARCH command.George Rimar2017-02-082-9/+4
| | | | | | | | | | | | | | OUTPUT_ARCH command can contain architecture values separated with ":", like: OUTPUT_ARCH(i386:x86-64) We did not support that, because got 3 lexer tokens here after recent changes. This trivial patch fixes the issue, now whole expression inside OUTPUT_ARCH is just ignored. Differential revision: https://reviews.llvm.org/D29640 llvm-svn: 294432
* [ELF] - Rename the test. NFC.George Rimar2017-02-081-0/+0
| | | | | | | Addressing post commit comments, it do nothing relative with orphans. llvm-svn: 294429
* [ELF] Handle output section alignment in linker scriptsPetr Hosek2017-02-072-0/+66
| | | | | | | | | | LLD already parses ALIGN expression to specifiy alignment for output sections in linker scripts but it never applies the alignment to the output section. This change handles that. Differential Revision: https://reviews.llvm.org/D29689 llvm-svn: 294374
* Simplify symbol computation for non alloc sections.Rafael Espindola2017-02-072-11/+4
| | | | | | | We now just keep the address the section would have if it was allocatable. Only the writer ignores it at the very end. llvm-svn: 294346
* Handle the case where 'local' is the name of a global in a version script:Dmitry Mikulin2017-02-074-7/+37
| | | | | | { global : local; local: *; }; llvm-svn: 294343
* [ELF] - Assign proper values for DefinedSynthetic symbols attached to ↵George Rimar2017-02-072-2/+22
| | | | | | | | | | | | | | | | | | | | non-allocatable sections. DefinedSynthetic symbols are attached to sections, for the case when such symbol was attached to non-allocated section, we calculated its value incorrectly. We subtracted Body->Section->Addr, but non-allocatable sections should have zero VA in output and therefore result value was wrong. And at the same time we have Body->Section->Addr != 0 for them internally because use it for calculation of section size. Patch fixes calculation of such symbols values. Differential revision: https://reviews.llvm.org/D29653 llvm-svn: 294322
* [ELF] - Removed excessive check call from outputarch.s. NFC.George Rimar2017-02-071-1/+0
| | | | | | | For case when LLD should error out, llm-readobj was called, what worked because argument was an output from first test run. llvm-svn: 294310
* [ELF] - Refactoring: reuse similar method.George Rimar2017-02-071-33/+20
| | | | | | | | | We had assignSymbol and assignSectionSymbol methods which has similar functionality. Patch removes one of copy and reuses another in code. Differential revision: https://reviews.llvm.org/D29582 llvm-svn: 294290
* [ELF] - Use SignExtend when reading R_386_PC8, R_386_PC16 addends.George Rimar2017-02-072-2/+21
| | | | | | | | | | | | | Previously we did not do that. For example, for R_386_PC8, 0xFF addend was not treated as 0xFFFFFFFF(-1), but was 0x000000FF. Recently added checks for R_386_PC8/R_386_PC16 failed because of calculation overflow as a result. Differential revision: https://reviews.llvm.org/D29490 llvm-svn: 294289
* COFF: ensure that we handle bad argumentsSaleem Abdulrasool2017-02-072-1/+7
| | | | | | | The parameter to /debugtype is user provided and may be invalid. Ensure that we gracefully handle bad input. llvm-svn: 294280
* COFF: prevent nullptr dereferenceSaleem Abdulrasool2017-02-073-5/+25
| | | | | | | | If `/debugtypes` is used to omit the codeview information, we would not have constructed the debug info codeview record which is used to tie the PDB to the binary. In such a case, rub out the GUID and Age fields. llvm-svn: 294279
* Change the return type of getImplicitAddend to signed integer.Rui Ueyama2017-02-062-12/+11
| | | | | | | | | If relocations don't have addends, addends are embedded in operands. getImplicitAddend is a function to read addends. Addends can be negative numbers, so the return type of the function should be a signed integer type. llvm-svn: 294253
* Handle symbol assignments before the first section switch.Rafael Espindola2017-02-062-8/+28
| | | | | | | | | | We now create a dummy section with index 1 before processing the linker script. Thanks to George Rimar for finding the bug and providing the initial testcase. llvm-svn: 294252
* Attempt to fix a flakey test.Rui Ueyama2017-02-061-1/+1
| | | | | | | I believe that the test is flakey because the order of stdout and stderr is not deterministic. llvm-svn: 294238
* Add an option to use the MSVC linker to link LTO-generated object files.Rui Ueyama2017-02-0610-17/+120
| | | | | | | | | | | This patch defines a new command line option, /MSVCLTO, to LLD. If that option is given, LLD invokes link.exe to link LTO-generated object files. This is hacky but useful because link.exe can create PDB files. Differential Revision: https://reviews.llvm.org/D29526 llvm-svn: 294234
* [ELF] - Simplify i386-ps8.s testcase.George Rimar2017-02-062-4/+4
| | | | | | Removes dependency on second input file. llvm-svn: 294178
* Use a utility function to reduce repetition. NFC.Rui Ueyama2017-02-051-30/+34
| | | | llvm-svn: 294117
* fix nullptr dereference in COFF/Symbol.hBob Haarman2017-02-031-1/+1
| | | | llvm-svn: 294064
* Simplify. NFC.Rafael Espindola2017-02-031-18/+16
| | | | | | | Now that each OutputSectionCommand maps to just one OutputSection, we can remove a few std::vectors. llvm-svn: 294060
* Simplify. NFC.Rafael Espindola2017-02-032-12/+3
| | | | llvm-svn: 294057
* Don't worry about dropping SHF_MERGE.Rafael Espindola2017-02-032-7/+2
| | | | | | | Now that it doesn't impact which sections are merged, this is not a problem. llvm-svn: 294054
* Stop propagating Entsize.Rafael Espindola2017-02-0317-26/+21
| | | | | | | Now that we combine multiple synthetic merge section into one output section there is no point in trying to propagate a value. llvm-svn: 294048
* Handle numbers followed by ":" in linker scripts.Rafael Espindola2017-02-034-8/+28
| | | | | | | | | | | This is a fix for Bugzilla 31813. The problem is that the tokenizer does not create a separate token for ":" unless there's white space before it. Changed it to always create a token for ":" and reworked some logic that relied on ":" being attached to some tokens like "global:" and "local:". llvm-svn: 294006
* Replace MergeOutputSection with a synthetic section.Rafael Espindola2017-02-0314-202/+273
| | | | | | | | | | | | | | With a synthetic merge section we can have, for example, a single .rodata section with stings, fixed sized constants and non merge constants. I can be simplified further by not setting Entsize, but that is probably better done is a followup patch. This should allow some cleanup in the linker script code now that every output section command maps to just one output section. llvm-svn: 294005
* Fix shared build after r293965 (Core) and r293967 (COFF)Ismail Donmez2017-02-032-0/+2
| | | | llvm-svn: 293996
* Revert "[ThinLTO] Add an auto-hide feature"Mehdi Amini2017-02-031-2/+2
| | | | | | | | | This reverts commit r293970. After more discussion, this belongs to the linker side and there is no added value to do it at this level. llvm-svn: 293993
* added missing dependency on intrinsics_gen to lib/CoreBob Haarman2017-02-031-0/+7
| | | | llvm-svn: 293986
* [ThinLTO] Add an auto-hide featureMehdi Amini2017-02-031-2/+2
| | | | | | | | | | | | | | | When a symbol is not exported outside of the DSO, it is can be hidden. Usually we try to internalize as much as possible, but it is not always possible, for instance a symbol can be referenced outside of the LTO unit, or there can be cross-module reference in ThinLTO. This is a recommit of r293912 after fixing build failures, and a recommit of r293918 after fixing LLD tests. Differential Revision: https://reviews.llvm.org/D28978 llvm-svn: 293970
* refactor COFF linker to use new LTO APIBob Haarman2017-02-0215-255/+373
| | | | | | | | | | | | | | Summary: The COFF linker previously implemented link-time optimization using an API which has now been marked as legacy. This change refactors the COFF linker to use the new LTO API, which is also used by the ELF linker. Reviewers: pcc, ruiu Reviewed By: pcc Subscribers: mgorny, mehdi_amini Differential Revision: https://reviews.llvm.org/D29059 llvm-svn: 293967
* added missing files for r293965Bob Haarman2017-02-022-0/+46
| | | | llvm-svn: 293966
* add the ability to call InitTargetOptionsFromCodeGenFlags from multiple objectsBob Haarman2017-02-022-1/+2
| | | | | | | | | | | | | | Summary: llvm/CodeGen/CommandFlags.h a utility function InitTargetOptionsFromCodeGenFlags which is used to set target options from flags based on the command line. The command line flags are stored in globals defined in the same file, and including the file in multiple places causes the globals to be defined multiple times, leading to linker errors. This change adds a single place in lld where these globals are defined and exports only the utility function. This makes it possible to call InitTargetOptionsFromCodeGenFlags from multiple places in lld, which a follow-up change will do. Reviewers: davide, ruiu Reviewed By: davide, ruiu Subscribers: mgorny Differential Revision: https://reviews.llvm.org/D29058 llvm-svn: 293965
* Update comments.Rui Ueyama2017-02-021-3/+22
| | | | llvm-svn: 293963
OpenPOWER on IntegriCloud