|
Revision tags: llvmorg-20.1.0, llvmorg-20.1.0-rc3, llvmorg-20.1.0-rc2, llvmorg-20.1.0-rc1, llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2 |
|
| #
525ffb05 |
| 08-Aug-2022 |
Alex Brachet <[email protected]> |
[ELF] Support --package-metadata
This was recently introduced in GNU linkers and it makes sense for ld.lld to have the same support. This implementation omits checking if the input string is valid j
[ELF] Support --package-metadata
This was recently introduced in GNU linkers and it makes sense for ld.lld to have the same support. This implementation omits checking if the input string is valid json to reduce size bloat.
Differential Revision: https://reviews.llvm.org/D131439
(cherry picked from commit dbd04b853b680b0a383e5f58edf3643364f67bdf)
show more ...
|
|
Revision tags: llvmorg-15.0.0-rc1, llvmorg-16-init |
|
| #
85cfd917 |
| 24-Jul-2022 |
Fangrui Song <[email protected]> |
[ELF] Optimize some non-constant alignTo with alignToPowerOf2. NFC
My x86-64 lld executable is 2KiB smaller. .eh_frame writing gets faster as there were lots of divisions.
|
| #
51b9e099 |
| 15-Jul-2022 |
Fangrui Song <[email protected]> |
[ELF] Reword --no-allow-shlib-undefined diagnostic
Use a format more similar to unresolved references from regular object files. It's probably easier to read for people who are less familiar with th
[ELF] Reword --no-allow-shlib-undefined diagnostic
Use a format more similar to unresolved references from regular object files. It's probably easier to read for people who are less familiar with the linker diagnostics.
Reviewed By: ikudrin
Differential Revision: https://reviews.llvm.org/D129790
show more ...
|
| #
2324c2e3 |
| 12-Jul-2022 |
YongKang Zhu <[email protected]> |
[LLD] Two tweaks to symbol ordering scheme
When `--symbol-ordering-file` is specified, the linker today will always put hot contributions in the middle of cold ones when targeting RISC machine, so t
[LLD] Two tweaks to symbol ordering scheme
When `--symbol-ordering-file` is specified, the linker today will always put hot contributions in the middle of cold ones when targeting RISC machine, so to minimize the chances that branch thunks need be generated for hot code calling into cold code. This is not necessary when user specifies an ordering of read-only data (vs. function) symbols, or when output section is small such that no branch thunk would ever be required. The latter is common for mobile apps. For example, among all the native ARM64 libraries in Facebook Instagram App for Android, 80% of them have text section smaller than 64KB and the largest text section seen is less than 8MB, well below the distance that a BRANCH26 can reach.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D128382
show more ...
|
| #
6611d58f |
| 07-Jul-2022 |
Fangrui Song <[email protected]> |
[ELF] Relax R_RISCV_ALIGN
Alternative to D125036. Implement R_RISCV_ALIGN relaxation so that we can handle -mrelax object files (i.e. -mno-relax is no longer needed) and creates a framework for futu
[ELF] Relax R_RISCV_ALIGN
Alternative to D125036. Implement R_RISCV_ALIGN relaxation so that we can handle -mrelax object files (i.e. -mno-relax is no longer needed) and creates a framework for future relaxation.
`relaxAux` is placed in a union with InputSectionBase::jumpInstrMod, storing auxiliary information for relaxation. In the first pass, `relaxAux` is allocated. The main data structure is `relocDeltas`: when referencing `relocations[i]`, the actual offset is `r_offset - (i ? relocDeltas[i-1] : 0)`.
`relaxOnce` performs one relaxation pass. It computes `relocDeltas` for all text section. Then, adjust st_value/st_size for symbols relative to this section based on `SymbolAnchor`. `bytesDropped` is set so that `assignAddresses` knows that the size has changed.
Run `relaxOnce` in the `finalizeAddressDependentContent` loop to wait for convergence of text sections and other address dependent sections (e.g. SHT_RELR). Note: extrating `relaxOnce` into a separate loop works for many cases but has issues in some linker script edge cases.
After convergence, compute section contents: shrink the NOP sequence of each R_RISCV_ALIGN as appropriate. Instead of deleting bytes, we run a sequence of memcpy on the content delimitered by relocation locations. For R_RISCV_ALIGN let the next memcpy skip the desired number of bytes. Section content computation is parallelizable, but let's ensure the implementation is mature before optimizations. Technically we can save a copy if we interleave some code with `OutputSection::writeTo`, but let's not pollute the generic code (we don't have templated relocation resolving, so using conditions can impose overhead to non-RISCV.)
Tested: `make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- LLVM=1 defconfig all` built Linux kernel using -mrelax is bootable. FreeBSD RISCV64 system using -mrelax is bootable. bash/curl/firefox/libevent/vim/tmux using -mrelax works.
Differential Revision: https://reviews.llvm.org/D127581
show more ...
|
| #
e0612c91 |
| 06-Jul-2022 |
Fangrui Song <[email protected]> |
[ELF] Optimize getInputSections. NFC
In the majority of cases (e.g. orphan sections), an OutputSection has at most one InputSectionDescription (isd). By changing the return type to ArrayRef<InputSec
[ELF] Optimize getInputSections. NFC
In the majority of cases (e.g. orphan sections), an OutputSection has at most one InputSectionDescription (isd). By changing the return type to ArrayRef<InputSection *> we can just reference the isd->sections. For OutputSections with more than one InputSectionDescription we use a caller provided SmallVector to copy the elements as before.
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D129111
show more ...
|
| #
9a572164 |
| 30-Jun-2022 |
Fangrui Song <[email protected]> |
[ELF] Move InputFiles global variables (memoryBuffers, objectFiles, etc) into Ctx. NFC
|
|
Revision tags: llvmorg-14.0.6 |
|
| #
7effcbda |
| 19-Jun-2022 |
Nico Weber <[email protected]> |
Rename parallelForEachN to just parallelFor
Patch created by running:
rg -l parallelForEachN | xargs sed -i '' -c 's/parallelForEachN/parallelFor/'
No behavior change.
Differential Revision: ht
Rename parallelForEachN to just parallelFor
Patch created by running:
rg -l parallelForEachN | xargs sed -i '' -c 's/parallelForEachN/parallelFor/'
No behavior change.
Differential Revision: https://reviews.llvm.org/D128140
show more ...
|
|
Revision tags: llvmorg-14.0.5, llvmorg-14.0.4 |
|
| #
2ac8ce5d |
| 13-May-2022 |
Fangrui Song <[email protected]> |
Revert D125410 "[ELF] Align the end of PT_GNU_RELRO to max-page-size instead of common-page-size"
This reverts commit ebdb9d635a077274e38baa8584f5b0e631b4b1d3.
Changing p_memsz is insufficient and
Revert D125410 "[ELF] Align the end of PT_GNU_RELRO to max-page-size instead of common-page-size"
This reverts commit ebdb9d635a077274e38baa8584f5b0e631b4b1d3.
Changing p_memsz is insufficient and may make PT_GNU_RELRO extend beyond the PT_LOAD.
show more ...
|
| #
ebdb9d63 |
| 12-May-2022 |
Fangrui Song <[email protected]> |
[ELF] Align the end of PT_GNU_RELRO to max-page-size instead of common-page-size
We picked common-page-size to match GNU ld. Recently, the resolution to GNU ld https://sourceware.org/bugzilla/show_b
[ELF] Align the end of PT_GNU_RELRO to max-page-size instead of common-page-size
We picked common-page-size to match GNU ld. Recently, the resolution to GNU ld https://sourceware.org/bugzilla/show_bug.cgi?id=28824 (milestone: 2.39) switched to max-page-size so that the last page can be protected by RELRO in case the system page size is larger than common-page-size.
Thanks to our two RW PT_LOAD scheme (D58892), switching to max-page-size does not change file size (while GNU ld's scheme may increase file size).
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D125410
show more ...
|
| #
5a44980f |
| 04-May-2022 |
Fangrui Song <[email protected]> |
[ELF] Support custom sections between DATA_SEGMENT_ALIGN and DATA_SEGMENT_RELRO_END
We currently hard code RELRO sections. When a custom section is between DATA_SEGMENT_ALIGN and DATA_SEGMENT_RELRO_
[ELF] Support custom sections between DATA_SEGMENT_ALIGN and DATA_SEGMENT_RELRO_END
We currently hard code RELRO sections. When a custom section is between DATA_SEGMENT_ALIGN and DATA_SEGMENT_RELRO_END, we may report a spurious `error: section: ... is not contiguous with other relro sections`. GNU ld makes such sections RELRO.
glibc recently switched to default --with-default-link=no. This configuration places `__libc_atexit` and others between DATA_SEGMENT_ALIGN and DATA_SEGMENT_RELRO_END. This patch allows such a ld.bfd --verbose linker script to be fed into lld.
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D124656
show more ...
|
|
Revision tags: llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1 |
|
| #
be01af4a |
| 07-Apr-2022 |
Fangrui Song <[email protected]> |
[ELF] Fix non-relocatable-non-emit-relocs --gc-sections to discard .L symbols
This reverts commit 764cd491b126318add093c7c8ba3884967d64b21, which I incorrectly assumed NFC partly because there were
[ELF] Fix non-relocatable-non-emit-relocs --gc-sections to discard .L symbols
This reverts commit 764cd491b126318add093c7c8ba3884967d64b21, which I incorrectly assumed NFC partly because there were no test coverage for the non-relocatable non-emit-relocs case before 9d6d936243fe343abe89323a27c7241b395af541.
The interaction of {,-r,--emit-relocs} {,--discard-locals} {,--gc-sections} is complex but without -r/--emit-relocs, --gc-sections does need to discard .L symbols like --no-gc-sections. The behavior matches GNU ld.
show more ...
|
|
Revision tags: llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2 |
|
| #
786c89fe |
| 09-Feb-2022 |
Mitch Phillips <[email protected]> |
[ELF][MTE] Add --android-memtag-* options to synthesize ELF notes
This ELF note is aarch64 and Android-specific. It specifies to the dynamic loader that specific work should be scheduled to enable M
[ELF][MTE] Add --android-memtag-* options to synthesize ELF notes
This ELF note is aarch64 and Android-specific. It specifies to the dynamic loader that specific work should be scheduled to enable MTE protection of stack and heap regions.
Current synthesis of the ".note.android.memtag" ELF note is done in the Android build system. We'd like to move that to the compiler. This patch adds the --memtag-stack, --memtag-heap, and --memtag-mode={async, sync, none} flags to the linker, which synthesises the note for us.
Future changes will add -fsanitize=memtag* flags to clang which will pass these through to lld.
Depends on D119381.
Differential Revision: https://reviews.llvm.org/D119384
show more ...
|
| #
7370a489 |
| 29-Mar-2022 |
Fangrui Song <[email protected]> |
[ELF] --emit-relocs: fix missing STT_SECTION when the first input section is synthetic
addSectionSymbols suppresses the STT_SECTION symbol if the first input section is non-SHF_MERGE synthetic. This
[ELF] --emit-relocs: fix missing STT_SECTION when the first input section is synthetic
addSectionSymbols suppresses the STT_SECTION symbol if the first input section is non-SHF_MERGE synthetic. This is incorrect when the first input section is synthetic while a non-synthetic input section exists:
* `.bss : { *(COMMON) *(.bss) }` (abc388ed3cf0ef7e617ebe243d3b0b32d29e69a5 regressed the case because COMMON symbols precede .bss in the absence of a linker script) * Place a synthetic section in another section: `.data : { *(.got) *(.data) }`
For `%t/a1` in the new test emit-relocs-synthetic.s, ld.lld produces incorrect relocations with symbol index 0. ``` 0000000000000000 <_start>: 0: 8b 05 33 00 00 00 movl 51(%rip), %eax # 0x39 <bss> 0000000000000002: R_X86_64_PC32 *ABS*+0xd 6: 8b 05 1c 00 00 00 movl 28(%rip), %eax # 0x28 <common> 0000000000000008: R_X86_64_PC32 common-0x4 c: 8b 05 06 00 00 00 movl 6(%rip), %eax # 0x18 000000000000000e: R_X86_64_GOTPCRELX *ABS*+0x4 ```
Fix the issue by checking every input section.
Reviewed By: ikudrin
Differential Revision: https://reviews.llvm.org/D122463
show more ...
|
| #
8565a87f |
| 28-Mar-2022 |
Fangrui Song <[email protected]> |
[ELF] Simplify MergeInputSection::getParentOffset. NFC
and remove overly verbose comments.
|
| #
940bd4c7 |
| 25-Mar-2022 |
Fangrui Song <[email protected]> |
[ELF] addSectionSymbols: simplify isec->getOutputSection(). NFC
|
| #
d3e5b6f7 |
| 24-Mar-2022 |
Fangrui Song <[email protected]> |
[ELF] Implement --build-id={md5,sha1} with truncated BLAKE3
--build-id was introduced as "approximation of true uniqueness across all binaries that might be used by overlapping sets of people". It d
[ELF] Implement --build-id={md5,sha1} with truncated BLAKE3
--build-id was introduced as "approximation of true uniqueness across all binaries that might be used by overlapping sets of people". It does not require the some resistance mentioned below. In practice, people just use --build-id=md5 for 16-byte build ID and --build-id=sha1 for 20-byte build ID.
BLAKE3 has 256-bit key length, which provides 128-bit security against (second-)preimage, collision, and differentiability attacks. Its portable implementation is fast. It additionally provides Arm Neon/AVX2/AVX-512. Just implement --build-id={md5,sha1} with truncated BLAKE3.
Linking clang 14 RelWithDebInfo with --threads=8 on a Skylake CPU:
* 1.13x as fast with --build-id=md5 * 1.15x as fast with --build-id=sha1
--threads=4 on Apple m1:
* 1.25x as fast with --build-id=md5 * 1.17x as fast with --build-id=sha1
Reviewed By: ikudrin
Differential Revision: https://reviews.llvm.org/D121531
show more ...
|
| #
6c814931 |
| 08-Mar-2022 |
Fangrui Song <[email protected]> |
[ELF] Don't use multiple inheritance for OutputSection. NFC
Add an OutputDesc class inheriting from SectionCommand. An OutputDesc wraps an OutputSection. This change allows InputSection::getParent t
[ELF] Don't use multiple inheritance for OutputSection. NFC
Add an OutputDesc class inheriting from SectionCommand. An OutputDesc wraps an OutputSection. This change allows InputSection::getParent to be inlined.
Differential Revision: https://reviews.llvm.org/D120650
show more ...
|
| #
9e9c86fd |
| 28-Feb-2022 |
Fangrui Song <[email protected]> |
[ELF] Change some non-null pointer parameters to references. NFC
To decrease difference for D120650. Also, rename some `OutputSection *sec` (and `cmd`) to the more common `osec`.
|
| #
8d01ac75 |
| 28-Feb-2022 |
Fangrui Song <[email protected]> |
[ELF] Replace an unneeded dyn_cast_or_null with dyn_cast. NFC
|
| #
7fd3849b |
| 27-Feb-2022 |
Fangrui Song <[email protected]> |
[ELF] Move --print-archive-stats= and --why-extract= beside --warn-backrefs report
So that early errors don't suppress their output.
|
| #
8ca46bba |
| 24-Feb-2022 |
Fangrui Song <[email protected]> |
[ELF] Move isUsedInRegularObj assignment from ctor to call sites. NFC
This removes the tricky `isUsedInRegularObj(!file || file->kind() == InputFile::ObjKind)` and the copy from `Symbol::mergeProper
[ELF] Move isUsedInRegularObj assignment from ctor to call sites. NFC
This removes the tricky `isUsedInRegularObj(!file || file->kind() == InputFile::ObjKind)` and the copy from `Symbol::mergeProperties`.
show more ...
|
| #
b01430a0 |
| 24-Feb-2022 |
Fangrui Song <[email protected]> |
[ELF] Don't rely on Symbols.h's transitive inclusion of InputFiles.h. NFC
|
| #
fc0aa842 |
| 23-Feb-2022 |
Fangrui Song <[email protected]> |
[ELF] Check COMMON symbols for PROVIDE and don't redefine COMMON symbols edata/end/etext
In GNU ld, the definition precedence is: regular symbol assignment > relocatable object definition > `PROVIDE
[ELF] Check COMMON symbols for PROVIDE and don't redefine COMMON symbols edata/end/etext
In GNU ld, the definition precedence is: regular symbol assignment > relocatable object definition > `PROVIDE` symbol assignment.
GNU ld's internal linker scripts define the non-reserved (by C and C++) edata/end/etext with `PROVIDE` so the relocatable object definition takes precedence. This makes sense because `int end;` is valid.
We currently redefine such symbols if they are COMMON, but not if they are regular definitions, so `int end;` with -fcommon is essentially a UB in ld.lld. Fix this (also improve consistency and match GNU ld) by using the `isDefined` code path for `isCommon`. In GNU ld, reserved identifiers like `__ehdr_start` do not use `PROVIDE`, while we treat them all as `PROVIDE`, this seems fine.
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D120389
show more ...
|
| #
ae1ba619 |
| 21-Feb-2022 |
Fangrui Song <[email protected]> |
[ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC
In many call sites we know uncompression cannot happen (non-SHF_ALLOC, or the data (even if compressed) must have been uncompres
[ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC
In many call sites we know uncompression cannot happen (non-SHF_ALLOC, or the data (even if compressed) must have been uncompressed by a previous pass). Prefer rawData in these cases. data() increases code size and prevents optimization on rawData.
show more ...
|