summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Detemplate SymbolTable.Rafael Espindola2017-07-261-17/+17
| | | | | | NFC, just makes it easier to access from non templated code. llvm-svn: 309152
* Make a function static. NFC.Rafael Espindola2017-07-241-1/+1
| | | | llvm-svn: 308939
* If user requested section alignment is greater than MaxPageSize, propagate ↵Dmitry Mikulin2017-07-241-1/+1
| | | | | | | | it to segment headers correctly. Differential Revision: https://reviews.llvm.org/D35813 llvm-svn: 308930
* Handle a section being more aligned than a page size.Rafael Espindola2017-07-221-1/+2
| | | | llvm-svn: 308812
* Fix a crash.Rafael Espindola2017-07-181-1/+1
| | | | | | | | | This is PR33821. What we really want to check in here is if the output section was created, not if the command was empty. llvm-svn: 308382
* [ELF] - Apply clang-format. NFC.George Rimar2017-07-181-2/+2
| | | | llvm-svn: 308297
* Refactor gdb index creation.Rafael Espindola2017-07-121-1/+1
| | | | | | | | | | | | | | I have a patch to let DwarfContext defer to lld for getting section contents and relocations. That is a pretty big performance improvement. This is just a refactoring to make that easier to do. This change makes the *creation* of gdb index a dedicated step and makes that templated. That is so that we can uses Elf_Rel in the code. llvm-svn: 307867
* [ELF] Add call to assignAddresses() before createThunks() [NFC]Peter Smith2017-07-071-0/+1
| | | | | | | | | | In preparation for the addition of rangeThunks() calculate the addresses of all the inputSections so that ThunkSections can be inserted at the right place. Differential Revision: https://reviews.llvm.org/D34688 llvm-svn: 307373
* Remove redundant argument. NFC.Rafael Espindola2017-07-061-1/+1
| | | | llvm-svn: 307279
* Move fabricateDefaultCommands earlier.Rafael Espindola2017-07-051-25/+17
| | | | | | | It is now just after the OutputSections are created, which is as early as it can possibly go. llvm-svn: 307225
* Remove dummy cast.Rafael Espindola2017-07-051-3/+2
| | | | llvm-svn: 307220
* Use Entry::SecSize in a couple of cases.Rafael Espindola2017-07-051-6/+0
| | | | | | | This avoids having to compute relocation section sizes early, removing the last use of assignOffsets. llvm-svn: 307219
* Remove a function that is now trivial.Rafael Espindola2017-07-051-2/+2
| | | | llvm-svn: 307214
* Remove two dummy casts. NFC.Rafael Espindola2017-07-051-2/+2
| | | | llvm-svn: 307209
* Merge createOrphanCommands into addOrphanSections.Rafael Espindola2017-07-051-1/+0
| | | | | | This is a bit simpler and avoids a walk over OutputSections. llvm-svn: 307178
* [ELF] Extract allocateHeaders() from assignAddresses()Peter Smith2017-07-051-1/+2
| | | | | | | | | | | | | | | The allocateHeaders() function is called at the end of assignAddresses(), it decides whether the ELF header and program header table can be allocated to a PT_LOAD program header. As the function alters state, it prevents assignAddresses() from being called multiple times. This change splits out the call to allocateHeaders() from assignAddresses() this will permit assignAddresses() to be called while processing range extension thunks without trying to allocateHeaders(). Differential Revision: https://reviews.llvm.org/D34344 llvm-svn: 307131
* Move clearOutputSections earlier. NFC.Rafael Espindola2017-07-041-6/+3
| | | | | | | | | | This is finally getting to the point where output sections are constructed. createOrphanCommands and fabricateDefaultCommands are moved out so they can be merged with existing code in followup commits. llvm-svn: 307107
* Move clearOutputSections earlier. NFC.Rafael Espindola2017-07-041-6/+13
| | | | | | Now addSectionSymbols operates on the linker script. llvm-svn: 307102
* Move clearOutputSections earlier. NFC.Rafael Espindola2017-07-041-8/+11
| | | | | | Now all of finalizeSections works on the linker script. llvm-svn: 307101
* Move clearOutputSections earlier. NFC.Rafael Espindola2017-07-041-16/+14
| | | | | | Now addPredefinedSections operates only on the linker script. llvm-svn: 307100
* [ELF] - Use llvm::find_if instead std::find_if where possible. NFC.George Rimar2017-07-041-5/+3
| | | | | | Two more places. llvm-svn: 307076
* fix msvc buildRafael Espindola2017-07-031-8/+9
| | | | llvm-svn: 307044
* Move clearOutputSections earlier.Rafael Espindola2017-07-031-7/+19
| | | | | | | Now removeUnusedSyntheticSections operates entirely on the linker script. llvm-svn: 307043
* [ELF] Remove unused synthetic sections from script commandsPetr Hosek2017-07-031-1/+10
| | | | | | | | | | | | | | Script commands are processed before unused synthetic sections are removed. Therefore, if a linker script matches one of these sections it'll get emitted as an empty output section because the logic for removing unused synthetic sections ignores script commands which could have already matched and captured one of these sections. This patch fixes that by also removing the unused synthetic sections from the script commands. Differential Revision: https://reviews.llvm.org/D34800 llvm-svn: 307037
* Fix indentation.Rafael Espindola2017-06-281-1/+1
| | | | llvm-svn: 306609
* [ELF] - Do not crash when LLD synthesizes output sections with BYTE commands ↵George Rimar2017-06-281-4/+4
| | | | | | | | | | | | | | | | | and -r This is PR33596. Previously LLD would crash because BYTE command synthesized output section, but it was not assigned to Sec member of OutputSectionCommand. Behaviour of -script and -r combination is not well defined, but it seems after this change LLD naturally inherits behavior of GNU linkers - creates output section requested in script and does not crash anymore. Differential revision: https://reviews.llvm.org/D34676 llvm-svn: 306527
* [ELF] Consolidate .ARM.extab.* sections into .ARM.extabPeter Smith2017-06-281-1/+1
| | | | | | | | | | | | | | | | | | | When -ffunction-sections and ARM C++ exceptions are used each .text.suffix section will have at least one .ARM.exidx.suffix section and may have an additional .ARM.extab.suffix section if the unwinding instructions are too large to inline into the .ARM.exidx table entry. For a large program without a linker script this can lead to a large number of section header table entries that can increase the size of the ELF file. This change introduces a default rule for .ARM.extab.* to be placed in a single output section called .ARM.extab . This follows the behavior of ld.gold and ld.bfd. fixes pr33407 Differential Revision: https://reviews.llvm.org/D34678 llvm-svn: 306522
* Add GlobalOffsetTable to ElfSym. NFC.Rui Ueyama2017-06-261-8/+7
| | | | | | | | Most "reserved" symbols are in ElfSym and it looks like there's no reason to not do the same thing for _GLOBAL_OFFSET_TABLE_. This should help https://reviews.llvm.org/D34618 too. llvm-svn: 306292
* [ELF] Define _GLOBAL_OFFSET_TABLE_ symbol relative to .gotPeter Smith2017-06-261-15/+14
| | | | | | | | | | | | | | | | | | On many architectures gcc and clang will recognize _GLOBAL_OFFSET_TABLE_ - . and produce a relocation that can be processed without needing to know the value of _GLOBAL_OFFSET_TABLE_. This is not always the case; for example ARM gcc produces R_ARM_BASE_PREL but clang produces the more general R_ARM_REL32 to _GLOBAL_OFFSET_TABLE_. To evaluate this relocation correctly _GLOBAL_OFFSET_TABLE_ must be defined to be the either the base of the GOT or end of the GOT dependent on architecture.. If/when llvm-mc is changed to recognize _GLOBAL_OFFSET_TABLE_ - . this change will not be necessary for new objects. However there may still be old objects and versions of clang. Differential Revision: https://reviews.llvm.org/D34355 llvm-svn: 306282
* Prefer -Ttext over linker script values.Rafael Espindola2017-06-201-0/+7
| | | | | | | | | | | | | | | | | | | | I found this while trying to build u-boot. It uses -Ttext in combination with linker scripts. My first reaction was to change the linker scripts to have the correct value, but I found that it is actually quite convenient to have -Ttext take precedence. By having just .text : { *(.text) } In the script, they can define the text address in a single Makefile and pass it to ld with -Ttext and for the C code with -DFoo=value. Doing the same with linker scripts would require them to be generated during the build. llvm-svn: 305766
* [ELF] Enable createThunks to be called more than once.Peter Smith2017-06-161-1/+4
| | | | | | | | | | | | In preparation for supporting range extension thunks we now continually call createThunks() until no more thunks are added. This requires us to record the thunks we add on each pass and only merge the new ones into the OutputSection. We also need to check if a Relocation is targeting a thunk to prevent us from infinitely creating more thunks. Differential Revision: https://reviews.llvm.org/D34034 llvm-svn: 305555
* Try to fix MSVC build.Rafael Espindola2017-06-151-3/+3
| | | | llvm-svn: 305514
* Move clearOutputSections before sortSections.Rafael Espindola2017-06-151-46/+122
| | | | | | | | | | | | | | | | | | This is probably the main patch left in unifying our intermediary representation. It moves the creation of default commands before section sorting. This has the nice effect that we now have one location where we decide where an orphan section should be placed. Before this patch sortSections would decide the relative location of orphan sections to other sections, but it was up to placeOrphanSection to decide on the exact location. We now only sort sections we created since the linker script is already in the correct order. llvm-svn: 305512
* Make OutputSections and OutputSectionCommands globals.Rafael Espindola2017-06-131-7/+2
| | | | | | | This is similar to what we do for InputSections and makes them easier to access. llvm-svn: 305337
* Move clearOutputSections earlier. NFC.Rafael Espindola2017-06-131-8/+8
| | | | llvm-svn: 305333
* ELF: Move section merging before ICF. NFCI.Peter Collingbourne2017-06-121-44/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D34093 llvm-svn: 305176
* Move clearOutputSections before createPhdrs. NFC.Rafael Espindola2017-06-101-14/+23
| | | | llvm-svn: 305156
* Move fabricateDefaultCommands earlier.Rafael Espindola2017-06-081-5/+6
| | | | | | This then requires delaying a call to getHeaderSize. llvm-svn: 304961
* Use OutputSectionCommands in assignOffsets.Rafael Espindola2017-06-071-6/+6
| | | | | | This allows moving clearOutputSections earlier. llvm-svn: 304952
* Delete dead code.Rafael Espindola2017-06-071-3/+0
| | | | | | | The real offsets are computed in assignAddresses and we compute the special cases we need earlier after this. llvm-svn: 304950
* Move clearOutputSections earlier. NFC.Rafael Espindola2017-06-071-2/+1
| | | | llvm-svn: 304948
* Convert an use of OutputSections to OutputSectionCommands.Rafael Espindola2017-06-071-3/+3
| | | | | | This allows moving clearOutputSections a bit earlier. llvm-svn: 304947
* [ELF] Convert Thunks to use InputSectionDescriptionsPeter Smith2017-06-071-7/+6
| | | | | | | | | | | | | | | | Thunks are now generated per InputSectionDescription instead of per OutputSection. This allows created ThunkSections to be inserted directly into InputSectionDescription. Changes in this patch: - Loop over InputSectionDescriptions to find relocations to Thunks - Generate a ThunkSection per InputSectionDescription - Remove synchronize() as we no longer need it - Move fabricateDefaultCommands() before createThunks Differential Revision: https://reviews.llvm.org/D33835 llvm-svn: 304887
* [ELF] - Do not merge relocation sections by name when using --emit-relocs.George Rimar2017-06-071-12/+0
| | | | | | | | | | | | Previously we would merge relocation sections by name. That did not work in some cases, like testcase shows. Patch implements logic to merge relocation sections if their target sections were merged into the same output section. Differential revision: https://reviews.llvm.org/D33824 llvm-svn: 304886
* Move clearOutputSections earlier. NFC.Rafael Espindola2017-06-071-5/+8
| | | | | | This now just requires not calling assignOffsets after it. llvm-svn: 304861
* Use assignAddresses with -r.Rafael Espindola2017-06-071-13/+15
| | | | | | | | Before this patch in -r we compute the OutputSection sizes early in the various calls to assignOffsets. With this change we can remove most of those calls. llvm-svn: 304860
* Move finalize to OutputSectionCommands. NFC.Rafael Espindola2017-06-061-1/+1
| | | | | | | This removes a mapping from OutputSection to OutputSectionCommand and is another step in moving clearOutputSections earlier. llvm-svn: 304821
* Convert a use of OutputSections. NFC.Rafael Espindola2017-06-061-2/+2
| | | | llvm-svn: 304820
* Define __executable_start.Rafael Espindola2017-06-061-6/+8
| | | | | | This is defined by both bfd and gold and used by the android libc. llvm-svn: 304803
* Move clearOutputSections earlier.Rafael Espindola2017-06-051-7/+6
| | | | | | | This moves clearOutputSections and OutputSectionCommands creation as early as possible without changing other code. llvm-svn: 304751
OpenPOWER on IntegriCloud