summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* Initialize OffsetMap in a known location.Rafael Espindola2018-03-284-14/+13
| | | | | | This is a small optimization and avoids the need to use call_once. llvm-svn: 328686
* Define a trivial method inline.Rafael Espindola2018-03-282-8/+5
| | | | llvm-svn: 328685
* Store live offsets as uint32_t.Rafael Espindola2018-03-282-2/+2
| | | | | | | We don't support input merge sections larger than 4gb, so these can be uint32_t. llvm-svn: 328684
* Force SHF_MERGE optimizations with -r.Rafael Espindola2018-03-271-3/+13
| | | | | | | | | | | | | | Some tools (dwarfdump for example) get confused by the current -O0 -r output since it has multiple copies of .debug_str. We cannot just merge sections with the same name as they can have different sh_entsize. We could have duplicated logic for merging sections based on name and sh_entsize, but it seems better to just use the existing logic by enabling optimizations. llvm-svn: 328640
* [ELF] Disable ICF for synthetic sectionsAndrew Ng2018-03-271-0/+7
| | | | | | | | | | | | | The Data member of synthetic section's is not valid and empty. The Data member is required to be valid by ICF as it is used by ICF to determine the equality of section contents. Therefore, exclude synthetic sections from ICF. Fixes bug PR36910. Differential Revision: https://reviews.llvm.org/D44923 llvm-svn: 328624
* Remove extraneous local variable. NFC.Rui Ueyama2018-03-271-5/+3
| | | | llvm-svn: 328605
* Update comments.Rui Ueyama2018-03-271-11/+10
| | | | llvm-svn: 328604
* Refactor SharedFile::parseRest. NFC.Rui Ueyama2018-03-262-57/+80
| | | | | | | | | SharedFile::parseRest function grew organically and got a bit hard to understand. This patch refactor it. This patch also adds comments. Differential Revision: https://reviews.llvm.org/D44860 llvm-svn: 328579
* Reduce code duplication a bit.Rafael Espindola2018-03-261-3/+3
| | | | | | Thanks to George Rimar for pointing it out. llvm-svn: 328571
* Reduce code duplication a bit. NFCRafael Espindola2018-03-263-11/+11
| | | | llvm-svn: 328569
* [ELF] GotSection increment NumEntries when Target saves GlobalOffsetTable in ↵Zaara Syeda2018-03-261-3/+11
| | | | | | | | | | | | | | the .got When the target saves ElfSym::GlobalOffsetTable in the .got rather than .got.plt, Target->GotHeaderEntriesNum states the number of extra entries required in the .got. Rather than having to add Target->GotHeaderEntriesNum to NumEntries in every function which refers to NumEntries, this patch changes the initial value of NumEntries in the constructor. Differential Revision: https://reviews.llvm.org/D44744 llvm-svn: 328559
* This is PR36799.George Rimar2018-03-262-3/+10
| | | | | | | | | | | | | | | | Currently, we might have a bug with scripts like below: .foo : ALIGN(8) { *(.foo) } > ram because do not expand the memory region when doing ALIGN. This might result in file range overlaps. The patch fixes the issue. Differential revision: https://reviews.llvm.org/D44730 llvm-svn: 328479
* [ELF] - Do not ignore discarding of .rela.plt/.rela.dyn, allow doing custom ↵George Rimar2018-03-241-2/+5
| | | | | | | | | | | | | | | | | | | | | | layout for them. Currently when we build input sections list in linker script we ignore all rel[a] sections. That was done to support scripts like .rela.dyn : { *(.rela.data) } for emit relocs. Though as a result following scripts were also silently ignored: /DISCARD/ : { *(.rela.plt) /DISCARD/ : { *(.rela.dyn) and we produced output with this sections. That is not ideal. The solution this patch suggests is simple: do not ignore synthetic rel[a] sections. That way we can enable common discarding logic for them and report a proper error. Differential revision: https://reviews.llvm.org/D41640 llvm-svn: 328419
* Add a SectionBase::getVA helper. NFC.Rafael Espindola2018-03-247-21/+21
| | | | | | There were a few too many places duplicating this. llvm-svn: 328402
* Do not add a dummy entry to SharedFile::Verdefs. NFC.Rui Ueyama2018-03-242-10/+7
| | | | | | | | Previously, we used 0 as an alias for VER_NDX_GLOBAL and had a dummy entry in SharedFile::Verdefs so that the access to the array is within its boundary. But that's not straightforwad. We can just stop doing both. llvm-svn: 328401
* Move a Repl access.Rafael Espindola2018-03-232-3/+2
| | | | | | | | Since SectionBase::getOutputSection handles ICF replaces and SectionBase::getOffset was handling it in some cases, it is more consistent to have getOffset always handle it. llvm-svn: 328391
* Drop redundant ->Repl.Rafael Espindola2018-03-231-1/+1
| | | | | | | SectionBase::getOutputSection handles replacement sections, so this code doesn't have to. llvm-svn: 328390
* Remove "FIXME" from a comment.Rui Ueyama2018-03-231-7/+6
| | | | | | A bug in BFD linker is not our FIXME item. llvm-svn: 328381
* Add a minimal fix for PR36878.Rafael Espindola2018-03-231-3/+3
| | | | | | | | | | | | | | | When looking for the output section and the output offset the expectation was that the caller had looked at Repl. That works fine for InputSections, but in the case of MergeInputSections the caller doesn't have the section that is actually replaced. The original testcase was failing because getOutputSection was returning null. The slightly extended testcase also checks that getOffset also checks Repl. I will send a refactoring separetelly. llvm-svn: 328332
* [ELF] - Simplify. NFC.George Rimar2018-03-231-4/+2
| | | | llvm-svn: 328319
* [ELF] - Another fix for "LLD crashes with --emit-relocs when trying to ↵George Rimar2018-03-231-4/+17
| | | | | | | | | | | | | | | proccess .eh_frame" This fixes PR36367 which is about segfault when --emit-relocs is used together with .eh_frame sections which happens because of reordering of regular and .rel[a] sections. Path changes loop that iterates over input sections to create relocation target sections first. Differential revision: https://reviews.llvm.org/D44679 llvm-svn: 328299
* Fix the MSVC build.Rafael Espindola2018-03-231-1/+1
| | | | llvm-svn: 328285
* Fix PR36793.Rafael Espindola2018-03-232-54/+42
| | | | | | | With this patch lld will iterate over compile units to find the line tables instead of assuming there is only one at offset 0. llvm-svn: 328284
* [ELF] - Apply clang-format. NFC.George Rimar2018-03-221-10/+10
| | | | llvm-svn: 328195
* Replace a std::pair with a struct.Rafael Espindola2018-03-212-3/+7
| | | | | | This is more readable and should reduce the noise in a followup patch. llvm-svn: 328164
* [ELF][PPC64] Fix getRelExpr for R_PPC64_REL16_LO and R_PPC64_REL16_HAZaara Syeda2018-03-211-1/+4
| | | | | | | | | The relocations R_PPC64_REL16_LO and R_PPC64_REL16_HA should return R_PC for getRelExpr since they compute #lo(S + A – P) and #ha(S + A – P). Differential Revision: https://reviews.llvm.org/D44648 llvm-svn: 328103
* [ELF] - Teach LLD to hint about -fdebug-types-section.George Rimar2018-03-212-12/+28
| | | | | | | | | Patch teaches LLD to hint user about -fdebug-types-section flag if relocation overflow happens in debug section. Differential revision: https://reviews.llvm.org/D40954 llvm-svn: 328081
* Fix consitent -> consistent.Eric Christopher2018-03-201-1/+1
| | | | llvm-svn: 328010
* [ELF] Simplify compCtors and writeInt.Fangrui Song2018-03-201-6/+3
| | | | | | | | | | Reviewers: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D44690 llvm-svn: 328009
* [ELF] - Make __start_/__stop_<section_name> symbols STV_PROTECTEDGeorge Rimar2018-03-201-2/+2
| | | | | | | | | There are no reasons for them to be STV_DEFAULT, recently bfd did the same change. Differential revision: https://reviews.llvm.org/D44566 llvm-svn: 327983
* Remove GnuHashTableSection::getShift2().Rui Ueyama2018-03-192-3/+3
| | | | | | | | | | | Choosing a Shift2 value based on wordsize is cargo-culted from gold. Assuming that djb hash is a good hash function, choosing bits [4,9] shouldn't be any worse or better than choosing bits [5,10]. We shouldn't have copied that behavior that we can't justify in the first place. Differential Revision: https://reviews.llvm.org/D44547 llvm-svn: 327921
* allow-multiple-definitions should completely suppress errors instead of ↵Rui Ueyama2018-03-191-10/+7
| | | | | | | | | | | | | making them warnings. We found that when you pass --allow-multiple-definitions or `-z muldefs` to GNU linkers, they don't complain about duplicate symbols at all. They don't even print out warnings on it. We emit warnings in that case. If you pass --fatal-warnings, that difference results in a link failure. Differential Revision: https://reviews.llvm.org/D44549 llvm-svn: 327920
* [ELF] Add basic support for PPC LEZaara Syeda2018-03-194-3/+66
| | | | | | | | | | | | This patch adds changes to start supporting the Power 64-Bit ELF V2 ABI. This includes: - Changing the ElfSym::GlobalOffsetTable to be named .TOC. - Creating a GotHeader so the first entry in the .got is .TOC. - Setting the e_flags to be 1 for ELF V1 and 2 for ELF V2 Differential Revision: https://reviews.llvm.org/D44483 llvm-svn: 327871
* [ELF] Recommit 327248 with Arm using the .got for _GLOBAL_OFFSET_TABLE_Peter Smith2018-03-199-13/+29
| | | | | | | | | | | | | | | | | | | | | | This is the same as 327248 except Arm defining _GLOBAL_OFFSET_TABLE_ to be the base of the .got section as some existing code is relying upon it. For most Targets the _GLOBAL_OFFSET_TABLE_ symbol is expected to be at the start of the .got.plt section so that _GLOBAL_OFFSET_TABLE_[0] = reserved value that is by convention the address of the dynamic section. Previously we had defined _GLOBAL_OFFSET_TABLE_ as either the start or end of the .got section with the intention that the .got.plt section would follow the .got. However this does not always hold with the current default section ordering so _GLOBAL_OFFSET_TABLE_[0] may not be consistent with the reserved first entry of the .got.plt. X86, X86_64 and AArch64 will use the .got.plt. Arm, Mips and Power use .got Fixes PR36555 Differential Revision: https://reviews.llvm.org/D44259 llvm-svn: 327823
* Revert r327248, "For most Targets the _GLOBAL_OFFSET_TABLE_ symbol is ↵Peter Collingbourne2018-03-168-28/+13
| | | | | | | | | | | expected to be at" This change broke ARM code that expects to be able to add _GLOBAL_OFFSET_TABLE_ to the result of an R_ARM_REL32. I will provide a reproducer on llvm-commits. llvm-svn: 327688
* Fix linker script operator precedence.Rui Ueyama2018-03-151-5/+6
| | | | | | | | | | | "&" should have higher priority than "|" [1]. Previously, they had the same priority. [1] https://sourceware.org/binutils/docs/ld/Operators.html Differential Revision: https://reviews.llvm.org/D43880 llvm-svn: 327684
* Add a comment about ELF spec and the symbol table's sh_info.Rui Ueyama2018-03-151-0/+4
| | | | llvm-svn: 327645
* [ELF] - Fix build bot after rL327612.George Rimar2018-03-151-1/+1
| | | | | | Missed this one. llvm-svn: 327616
* [ELF] - Fix build bot after rL327612.George Rimar2018-03-151-2/+2
| | | | | | | Error was: error: field 'Size' will be initialized after field 'CommandString' [-Werror,-Wreorder] llvm-svn: 327613
* [ELF] - Show data and assignment commands in the map file.George Rimar2018-03-154-14/+62
| | | | | | | | | Patch teaches LLD to print BYTE/SHORT/LONG/QUAD and location move commands to the map file. Differential revision: https://reviews.llvm.org/D44004 llvm-svn: 327612
* Update Error MessageRumeet Dhindsa2018-03-141-1/+2
| | | | | | | | | | | | | | Summary: Updates error message for dynamic relocation attempt for read only segments. Reviewers: ruiu Reviewed By: ruiu Subscribers: emaste, javed.absar, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D44453 llvm-svn: 327584
* [ELF] Add .eh_frame pieces to map fileRui Ueyama2018-03-142-0/+43
| | | | | | | | | This patch is a simplified version of https://reviews.llvm.org/D42960 written by Andrew Ng. Differential Revision: https://reviews.llvm.org/D44168 llvm-svn: 327574
* Implement --cref.Rui Ueyama2018-03-146-2/+58
| | | | | | | | | | | | | | This is an option to print out a table of symbols and filenames. The output format of this option is the same as GNU, so that it can be processed by the same scripts as before after migrating from GNU to lld. This option is mildly useful; we can live without it. But it is pretty convenient sometimes, and it can be implemented in 50 lines of code, so I think lld should support this option. Differential Revision: https://reviews.llvm.org/D44336 llvm-svn: 327565
* Separate sentences to clarify a comment.Rui Ueyama2018-03-141-7/+9
| | | | llvm-svn: 327555
* Error instead of producing broken binary.Rafael Espindola2018-03-141-0/+11
| | | | | | | | This "fixes" PR36678 by just producing an error when we find a case where we would produce an plt entry that used ebx but ebx would not be set. llvm-svn: 327542
* Reduce code duplication a bit.Rafael Espindola2018-03-145-14/+18
| | | | | | | The code for computing the offset of an entry in the plt is simple, but it was duplicated in quite a few places. llvm-svn: 327536
* [ELF] - Never create .gnu_hash with NBuckets == 0.George Rimar2018-03-141-6/+10
| | | | | | | | | | | | Currently, we can end up with NBuckets==0 and android loader does not like it (PR36537). Seems we can go with a minimal amount of changes here for simplicity and be consistent with gold and so just always use >= 1 value for NBuckets. Differential revision: https://reviews.llvm.org/D44422 llvm-svn: 327481
* [ELF] - Implement INSERT BEFORE.George Rimar2018-03-133-13/+28
| | | | | | | | | | | This finishes PR35877. INSERT BEFORE used similar to INSERT AFTER, it inserts sections before the given target section. Differential revision: https://reviews.llvm.org/D44380 llvm-svn: 327378
* [ELF] - Restrict section offsets that exceeds file size.George Rimar2018-03-131-6/+25
| | | | | | | | | | | | | | | | | This is part of PR36515. With some linkerscripts it is possible to get file offset overlaps and overflows. Currently LLD checks overlaps in checkNoOverlappingSections(). And also we allow broken output with --no-inhibit-exec. Problem is that sometimes final offset of sections is completely broken and we calculate output file size wrong and might crash. Patch implements check to verify that there is no output section which offset exceeds file size. Differential revision: https://reviews.llvm.org/D43819 llvm-svn: 327376
* [ELF] - Drop special flags for empty output sections.George Rimar2018-03-131-7/+11
| | | | | | | | | | | | | | | | This fixes PR36598. LLD currently crashes when we have empty output section with SHF_LINK_ORDER flag. This might happen if we place an empty synthetic section in the linker script, but keep output section alive with the use of additional symbol, for example. The patch fixes the issue by dropping all special flags for empty sections. Differential revision: https://reviews.llvm.org/D44376 llvm-svn: 327374
OpenPOWER on IntegriCloud