summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputSection.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - Rename PhdrEntry::First/Last to FirstSec/LastSec. NFC.George Rimar2017-09-071-2/+2
| | | | | | As was suggested in D34956 thread. llvm-svn: 312712
* [ELF] - Store pointer to PT_LOAD instead of pointer to first section in ↵George Rimar2017-09-071-2/+2
| | | | | | | | | | | OutputSection It is a bit more convinent and helps to simplify logic of program headers allocation a little. Differential revision: https://reviews.llvm.org/D34956 llvm-svn: 312711
* Simplify type. NFC.Rafael Espindola2017-09-061-3/+3
| | | | llvm-svn: 312675
* [ELF] - Never call splitIntoPieces() twice. NFC.George Rimar2017-09-011-0/+1
| | | | | | | | Previously it was called twice for .comment synthetic section. That created 2 pieces of data, which was deduplicated anyways, but was not clean. llvm-svn: 312327
* Update comments: parallel_for_each -> parallelForEachSam Clegg2017-08-231-2/+2
| | | | | | | | Also remove unused include of raw_ostream.h Differential Revision: https://reviews.llvm.org/D37048 llvm-svn: 311587
* Remove a lock and use a std::unique_ptr instead.Rui Ueyama2017-08-171-9/+4
| | | | | | | | We had a lock to guard BAlloc from being used concurrently, but that is not very easy to understand. This patch replaces it with a std::unique_ptr. llvm-svn: 311056
* Fix which file is in an error message.Rafael Espindola2017-08-041-1/+1
| | | | | | | When reporting an invalid relocation we were blaming the destination file instead of the file with the relocation. llvm-svn: 310084
* [ELF] - Fix "--symbol-ordering-file doesn't work with linker scripts"George Rimar2017-08-041-0/+28
| | | | | | | | | | | | | | | This is PR33889, Patch adds support of combination of linkerscript and -symbol-ordering-file option. If no sorting commands are present in script inside section declaration and no --sort-section option specified, code uses sorting from ordering file if any exist. Differential revision: https://reviews.llvm.org/D35843 llvm-svn: 310045
* Rename ObjectFile -> ObjFile.Rui Ueyama2017-07-261-30/+30
| | | | | | | Rename it because it was too easy to conflict with llvm::object::ObjectFile which broke buildbots several times. llvm-svn: 309199
* Fix symbol type with icf.Rafael Espindola2017-07-201-1/+1
| | | | | | | | | | We were not looking at Repl and so thinking there was no output section associated with the merged symbol. Because of that it was produced as absolute. This was found by an internal round of testing. llvm-svn: 308681
* Remove redundant newline.Rui Ueyama2017-07-121-1/+1
| | | | llvm-svn: 307750
* [ELF] Fix nullptr dereference when creating an error message for a synthetic ↵Sean Eveson2017-07-051-1/+3
| | | | | | | | section. Differential Revision: https://reviews.llvm.org/D34752 llvm-svn: 307162
* [ELF] make default for get{ARM,AArch64}UndefinedRelativeWeakVA unreachablePeter Smith2017-06-191-2/+25
| | | | | | | | | | | | | | The get{ARM,AArch64}UndefinedRelativeWeakVA() functions should only be called for PC-relative relocations. Complete the supported pc-relative relocations in the switch statement and make the default case unreachable. The R_ARM_TARGET relocation can be evaluated as R_ARM_REL32 but it is only used in the context of exception tables, and is never output with respect to a weak reference so it does not appear in the switch statement. Differential Revision: https://reviews.llvm.org/D34138 llvm-svn: 305673
* Fix weak symbols on arm and aarch64.Rafael Espindola2017-06-121-14/+24
| | | | | | | | | | | | | | | | | | | | Given .weak target .global _start _start: b target The intention is that the branch goes to the instruction after the branch, effectively turning it on a nop. The branch adds the runtime PC, but we were adding it statically too. I noticed the oddity by inspection, but llvm-objdump seems to agree, since it now prints things like: b #-4 <_start+0x4> llvm-svn: 305212
* [ICF] Ignore SHF_GROUP flag when comparing two sections.Rui Ueyama2017-06-101-1/+11
| | | | | | | | | | | | | | | | | | | | SHF_GROUP bit doesn't make sense in executables or DSOs, so linkers are expected to remove that bit from section flags. We did that when we create output sections. This patch is to do that earlier than before. Now the flag is dropped when we instantiate input section objects. This change improves ICF. Previously, two sections that differ only in SHF_GROUP flag were not merged, because when the control reached ICF, the flag was still there. Now the flag is dropped before reaching to ICF, so the difference is ignored naturally. This issue was found by pcc. Differential Revision: https://reviews.llvm.org/D34074 llvm-svn: 305134
* Simplify. NFC.Rui Ueyama2017-06-091-17/+14
| | | | llvm-svn: 305048
* Use LLVM_FALLTHROUGH.Rui Ueyama2017-06-081-1/+2
| | | | llvm-svn: 305010
* Store a single Parent pointer for InputSectionBase.Rafael Espindola2017-05-311-11/+27
| | | | | | | | | | | | | | | Before InputSectionBase had an OutputSection pointer, but that was not always valid. For example, if it was a merge section one actually had to look at MergeSec->OutSec. This was brittle and caused bugs like the one fixed by r304260. We now have a single Parent pointer that points to an OutputSection for InputSection, but to a SyntheticSection for merge sections and .eh_frame. This makes it impossible to accidentally access an invalid OutSec. llvm-svn: 304338
* Fix a crash.Rafael Espindola2017-05-311-3/+9
| | | | | | | | 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] - Do not allow -r to eat comdats.George Rimar2017-05-291-0/+25
| | | | | | | | | | | | | This is PR33052, "Bug 33052 - -r eats comdats ". To fix it I stop removing group section from out when -r is given and fixing SHT_GROUP content when writing it just like we do some other fixup, e.g. for Rel[a]. (it needs fix for section indices that are in group). Differential revision: https://reviews.llvm.org/D33485 llvm-svn: 304140
* When uncompressing sections, remove SHF_COMPRESSED bits. NFC.Rui Ueyama2017-05-251-1/+2
| | | | | | | In this way, the content and the flag is always consistent, which I think better than removing the bit when input sections reaches the Writer. llvm-svn: 303926
* Replace std::call_once with llvm:call_onceKamil Rytarowski2017-05-241-1/+2
| | | | | | | | | | | | | | | | | | | | | Summary: This is required on some platforms, as GNU libstdc++ std::call_once is known to be buggy. This fixes operation of LLD on at least NetBSD and perhaps OpenBSD and Linux PowerPC. The same change has been introduced to LLVM and LLDB. Reviewers: ruiu Reviewed By: ruiu Subscribers: emaste, #lld Tags: #lld Differential Revision: https://reviews.llvm.org/D33508 llvm-svn: 303788
* Alternative way to detemplate GotSection.Rafael Espindola2017-05-181-17/+24
| | | | | | | | | | | | | | | | | | | | 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] Support R_ARM_SBREL32 RelocationPeter Smith2017-05-181-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | This change adds support for the R_ARM_SBREL32 relocation. The relocation is a base relative relocation that is produced by clang/llvm when -frwpi is used. The use case for the -frwpi option is position independent data for embedded systems that do not have a GOT. With -frwpi all data is accessed via an offset from a base register (usually r9), where r9 is set at run time to where the data has been loaded. The base of the data is known as the static base. The ARM ABI defines the static base as: B(S) is the addressing origin of the output segment defining the symbol S. The origin is not required to be the base address of the segment. For simplicity we choose to use the base address of the segment. The ARM procedure call standard only defines a read write variant using R_ARM_SBREL32 relocations. The read-only data is accessed via pc-relative offsets from the code, this is implemented in clang as -fropi. Fixes PR32924 Differential Revision: https://reviews.llvm.org/D33280 llvm-svn: 303337
* [ELF] - Detemplate access to SymTab, DynSymTab, GnuHashTab. NFC.George Rimar2017-05-161-1/+1
| | | | | | Follow up for r303150. llvm-svn: 303153
* Detemplate SymbolBody::getGotVA. NFC.Rafael Espindola2017-05-111-3/+3
| | | | llvm-svn: 302846
* Detemplate the got.Rafael Espindola2017-05-111-12/+11
| | | | | | This is a bit hackish, but allows for a lot of followup cleanups. llvm-svn: 302845
* Reduce template usage. NFC.Rafael Espindola2017-05-111-14/+11
| | | | llvm-svn: 302828
* Use toString(Inputfile*) to format a file object.Rui Ueyama2017-04-281-3/+1
| | | | llvm-svn: 301674
* Remove useless local variable.Rui Ueyama2017-04-141-4/+2
| | | | llvm-svn: 300294
* Replace uintX_t with uint64_t.Rui Ueyama2017-04-141-6/+4
| | | | | | | | 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] - Stop producing broken output for R_386_GOT32[X] relocations.George Rimar2017-04-081-1/+1
| | | | | | | | | | | | | | | | | | Previously we silently produced broken output for R_386_GOT32X/R_386_GOT32 relocations if they were used to compute the address of the symbol’s global offset table entry without base register when position-independent code is disabled. Situation happened because of recent ABI changes. Released ABI mentions that R_386_GOT32X can be calculated in a two different ways (so we did not follow ABI here before this patch), but draft ABI also mentions R_386_GOT32 relocation here. We should use the same calculations for both relocations. Problem is that we always calculated them as G + A - GOT (offset from end of GOT), but for case when PIC is disabled, according to i386 ABI calculation should be G + A, what should produce just an address in GOT finally. ABI: https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-draft.pdf (p36, p60). llvm-svn: 299812
* Change the error message format for undefined symbols.Rui Ueyama2017-03-301-0/+68
| | | | | | | | | | | | | | | | | | | | Previously, undefined symbol errors are one line like this and wasn't easy to read. /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Writer.cpp:207: undefined symbol 'lld::elf::EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::addSection(lld::elf::InputSectionBase*)' This patch make it more structured like this. bin/ld.lld: error: undefined symbol: lld::elf::EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >>> Referenced by Writer.cpp:207 (/ssd/llvm-project/lld/ELF/Writer.cpp:207) >>> Writer.cpp.o in archive lib/liblldELF.a Discussion thread: http://lists.llvm.org/pipermail/llvm-dev/2017-March/111459.html Differential Revision: https://reviews.llvm.org/D31481 llvm-svn: 299097
* Remove parameter names from template instantiations to make them compact. NFC.Rui Ueyama2017-03-291-47/+35
| | | | llvm-svn: 299025
* Sort. NFC.Rui Ueyama2017-03-261-88/+89
| | | | llvm-svn: 298797
* Force @{init,fini}_array if section name starts with ".{init,fini}_array.".Rui Ueyama2017-03-231-4/+22
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=32307. Differential Revision: https://reviews.llvm.org/D31255 llvm-svn: 298569
* Define Config::Is64.Rui Ueyama2017-03-221-2/+2
| | | | | | | | 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
* [ELF] - Detemplate InputSection::getRelocatedSection(). NFC.George Rimar2017-03-211-8/+3
| | | | llvm-svn: 298353
* [ELF] - Detemplate InputSectionBase::uncompress(). NFCGeorge Rimar2017-03-211-8/+2
| | | | llvm-svn: 298351
* [ELF] - Detemplate InputSectionBase::getLinkOrderDep(). NFC.George Rimar2017-03-211-7/+1
| | | | llvm-svn: 298346
* [ELF][MIPS] Calculate relocations agains _gp_disp / __gnu_local_gp using ↵Simon Atanasyan2017-03-201-0/+12
| | | | | | | | | | | | | | | | | | | | | | | dedicated 'expressions' The patch introduces two new relocations expressions R_MIPS_GOT_GP and R_MIPS_GOT_GP_PC. The first one represents a current value of `_gp` pointer and used to calculate relocations against the `__gnu_local_gp` symbol. The second one represents the offset between the beginning of the function and the `_gp` pointer's value. There are two motivations for introducing new expressions: - It's better to keep all non-trivial relocation calculations in the single place - `getRelocTargetVA` function. - Relocations against both `_gp_disp` and `__gnu_local_gp` symbols depend on the `_gp` value. It's a magical value points to the "middle" of GOT. Now all relocations use a common `_gp` value. But in fact, under some conditions each input file might require its own `_gp` value. I'm going to implement it in the future patches. So it's better to make `MipsGotSection` responsible for calculation of the `_gp` value. llvm-svn: 298306
* Compute Config member function return values only once.Rui Ueyama2017-03-171-5/+5
| | | | | | | | | | | We had a few Config member functions that returns configuration values. For example, we had is64() which returns true if the target is 64-bit. The return values of these functions are constant and never change. This patch is to compute them only once to make it clear that they'll never change. llvm-svn: 298168
* [ELF] - Detemplate SymbolBody::getGotOffset(). NFC.George Rimar2017-03-171-2/+2
| | | | llvm-svn: 298091
* [ELF] - Detemplate SymbolBody::getVA and SymbolBody::getPltVA. NFC.George Rimar2017-03-171-15/+13
| | | | llvm-svn: 298071
* [ELF] Fix error reporting for synthetic sectionsEugene Leviant2017-03-141-0/+5
| | | | | | | | | | | Synthetic sections don't belong to any input file, but still they are input sections. Whenever problem occurs with relocations in these sections lld crashes in error reporting, trying to print input file name. Differential revision: https://reviews.llvm.org/D30889 llvm-svn: 297711
* Remove DefinedSynthetic.Rafael Espindola2017-03-081-19/+31
| | | | | | | | | | | | | With this we have a single section hierarchy. It is a bit less code, but the main advantage will be in a future patch being able to handle foo = symbol_in_obj; in a linker script. Currently that fails since we try to find the output section of symbol_in_obj. With this we should be able to just return an InputSection from the expression. llvm-svn: 297313
* Use uint32_t for alignment in more places, NFC.Rafael Espindola2017-03-081-9/+8
| | | | llvm-svn: 297305
* Remove unnecessary template.Rafael Espindola2017-03-081-7/+1
| | | | llvm-svn: 297293
* Remove unnecessary template. NFC.Rafael Espindola2017-03-081-20/+4
| | | | llvm-svn: 297292
* Rename one of the getOffset methods.Rafael Espindola2017-03-081-1/+1
| | | | | | | It is sufficiently different in that it returns an offset in the input file, not the output section. llvm-svn: 297290
OpenPOWER on IntegriCloud