summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SyntheticSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify. NFC.Rafael Espindola2017-05-311-2/+1
| | | | llvm-svn: 304328
* Fix a crash.Rafael Espindola2017-05-311-1/+1
| | | | | | | | We would crash if a SHF_LINK_ORDER section pointed to a non InputSection section. Since those sections are not merged in order, SHF_LINK_ORDER is pretty meaningless and we can error on that case. llvm-svn: 304327
* [ELF] .ARM.exidx sentinel section should use InputSectionDescriptions.Peter Smith2017-05-311-6/+16
| | | | | | | | | | This change converts the writing of the .ARM.exidx sentinel section to use the InputSectionDescriptions instead of OutputSection::Sections this is in preparation for the retirement of OutputSection::Sections. Differential Revision: https://reviews.llvm.org/D33500 llvm-svn: 304289
* Fix crash when processing relocations in .eh_frame.Rafael Espindola2017-05-311-1/+1
| | | | | | | | | | | This happens when attempting to link shared libraries using exceptions on MIPS. It requires -z notext because clang generates R_MIPS_64 relocations inside .eh_frame. The crash happened because for EhInputSection the OutSec member is null. Patch by Alexander Richardson! llvm-svn: 304260
* [lld][ELF]Add option to make .dynamic read onlyPetr Hosek2017-05-261-3/+12
| | | | | | | | | | | | | | The .dynamic section of an ELF almost doesn't need to be written to with the exception of the DT_DEBUG entry. For several reasons having a read only .dynamic section would be useful. This change adds the -z keyword "rodynamic" which forces .dynamic to be read-only. In this case DT_DEBUG will not be emited. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D33251 llvm-svn: 304024
* [ELF] - Attemp to fix botGeorge Rimar2017-05-261-1/+1
| | | | | | http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/8549/steps/build_Lld/logs/stdio llvm-svn: 304016
* [ELF] - Follow up for r303975. NFCi.George Rimar2017-05-261-1/+1
| | | | | | | Restore bitwise-or order and fix warning (was changed by mistake during resolve of conflicts). llvm-svn: 303976
* [ELF] - Do not produce duplicate values in .gdb_index's constant pool area.George Rimar2017-05-261-4/+3
| | | | | | | | | | | | | | | | | | | | | | I found this when builded llc binary using gcc 5.4.1 + LLD. gcc produces duplicate entries in .debug_gnu_pubtypes section, ex: UnifyFunctionExitNodes.cpp.o has: 0x0000ac07 EXTERNAL TYPE "std::success_type<void*>" 0x0000ac07 EXTERNAL TYPE "std::success_type<void*>" clang produces single entry here: 0x0000d291 EXTERNAL TYPE "std::__success_type<void *>" If we link output from gcc with LLD, that would produce excessive duplicate entries in .gdb_index constant pool area. That does not seem affect gdb work, but makes .gdb_index larger than it can be. I also checked that gold filters out such duplicates too. Patch fixes it. Differential revision: https://reviews.llvm.org/D32647 llvm-svn: 303975
* [ELF] - Simplify implementation of constant pool when building .gdb_indexGeorge Rimar2017-05-261-10/+7
| | | | | | | | | | | | | | | https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html says: "A CU vector in the constant pool is a sequence of offset_type values. The first value is the number of CU indices in the vector. Each subsequent value is the index and symbol attributes of a CU in the CU list." Previously we keeped 2 values until the end, what was useless. Initially was a part of D32647, though it is possible to split out. Patch do that. Differential revision: https://reviews.llvm.org/D33551 llvm-svn: 303973
* Remove dummy cast. NFC.Rafael Espindola2017-05-261-1/+1
| | | | llvm-svn: 303948
* Simplify MipsRldMapSection::writeTo.Rafael Espindola2017-05-241-10/+0
| | | | | | | | | It is not clear why a synthetic section wants to use padding defined in the linker script. The padding is for the space between sections. It was also missing a test. llvm-svn: 303812
* Move writeTo to OutputSectionCommand.Rafael Espindola2017-05-241-3/+2
| | | | | | | | | | | | This reduces how many times we have to map from OutputSection to OutputSectionCommand. It is a required step to moving clearOutputSections earlier. In order to always use writeTo in OutputSectionCommand we have to call fabricateDefaultCommands for -r links and move section compression after it. llvm-svn: 303784
* Alternative way to detemplate GotSection.Rafael Espindola2017-05-181-20/+11
| | | | | | | | | | | | | | | | | | | | GetSection is a template because write calls relocate. relocate has two parts. The non alloc code really has to be a template, as it is looking a raw input file data. The alloc part is only a template because of getSize. This patch folds the value of getSize early, detemplates getRelocTargetVA and splits relocate into a templated non alloc case and a regular function for the alloc case. This has the nice advantage of making sure we collect all the information we need for relocations before getting to InputSection::relocateNonAlloc. Since we know got is alloc, it can just call the function directly and avoid the template. llvm-svn: 303355
* [ELF] - Update for LLVM's r303163 change. NFCi.George Rimar2017-05-161-4/+4
| | | | llvm-svn: 303164
* [ELF] - Detemplate elf::addSyntheticLocal(). NFC.George Rimar2017-05-161-14/+0
| | | | llvm-svn: 303155
* [ELF] - Detemplate access to SymTab, DynSymTab, GnuHashTab. NFC.George Rimar2017-05-161-17/+17
| | | | | | Follow up for r303150. llvm-svn: 303153
* [ELF] - Detemplate GnuHashTableSection and SymbolTableSection sections.George Rimar2017-05-161-30/+25
| | | | | | | | | | SymbolTableBaseSection was introduced. Detemplation of SymbolTableSection should allow to detemplate more things. Differential revision: https://reviews.llvm.org/D33124 llvm-svn: 303150
* ELF: --gdb-index: Change findSection to return an InputSection.Peter Collingbourne2017-05-151-7/+8
| | | | | | | | | | | | | | | | | | | | We should only ever expect this function to return a regular InputSection; I would not expect a function definition to be in a MergeInputSection or EhInputSection. We were previously crashing in writeTo if this function returned a section that was not an InputSection because we do not set OutSec for such sections. This can happen in practice if a function is defined in an empty section which shares its offset-in-file with a MergeInputSection, as in the provided test case. A better fix for this bug would be to fix the DWARFUnit::collectAddressRanges() interface to provide section information (see D33183), but this at least fixes the crash. Differential Revision: https://reviews.llvm.org/D33176 llvm-svn: 303089
* ELF: --gdb-index: Do not add dead sections to the address area.Peter Collingbourne2017-05-151-1/+1
| | | | | | | | Fixes PR33032. Differential Revision: https://reviews.llvm.org/D33175 llvm-svn: 303088
* [ELF] - Stop support of DF_STATIC_TLS flag.George Rimar2017-05-121-11/+9
| | | | | | | | This reverts changes introduced in r302414 "[ELF] - Set DF_STATIC_TLS flag for i386 target." Because DF_STATIC_TLS does not look to be used by glibc or anything else. llvm-svn: 302884
* Detemplate the got.Rafael Espindola2017-05-111-11/+9
| | | | | | This is a bit hackish, but allows for a lot of followup cleanups. llvm-svn: 302845
* Reduce templating. NFC.Rafael Espindola2017-05-111-0/+1
| | | | llvm-svn: 302843
* Reduce template usage. NFC.Rafael Espindola2017-05-111-16/+16
| | | | llvm-svn: 302832
* Reduce template usage. NFC.Rafael Espindola2017-05-111-7/+7
| | | | llvm-svn: 302828
* Reduce template usage. NFC.Rafael Espindola2017-05-111-1/+1
| | | | llvm-svn: 302826
* Rename parallelFor -> parallelForEachN.Rui Ueyama2017-05-101-1/+1
| | | | | | So that it is clear that the function is a wrapper for for_each_n. llvm-svn: 302718
* Don't use section names in getFiller. NFC.Rafael Espindola2017-05-101-1/+1
| | | | | | This is just faster and avoids using names. llvm-svn: 302661
* [ELF] - Set DF_STATIC_TLS flag for i386 target.George Rimar2017-05-081-9/+11
| | | | | | | | | | | | | | | | | | This is PR32437. DF_STATIC_TLS If set in a shared object or executable, this flag instructs the dynamic linker to reject attempts to load this file dynamically. It indicates that the shared object or executable contains code using a static thread-local storage scheme. Implementations need not support any form of thread-local storage. Patch checks if IE/LE relocations were used to check if code uses static model. If so it sets the DF_STATIC_TLS flag. Differential revision: https://reviews.llvm.org/D32354 llvm-svn: 302414
* Avoid empty .eh_frame sections.Rafael Espindola2017-05-021-0/+7
| | | | | | | | | | | | | | | | | | | | Strip on OpenBSD does not correctly handle an empty .eh_frame section and produces broken binaries in that case. Currently lld creates such an empty .eh_frame section, despite the fact that the OpenBSD crtend.o explicitly inserts a terminator. The Linux LSB "standard": https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html#EHFRAME explicitly says that The .eh_frame section shall contain 1 or more Call Frame Information (CFI) records. This diff includes a test that specifically tests the issue I'm seeing on OpenBSD. Patch by Mark Kettenis! llvm-svn: 301931
* Rename RPath Rpath for consistency. NFC.Rui Ueyama2017-04-291-2/+2
| | | | | | | For an option -foo-bar-baz, we have Config->FooBarBaz. Since -rpath is -rpath and not -r-path, it should be Config->Rpath instead Config->RPath. llvm-svn: 301759
* Recommend users use readelf instead of objdump to dump .comment contents.Rui Ueyama2017-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | readelf's output is much easier to read than objdump's as you can see below. $ readelf --string-dump .comment foo String dump of section '.comment': [ 1] GCC: (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 [ 2c] clang version 5.0.0 [ 41] Linker: LLD 5.0.0 $ objdump -j .comment -s foo Contents of section .comment: 0000 00474343 3a202855 62756e74 7520342e .GCC: (Ubuntu 4. 0010 382e342d 32756275 6e747531 7e31342e 8.4-2ubuntu1~14. 0020 30342e33 2920342e 382e3400 636c616e 04.3) 4.8.4.clan 0030 67207665 7273696f 6e20352e 302e3020 g version 5.0.0 0040 004c696e 6b65723a 204c4c44 20352e30 .Linker: LLD 5.0 0050 2e3000 .0. llvm-svn: 301515
* Remove DefaultSoName.Rafael Espindola2017-04-241-2/+2
| | | | | | | | We can just use the existing SoName member variable. It now initially contains what was in DefaultSoName and is modified if the .so has an actual soname. llvm-svn: 301259
* Replace uintX_t with uint64_t.Rui Ueyama2017-04-141-20/+18
| | | | | | | | We generally want to use uint64_t instead of uintX_t if the 64-bit type works for both 32-bit and 64-bit because it is simpler than the variable-size type. llvm-svn: 300293
* [ELF] Recommit r299635 to pad x86 executable sections with 0xccJames Henderson2017-04-071-1/+5
| | | | | | This follows r299748 which fixed a latent bug the original commit exposed. llvm-svn: 299755
* Revert r299635 because it exposed a latent bug.James Henderson2017-04-061-5/+1
| | | | llvm-svn: 299655
* [ELF] Pad x86 executable sections with 0xcc int3 instructionsJames Henderson2017-04-061-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Executable sections should not be padded with zero by default. On some architectures, 0x00 is the start of a valid instruction sequence, so can confuse disassembly between InputSections (and indeed the start of the next InputSection in some situations). Further, in the case of misjumps into padding, padding may start to be executed silently. On x86, the "0xcc" byte represents the int3 trap instruction. It is a single byte long so can serve well as padding. This change switches x86 (and x86_64) to use this value for padding in executable sections, if no linker script directive overrides it. It also puts the behaviour into place making it easy to change the behaviour of other targets when desired. I do not know the relevant instruction sequences for trap instructions on other targets however, so somebody should add this separately. Because the old behaviour simply wrote padding in the whole section before overwriting most of it, this change also modifies the padding algorithm to write padding only where needed. This in turn has caused a small behaviour change with regards to what values are written via Fill commands in linker scripts, bringing it into line with ld.bfd. The fill value is now written starting from the end of the previous block, which means that it always starts from the first byte of the fill, whereas the old behaviour meant that the padding sometimes started mid-way through the fill value. See the test changes for more details. Reviewed by: ruiu Differential Revision: https://reviews.llvm.org/D30886 Bugzilla: http://bugs.llvm.org/show_bug.cgi?id=32227 llvm-svn: 299635
* [ELF] - Prepare GnuHashTableSection<ELFT> for detemplation.George Rimar2017-03-291-27/+31
| | | | | | | | | | This patch changes GnuHashTableSection implementation to avoid depend on uintX_t and other ELFT stuff, reducing amount of changes for following patch(es). Differential revision: https://reviews.llvm.org/D31184 llvm-svn: 298998
* Use uint64_t instead of uintX_t and size_t.Rui Ueyama2017-03-291-2/+2
| | | | | | uint64_t is simpler and less error-prone than target or host-dependent types. llvm-svn: 298969
* Change the order of parameters. NFC.Rui Ueyama2017-03-291-5/+5
| | | | | | | If a function takes a size and an alignment, we usually pass them in that order instead of the reverse order. llvm-svn: 298968
* Do not set entsize for .gnu.hash.Rui Ueyama2017-03-281-3/+1
| | | | | | | | | .gnu.hash happen to contain only 32-bit integers for 32-bit arch, but the section contents are not uniform array members, so setting entsize doesn't make much sense. This behavior seems to have been blindly copied from GNU linkers. llvm-svn: 298934
* [ELF] Add -z nodlopen option.Davide Italiano2017-03-231-0/+2
| | | | | | Patch by Mark Kettenis. llvm-svn: 298567
* Rename forEach -> parallelForEach and forLoop -> parallelFor.Rui Ueyama2017-03-221-2/+3
| | | | | | | "Parallel" is the most important aspect of the functions, so we shouldn't omit that. llvm-svn: 298557
* Define Config::Is64.Rui Ueyama2017-03-221-1/+1
| | | | | | | | This is a shorthand for Config->Wordsize == 8. So this is not strictly necessary but seems handy. "Is 64 bit?" is easier to read than "Is wordsize 8 byte?" llvm-svn: 298463
* Define Config::Endianness.Rui Ueyama2017-03-211-5/+3
| | | | | | This is a shorthand for `Config->IsLE ? support::little : support::big`. llvm-svn: 298445
* [ELF] - Detemplate ARMExidxSentinelSection. NFC.George Rimar2017-03-211-10/+3
| | | | llvm-svn: 298350
* [ELF] - Detemplate InputSectionBase::getLinkOrderDep(). NFC.George Rimar2017-03-211-1/+1
| | | | llvm-svn: 298346
* [ELF] - Detemplate GdbIndexSection.George Rimar2017-03-211-19/+11
| | | | | | | | | | | Patch moves Sections array to InputFile (root class for input files). That allows to detemplate GdbIndexSection. Differential revision: https://reviews.llvm.org/D30976 llvm-svn: 298345
* [ELF][MIPS] Follow-up to r298272. Fix typo to fix buildbot.Simon Atanasyan2017-03-201-1/+1
| | | | llvm-svn: 298304
* [ELF] - Detemplate MipsGotSection<ELFT>George Rimar2017-03-201-70/+53
| | | | | | | | | | | | | This continues detemplation process. Detemplating MipsGotSection<ELFT> is helpfull because can help to detemplate getRelocTargetVA. (one more change is required) It opens road to detemplation of GotSection<ELFT> and probably something else after that. Differential revision: https://reviews.llvm.org/D31090 llvm-svn: 298272
* [ELF] - Detemplate BuildIdSection section.George Rimar2017-03-201-16/+9
| | | | | | | | | | Does not introduce anything new, just performs detemplate, using methods we already have. Differential revision: https://reviews.llvm.org/D30935 llvm-svn: 298269
OpenPOWER on IntegriCloud