summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* De-template DefinedRegular.Rui Ueyama2017-02-281-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D30348 llvm-svn: 296508
* Add Triple::thumb to getBitcodeMachineKindSean Silva2017-02-281-0/+1
| | | | | | | | | | | | We really need to find a way to get this info from a single point of truth in the LLVM backend, but it seems that the EM_* constants are buried deep inside the constructors of the MCAsmBackend's. For now, just fill in entries as we run into cases. AFAIK these mappings are largely immutable, so we get a 75% discount on the technical debt (code is duplicated, but little chance of divergence). llvm-svn: 296429
* Use uint64_t instead of uintX_t where the larger type just works.Rui Ueyama2017-02-241-6/+6
| | | | llvm-svn: 296162
* Make InputSection a class. NFC.Rafael Espindola2017-02-231-18/+18
| | | | | | | | | With the current design an InputSection is basically anything that goes directly in a OutputSection. That includes plain input section but also synthetic sections, so this should probably not be a template. llvm-svn: 295993
* Slightly improve an error message.Rui Ueyama2017-02-231-1/+2
| | | | llvm-svn: 295942
* Add a comment about .note.GNU-split-stack.Rui Ueyama2017-02-231-0/+4
| | | | llvm-svn: 295941
* Update comment: .note.GNU-stack is added by default today.Rui Ueyama2017-02-231-3/+4
| | | | llvm-svn: 295939
* Update a comment about .note.GNU-stack.Rui Ueyama2017-02-231-4/+12
| | | | llvm-svn: 295938
* Use isa<MergeInputSection> to check if a section is a merge section.Rui Ueyama2017-02-231-1/+1
| | | | | | | | We have InputSection, MergeInputSection and EhInputSection, so isa<MergeInputSection> is equivalent to !isa<InputSection> && !isa< EhInputSection>. llvm-svn: 295937
* Convert InputSectionBase to a class.Rafael Espindola2017-02-231-10/+8
| | | | | | | Removing this template is not a big win by itself, but opens the way for removing more templates. llvm-svn: 295923
* Do not use errs() or outs() directly. Instead use message(), log() or error()Rui Ueyama2017-02-211-3/+2
| | | | | | | | | LLD is a multi-threaded program. errs() or outs() are not guaranteed to be thread-safe (they are actually not). LLD's message(), log() or error() are thread-safe. We should use them. llvm-svn: 295787
* [ELF] - Added support of linkerscript's "/DISCARD/" for --emit-relocsGeorge Rimar2017-02-171-2/+6
| | | | | | | | | | | | Previously LLD crashed on on provided testcases because "/DISCARD/" was not supported. Patch implements that. After this I think there is no known issues with --emit-relocs implementation required for linux kernel linking. Differential revision: https://reviews.llvm.org/D29273 llvm-svn: 295488
* [ELF] - Move DependentSections vector from InputSection to InputSectionBaseGeorge Rimar2017-02-171-2/+1
| | | | | | | | | | | | | | | | I splitted it from D29273. Since we plan to make relocatable sections as dependent for target ones for --emit-relocs implementation, this change is required to support .eh_frame case. EhInputSection inherets from InputSectionBase and not from InputSection. So for case when it has relocation section, it should be able to access DependentSections vector. This case is real for Linux kernel. Differential revision: https://reviews.llvm.org/D30084 llvm-svn: 295483
* [ELF] - Allow section to have multiple dependent sections.George Rimar2017-02-161-1/+1
| | | | | | | | | | | That fixes a case when section has more than one metadata section. Previously GC would collect one of such sections because we had implementation that stored only last one as dependent. Differential revision: https://reviews.llvm.org/D29981 llvm-svn: 295298
* [ELF] - Do not segfault when using -r and section groups.George Rimar2017-02-141-5/+8
| | | | | | | | | | | | | | | | If we had SHT_GROUP sections, then when -r was used we might crash. This is PR31952. Issue happened because we emited relocation section though its target was discared because was a member of duplicated group. When we tried to get VA of target, segfault happened. Core cause is the bug that GNU as 2.27 (and probably later versions) has. In compare with llvm-mc, it does not include relocation sections into the group, like shown in testcase. This patch covers that case. Differential revision: https://reviews.llvm.org/D29929 llvm-svn: 295067
* Recommit r294464 "[ELF] - Added partial support for --emit-relocs (no ↵George Rimar2017-02-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | --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-081-7/+0
| | | | | | | | | --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-081-0/+7
| | | | | | | | | | | | | | | | | | /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
* [ELF] Use SyntheticSections for ThunksPeter Smith2017-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Thunks are now implemented by redirecting the relocation to the symbol S, to a symbol TS in a Thunk. The Thunk will transfer control to S. This has the following implications: - All the side-effects of Thunks happen within createThunks() - Thunks are no longer stored in InputSections and Symbols no longer need to hold a pointer to a Thunk - The synthetic Thunk sections need to be merged into OutputSections This implementation is almost a direct conversion of the existing Thunks with the following exceptions: - Mips LA25 Thunks are placed before the InputSection that defines the symbol that needs a Thunk. - All ARM Thunks are placed at the end of the OutputSection of the first caller to the Thunk. Range extension Thunks are not supported yet so it is optimistically assumed that all Thunks can be reused. This is a recommit of r293283 with a fixed comparison predicate as std::merge requires a strict weak ordering. Differential revision: https://reviews.llvm.org/D29327 llvm-svn: 293757
* Revert "[ELF][ARM] Use SyntheticSections for Thunks"Rui Ueyama2017-01-281-1/+1
| | | | | | This reverts commit r293283 because it broke MSVC build. llvm-svn: 293352
* [ELF][ARM] Use SyntheticSections for ThunksPeter Smith2017-01-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Thunks are now implemented by redirecting the relocation to the symbol S, to a symbol TS in a Thunk. The Thunk will transfer control to S. This has the following implications: - All the side-effects of Thunks happen within createThunks() - Thunks are no longer stored in InputSections and Symbols no longer need to hold a pointer to a Thunk - The synthetic Thunk sections need to be merged into OutputSections This implementation is almost a direct conversion of the existing Thunks with the following exceptions: - Mips LA25 Thunks are placed before the InputSection that defines the symbol that needs a Thunk. - All ARM Thunks are placed at the end of the OutputSection of the first caller to the Thunk. Range extension Thunks are not supported yet so it is optimistically assumed that all Thunks can be reused. Differential Revision: https://reviews.llvm.org/D29129 llvm-svn: 293283
* Remove error(error_code, const Twine &).Rui Ueyama2017-01-121-1/+1
| | | | | | Now we have the consistent interface for all log/warn/error/fatal functions. llvm-svn: 291847
* Make the -b binary .data section rw.Rafael Espindola2017-01-111-2/+2
| | | | | | | This matches what bfd and gold do. It also matches the common flags of other .data sections. llvm-svn: 291674
* ELF: Discard .gnu.linkonce.* sections.Peter Collingbourne2017-01-091-0/+8
| | | | | | | | | | | | | | | | The linkonce feature is a sort of proto-comdat. As far as I am aware no compiler produces linkonce sections anymore, but some glibc i386 object files contain definitions of symbol "__x86.get_pc_thunk.bx" in linkonce sections. Drop those sections to avoid duplicate symbol errors. This is glibc PR20543, we should remove this hack once that has been fixed for a while. Fixes PR31215. Differential Revision: https://reviews.llvm.org/D28430 llvm-svn: 291474
* Add linker-script-included files to reproduce tar files.Rui Ueyama2017-01-091-4/+23
| | | | | | | | Previously, files added using INCLUDE directive weren't added to reproduce archives. In this patch, I defined a function to open a file and use that from Driver and LinkerScript. llvm-svn: 291413
* Handle versioned undefined symbols.Rafael Espindola2017-01-061-6/+16
| | | | | | | In order to keep symbol lookup a simple name lookup this patch adds versioned symbols with an explicit @ to the symbol table. llvm-svn: 291293
* Merge elf::toString and coff::toString.Rui Ueyama2017-01-061-1/+1
| | | | | | The two overloaded functions hid each other. This patch merges them. llvm-svn: 291222
* Use \ as the path separator on Windows.Rui Ueyama2017-01-061-2/+1
| | | | | | | | Previously, when we printed out a path obtained from DWARF debug info, we replaced \ with / on Windows. But that doesn't make sense. We should respect the system's path separator. llvm-svn: 291219
* Use TarWriter to create tar archives instead of cpio.Rui Ueyama2017-01-061-3/+3
| | | | | | | | | | This is how we use TarWriter in LLD. Now LLD does not append a file extension, so you need to pass `--reproduce foo.tar` instead of `--reproduce foo`. Differential Revision: https://reviews.llvm.org/D28103 llvm-svn: 291210
* [ELF] Add support for thunks to undefined non-weak symbolsPeter Smith2017-01-041-1/+1
| | | | | | | | | | | | In a shared library an undefined symbol is implicitly imported. If the symbol is called as a function a PLT entry is generated for it. When the caller is a Thumb b.w a thunk to the PLT entry is needed as all PLT entries are in ARM state. This change allows undefined symbols to have thunks in the same way that shared symbols may have thunks. llvm-svn: 290951
* Remove lld/Support/Memory.h.Rui Ueyama2016-12-181-1/+1
| | | | | | | | | | | | I thought for a while about how to remove it, but it looks like we can just copy the file for now. Of course I'm not happy about that, but it's just less than 50 lines of code, and we already have duplicate code in Error.h and some other places. I want to solve them all at once later. Differential Revision: https://reviews.llvm.org/D27819 llvm-svn: 290062
* [ELF] Accept first SHT_ARM_ATTRIBUTES sectionPeter Smith2016-12-141-2/+9
| | | | | | | | | | | | | | | | | | The eglibc library, as used by Ubuntu 14.04 requires the presence of an SHT_ARM_ATTRIBUTES section in for the purposes of checking hard/soft float compatibility when dlopen() is used. Unfortunately when the section is not present dlopen() fails with a generic could not find file message. This change makes lld keep the first .ARM.attributes section that it encounters and propagates it to the output. This is not a complete SHT_ARM_ATTRIBUTES implementation, that would involve reading the contents of the section and joining each individual attribute. It should suffice for a homogenous build all libraries and executables on the same system with a compatible set of command line options. Differential revision: https://reviews.llvm.org/D27718 llvm-svn: 289642
* Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.Rui Ueyama2016-12-081-1/+1
| | | | llvm-svn: 289084
* Remove redundant call of std::unique_ptr::get.Rui Ueyama2016-12-071-1/+1
| | | | | | Obj is an instance of std::unique_ptr, so *Obj.get() is the same as *Obj. llvm-svn: 288996
* Do not pass line number to convertToUnixPathSeparator.Rui Ueyama2016-12-071-2/+2
| | | | | | | Line number can never contain '/' or '\', so the previous code was pointless at that point. llvm-svn: 288973
* Make convertToUnixPathSeparator return a new string instead of mutating ↵Rui Ueyama2016-12-071-3/+2
| | | | | | argument. llvm-svn: 288972
* Format. NFC.George Rimar2016-12-071-1/+1
| | | | llvm-svn: 288967
* [ELF] - Print absolute file name in errors when possible.George Rimar2016-12-071-4/+6
| | | | | | | | | | | | | | | | | | | Currently LLD prints basename of source file name in error messages, for example: $ mkdir foo $ echo 'void _start(void) { foobar(); }' > foo/bar.c $ gcc -g -c foo/bar.c $ bin/ld.lld -o out bar.o bin/ld.lld: error: bar.c:1: undefined symbol 'foobar' $ This should say: bin/ld.lld: error: foo/bar.c:1: undefined symbol 'foobar' This is PR31299 Differential revision: https://reviews.llvm.org/D27506 llvm-svn: 288966
* Use StringRefZ explicitly instead of const char *.Rui Ueyama2016-11-291-1/+1
| | | | | | | This patch is to avoid an implicit conversion from const char * to StringRefZ, to make it apparent where we are using StringRefZ. llvm-svn: 288182
* Introduce StringRefZ class to represent null-terminated strings.Rui Ueyama2016-11-291-12/+18
| | | | | | | | | | | | | | StringRefZ is a class to represent a null-terminated string. String length is computed lazily, so it's more efficient than StringRef to represent strings in string table. The motivation of defining this new class is to merge functions that only differ in string types; we have many constructors that takes `const char *` or `StringRef`. With StringRefZ, we can merge them. Differential Revision: https://reviews.llvm.org/D27037 llvm-svn: 288172
* Move typedefs inside a class definition.Rui Ueyama2016-11-251-2/+0
| | | | llvm-svn: 287945
* Define toString() as a generic function to get a string for error message.Rui Ueyama2016-11-231-19/+18
| | | | | | | | | | | | | | | We have different functions to stringize objects to construct error messages. For InputFile, we have getFilename, and for InputSection, we have getName. You had to memorize them. I think this is the case where the function overloading comes in handy. This patch defines toString() functions that are overloaded for all these types, so that you just call it in error(). Differential Revision: https://reviews.llvm.org/D27030 llvm-svn: 287787
* [ELF] Refactor several error messagesEugene Leviant2016-11-231-3/+3
| | | | | | Differential revision: https://reviews.llvm.org/D26970 llvm-svn: 287753
* Remove one of SymbolTable::addRegular function that forwards other addRegular.Rui Ueyama2016-11-231-13/+18
| | | | | | So that we have less number of overloaded functions. llvm-svn: 287745
* Allow calling getName() on local symbols.Rui Ueyama2016-11-231-3/+7
| | | | | | | | | Previously, we stored offsets in string tables to symbols, so you needed to pass a string table to get a symbol name. This patch stores const char pointers instead to eliminate the need to pass a string table. llvm-svn: 287737
* Change the way how we print out line numbers.Rui Ueyama2016-11-211-1/+1
| | | | | | | | | | | | | | | | | | | LLD's error messages contain line numbers, function names or section names. Currently they are formatter as follows. foo.c (32): symbol 'foo' not found foo.c (function bar): symbol 'foo' not found foo.c (.text+0x1234): symbol 'foo' not found This patch changes them so that they are consistent with Clang's output. foo.c:32: symbol 'foo' not found foo.c:(function bar): symbol 'foo' not found foo.c:(.text+0x1234): symbol 'foo' not found Differential Revision: https://reviews.llvm.org/D26901 llvm-svn: 287537
* [ELF] Better error reporting for broken archivesEugene Leviant2016-11-211-1/+2
| | | | | | Differential revision: https://reviews.llvm.org/D26852 llvm-svn: 287527
* [ELF] - Better diagnostic for relative relocation to an absolute value error.George Rimar2016-11-151-4/+6
| | | | | | | | | | | | | | Patch adds a filename to that error message. I faced next error when debugged one of FreeBSD port: error: relocation R_X86_64_PLT32 cannot refer to absolute symbol __tls_get_addr error message was poor and this patch improves it to show the locations of symbol declaration and using. Differential revision: https://reviews.llvm.org/D26508 llvm-svn: 286940
* [ELF] - Allow symbols of STT_NOTYPE to be associated with SHT_SYMTAB sections.George Rimar2016-11-151-5/+6
| | | | | | | | | | | | | | | | | | | | Found this when tried to link lang/ccl FreeBSD port. Issue is very close to D23201. This is the reason of lang/ccl port link fail. GNU assembler 2.17.50 [FreeBSD] 2007-07-03 could generate broken objects, where notype symbols are associated with symtab: ... [ 9] .symtab SYMTAB 0000000000000000 00003c78 0000000000006858 0000000000000018 10 803 8 ... 192: 000000000000000d 0 NOTYPE LOCAL DEFAULT 9 _cons_org Patch allows to handle such objects. Differential revision: https://reviews.llvm.org/D26613 llvm-svn: 286939
* [ELF] - format. NFC.George Rimar2016-11-141-4/+3
| | | | llvm-svn: 286804
OpenPOWER on IntegriCloud