summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* ELF2: Create a function to get VA from Elf_Rel.Rui Ueyama2015-10-121-10/+20
| | | | | | And remove git getLocalSymVA because there's no user of the function anymore. llvm-svn: 250095
* Instead of computing offset from current and start, use a variable. NFC.Rui Ueyama2015-10-121-4/+4
| | | | llvm-svn: 250080
* ELF2: Implement --as-needed.Rui Ueyama2015-10-111-2/+7
| | | | | | | | | | | | | | 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
* ELF2: Make SymbolTable a template class.Rui Ueyama2015-10-091-12/+11
| | | | | | | | | | | | | | | | | | | | | | | SymbolTable was not a template class. Instead we had switch-case-based type dispatch to call desired functions. We had to do that because SymbolTable was created before we know what ELF type objects had been passed. Every time I tried to add a new function to the symbol table, I had to define a dispatcher which consist of a single switch statement. It also brought an restriction what the driver can do. For example, we cannot add undefined symbols before any files are added to the symbol table. That's because no symbols can be added until the symbol table knows the ELF type, but when it knows about that, it's too late. In this patch, the driver makes a decision on what ELF type objects are being handled. Then the driver creates a SymbolTable object for an appropriate ELF type. http://reviews.llvm.org/D13544 llvm-svn: 249902
* Simplify. NFC.Rui Ueyama2015-10-091-9/+6
| | | | llvm-svn: 249895
* ELF2: Reduce code repetition.Rui Ueyama2015-10-091-45/+0
| | | | llvm-svn: 249882
* Add support for comdats.Rafael Espindola2015-10-091-6/+32
| | | | | | The implementation is a direct translation to c++ of the rules in the ELF spec. llvm-svn: 249881
* Don't silently ignore an error.Rafael Espindola2015-10-091-3/+5
| | | | | | Found by inspection. llvm-svn: 249843
* Revert "[ELF2] - Implemented rel[a].plt sections"Rafael Espindola2015-10-091-20/+4
| | | | | | | | | | | | | | | | This reverts commit r249816. It broke building llvm with lld: $ ./bin/FileCheck ./bin/FileCheck: error while loading shared libraries: unexpected PLT reloc type 0x06 I think the only thing that is wrong with this patch is that it is too soon. The plt we create (and its relocs) don't support lazy loading, so they have to be relocated as ordinary dynamic relocations. llvm-svn: 249835
* [ELF2] - Implemented rel[a].plt sectionsGeorge Rimar2015-10-091-4/+20
| | | | | | | | .rela.plt contains list of elements in the PLT, which are liable to the relocation during the dynamic linking. Differential Revision: http://reviews.llvm.org/D13569 llvm-svn: 249816
* Simplify expressions. NFC.Rui Ueyama2015-10-091-5/+4
| | | | llvm-svn: 249793
* Remove getters/setters that don't provide much abstraction.Rui Ueyama2015-10-091-4/+4
| | | | llvm-svn: 249791
* [ELF2] Make the .plt entry size target dependentHal Finkel2015-10-081-2/+7
| | | | | | | | | The size of a .plt entry is different on different targets (it is, specifically, much larger than 8 on all PPC ABIs). There is no functional change here (later patches to create .plt entries for PPC64 will depend on this change). llvm-svn: 249756
* [ELF2] Use EntrySize, not 8, to advance the .plt buffer when writingHal Finkel2015-10-081-1/+1
| | | | | | | In preparation for making the size of a .plt entry target dependent, use the existing EntrySize variable when writing (instead of a hard-coded value). NFC. llvm-svn: 249720
* ELF2: Make singleton output sections globally accessible.Rui Ueyama2015-10-071-73/+97
| | | | | | | | | | | | | | | Previously, output sections that are handled specially by the linker (e.g. PLT or GOT) were created by Writer and passed to other classes that need them. The problem was that because these special sections are required by so many classes, the plumbing work became too much burden. This patch is to simply make them accessible from anywhere in the linker to eliminate the plumbing work once and for all. http://reviews.llvm.org/D13486 llvm-svn: 249590
* ELF2: Rename local variable name `Out` in preparation to define `Out` global ↵Rui Ueyama2015-10-071-13/+13
| | | | | | var. llvm-svn: 249568
* ELF2: Move functions out of line.Rui Ueyama2015-10-071-0/+44
| | | | llvm-svn: 249566
* [ELF2] -z now option implementedGeorge Rimar2015-10-071-0/+5
| | | | | | | | When generating an executable or shared library, mark it to tell the dynamic linker to resolve all symbols when the program is started, or when the shared library is linked to using dlopen, instead of deferring function call resolution to the point when the function is first called. Differential Revision: http://reviews.llvm.org/D13468 llvm-svn: 249551
* [ELF2] Fix gcc build errorDenis Protivensky2015-10-071-0/+1
| | | | llvm-svn: 249524
* Don't create dynamic relocations for weak undefined symbols.Rafael Espindola2015-10-071-1/+3
| | | | llvm-svn: 249520
* Skip entries handled by the dynamic linker.Rafael Espindola2015-10-071-2/+3
| | | | | | | We were writing got entries in the first positions, not in the positions corresponding to locally defined symbols. llvm-svn: 249518
* Create simpler dynamic relocations for local symbols in got.Rafael Espindola2015-10-071-26/+24
| | | | | | If the symbol is not preemptable, we can use a R_X86_64_RELATIVE. llvm-svn: 249496
* Fix typo.Rafael Espindola2015-10-071-5/+5
| | | | llvm-svn: 249488
* Don't create dynamic relocations when its known what the got points to.Rafael Espindola2015-10-061-2/+24
| | | | llvm-svn: 249485
* [ELF2] Implement --{enable, disable}-new-dtags options.Davide Italiano2015-10-061-2/+12
| | | | llvm-svn: 249428
* Handle strong undefined symbols fetching members after a weak undefined.Rafael Espindola2015-10-061-32/+35
| | | | | | | | | | This is a case that requires --start-group --end-group with regular ELF linkers. Fortunately it is still possible to handle it with lazy symbols without taking a second look at archives. Thanks to Michael Spencer for the bug report. llvm-svn: 249406
* Rearrange a bit for clarity. NFC.Rafael Espindola2015-10-061-7/+4
| | | | llvm-svn: 249404
* External symbols need a full dynamic reloc, not R_X86_64_RELATIVE.Rafael Espindola2015-10-061-1/+7
| | | | | | | We were already doing the right thing if the symbol was seen in a shared library, but not if it was completely missing. llvm-svn: 249397
* Fix R_X86_64_RELATIVE for local symbols that refer to other sections.Rafael Espindola2015-10-051-2/+6
| | | | | | We were mixing up the relocated and target sections. llvm-svn: 249360
* Handle a common symbol needing a R_X86_64_RELATIVE.Rafael Espindola2015-10-051-3/+5
| | | | llvm-svn: 249357
* Include existing addend when computing R_X86_64_RELATIVE.Rafael Espindola2015-10-051-5/+11
| | | | llvm-svn: 249353
* Create R_X86_64_RELATIVE when needed.Rafael Espindola2015-10-051-5/+12
| | | | | | | The dynamic relocation code needs refactoring, but it is probably better to do it with this test passing. llvm-svn: 249340
* Don't copy STT_SECTION from the inputs.Rafael Espindola2015-10-051-2/+16
| | | | | | This matches the behavior of gold and bfd ld. llvm-svn: 249326
* Remove an extra blank line.Igor Kudrin2015-10-051-1/+0
| | | | llvm-svn: 249324
* Include hidden and internal symbols in the regular symbol table.Rafael Espindola2015-10-051-7/+31
| | | | | | | This matches the behavior of bfd ld and gold. It is also convenient for testing other changes. llvm-svn: 249323
* [ELF2] Add DT_INIT and DT_FINI dynamic table entriesIgor Kudrin2015-10-051-2/+18
| | | | | | | | | | | | | | The entries are added if there are "_init" or "_fini" entries in the symbol table respectively. According to the behavior of ld, entries are inserted even for undefined symbols. Symbol names can be overridden by using -init and -fini command line switches. If used, these switches neither add new symbol table entries nor require those symbols to be resolved. Differential Revision: http://reviews.llvm.org/D13385 llvm-svn: 249297
* Add static initialization/finalization array support.Rafael Espindola2015-10-021-0/+18
| | | | | | | This adds entries in the dynamic table for .init_array, .fini_array and .preinit_array. llvm-svn: 249175
* [ELF2] Fix mixed-Endian handling in DynamicSection<ELFT>::writeToHal Finkel2015-10-021-2/+0
| | | | | | | | | | | | | | Using the "raw" Elf64_Dyn or Elf32_Dyn structures in DynamicSection<ELFT>::writeTo does not correctly handle mixed-Endian situations. Instead, use the corresponding llvm::object::* structures which have Endian-converting members (like the rest of the code). This fixes all currently-failing elf2 tests when running on big-Endian PPC64/Linux (I've added a big-Endian test case which should fail on little-Endian machines in the same way that test/elf2/shared.s failed on big-Endian machines prior to this change). llvm-svn: 249150
* ELF2: Merge duplicates using lambdas. NFC.Rui Ueyama2015-10-021-46/+26
| | | | llvm-svn: 249118
* [lld][elf2] Sort output sections.Michael J. Spencer2015-10-011-0/+3
| | | | | | | | | | | | | | | Sort by: ALLOC ALLOC && NOBITS ALLOC & EXEC ALLOC & EXEC && NOBITS ALLOC & WRITE ALLOC & WRITE && NOBITS <nothing> (ignoring NOBITS) The dynamic section is finalized early because it adds strings to the dynamic string table, which comes before the dynamic table. llvm-svn: 249071
* ELF2: Add -soname option.Rui Ueyama2015-10-011-6/+15
| | | | llvm-svn: 249058
* Copy DT_SONAME to DT_NEEDED.Rafael Espindola2015-10-011-2/+2
| | | | | | | | | 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: Add DT_REL{,A}ENT and DT_SYMENT.Rui Ueyama2015-09-301-1/+11
| | | | | | | | According to the ELF specification, these dynamic array entries are mandatory. http://reviews.llvm.org/D13303 llvm-svn: 248952
* ELF2: Advance the buffer pointers right after we use them.Rui Ueyama2015-09-301-4/+3
| | | | | | So that it is clear that we are incrementing the pointers for sure. NFC. llvm-svn: 248868
* Make template instantiation code a bit shorter. NFC.Rui Ueyama2015-09-301-12/+8
| | | | llvm-svn: 248866
* ELF2: Split SymbolTableSection<ELFT>::writeTo into two smaller functions.Rui Ueyama2015-09-301-30/+42
| | | | | | Also added brief comments. llvm-svn: 248864
* Start adding support for static programs using dynamic libraries.Rafael Espindola2015-09-291-1/+1
| | | | | | This is just enough for a hello world using a dynamic glibc. llvm-svn: 248854
* This reverts commit r248845 and r248848.Rafael Espindola2015-09-291-3/+0
| | | | | | | | | They broke elf2/basic-mips.s. Revert "[elf2] Sort output sections." Revert "[elf2] Fix build." llvm-svn: 248851
* [elf2] Fix build.Michael J. Spencer2015-09-291-1/+1
| | | | llvm-svn: 248848
* [elf2] Sort output sections.Michael J. Spencer2015-09-291-0/+3
| | | | | | | | | | | | | | | Sort by: ALLOC ALLOC && NOBITS ALLOC & EXEC ALLOC & EXEC && NOBITS ALLOC & WRITE ALLOC & WRITE && NOBITS <nothing> (ignoring NOBITS) The dynamic section is finalized early because it adds strings to the dynamic string table, which comes before the dynamic table. llvm-svn: 248845
OpenPOWER on IntegriCloud