summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* ELF: Perform per-section .ARM.exidx processing during ↵Peter Collingbourne2019-04-013-54/+56
| | | | | | | | | | | | combineEhFrameSections(). NFCI. And rename the function to combineEhSections(). This makes the processing of .ARM.exidx even more similar to .eh_frame and means that we can avoid an additional loop over InputSections. Differential Revision: https://reviews.llvm.org/D60026 llvm-svn: 357417
* [ELF] Rename SyntheticSection::empty to more appropriate isNeeded() with ↵Fangrui Song2019-04-013-41/+41
| | | | | | | | | | | | | | | | | | | | | | | opposite meaning Summary: Some synthetic sections can be empty while still being needed, thus they can't be removed by removeUnusedSyntheticSections(). Rename this member function to more appropriate isNeeded() with the opposite meaning. No functional change intended. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: jhenderson, grimar, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59982 llvm-svn: 357377
* Simplify. NFC.Rui Ueyama2019-04-011-13/+13
| | | | llvm-svn: 357373
* Replace `typedef A B` with `using B = A`. NFC.Rui Ueyama2019-04-0111-55/+55
| | | | | | | | I did this using Perl. Differential Revision: https://reviews.llvm.org/D60003 llvm-svn: 357372
* [ELF][MachO][wasm] Simplify range-style std::find{,_if} with STLExtras.h ↵Fangrui Song2019-03-293-5/+5
| | | | | | utilities. NFC llvm-svn: 357269
* Remove a duplicate assignment. NFC.Rui Ueyama2019-03-281-1/+0
| | | | llvm-svn: 357223
* Create an instance of Target after reading all input files. NFC.Rui Ueyama2019-03-285-19/+26
| | | | | | | | This change itself doesn't mean anything, but it helps D59780 because in patch, we don't know whether we need to create a CET-aware PLT or not until we read all input files. llvm-svn: 357194
* Make a member function a non-member function.Rui Ueyama2019-03-281-6/+2
| | | | | | | Since this member function doesn't use anything in the class, it doesn't have to be a member of the class. llvm-svn: 357193
* De-template X86_64TargetInfo. NFC.Rui Ueyama2019-03-283-90/+54
| | | | llvm-svn: 357191
* Make TargetInfo const. NFC.Rui Ueyama2019-03-282-4/+4
| | | | | | | We do not mutate a TargetInfo instance after creating it. This change makes it explicit. llvm-svn: 357185
* [ELF][ARM] Recommit Redesign of .ARM.exidx handling to use a SyntheticSectionPeter Smith2019-03-284-123/+269
| | | | | | | | | | | | | | | | | | | | | | Recommit r356666 with fixes for buildbot failure, as well as handling for --emit-relocs, which we decide not to emit any relocation sections as the table is already position independent and an offline tool can deduce the relocations. Instead of creating extra Synthetic .ARM.exidx sections to account for gaps in the table, create a single .ARM.exidx SyntheticSection that can derive the contents of the gaps from a sorted list of the executable InputSections. This has the benefit of moving the ARM specific code for SyntheticSections in SHF_LINK_ORDER processing and the table merging code into the ARM specific SyntheticSection. This also makes it easier to create EXIDX_CANTUNWIND table entries for executable InputSections that don't have an associated .ARM.exidx section. Fixes pr40277 Differential Revision: https://reviews.llvm.org/D59216 llvm-svn: 357160
* Inline a trivial function. NFC.Rui Ueyama2019-03-285-12/+10
| | | | | | | I found that hiding this particular actual expression doesn't help readers understand the code. So I remove and inline that function. llvm-svn: 357140
* [ELF] Dump symbols ordered by profiled guided section layout to file.Rui Ueyama2019-03-274-0/+27
| | | | | | | | | | | | | | | | Patch by Tiancong Wang. In D36351, Call-Chain Clustering (C3) heuristic is implemented with option --call-graph-ordering-file <file>. This patch adds a flag --print-symbol-order=<file> to LLD, and when specified, it prints out the symbols ordered by the heuristics to the file. The symbols printout is helpful to those who want to understand the heuristics and want to reproduce the ordering with --symbol-ordering-file in later pass. Differential Revision: https://reviews.llvm.org/D59311 llvm-svn: 357133
* [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))Fangrui Song2019-03-258-63/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This should address remaining issues discussed in PR36555. Currently R_GOT*_FROM_END are exclusively used by x86 and x86_64 to express relocations types relative to the GOT base. We have _GLOBAL_OFFSET_TABLE_ (GOT base) = start(.got.plt) but end(.got) != start(.got.plt) This can have problems when _GLOBAL_OFFSET_TABLE_ is used as a symbol, e.g. glibc dl_machine_dynamic assumes _GLOBAL_OFFSET_TABLE_ is start(.got.plt), which is not true. extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden; return _GLOBAL_OFFSET_TABLE_[0]; // R_X86_64_GOTPC32 In this patch, we * Change all GOT*_FROM_END to GOTPLT* to fix the problem. * Add HasGotPltOffRel to denote whether .got.plt should be kept even if the section is empty. * Simplify GotSection::empty and GotPltSection::empty by setting HasGotOffRel and HasGotPltOffRel according to GlobalOffsetTable early. The change of R_386_GOTPC makes X86::writePltHeader simpler as we don't have to compute the offset start(.got.plt) - Ebx (it is constant 0). We still diverge from ld.bfd (at least in most cases) and gold in that .got.plt and .got are not adjacent, but the advantage doing that is unclear. Reviewers: ruiu, sivachandra, espindola Subscribers: emaste, mehdi_amini, arichardson, dexonsmith, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59594 llvm-svn: 356968
* Use a class instead of lambda-based callbacks to organize garbage collector.Rui Ueyama2019-03-251-117/+120
| | | | | | | | | | | | | | | | | | | | | | lld's mark-sweep garbage collector was written in the visitor pattern. There are functions that traverses a given graph, and the functions calls callback functions to dispatch according to node type. The code was originaly pretty simple, and lambdas worked pretty well. However, as we add more features to the garbage collector, that became more like a callback hell. We now have a callback function that wraps another callback function, for example. It is not easy to follow the flow of the control. This patch rewrites it as a regular class. What was once a lambda is now a regular class member function. I think this change fixes the readability issue. No functionality change intended. Differential Revision: https://reviews.llvm.org/D59800 llvm-svn: 356966
* Simplify PltSection.Rui Ueyama2019-03-222-22/+11
| | | | | | | | | Previously, `Entries` contains pairs of symbols and their indices. The indices are always 0, x, 2x, 3x, ..., where x is the size of relocation entry. We didn't have to store that values because we can compute them when we consume them. llvm-svn: 356812
* [DWARF] Refactor RelocVisitor and fix computation of SHT_RELA-typed ↵Fangrui Song2019-03-221-2/+24
| | | | | | | | | | | | | | | | | | relocation entries Summary: This is the lld-side change of D57939 Reviewers: echristo, dblaikie, ruiu, espindola Reviewed By: echristo, ruiu Subscribers: jdoerfert, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57940 llvm-svn: 356730
* [ELF][ARM] Revert Redesign of .ARM.exidx handling to use a SyntheticSectionPeter Smith2019-03-214-258/+123
| | | | | | | | | There is a reproducible buildbot failure (segfault) on the 2 stage clang-cmake-armv8-lld bot. Reverting while I investigate. Differential Revision: https://reviews.llvm.org/D59216 llvm-svn: 356684
* [ELF][ARM] Redesign of .ARM.exidx handling to use a SyntheticSectionPeter Smith2019-03-214-123/+258
| | | | | | | | | | | | | | | | | Instead of creating extra Synthetic .ARM.exidx sections to account for gaps in the table, create a single .ARM.exidx SyntheticSection that can derive the contents of the gaps from a sorted list of the executable InputSections. This has the benefit of moving the ARM specific code for SyntheticSections in SHF_LINK_ORDER processing and the table merging code into the ARM specific SyntheticSection. This also makes it easier to create EXIDX_CANTUNWIND table entries for executable InputSections that don't have an associated .ARM.exidx section. Fixes pr40277 Differential Revision: https://reviews.llvm.org/D59216 llvm-svn: 356666
* [ELF] Allow sh_entsize to be unrelated to sh_addralign and not a power of 2Fangrui Song2019-03-181-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This implements Rui Ueyama's idea in PR39044. I've checked that ld.bfd and gold do not have the power-of-2 requirement and do not require sh_entsize to be a multiple of sh_align. Now on the updated test merge-entsize.s, all the 3 linkers happily create .rodata that is not 3-byte aligned. This has a use case in Linux arch/x86/crypto/sha512-avx2-asm.S It uses sh_entsize of 640, which is not a power of 2. See https://github.com/ClangBuiltLinux/linux/issues/417 Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: nickdesaulniers, E5ten, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59478 llvm-svn: 356428
* [ELF] Emit weak-undef symbols in .dynsym of a PIE binary only if linked ↵Siva Chandra2019-03-181-0/+4
| | | | | | | | | | | | | | against shared libs. Reviewers: espindola Subscribers: emaste, arichardson, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59275 llvm-svn: 356374
* [ELF] De-virtualize findOrphanPos, excludeLibs and handleARMTlsRelocationFangrui Song2019-03-173-6/+3
| | | | llvm-svn: 356331
* [ELF] Delete unused forward declarations and unused ↵Fangrui Song2019-03-154-20/+0
| | | | | | DynamicReloc::getInputSec(). NFC llvm-svn: 356239
* [ELF] De-template wrapSymbols, isReserved and addGotEntry. NFCFangrui Song2019-03-153-7/+7
| | | | llvm-svn: 356237
* [ELF] Split RW PT_LOAD on the PT_GNU_RELRO boundaryFangrui Song2019-03-151-24/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Based on Peter Collingbourne's suggestion in D56828. Before D56828: PT_LOAD(.data PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .bss) Old: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .data .bss) New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro)) PT_LOAD(.data. .bss) The new layout reflects the runtime memory mappings. By having two PT_LOAD segments, we can utilize the NOBITS part of the first PT_LOAD and save bytes for .bss.rel.ro. .bss.rel.ro is currently small and only used by copy relocations of symbols in read-only segments, but it can be used for other purposes in the future, e.g. if a relro section's statically relocated data is all zeros, we can move it to .bss.rel.ro. Reviewers: espindola, ruiu, pcc Reviewed By: ruiu Subscribers: nemanjai, jvesely, nhaehnle, javed.absar, kbarton, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58892 llvm-svn: 356226
* Make a hack for LTO work only when you are actually doing LTO.Rui Ueyama2019-03-141-1/+9
| | | | | | | | | | | | We allow an archive file without symbol table as a linker input as a workaround for a very common error in LTO build. But that logic worked even for an archive file containing non-bitcode files, which is not expected. This patch limits that workaround to one that contains only bitcode files. Differential Revision: https://reviews.llvm.org/D59373 llvm-svn: 356186
* [ELF] Simplify RelRo, TLS, NOBITS section ranks and make RW PT_LOAD start ↵Fangrui Song2019-03-141-35/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with RelRo Old: PT_LOAD(.data | PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .bss) New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .data .bss) The placement of | indicates page alignment caused by PT_GNU_RELRO. The new layout has simpler rules and saves space for many cases. Old size: roundup(.data) + roundup(.data.rel.ro) New size: roundup(.data.rel.ro + .bss.rel.ro) + .data Other advantages: * At runtime the 3 memory mappings decrease to 2. * start(PT_TLS) = start(PT_GNU_RELRO) = start(RW PT_LOAD). This simplifies binary manipulation tools. GNU strip before 2.31 discards PT_GNU_RELRO if its address is not equal to the start of its associated PT_LOAD. This has been fixed by https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f But with this change, we will be compatible with GNU strip before 2.31 * Before, .got.plt (non-relro by default) was placed before .got (relro by default), which made it impossible to have _GLOBAL_OFFSET_TABLE_ (start of .got.plt on x86-64) equal to the end of .got (R_GOT*_FROM_END) (https://bugs.llvm.org/show_bug.cgi?id=36555). With the new ordering, we can improve on this regard if we'd like to. Reviewers: ruiu, espindola, pcc Subscribers: emaste, arichardson, llvm-commits, joerg, jdoerfert Differential Revision: https://reviews.llvm.org/D56828 llvm-svn: 356117
* [mips] Remove redundant setup of less-significant bit. NFCSimon Atanasyan2019-03-131-2/+2
| | | | | | | The less-significant bit for microMIPS symbols configured in the `getSymVA` function. Do not need to setup it once again. llvm-svn: 356058
* Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"Francis Visoiu Mistrih2019-03-124-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently we have -Rpass for filtering the remarks that are displayed as diagnostics, but when using -fsave-optimization-record, there is no way to filter the remarks while generating them. This adds support for filtering remarks by passes using a regex. Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline` will only emit the remarks coming from the pass `inline`. This adds: * `-fsave-optimization-record` to the driver * `-opt-record-passes` to cc1 * `-lto-pass-remarks-filter` to the LTOCodeGenerator * `--opt-remarks-passes` to lld * `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2 * `-opt-remarks-passes` to gold-plugin Differential Revision: https://reviews.llvm.org/D59268 Original llvm-svn: 355964 llvm-svn: 355984
* ELF: Don't add .dynamic strings to .dynstr early.Peter Collingbourne2019-03-122-20/+17
| | | | | | | | | | This does not appear to be necessary because StringTableSection does not need to be finalized, which also means that we can remove the call to finalizeSynthetic on .dynstr. Differential Revision: https://reviews.llvm.org/D59240 llvm-svn: 355977
* Revert "[Remarks] Add -foptimization-record-passes to filter remark emission"Francis Visoiu Mistrih2019-03-124-5/+0
| | | | | | This reverts commit 20fff32b7d1f1a1bd417b22aa9f26ededd97a3e5. llvm-svn: 355976
* ELF: Use bump pointer allocator for uncompressed section buffers. NFCI.Peter Collingbourne2019-03-122-10/+16
| | | | | | | | | | | | | | This shaves another word off SectionBase and makes it possible to clone a section using the implicit copy constructor. This basically reverts r311056, which removed the mutex in order to make the code easier to understand. On balance I think it's probably more straightforward to have a mutex here than to have an unusual copy constructor in SectionBase. Differential Revision: https://reviews.llvm.org/D59269 llvm-svn: 355966
* [Remarks] Add -foptimization-record-passes to filter remark emissionFrancis Visoiu Mistrih2019-03-124-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Currently we have -Rpass for filtering the remarks that are displayed as diagnostics, but when using -fsave-optimization-record, there is no way to filter the remarks while generating them. This adds support for filtering remarks by passes using a regex. Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline` will only emit the remarks coming from the pass `inline`. This adds: * `-fsave-optimization-record` to the driver * `-opt-record-passes` to cc1 * `-lto-pass-remarks-filter` to the LTOCodeGenerator * `--opt-remarks-passes` to lld * `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2 * `-opt-remarks-passes` to gold-plugin Differential Revision: https://reviews.llvm.org/D59268 llvm-svn: 355964
* ELF: Simplify. NFCI.Peter Collingbourne2019-03-121-3/+1
| | | | | | | | | We don't need to take a slice of SectionCommands in addOrphanSections() because it is not modified until the end of the function. Differential Revision: https://reviews.llvm.org/D59239 llvm-svn: 355954
* [LLD][ELF] - Show symbols visibility in "undefined symbol..." error messages.George Rimar2019-03-121-2/+8
| | | | | | | | | This teaches LLD to report visibility when showing undefined symbol errors and fixes https://bugs.llvm.org/show_bug.cgi?id=40770. Differential revision: https://reviews.llvm.org/D58577 llvm-svn: 355909
* ELF: Remove dead code. NFCI.Peter Collingbourne2019-03-121-3/+1
| | | | | | | | The Live bit is already set to false by SectionBase. Differential Revision: https://reviews.llvm.org/D59052 llvm-svn: 355893
* [ELF] Print a better error for an archive containing a non-ELF file.Eli Friedman2019-03-121-5/+7
| | | | | | | | | Hopefully gives a more readable error message for the most obvious mistake. Differential Revision: https://reviews.llvm.org/D59170 llvm-svn: 355888
* Include an archive file name in an error message for a corrupted file.Rui Ueyama2019-03-121-7/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D59212 llvm-svn: 355886
* [PGO] Add options for context-sensitive PGORong Xu2019-03-114-0/+15
| | | | | | | | Add lld options for CSPGO (context-sensitive PGO). Differential Revision: https://reviews.llvm.org/D56675 llvm-svn: 355876
* Fail early if an output file is not writableRui Ueyama2019-03-115-127/+2
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=36478 Differential Revision: https://reviews.llvm.org/D43664 llvm-svn: 355834
* [WebAssembly] Don't mark lazy symbols as `IsUsedInRegularObj`Sam Clegg2019-03-081-2/+2
| | | | | | | | | | | This matches the ELF does. Update the comment in ELF/Symbols.h and duplicate it in wasm/Symbols.h This a followup on rL355580 and rL355577. Differential Revision: https://reviews.llvm.org/D59075 llvm-svn: 355737
* ELF: Reduce the size of InputSectionBase by two words. NFCI.Peter Collingbourne2019-03-071-21/+21
| | | | | | | | | | | | - The Assigned bit was previously taking a word on its own. Move it into the bit fields in SectionBase. - NumRelocations and AreRelocsRela were previously also taking up a word despite only using half of it. Move them into the alignment gap after SectionBase's fields. Differential Revision: https://reviews.llvm.org/D59044 llvm-svn: 355622
* ELF: De-template OutputSection::finalize() and MipsGotSection::build(). NFCI.Peter Collingbourne2019-03-065-20/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D58810 llvm-svn: 355479
* ELF: Extract a non-ELFT base class for VersionNeedSection.Peter Collingbourne2019-03-064-42/+35
| | | | | | | | | | | We're going to need a separate VersionNeedSection for each partition, and the partition data structure won't be templated. With this the VersionTableSection class no longer needs ELFT, so detemplate it. Differential Revision: https://reviews.llvm.org/D58808 llvm-svn: 355478
* ELF: Change FileSize back to a uint64_t.Peter Collingbourne2019-03-011-3/+3
| | | | | | | | | This lets us detect file size overflows when creating a 64-bit binary on a 32-bit machine. Differential Revision: https://reviews.llvm.org/D58840 llvm-svn: 355218
* [ELF][ARM] Fix clang-armv7-linux-build-cache builds of LLD [NFC]Peter Smith2019-03-011-1/+1
| | | | | | | | r355153 introduced a build failure on a build bot that uses clang natively on an armv7-a machine. This a temporary fix to use size_t rather than uint64_t. llvm-svn: 355195
* ELF: Write .eh_frame_hdr explicitly after writing .eh_frame.Peter Collingbourne2019-02-286-40/+37
| | | | | | | | | | | This lets us remove the special case from Writer::writeSections(), and also fixes a bug where .eh_frame_hdr isn't necessarily written in the correct order if a linker script moves .eh_frame and .eh_frame_hdr into the same output section. Differential Revision: https://reviews.llvm.org/D58795 llvm-svn: 355153
* [DebugInfo] add SectionedAddress to DebugInfo interfaces.Alexey Lapshin2019-02-271-2/+13
| | | | | | | | | | | | | | | | | That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703 "wrong line number info for obj file compiled with -ffunction-sections" bug. The problem happened with only .o files. If object file contains several .text sections then line number information showed incorrectly. The reason for this is that DwarfLineTable could not detect section which corresponds to specified address(because address is the local to the section). And as the result it could not select proper sequence in the line table. The fix is to pass SectionIndex with the address. So that it would be possible to differentiate addresses from various sections. With this fix llvm-objdump shows correct line numbers for disassembled code. Differential review: https://reviews.llvm.org/D58194 llvm-svn: 354972
* [LLD][ELF] - Improve "sh_addralign is not a power of 2" diagnostics.George Rimar2019-02-271-1/+1
| | | | | | | | | | This patch removes the precompiled binary from inputs, replacing it with a YAML. And teaches LLD to report a section name in case of such error. Differential revision: https://reviews.llvm.org/D58670 llvm-svn: 354959
* Output ELF files after ThinLTO is run.Bill Wendling2019-02-261-12/+15
| | | | | | | | | | | | | | | | | | Summary: The gold linker allowed you to output the ELF files after LTO was run. It did it by using the 'obj-path' option. This replicates that behavior. Reviewers: espindola, ruiu, MaskRay, pcc Reviewed By: MaskRay, pcc Subscribers: grimar, emaste, inglorion, arichardson, steven_wu, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D56046 llvm-svn: 354917
OpenPOWER on IntegriCloud