summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove redundant this->.Rui Ueyama2016-01-061-2/+2
| | | | llvm-svn: 256894
* Simplify --whole-archive handling.Rui Ueyama2016-01-061-1/+0
| | | | | | | | | | | | | | | | | Previously, we handle archive files with --whole-archive this way: create instances of ArchiveFile, call getMembers to obtain memory buffers of archive members, and create ObjectFiles for the members. We didn't call anything except getMembers if --whole-archive was specified. I noticed that we didn't actually have to create ArchiveFile instaces at all for that case. All we need is to get a list of memory buffers for members, which can be done by a non-member function. This patch removes getMembers member function from ArchiveFile. Also removed unnecessary code for memory management. llvm-svn: 256893
* Do not use templates to instantiate {Object,Shared}Files.Rui Ueyama2016-01-061-2/+2
| | | | | | | createELFFile looked complex because of its use of template, so I want to keep it private within this file. llvm-svn: 256880
* [ELF][MIPS] Implement R_MIPS_GPREL16/R_MIPS_GPREL32 relocationsSimon Atanasyan2015-12-251-0/+8
| | | | | | | | | | | | | | | | | | | | The R_MIPS_GPREL16 / R_MIPS_GPREL32 relocations use the following expressions for calculations: ``` local symbol: S + A + GP0 - GP global symbol: S + A - GP GP - Represents the final gp value, i.e. _gp symbol GP0 - Represents the gp value used to create the relocatable object ``` The GP0 value is taken from the .reginfo data section defined by an object file. To implement that I keep a reference to `MipsReginfoInputSection` in the `ObjectFile` class. This reference is used by the `ObjectFile::getMipsGp0` method to return the GP0 value. Differential Revision: http://reviews.llvm.org/D15760 llvm-svn: 256416
* Split functions and add comments. NFC.Rui Ueyama2015-12-241-0/+1
| | | | llvm-svn: 256369
* Simplify memory management.Rafael Espindola2015-12-231-1/+0
| | | | | | We no longer need an explicit delete or a polymorphic destructor. llvm-svn: 256333
* Fix the last leak asan found in test/ELF.Rafael Espindola2015-12-231-0/+1
| | | | llvm-svn: 256316
* Fix another asan detected leak.Rafael Espindola2015-12-231-0/+1
| | | | llvm-svn: 256311
* Fix two asan found bugs:Rafael Espindola2015-12-231-0/+1
| | | | | | | We were leaking InputFile subclasses data. UndefinedElf was missing a classof. llvm-svn: 256309
* Make a function out-of-line.Rui Ueyama2015-11-201-11/+1
| | | | | | There's no need to write it in a .h file. llvm-svn: 253633
* Two small fixes to copy relocation processing.Rafael Espindola2015-11-031-3/+7
| | | | | | | * We can determine the alignment requirement. * We have to update the bss alignment with it. llvm-svn: 251914
* Delete dead getter.Rafael Espindola2015-11-031-1/+0
| | | | llvm-svn: 251908
* ELF2: Implement --gc-sections.Rui Ueyama2015-10-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Section garbage collection is a feature to remove unused sections from outputs. Unused sections are sections that cannot be reachable from known GC-root symbols or sections. Naturally the feature is implemented as a mark-sweep garbage collector. In this patch, I added Live bit to InputSectionBase. If and only if Live bit is on, the section will be written to the output. Starting from GC-root symbols or sections, a new function, markLive(), visits all reachable sections and sets their Live bits. Writer then ignores sections whose Live bit is off, so that such sections are excluded from the output. This change has small negative impact on performance if you use the feature because making sections means more work. The time to link Clang changes from 0.356s to 0.386s, or +8%. It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes. That is 4.3% reduction. http://reviews.llvm.org/D13950 llvm-svn: 251043
* Add support for merging the contents of SHF_MERGE sections.Rafael Espindola2015-10-191-3/+4
| | | | | | For now SHF_STRINGS are not supported. llvm-svn: 250737
* Add a ObjectFile<ELFT>::getSection helper and simplify. NFC.Rafael Espindola2015-10-161-0/+1
| | | | llvm-svn: 250519
* ELF2: Fix BSD's __progname symbol issue.Rui Ueyama2015-10-131-0/+3
| | | | | | | | | | | | | BSD's DSO files have undefined symbol "__progname" which is defined in crt1.o. On that system, both user programs and system shared libraries depend on each other. In general, we need to put symbols defined by user programs which are referenced by shared libraries to user program's .dynsym. http://reviews.llvm.org/D13637 llvm-svn: 250176
* Remove the EKind member variable.Rafael Espindola2015-10-131-18/+13
| | | | | | Now that the base class is templated, it is redundant with the type. llvm-svn: 250139
* ELF2: Move createELFFile() from .h to .cpp.Rui Ueyama2015-10-121-35/+1
| | | | llvm-svn: 250051
* Fix indentation.Rui Ueyama2015-10-121-14/+14
| | | | llvm-svn: 250047
* Make getStaticELFKind a member function now that we can.Rafael Espindola2015-10-121-12/+12
| | | | llvm-svn: 250031
* This doesn't need to be virtual anymore.Rafael Espindola2015-10-121-1/+0
| | | | llvm-svn: 250028
* Simplify the InputFile type hierarchy by removing unnecessary middle classses.Rafael Espindola2015-10-121-51/+21
| | | | llvm-svn: 250006
* Simplify the InputFile type hierarchy.Rafael Espindola2015-10-121-68/+68
| | | | | | | Now that the SymbolTable is templated, we don't need the ELFData class or multiple inheritance. llvm-svn: 250005
* ELF2: Implement --as-needed.Rui Ueyama2015-10-111-1/+6
| | | | | | | | | | | | | | This patch adds AsNeeded and IsUsed bool fields to SharedFile. AsNeeded bit is set if the DSO is enclosed with --as-needed and --no-as-needed. IsUsed bit is off by default. When we adds a symbol to the symbol table for dynamic linking, we set its SharedFile's IsUsed bit. If AsNeeded is set but IsUsed is not set, we don't want to write that file's SO name to DT_NEEDED field. http://reviews.llvm.org/D13579 llvm-svn: 249998
* Handle a crash in conflict detection with archive members.Rafael Espindola2015-10-111-0/+3
| | | | llvm-svn: 249996
* Detect incompatible files when one of them comes from an archive.Rafael Espindola2015-10-111-7/+17
| | | | llvm-svn: 249968
* Add support for comdats.Rafael Espindola2015-10-091-6/+10
| | | | | | The implementation is a direct translation to c++ of the rules in the ELF spec. llvm-svn: 249881
* ELF2: Use the same name as COFF.Rui Ueyama2015-10-071-1/+1
| | | | llvm-svn: 249635
* [ELF2] Handle -m optionDenis Protivensky2015-10-071-3/+1
| | | | | | | | | Parse and apply emulation given with -m option. Check input files to match ELF type and machine architecture provided with -m. Differential Revision: http://reviews.llvm.org/D13055 llvm-svn: 249529
* Don't include shared libraries multiple times.Rafael Espindola2015-10-011-0/+3
| | | | llvm-svn: 249061
* [ELF2] Add --[no-]whole-archive command line switchesIgor Kudrin2015-10-011-0/+1
| | | | | | | | | | | | | | | | | Summary: If --whole-archive is used, all symbols from the following archives are added to the output. --no-whole-archive restores default behavior. These switches can be used multiple times. NB. We have to keep an ArchiveFile instance within SymbolTable even if --whole-archive mode is active since it can be a thin archive which contains just names of external files. In that case actual memory buffers for the archive members will be stored within the File member of ArchiveFile class. Reviewers: rafael, ruiu Subscribers: grimar, llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D13286 llvm-svn: 249045
* Copy DT_SONAME to DT_NEEDED.Rafael Espindola2015-10-011-0/+4
| | | | | | | | | If a shared library has a DT_SONAME entry, that is what should be included in the DT_NEEDED of a program using it. We don't implement -soname yet, so check in a .so for now. llvm-svn: 249025
* ELF2: Define Driver::addFile() as a one-stop place to open a file.Rui Ueyama2015-10-011-2/+0
| | | | | | | | | | | | | | Opening a file and dispatching to readLinkerScript() or createFile() is a common operation. We want to use that at least from Driver and from LinkerScript. In COFF, we had the same problem. This patch resolves the problem in the same way as we did for COFF. Now, if you have a path that you want to open, just call Driver->addFile(StringRef). That function opens the file and handles that as if that were given by command line. This function is the only place we call identify_magic(). llvm-svn: 249023
* ELF2: Add basic linker script support.Rui Ueyama2015-09-301-0/+3
| | | | | | | | | | | | | | | | This linker script parser and evaluator is powerful enough to read Linux's libc.so, which is (despite its name) a linker script that contains OUTPUT_FORMAT, GROUP and AS_NEEDED directives. The parser implemented in this patch is a recursive-descendent one. It does *not* construct an AST but consumes directives in place and sets the results to Symtab object, like what Driver is doing. This should be very fast since less objects are allocated, and this is also more readable. http://reviews.llvm.org/D13232 llvm-svn: 248918
* Remove `explicit` from constructors that take more than one parameter.Rui Ueyama2015-09-301-4/+4
| | | | llvm-svn: 248873
* ELF2: Include file names in error messages.Rui Ueyama2015-09-281-2/+2
| | | | llvm-svn: 248724
* [ELF2] Fix binaries so they actually run on FreeBSD.Davide Italiano2015-09-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Since FreeBSD 4.1, the kernel expects binaries to be marked with ELFOSABI_FREEBSD in the ELF header to exec() them. LLD unconditionally sets OSABI to ELF_OSABINONE, and everything linked with it won't run on FreeBSD (unless explicitly rebranded). Example: % ./aarch64-hello ELF binary type "0" not known. zsh: exec format error: ./aarch64-hello FreeBSD could be modified to accept ELF_OSABINONE, but that would break all existing binaries, so the kernel needs to support both ABINONE and ABIFREEBSD. I plan to push this change in FreeBSD one day, which, unfortunately, is not today. This code patches lld so it sets the header field correctly. For completeness, the rationale of this change is explained in the FreeBSD commit message, and it's apparently to pleasee binutils maintainers at the time. https://svnweb.freebsd.org/base?view=revision&revision=59342 Differential Revision: http://reviews.llvm.org/D13140 llvm-svn: 248554
* Simplify memory management by having ELFData contain a ELFObj.Rafael Espindola2015-09-241-9/+7
| | | | llvm-svn: 248502
* Expose ELFFileBase::getEMachine. NFC.Rafael Espindola2015-09-221-0/+4
| | | | | | I will use it in a followup patch. llvm-svn: 248287
* Remove the Chunk terminology from ELF.Rafael Espindola2015-09-221-4/+4
| | | | llvm-svn: 248229
* Rename Chunks.(h|cpp) to InputSection.(h|cpp). NFC.Rafael Espindola2015-09-221-1/+1
| | | | llvm-svn: 248226
* Rename SectionChunk to InputSection.Rafael Espindola2015-09-211-2/+2
| | | | | | | | This is more consistent with OutputSection. This is also part of removing the "Chunk" term from the ELF linker, since we just have input/output sections and program headers. llvm-svn: 248183
* [ELF2] Constify member functions.Davide Italiano2015-09-181-3/+3
| | | | llvm-svn: 248019
* Start adding support for creating the GOT.Rafael Espindola2015-09-181-1/+1
| | | | | | | | With this a program can call into a shared library with jmp *foo@GOTPCREL(%rip) llvm-svn: 247992
* [ELF2] Fill up local symbols fields correctly.Davide Italiano2015-09-181-0/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D12944 llvm-svn: 247960
* [ELF2] Initial support for local symbols.Davide Italiano2015-09-161-0/+5
| | | | | | | | | | Symbol table is now populated correctly, but some fields are missing, they'll be added in the future. This patch also adds --discard-all flag, which was the default behavior until now. Differential Revision: http://reviews.llvm.org/D12874 llvm-svn: 247849
* Start creating dynamic relocations.Rafael Espindola2015-09-161-1/+1
| | | | | | For now we don't create got/plt and only Elf_Rela is supported. llvm-svn: 247811
* Start adding support for symbols in shared libraries.Rafael Espindola2015-09-081-2/+17
| | | | llvm-svn: 247019
* [elf2] Add basic archive file support.Michael J. Spencer2015-09-041-1/+50
| | | | llvm-svn: 246886
* Start adding support for shared libraries.Rafael Espindola2015-09-031-28/+68
| | | | | | | This just adds the types and enough support to detect incompatibilities among shared libraries and object files. llvm-svn: 246797
OpenPOWER on IntegriCloud