| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
ELF: Add support for relocating R_AARCH64_FUNCINIT64. R_AARCH64_FUNCINIT64 is a dynamic relocation type for relocating word-sized data in the output file using the return value of a function. An R_AARCH64_FUNCINIT64 shall be relocated as an R_AARCH64_IRELATIVE with the target symbol address if the target symbol is non-preemptible, and it shall be a usage error to relocate an R_AARCH64_FUNCINIT64 with a preemptible or STT_GNU_IFUNC target symbol. The initial use case for this relocation type shall be for emitting global variable field initializers for structure protection. With structure protection, the relocation value computation is tied to the compiler implementation in such a way that it would not be reasonable to define a relocation type for it (for example, it may involve computing a hash using a compiler-determined algorithm), hence the need for the computation to be implemented as code in the binary. Part of the AArch64 psABI extension: https://github.com/ARM-software/abi-aa/issues/340 Reviewers: smithp35, fmayer, MaskRay Reviewed By: fmayer Pull Request: https://github.com/llvm/llvm-project/pull/156564 | 8 个月前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[ELF] Pass Ctx & | 1 年前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[ELF] Pass Ctx & to Arch/ | 1 年前 | |
[lld][ELF] filter out section symbols when use BP reorder (#151685) When using Temporal Profiling with the BP algorithm, we encounter an issue with the internal function reorder. In cases where the symbol table contains entries like: Symbol table '.symtab' contains 45 entries: Num: Value Size Type Bind Vis Ndx Name 10: 0000000000000000 0 SECTION LOCAL DEFAULT 18 .text.L1 11: 0000000000000000 24 FUNC LOCAL DEFAULT 18 L1 ` The zero-sized section symbol .text.L1 gets stored in the secToSym map first. However, when the function lookup searches for L1 (as seen in [BPSectionOrdererBase.inc:191](https://github.com/llvm/llvm-project/blob/main/lld/include/lld/Common/BPSectionOrdererBase.inc#L191)), it fails to find the correct entry in rootSymbolToSectionIdxs because the section symbol has already claimed that slot. This patch fixes the issue by skipping zero-sized symbols during the addSections process, ensuring that function symbols are properly registered for lookup. | 11 个月前 | |
[ELF] Add BPSectionOrderer options (#125559) Reland #120514 after 2f6e3df08a8b7cd29273980e47310cf09c6fdbd8 fixed iteration order issue and libstdc++/libc++ differences. --- Both options instruct the linker to optimize section layout with the following goals: * --bp-compression-sort=[data|function|both]: Improve Lempel-Ziv compression by grouping similar sections together, resulting in a smaller compressed app size. * --bp-startup-sort=function --irpgo-profile=<file>: Utilize a temporal profile file to reduce page faults during program startup. The linker determines the section order by considering three groups: * Function sections ordered according to the temporal profile (--irpgo-profile=), prioritizing early-accessed and frequently accessed functions. * Function sections. Sections containing similar functions are placed together, maximizing compression opportunities. * Data sections. Similar data sections are placed together. Within each group, the sections are ordered using the Balanced Partitioning algorithm. The linker constructs a bipartite graph with two sets of vertices: sections and utility vertices. * For profile-guided function sections: + The number of utility vertices is determined by the symbol order within the profile file. + If --bp-compression-sort-startup-functions is specified, extra utility vertices are allocated to prioritize nearby function similarity. * For sections ordered for compression: Utility vertices are determined by analyzing k-mers of the section content and relocations. The call graph profile is disabled during this optimization. When --symbol-ordering-file= is specified, sections described in that file are placed earlier. Co-authored-by: Pengying Xu <xpy66swsry@gmail.com> | 1 年前 | |
[ELF] Add BPSectionOrderer options (#125559) Reland #120514 after 2f6e3df08a8b7cd29273980e47310cf09c6fdbd8 fixed iteration order issue and libstdc++/libc++ differences. --- Both options instruct the linker to optimize section layout with the following goals: * --bp-compression-sort=[data|function|both]: Improve Lempel-Ziv compression by grouping similar sections together, resulting in a smaller compressed app size. * --bp-startup-sort=function --irpgo-profile=<file>: Utilize a temporal profile file to reduce page faults during program startup. The linker determines the section order by considering three groups: * Function sections ordered according to the temporal profile (--irpgo-profile=), prioritizing early-accessed and frequently accessed functions. * Function sections. Sections containing similar functions are placed together, maximizing compression opportunities. * Data sections. Similar data sections are placed together. Within each group, the sections are ordered using the Balanced Partitioning algorithm. The linker constructs a bipartite graph with two sets of vertices: sections and utility vertices. * For profile-guided function sections: + The number of utility vertices is determined by the symbol order within the profile file. + If --bp-compression-sort-startup-functions is specified, extra utility vertices are allocated to prioritize nearby function similarity. * For sections ordered for compression: Utility vertices are determined by analyzing k-mers of the section content and relocations. The call graph profile is disabled during this optimization. When --symbol-ordering-file= is specified, sections described in that file are placed earlier. Co-authored-by: Pengying Xu <xpy66swsry@gmail.com> | 1 年前 | |
[ELF] Allow --symbol-ordering-file and call graph profile to be used together Port https://reviews.llvm.org/D117354 from the MachO port. If both --symbol-ordering-file and call graph profile are present, the --symbol-ordering-file takes precedence, but the call graph profile is still used for symbols that don't appear in the order file. In addition, call graph profile described sections are now ordered before other sections. | 1 年前 | |
[ELF] Internalize computeCacheDirectedSortOrder. NFC and delete an incorremtn comment about ctx.arg.callGraphProfile | 1 年前 | |
[DTLTO][Clang][LLD] Fix DTLTO for multi-call LLVM driver toolchain (#162456) Add DTLTO linker option --thinlto-remote-compiler-prepend-arg to enable support for the multi-call LLVM driver that requires an additional option to specify the subcommand, e.g. "llvm clang ...". Fixes https://github.com/llvm/llvm-project/issues/159125. | 9 个月前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[lld] Add missing includes. (#143453) Some inline methods in these headers require a complete type but the corresponding include was missing. | 1 年前 | |
[ADT] Prepare to deprecate variadic StringSwitch::Cases. NFC. (#166020) Update all uses of variadic .Cases to use the initializer list overload instead. I plan to mark variadic .Cases as deprecated in a followup PR. For more context, see https://github.com/llvm/llvm-project/pull/163117. | 8 个月前 | |
[ELF] Migrate away from global ctx | 1 年前 | |
Rework the Option library to reduce dynamic relocations (#119198) Apologies for the large change, I looked for ways to break this up and all of the ones I saw added real complexity. This change focuses on the option's prefixed names and the array of prefixes. These are present in every option and the dominant source of dynamic relocations for PIE or PIC users of LLVM and Clang tooling. In some cases, 100s or 1000s of them for the Clang driver which has a huge number of options. This PR addresses this by building a string table and a prefixes table that can be referenced with indices rather than pointers that require dynamic relocations. This removes almost 7k dynmaic relocations from the clang binary, roughly 8% of the remaining dynmaic relocations outside of vtables. For busy-boxing use cases where many different option tables are linked into the same binary, the savings add up a bit more. The string table is a straightforward mechanism, but the prefixes required some subtlety. They are encoded in a Pascal-string fashion with a size followed by a sequence of offsets. This works relatively well for the small realistic prefixes arrays in use. Lots of code has to change in order to land this though: both all the option library code has to be updated to use the string table and prefixes table, and all the users of the options library have to be updated to correctly instantiate the objects. Some follow-up patches in the works to provide an abstraction for this style of code, and to start using the same technique for some of the other strings here now that the infrastructure is in place. | 1 年前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[lld/elf] Use C++17 nested namespace syntax in most places Like D131405, but for ELF. No behavior change. Differential Revision: https://reviews.llvm.org/D131612 | 3 年前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[ELF] Pass Ctx & to ICF and SymbolTable | 1 年前 | |
ELF: Use index 0 for unversioned undefined symbols (#168189) The GNU documentation is ambiguous about the version index for unversioned undefined symbols. The current specification at https://sourceware.org/gnu-gabi/program-loading-and-dynamic-linking.txt defines VER_NDX_LOCAL (0) as "The symbol is private, and is not available outside this object." However, this naming is misleading for undefined symbols. As suggested in discussions, VER_NDX_LOCAL should conceptually be VER_NDX_NONE and apply to unversioned undefined symbols as well. GNU ld has used index 0 for unversioned undefined symbols both before version 2.35 (see https://sourceware.org/PR26002) and in the upcoming 2.46 release (see https://sourceware.org/PR33577). This change aligns with GNU ld's behavior by switching from index 1 to index 0. While here, add a test to dso-undef-extract-lazy.s that undefined symbols of index 0 in DSO are treated as unversioned symbols. | 8 个月前 | |
[lld] Refactor storage of PAuth ABI core info (#141920) Previously, the AArch64 PAuth ABI core values were stored as an ArrayRef<uint8_t>, introducing unnecessary indirection. This patch replaces the ArrayRef with two explicit uint64_t fields: aarch64PauthAbiPlatform and aarch64PauthAbiVersion. This simplifies the representation and improves readability. No functional change intended, aside from improved error messages. | 1 年前 | |
ELF: Use preprocessed relocations for EhInputSection scanning .eh_frame sections require special sub-section processing, specifically, CIEs are de-duplicated and FDEs are garbage collected. Create a specialized scanEhSection() function utilizing the just-added EhInputSection::rels. OffsetGetter is moved to scanEhSection. This improves separation of concerns between InputSection and EhInputSection processing. This removes another relsOrRelas call using supportsCrel=false. DWARF.cpp now has the last call. Pull Request: https://github.com/llvm/llvm-project/pull/161091 | 9 个月前 | |
ELF: Store EhInputSection relocations to simplify code. NFC Store relocations directly as SmallVector<Relocation, 0> within EhInputSection to avoid processing different relocation formats (REL/RELA/CREL) throughout the codebase. Next: Refactor RelocationScanner to utilize EhInputSection::rels Pull Request: https://github.com/llvm/llvm-project/pull/161041 | 9 个月前 | |
[DTLTO][Clang][LLD] Fix DTLTO for multi-call LLVM driver toolchain (#162456) Add DTLTO linker option --thinlto-remote-compiler-prepend-arg to enable support for the multi-call LLVM driver that requires an additional option to specify the subcommand, e.g. "llvm clang ...". Fixes https://github.com/llvm/llvm-project/issues/159125. | 9 个月前 | |
[ELF] Move InputFile storage from make<> to LinkerDriver::files | 1 年前 | |
[ELF] -r/--emit-relocs: Fix crash when processing .rela.text before .text (#156354) fixes #156417 When the relocation section is placed before the relocated section and the relocated section is not defined in the linker script, an error will occur during the linking process. **Issue Cause:** In a.ro, .rela.text precedes its relocated InputSection .text. addOrphanSections doesn't handle this scenario. When it processes .rela.text, in the called getOutputSectionName, rel->getOutputSection() is nullptr (input .text doesn't yet have a parent output section), leading to an assertion failure. **Solution:** For --emit-relocs and -r, ensure the output section for .text.foo is created before the output section for .rela.text.foo. --------- Co-authored-by: Fangrui Song <i@maskray.me> | 10 个月前 | |
[LLD][ELF] Allow memory region in OVERLAY (#133540) This allows the contents of OVERLAYs to be attributed to memory regions. This is the only clean way to overlap VMAs in linker scripts that choose to primarily use memory regions to lay out addresses. This also simplifies OVERLAY expansion to better match GNU LD. Expressions for the first section's LMA and VMA are not generated if the user did not provide them. This allows the LMA/VMA offset to be preserved across multiple overlays in the same region, as with regular sections. Closes #129816 | 1 年前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[ELF] Pass Ctx & to MapFile | 1 年前 | |
ELF: Store EhInputSection relocations to simplify code. NFC Store relocations directly as SmallVector<Relocation, 0> within EhInputSection to avoid processing different relocation formats (REL/RELA/CREL) throughout the codebase. Next: Refactor RelocationScanner to utilize EhInputSection::rels Pull Request: https://github.com/llvm/llvm-project/pull/161041 | 9 个月前 | |
[ELF] Pass Ctx & to MarkLive | 1 年前 | |
[DTLTO][Clang][LLD] Fix DTLTO for multi-call LLVM driver toolchain (#162456) Add DTLTO linker option --thinlto-remote-compiler-prepend-arg to enable support for the multi-call LLVM driver that requires an additional option to specify the subcommand, e.g. "llvm clang ...". Fixes https://github.com/llvm/llvm-project/issues/159125. | 9 个月前 | |
[ELF][LoongArch] -r: Synthesize R_LARCH_ALIGN at input section start (#153935) Similay to https://github.com/llvm/llvm-project/commit/94655dc8aec2f4e4b287e4c6ac829263f93e9740 The difference is that in LoongArch, the ALIGN is synthesized when the alignment is >4, (instead of >=4), and the number of bytes inserted is sec->addralign - 4. | 11 个月前 | |
[LLD][ELF] Allow memory region in OVERLAY (#133540) This allows the contents of OVERLAYs to be attributed to memory regions. This is the only clean way to overlap VMAs in linker scripts that choose to primarily use memory regions to lay out addresses. This also simplifies OVERLAY expansion to better match GNU LD. Expressions for the first section's LMA and VMA are not generated if the user did not provide them. This allows the LMA/VMA offset to be preserved across multiple overlays in the same region, as with regular sections. Closes #129816 | 1 年前 | |
Update the documents of the new LLD. This patch merges the documents for ELF and COFF into one and puts it into docs directory. llvm-svn: 263336 | 10 年前 | |
[ELF] Refactor RelocScan::scan to be target-specific (#163138) - Extract RelocScan to RelocScan.h. The file includes Target.h, and cannot be merged with Relocations.h - Add MIPS and PPC64 specific relocation scanners, removing runtime checks for other targets. This refactoring prepares the codebase for better target-specific optimizations and easier addition of target-specific behavior. | 9 个月前 | |
ELF: Add support for relocating R_AARCH64_FUNCINIT64. R_AARCH64_FUNCINIT64 is a dynamic relocation type for relocating word-sized data in the output file using the return value of a function. An R_AARCH64_FUNCINIT64 shall be relocated as an R_AARCH64_IRELATIVE with the target symbol address if the target symbol is non-preemptible, and it shall be a usage error to relocate an R_AARCH64_FUNCINIT64 with a preemptible or STT_GNU_IFUNC target symbol. The initial use case for this relocation type shall be for emitting global variable field initializers for structure protection. With structure protection, the relocation value computation is tied to the compiler implementation in such a way that it would not be reasonable to define a relocation type for it (for example, it may involve computing a hash using a compiler-determined algorithm), hence the need for the computation to be implemented as code in the binary. Part of the AArch64 psABI extension: https://github.com/ARM-software/abi-aa/issues/340 Reviewers: smithp35, fmayer, MaskRay Reviewed By: fmayer Pull Request: https://github.com/llvm/llvm-project/pull/156564 | 8 个月前 | |
[ELF] Refactor RelocScan::scan to be target-specific (#163138) - Extract RelocScan to RelocScan.h. The file includes Target.h, and cannot be merged with Relocations.h - Add MIPS and PPC64 specific relocation scanners, removing runtime checks for other targets. This refactoring prepares the codebase for better target-specific optimizations and easier addition of target-specific behavior. | 9 个月前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[ELF] Replace inExpr with lexState. NFC We may add another state State::Wild to behave more lik GNU ld. | 1 年前 | |
[ADT] Prepare to deprecate variadic StringSwitch::Cases. NFC. (#166020) Update all uses of variadic .Cases to use the initializer list overload instead. I plan to mark variadic .Cases as deprecated in a followup PR. For more context, see https://github.com/llvm/llvm-project/pull/163117. | 8 个月前 | |
[ELF] ScriptParser: pass Ctx to ScriptParser and ScriptLexer. NFC | 1 年前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
Revert "[lld] Merge equivalent symbols found during ICF (#134342)" The change would also merge *non-equivalent* symbols under some circumstances, see comment with a reproducer on the PR. > Fixes a correctness issue for AArch64 when ADRP and LDR instructions are > outlined in separate sections and sections are fed to ICF for > deduplication. > > See test case (based on > https://github.com/llvm/llvm-project/issues/129122) for details. All > rodata.* sections are folded into a single section with ICF. This leads > to all f2_* function sections getting folded into one (as their > relocation target symbols g* belong to .rodata.g* sections that have > already been folded into one). Since relocations still refer original g* > symbols, we end up creating duplicate GOT entry for all such symbols. > This PR addresses that by tracking such folded symbols and create one > GOT entry for all such symbols. > > Fixes https://github.com/llvm/llvm-project/issues/129122 > > Co-authored by: @jyknight This reverts commit 8389d6fad76bd880f02bddce7f0f2612ff0afc40. | 1 年前 | |
[lld] Replace LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]] (NFC) (#163701) This patch replaces LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]], introduced as part of C++17. | 9 个月前 | |
ELF: Use index 0 for unversioned undefined symbols (#168189) The GNU documentation is ambiguous about the version index for unversioned undefined symbols. The current specification at https://sourceware.org/gnu-gabi/program-loading-and-dynamic-linking.txt defines VER_NDX_LOCAL (0) as "The symbol is private, and is not available outside this object." However, this naming is misleading for undefined symbols. As suggested in discussions, VER_NDX_LOCAL should conceptually be VER_NDX_NONE and apply to unversioned undefined symbols as well. GNU ld has used index 0 for unversioned undefined symbols both before version 2.35 (see https://sourceware.org/PR26002) and in the upcoming 2.46 release (see https://sourceware.org/PR33577). This change aligns with GNU ld's behavior by switching from index 1 to index 0. While here, add a test to dso-undef-extract-lazy.s that undefined symbols of index 0 in DSO are treated as unversioned symbols. | 8 个月前 | |
ELF: Use index 0 for unversioned undefined symbols (#168189) The GNU documentation is ambiguous about the version index for unversioned undefined symbols. The current specification at https://sourceware.org/gnu-gabi/program-loading-and-dynamic-linking.txt defines VER_NDX_LOCAL (0) as "The symbol is private, and is not available outside this object." However, this naming is misleading for undefined symbols. As suggested in discussions, VER_NDX_LOCAL should conceptually be VER_NDX_NONE and apply to unversioned undefined symbols as well. GNU ld has used index 0 for unversioned undefined symbols both before version 2.35 (see https://sourceware.org/PR26002) and in the upcoming 2.46 release (see https://sourceware.org/PR33577). This change aligns with GNU ld's behavior by switching from index 1 to index 0. While here, add a test to dso-undef-extract-lazy.s that undefined symbols of index 0 in DSO are treated as unversioned symbols. | 8 个月前 | |
Remove shadowing "size" field from classes that inherit from SyntheticSection (#166323) A field-named 'size' already available and perfectly usable via inheritance from InputSection, and these variables shadow it for no good reason. The only interesting change here is in PaddingSection, because a parent's field cannot be initialized via a constructor initializer list, setting it needs to be done inside the constructor body. | 8 个月前 | |
[ELF] Refactor RelocScan::scan to be target-specific (#163138) - Extract RelocScan to RelocScan.h. The file includes Target.h, and cannot be merged with Relocations.h - Add MIPS and PPC64 specific relocation scanners, removing runtime checks for other targets. This refactoring prepares the codebase for better target-specific optimizations and easier addition of target-specific behavior. | 9 个月前 | |
ELF: Add support for relocating R_AARCH64_FUNCINIT64. R_AARCH64_FUNCINIT64 is a dynamic relocation type for relocating word-sized data in the output file using the return value of a function. An R_AARCH64_FUNCINIT64 shall be relocated as an R_AARCH64_IRELATIVE with the target symbol address if the target symbol is non-preemptible, and it shall be a usage error to relocate an R_AARCH64_FUNCINIT64 with a preemptible or STT_GNU_IFUNC target symbol. The initial use case for this relocation type shall be for emitting global variable field initializers for structure protection. With structure protection, the relocation value computation is tied to the compiler implementation in such a way that it would not be reasonable to define a relocation type for it (for example, it may involve computing a hash using a compiler-determined algorithm), hence the need for the computation to be implemented as code in the binary. Part of the AArch64 psABI extension: https://github.com/ARM-software/abi-aa/issues/340 Reviewers: smithp35, fmayer, MaskRay Reviewed By: fmayer Pull Request: https://github.com/llvm/llvm-project/pull/156564 | 8 个月前 | |
[lld] Add thunks for hexagon (#111217) Without thunks, programs will encounter link errors complaining that the branch target is out of range. Thunks will extend the range of branch targets, which is a critical need for large programs. Thunks provide this flexibility at a cost of some modest code size increase. When configured with the maximal feature set, the hexagon port of the linux kernel would often encounter these limitations when linking with lld. The relocations which will be extended by thunks are: * R_HEX_B22_PCREL, R_HEX_{G,L}D_PLT_B22_PCREL, R_HEX_PLT_B22_PCREL relocations have a range of ± 8MiB on the baseline * R_HEX_B15_PCREL: ±65,532 bytes * R_HEX_B13_PCREL: ±16,380 bytes * R_HEX_B9_PCREL: ±1,020 bytes Fixes #149689 Co-authored-by: Alexey Karyakin <akaryaki@quicinc.com> --------- Co-authored-by: Alexey Karyakin <akaryaki@quicinc.com> | 1 年前 | |
[ELF] Make ThunkCreator take ownership of thunks This removes many SpecificAlloc instantiations and makes my lld (x86-64 Release+Assertions) smaller by ~36k. | 1 年前 | |
ELF: Rename RandomizePaddingSection to PaddingSection. This section type is about to be used by #147424 so let's give it a more generic name. Reviewers: smithp35, MaskRay Reviewed By: MaskRay Pull Request: https://github.com/llvm/llvm-project/pull/155540 | 8 个月前 | |
[ELF] Move PhdrEntry to SyntheticSections The next change will change Partition::phdrs to a unique_ptr vector, which requires PhdrEntry to be a complete type. And make OutputSection::getLMA out-of-line, since it should not include either SyntheticSections.h or Writer.h. | 1 年前 |
See docs/NewLLD.rst