Structs with delicate packing are often larger in MSVC than Itanium.
099a52fd2f3723db6b0550c99a1adc12d2d8d909 did not make
sizeof(InputSection) smaller for MSVC. Just exclude MSVC.
Store them in LinkerScript::descPool. This removes a SpecificAlloc
instantiation, makes lld smaller, and drops the small memory waste due
to the separate BumpPtrAllocator.
Move `sectionKind` outside the bitfield and move bss/keepUnique to
InputSectionBase.
* sizeof(InputSection) decreases from 160 to 152 on 64-bit systems.
* The numerous `sectionKind` accesses are faster.
Follow-up to the NFC refactoring
43e3871a327b8e2ff57e16b46d5bc44beb430d91 and test cleanup
3cecf17065919da0a7fa9b38f37592e5462c2f85.
SHF_MERGE sections with relocations are handled as InputSection (without
duplicate elimination). The output section retains the original
sh_entsize in non-relocatable links. This patch ports the behavior for
relocatable links as well.
https://github.com/ClangBuiltLinux/linux/issues/2057
SectionBase, InputSectionBase, InputSection, MergeInputSection, and
OutputSection have different member orders. Make them consistent and
adopt the order similar to the raw Elf64_Shdr.
When we create a thunk we don't know whether it will be short or long.
Move the emission of the long thunk mapping symbol to when we transition
to a long thunk. This improves disassembly and binary analysis as tools
like BOLT identify thunks by disassembly.
This removes a FIXME added in #108989 aarch64-thunk-bti-multipass.s
which had a corrupt disassembly due to missing mapping symbols.
Rename R_X86_64_REX2_GOTPCRELX to R_X86_64_CODE_4_GOTPCRELX, to align
with GCC/binutils and ABI.
GCC/binutils:
3d5a60de52
and
4a54cb0658
ABI:
357de358ba
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.
Range checks for R_HEX_B22_PCREL did not account for the fact that
offset is measured in instructions, not bytes.
Add a test for all range-checked relocations.
Assume PAC instructions being supported with PAuth core info different from (0,0). The (0,0) value means that an ELF file is incompatible with PAuth - see https://github.com/ARM-software/abi-aa/blob/2024Q3/pauthabielf64/pauthabielf64.rst#core-information. With PAC non-hint instructions supported, `autia1716; br x17` can be replaced with `braa x17, x16; nop`, where `braa` is an authenticated branch instruction using IA key, discriminator from x16 and signed target address from x17.
Commit 5b1b6a62b8bd986adc711d0c0be5b6a8182be263 introduced the following
issue for older clang with libstdc++
```
In file included from /home/ray/llvm/lld/ELF/EhFrame.cpp:18:
In file included from /home/ray/llvm/lld/ELF/EhFrame.h:12:
In file included from /home/ray/llvm/lld/include/lld/Common/LLVM.h:21:
In file included from /home/ray/llvm/llvm/include/llvm/Support/Casting.h:20:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/memory:78:
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/unique_ptr.h:91:16: error: invalid application of 'sizeof' to an incomplete type 'lld:🧝:OutputSection'
static_assert(sizeof(_Tp)>0,
^~~~~~~~~~~
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/unique_ptr.h:398:4: note: in instantiation of member function 'std::default_delete<lld:🧝:OutputSection>::operator()' requested here
get_deleter()(std::move(__ptr));
^
/home/ray/llvm/lld/ELF/Config.h:574:19: note: in instantiation of member function 'std::unique_ptr<lld:🧝:OutputSection>::~unique_ptr' requested here
OutSections out{};
^
```
This commit completes the work that eliminates global variables like
config/target/inputSections/symTab from lld/ELF.
Key changes:
* Introduced `lld:🧝:ctx` to encapsulate global state.
* Moved global variables into `Ctx lld:🧝:ctx`
* Updated many functions to accept `Ctx &ctx`
* Made `ctx` a local variable (this commit)
If we don't count `static std::mutex`, this is the last major global
state within lld/ELF (minor ones like `SharedFile::vernauxNum`
(33ff9e43b4c5bdc3da31c6b11ad51d35a69bec5f) might not all be eliminated
yet).
so that we can remove the global `ctx` from toString implementations.
Rename lld::toString (to lld:🧝:toStr) to simplify name lookup (we
have many llvm::toString and another lld::toString(const llvm::opt::Arg
&)).