summaryrefslogtreecommitdiff
path: root/lld/ELF/EhFrame.cpp
AgeCommit message (Collapse)Author
2025-05-25[lld] Remove unused includes (NFC) (#141421)Kazu Hirata
2025-01-25[ELF] EhFrame: replace failOn with errOnFangrui Song
These diagnostics are mostly reported by a thread during writeSections. In LLD_IN_TEST=2 mode, when a thread calls Fatal, there will be no output even if the process exits with code 1.
2024-11-14[ELF] Migrate away from global ctxFangrui Song
2024-11-06[ELF] Replace fatal(...) with Fatal or ErrFangrui Song
2024-10-10[ELF] Move InputSectionBase::file to SectionBaseFangrui Song
... and add getCtx (file->ctx). This allows InputSectionBase and OutputSection to access ctx without taking an extra function argument.
2024-10-06[ELF] Pass Ctx & to InputFilesFangrui Song
2024-09-21[ELF] Replace config-> with ctx.arg.Fangrui Song
2022-11-20[ELF] Change rawData to content() and data() to contentMaybeDecompress()Fangrui Song
Clarify data() which may trigger decompression and make it feasible to refactor the member variable rawData.
2022-06-08[ELF] Support 'G' in .eh_frameFlorian Mayer
Reviewed By: MaskRay, eugenis Differential Revision: https://reviews.llvm.org/D127148
2022-06-08Revert "[ELF] Support 'G' in .eh_frame"Florian Mayer
This reverts commit 40f34fe4a87d5171854b9b65678ef3d9baea5785.
2022-06-08[ELF] Support 'G' in .eh_frameFlorian Mayer
Reviewed By: MaskRay, eugenis Differential Revision: https://reviews.llvm.org/D127148
2022-02-21[ELF] Replace uncompressed InputSectionBase::data() with rawData. NFCFangrui Song
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.
2022-01-18[ELF] Simplify/optimize EhInputSection::splitFangrui Song
and change some `fatal` to `errorOrWarn`. EhFrame.cpp is a helper file. We don't place all .eh_frame implementation there, so the code move is fine.
2021-01-05ELF: Teach the linker about the 'B' augmentation string character.Peter Collingbourne
This character indicates that when return pointer authentication is being used, the function signs the return address using the B key. Differential Revision: https://reviews.llvm.org/D93954
2020-08-07[ELF] Support .cfi_signal_frameFangrui Song
glibc/sysdeps/unix/sysv/linux/x86_64/sigaction.c libc.a(sigaction.o) has a CIE with the augmentation string "zRS". Support 'S' to allow --icf={safe,all}.
2020-08-05[ELF] --icf: don't fold text sections with LSDAFangrui Song
Fix PR36272 and PR46835 A .eh_frame FDE references a text section and (optionally) a LSDA (in .gcc_except_table). Even if two text sections have identical content and relocations (e.g. a() and b()), we cannot fold them if their LSDA are different. ``` void foo(); void a() { try { foo(); } catch (int) { } } void b() { try { foo(); } catch (float) { } } ``` Scan .eh_frame pieces with LSDA and disallow referenced text sections to be folded. If two .gcc_except_table have identical semantics (usually identical content with PC-relative encoding), we will lose folding opportunity. For ClickHouse (an exception-heavy application), this can reduce --icf=all efficiency from 9% to 5%. There may be some percentage we can reclaim without affecting correctness, if we analyze .eh_frame and .gcc_except_table sections. gold 2.24 implemented a more complex fix (resolution to https://sourceware.org/bugzilla/show_bug.cgi?id=21066) which combines the checksum of .eh_frame CIE/FDE pieces. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D84610
2020-05-15[ELF] Use namespace qualifiers (lld:: or elf::) instead of `namespace lld { ↵Fangrui Song
namespace elf {` Similar to D74882. This reverts much code from commit bd8cfe65f5fee4ad573adc2172359c9552e8cdc0 (D68323) and fixes some problems before D68323. Sorry for the churn but D68323 was a mistake. Namespace qualifiers avoid bugs where the definition does not match the declaration from the header. See https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions (D74515) Differential Revision: https://reviews.llvm.org/D79982
2019-10-07[ELF] Wrap things in `namespace lld { namespace elf {`, NFCFangrui Song
This makes it clear `ELF/**/*.cpp` files define things in the `lld::elf` namespace and simplifies `elf::foo` to `foo`. Reviewed By: atanasyan, grimar, ruiu Differential Revision: https://reviews.llvm.org/D68323 llvm-svn: 373885
2019-07-10[Coding style change] Rename variables so that they start with a lowercase ↵Rui Ueyama
letter This patch is mechanically generated by clang-llvm-rename tool that I wrote using Clang Refactoring Engine just for creating this patch. You can see the source code of the tool at https://reviews.llvm.org/D64123. There's no manual post-processing; you can generate the same patch by re-running the tool against lld's code base. Here is the main discussion thread to change the LLVM coding style: https://lists.llvm.org/pipermail/llvm-dev/2019-February/130083.html In the discussion thread, I proposed we use lld as a testbed for variable naming scheme change, and this patch does that. I chose to rename variables so that they are in camelCase, just because that is a minimal change to make variables to start with a lowercase letter. Note to downstream patch maintainers: if you are maintaining a downstream lld repo, just rebasing ahead of this commit would cause massive merge conflicts because this patch essentially changes every line in the lld subdirectory. But there's a remedy. clang-llvm-rename tool is a batch tool, so you can rename variables in your downstream repo with the tool. Given that, here is how to rebase your repo to a commit after the mass renaming: 1. rebase to the commit just before the mass variable renaming, 2. apply the tool to your downstream repo to mass-rename variables locally, and 3. rebase again to the head. Most changes made by the tool should be identical for a downstream repo and for the head, so at the step 3, almost all changes should be merged and disappear. I'd expect that there would be some lines that you need to merge by hand, but that shouldn't be too many. Differential Revision: https://reviews.llvm.org/D64121 llvm-svn: 365595
2019-03-29[ELF][MachO][wasm] Simplify range-style std::find{,_if} with STLExtras.h ↵Fangrui Song
utilities. NFC llvm-svn: 357269
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-10-08Avoid unnecessary buffer allocation and memcpy for compressed sections.Rui Ueyama
Previously, we uncompress all compressed sections before doing anything. That works, and that is conceptually simple, but that could results in a waste of CPU time and memory if uncompressed sections are then discarded or just copied to the output buffer. In particular, if .debug_gnu_pub{names,types} are compressed and if no -gdb-index option is given, we wasted CPU and memory because we uncompress them into newly allocated bufers and then memcpy the buffers to the output buffer. That temporary buffer was redundant. This patch changes how to uncompress sections. Now, compressed sections are uncompressed lazily. To do that, `Data` member of `InputSectionBase` is now hidden from outside, and `data()` accessor automatically expands an compressed buffer if necessary. If no one calls `data()`, then `writeTo()` directly uncompresses compressed data into the output buffer. That eliminates the redundant memory allocation and redundant memcpy. This patch significantly reduces memory consumption (20 GiB max RSS to 15 Gib) for an executable whose .debug_gnu_pub{names,types} are in total 5 GiB in an uncompressed form. Differential Revision: https://reviews.llvm.org/D52917 llvm-svn: 343979
2018-03-30[ELF] Simplify read32. NFCFangrui Song
llvm-svn: 328908
2018-02-28Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.Rui Ueyama
This should resolve the issue that lld build fails in some hosts that uses case-insensitive file system. Differential Revision: https://reviews.llvm.org/D43788 llvm-svn: 326339
2018-02-20Consistent (non) use of empty lines in include blocksSam Clegg
The profailing style in lld seem to be to not include such empty lines. Clang-tidy/clang-format seem to handle this just fine. Differential Revision: https://reviews.llvm.org/D43528 llvm-svn: 325629
2017-10-27De-template EhReader. NFC.Rui Ueyama
llvm-svn: 316733
2017-10-27De-template elf::getObjMsg. NFC.Rui Ueyama
llvm-svn: 316732
2017-10-25[lld] unified COFF and ELF error handling on new Common/ErrorHandlerBob Haarman
Summary: The COFF linker and the ELF linker have long had similar but separate Error.h and Error.cpp files to implement error handling. This change introduces new error handling code in Common/ErrorHandler.h, changes the COFF and ELF linkers to use it, and removes the old, separate implementations. Reviewers: ruiu Reviewed By: ruiu Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits Differential Revision: https://reviews.llvm.org/D39259 llvm-svn: 316624
2017-09-20Revert rL313697, "Compact EhSectionPiece from 32 bytes to 16 bytes."NAKAMURA Takumi
It broke selfhosting. http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/4896 llvm-svn: 313731
2017-09-19Compact EhSectionPiece from 32 bytes to 16 bytes.Rui Ueyama
EhSectionPiece used to have a pointer to a section, but that pointer was mostly redundant because we almost always know what the section is without using that pointer. This patch removes the pointer from the struct. This patch also use uint32_t/int32_t instead of size_t to represent offsets that are hardly be larger than 4 GiB. At the moment, I think it is OK even if we cannot handle .eh_frame sections larger than 4 GiB. Differential Revision: https://reviews.llvm.org/D38012 llvm-svn: 313697
2017-09-18Rename EhSectionPiece::ID -> EhSectionPiece::Sec.Rui Ueyama
ID sounds like an identifier, but this is actually a pointer to a section. llvm-svn: 313588
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner
This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
2017-04-01Change the error format to report corrupted .eh_frame.Rui Ueyama
llvm-svn: 299289
2017-03-17Compute Config member function return values only once.Rui Ueyama
We had a few Config member functions that returns configuration values. For example, we had is64() which returns true if the target is 64-bit. The return values of these functions are constant and never change. This patch is to compute them only once to make it clear that they'll never change. llvm-svn: 298168
2017-03-17Define Config::isLE and Config::wordsize.Rui Ueyama
isLE() return true if the target is little-endian. wordsize() returns 8 for 64-bit and 4 for 32-bit. llvm-svn: 298167
2017-02-23Convert InputSectionBase to a class.Rafael Espindola
Removing this template is not a big win by itself, but opens the way for removing more templates. llvm-svn: 295923
2017-02-19Add a comment about the copy relocation.Rui Ueyama
llvm-svn: 295622
2016-11-25Move getLocation from Relocations.cpp to InputSection.cpp.Rui Ueyama
The function was used only within Relocations.cpp, but now we are using it in many places, so this patch moves it to a file that fits to the functionality. llvm-svn: 287943
2016-11-23[ELF] Print error location in .eh_frame parserEugene Leviant
Differential revision: https://reviews.llvm.org/D26914 llvm-svn: 287750
2016-11-19Split getFdeEncoding.Rui Ueyama
llvm-svn: 287452
2016-11-19Fix typo in error message.Rui Ueyama
llvm-svn: 287451
2016-07-29[ELF] Allow arbitrary code alignment in .eh_framePetr Hosek
According to the specification, CIE code alignment factor is an arbitrary unsigned LEB128 encoded value. Differential revision: https://reviews.llvm.org/D22954 llvm-svn: 277105
2016-05-25ELF: Handle empty CIE augmentation stringEd Maste
"A zero length string indicates that no augmentation data is present." The FreeBSD/mips toolchain (GCC 4.2.1) generates .debug_frame sections containing CIE records that have an empty augmentation string. Differential Revision: http://reviews.llvm.org/D19928 llvm-svn: 270706
2016-05-24Create a new file EhFrame.cpp and move code to read .eh_frame there.Rui Ueyama
llvm-svn: 270526