Revision tags: llvmorg-21-init |
|
#
10772807 |
| 23-Jan-2025 |
Igor Kudrin <ikudrin@accesssoftek.com> |
Reapply "[llvm-objcopy][ELF] Add an option to remove notes (#118739)"
This fixes "unused-local-typedef" warnings in 9324e6a7a5.
This adds an option `--remove-note=[name/]type` to selectively delete
Reapply "[llvm-objcopy][ELF] Add an option to remove notes (#118739)"
This fixes "unused-local-typedef" warnings in 9324e6a7a5.
This adds an option `--remove-note=[name/]type` to selectively delete notes in ELF files, where `type` is the numeric value of the note type and `name` is the name of the originator. The name can be omitted, in which case all notes of the specified type will be removed. For now, only `SHT_NOTE` sections that are not associated with segments are handled. The implementation can be extended later as needed.
RFC: https://discourse.llvm.org/t/rfc-llvm-objcopy-feature-for-editing-notes/83491
show more ...
|
#
621e5cd8 |
| 23-Jan-2025 |
Igor Kudrin <ikudrin@accesssoftek.com> |
Revert "[llvm-objcopy][ELF] Add an option to remove notes (#118739)"
This reverts commit 9324e6a7a5c5adc5b5c38c3e3cbecd7e1e98876a.
|
#
9324e6a7 |
| 23-Jan-2025 |
Igor Kudrin <ikudrin@accesssoftek.com> |
[llvm-objcopy][ELF] Add an option to remove notes (#118739)
This adds an option `--remove-note=[name/]type` to selectively delete notes in ELF files, where `type` is the numeric value of the note ty
[llvm-objcopy][ELF] Add an option to remove notes (#118739)
This adds an option `--remove-note=[name/]type` to selectively delete notes in ELF files, where `type` is the numeric value of the note type and `name` is the name of the originator. The name can be omitted, in which case all notes of the specified type will be removed. For now, only `SHT_NOTE` sections that are not associated with segments are handled. The implementation can be extended later as needed.
RFC: https://discourse.llvm.org/t/rfc-llvm-objcopy-feature-for-editing-notes/83491
show more ...
|
Revision tags: llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4 |
|
#
54dad9e2 |
| 17-Nov-2024 |
Kazu Hirata <kazu@google.com> |
[ObjCopy] Remove unused includes (NFC) (#116534)
Identified with misc-include-cleaner.
|
Revision tags: 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 |
|
#
e142a556 |
| 09-Jul-2024 |
Pranav Kant <prka@google.com> |
[llvm-objcopy] Remove references for empty section groups (#98106)
Otherwise, llvm-objcopy fails with use-after-free when built under
sanitizers. Simple repro: run the test
`ELF/remove-section-in-
[llvm-objcopy] Remove references for empty section groups (#98106)
Otherwise, llvm-objcopy fails with use-after-free when built under
sanitizers. Simple repro: run the test
`ELF/remove-section-in-group.test` under asan. This is due to symbol
table references to empty section groups that must be removed.
show more ...
|
#
2abe53a1 |
| 09-Jul-2024 |
Fangrui Song <i@maskray.me> |
Revert "[llvm-objcopy] Remove empty SHT_GROUP sections (#97141)"
This reverts commit 359c64f314ad568e78ee9a3723260286e3425c2d.
This caused heap-use-after-free. See #98106.
|
#
359c64f3 |
| 08-Jul-2024 |
Dmitriy Chestnykh <dm.chestnykh@gmail.com> |
[llvm-objcopy] Remove empty SHT_GROUP sections (#97141)
Currently `llvm-objcopy/llvm-strip` in `--strip-debug` mode doesn't
remove such sections. This behavior can lead to incompatibilities with
G
[llvm-objcopy] Remove empty SHT_GROUP sections (#97141)
Currently `llvm-objcopy/llvm-strip` in `--strip-debug` mode doesn't
remove such sections. This behavior can lead to incompatibilities with
GNU binutils (for examples ld.bfd before https://sourceware.org/PR20520
cannot process the object file contains empty .group section).
The ELF object that contains group section with `.debug_*` sections
inside can be obtained by `gcc -g3`.
Fix #97139
show more ...
|
#
9bb4cd59 |
| 08-Jul-2024 |
Fangrui Song <i@maskray.me> |
[llvm-objcopy] Support CREL
llvm-objcopy may modify the symbol table and need to rewrite relocations. For CREL, while we can reuse the decoder from #91280, we need an encoder to support CREL.
Since
[llvm-objcopy] Support CREL
llvm-objcopy may modify the symbol table and need to rewrite relocations. For CREL, while we can reuse the decoder from #91280, we need an encoder to support CREL.
Since MC/ELFObjectWriter.cpp has an existing encoder, and MC is at a lower layer than Object, extract the encoder to a new header file llvm/MC/MCELFExtras.h.
Link: https://discourse.llvm.org/t/rfc-crel-a-compact-relocation-format-for-elf/77600
Pull Request: https://github.com/llvm/llvm-project/pull/97521
show more ...
|
Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4 |
|
#
07942987 |
| 15-Apr-2024 |
Fangrui Song <i@maskray.me> |
[llvm-objcopy] Add --compress-sections
--compress-sections is similar to --compress-debug-sections but applies to arbitrary sections.
* `--compress-sections <section>=none`: decompress sections * `
[llvm-objcopy] Add --compress-sections
--compress-sections is similar to --compress-debug-sections but applies to arbitrary sections.
* `--compress-sections <section>=none`: decompress sections * `--compress-sections <section>=[zlib|zstd]`: compress sections with zlib/zstd
Like `--remove-section`, the pattern is by default a glob, but a regex when --regex is specified.
For `--remove-section` like options, `!` prevents matches and is not dependent on ordering (see `ELF/wildcard-syntax.test`). Since `--compress-sections a=zlib --compress-sections a=none` naturally allows overriding, having an order-independent `!` would be confusing. Therefore, `!` is disallowed.
Sections within a segment are effectively immutable. Report an error for an attempt to (de)compress them. `SHF_ALLOC` sections in a relocatable file can be compressed, but linkers usually reject them.
Note: Before this patch, a compressed relocation section is recognized as a `RelocationSectionBase` as well and `removeSections` `!ToRemove(*ToRelSec)` may incorrectly interpret a `CompressedSections` as `RelocationSectionBase`, leading to ubsan failure for the new test. Fix this by setting `OriginalFlags` in CompressedSection::CompressedSection.
Link: https://discourse.llvm.org/t/rfc-compress-arbitrary-sections-with-ld-lld-compress-sections/71674
Pull Request: https://github.com/llvm/llvm-project/pull/85036
show more ...
|
Revision tags: llvmorg-18.1.3 |
|
#
27633538 |
| 28-Mar-2024 |
Fangrui Song <i@maskray.me> |
[Object,ELFType] Rename TargetEndianness to Endianness (#86604)
`TargetEndianness` is long and unwieldy. "Target" in the name is confusing. Rename it to "Endianness".
I cannot find noticeable out
[Object,ELFType] Rename TargetEndianness to Endianness (#86604)
`TargetEndianness` is long and unwieldy. "Target" in the name is confusing. Rename it to "Endianness".
I cannot find noticeable out-of-tree users of `TargetEndianness`, but
keep `TargetEndianness` to make this patch safer. `TargetEndianness`
will be removed by a subsequent change.
show more ...
|
Revision tags: llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3 |
|
#
ef283790 |
| 20-Feb-2024 |
Fangrui Song <i@maskray.me> |
[llvm-objcopy] Fix file offsets when PT_INTERP/PT_LOAD offsets are equal (#80562)
(#79887) When the offset of a PT_INTERP segment equals the offset of a
PT_LOAD segment, we consider that the parent
[llvm-objcopy] Fix file offsets when PT_INTERP/PT_LOAD offsets are equal (#80562)
(#79887) When the offset of a PT_INTERP segment equals the offset of a
PT_LOAD segment, we consider that the parent of the PT_LOAD segment is
the PT_INTERP segment. In `layoutSegments`, we place both segments to be
after the current `Offset`, ignoring the PT_LOAD alignment.
This scenario is possible with fixed section addresses, but doesn't
happen with default linker layouts (.interp precedes other sections and
is part of a PT_LOAD segment containing the ELF header and program
headers).
```
% cat a.s
.globl _start; _start: ret
.rodata; .byte 0
.tdata; .balign 4096; .byte 0
% clang -fuse-ld=lld a.s -o a -nostdlib -no-pie -z separate-loadable-segments -Wl,-Ttext=0x201000,--section-start=.interp=0x202000,--section-start=.rodata=0x202020,-z,nognustack
% llvm-objcopy a a2
% llvm-readelf -l a2 # incorrect offset(PT_LOAD)
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000040 0x0000000000200040 0x0000000000200040 0x0001c0 0x0001c0 R 0x8
INTERP 0x001001 0x0000000000202000 0x0000000000202000 0x00001c 0x00001c R 0x1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x000000 0x0000000000200000 0x0000000000200000 0x000200 0x000200 R 0x1000
LOAD 0x001000 0x0000000000201000 0x0000000000201000 0x000001 0x000001 R E 0x1000
//// incorrect offset
LOAD 0x001001 0x0000000000202000 0x0000000000202000 0x000021 0x000021 R 0x1000
LOAD 0x002000 0x0000000000203000 0x0000000000203000 0x000001 0x001000 RW 0x1000
TLS 0x002000 0x0000000000203000 0x0000000000203000 0x000001 0x000001 R 0x1000
GNU_RELRO 0x002000 0x0000000000203000 0x0000000000203000 0x000001 0x001000 R 0x1000
```
The same issue occurs for PT_TLS/PT_GNU_RELRO if we PT_TLS's alignment
is smaller and we place the PT_LOAD after PT_TLS/PT_GNU_RELRO segments
(not linker default, but possible with a `PHDRS` linker script command).
Fix #79887: when two segments have the same offset, order the one with a
larger alignment first. In the previous case, the PT_LOAD segment will
go before the PT_INTERP segment. In case of equal alignments, it doesn't
matter which segment is treated as the parent segment.
show more ...
|
#
2cbe5a33 |
| 09-Feb-2024 |
Maksim Panchenko <maks@fb.com> |
[llvm-objcopy] Fix the build again after 7ddc320
|
#
5afbed19 |
| 09-Feb-2024 |
Jon Roelofs <jonathan_roelofs@apple.com> |
[llvm-objcopy] Fix the build after 7ddc32052546abd41656d2e670f3902b1bf805a7. NFCI
|
#
7ddc3205 |
| 09-Feb-2024 |
quic-areg <aregmi@quicinc.com> |
[llvm-objcopy] Support SREC output format (#75874)
Adds a new output target "srec" to write SREC files from ELF inputs.
https://en.wikipedia.org/wiki/SREC_(file_format)
|
Revision tags: llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init |
|
#
535520c6 |
| 19-Dec-2023 |
quic-akaryaki <123192073+quic-akaryaki@users.noreply.github.com> |
[llvm-objcopy] --gap-fill and 0-size sections (#75837)
In the change that added `--gap-fill`, the condition to choose the
sections to write in `BinaryWriter::write()` did not exclude zero-size
sec
[llvm-objcopy] --gap-fill and 0-size sections (#75837)
In the change that added `--gap-fill`, the condition to choose the
sections to write in `BinaryWriter::write()` did not exclude zero-size
sections. However, zero-size sections did not have correct offsets
assigned in `BinaryWriter::finalize()`. The result is either a failed
assertion, or memory corruption due to writing to the buffer beyond its
size.
To fix this, exclude zero-size sections from writing. Also, add a zero-size
section to the test, which would trigger the problem.
show more ...
|
#
4070dffd |
| 14-Dec-2023 |
quic-akaryaki <123192073+quic-akaryaki@users.noreply.github.com> |
[llvm-objcopy] Add --gap-fill and --pad-to options (#65815)
`--gap-fill <value>` fills the gaps between sections with a specified
8-bit value, instead of zero.
`--pad-to <address>` pads the output
[llvm-objcopy] Add --gap-fill and --pad-to options (#65815)
`--gap-fill <value>` fills the gaps between sections with a specified
8-bit value, instead of zero.
`--pad-to <address>` pads the output binary up to the specified load
address, using the 8-bit value from `--gap-fill` or zero.
These options are only supported for ELF input and binary output.
show more ...
|
Revision tags: llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3 |
|
#
4a0ccfa8 |
| 13-Oct-2023 |
Kazu Hirata <kazu@google.com> |
Use llvm::endianness::{big,little,native} (NFC)
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces suppo
Use llvm::endianness::{big,little,native} (NFC)
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces support::{big,little,native} with llvm::endianness::{big,little,native}.
show more ...
|
Revision tags: llvmorg-17.0.2 |
|
#
40dc8e68 |
| 27-Sep-2023 |
Gregory Alfonso <gfunni234@gmail.com> |
[NFC] Use const references to avoid copying objects in for-loops
Differential Revision: https://reviews.llvm.org/D139487
|
Revision tags: 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 |
|
#
c973123f |
| 20-Jun-2023 |
Alexey Karyakin <akaryaki@quicinc.com> |
[llvm-objcopy] -O binary: do not align physical addresses
llvm-objcopy should not insert padding before a section if its physical addresses is not aligned to section's alignment. This behavior will
[llvm-objcopy] -O binary: do not align physical addresses
llvm-objcopy should not insert padding before a section if its physical addresses is not aligned to section's alignment. This behavior will match GNU objcopy and is important for embedded images where the physical address is used to store the initial data image. The loader typically will copy this image using a start symbol created by the linker. If llvm-objcopy inserts padding before such a section, the symbol address will not match the location in the image.
This commit refines the change in https://reviews.llvm.org/D128961 which intended to align sections which type changed from NOBITS and their offset may not be aligned. However, it affected all sections.
Fix https://github.com/llvm/llvm-project/issues/62636
Reviewed By: jhenderson, MaskRay
Differential Revision: https://reviews.llvm.org/D150276
show more ...
|
#
ebc757d3 |
| 20-Jun-2023 |
Krzysztof Parzyszek <kparzysz@quicinc.com> |
Revert "[llvm-objcopy] -O binary: do not align physical addresses"
This reverts commit eb1442d0f73c76cfb5051d133f858fe760d189cf.
The test tools/llvm-objcopy/ELF/binary-paddr.test fails on ppc64be-c
Revert "[llvm-objcopy] -O binary: do not align physical addresses"
This reverts commit eb1442d0f73c76cfb5051d133f858fe760d189cf.
The test tools/llvm-objcopy/ELF/binary-paddr.test fails on ppc64be-clang-test-suite: https://lab.llvm.org/buildbot#builders/231/builds/13120
Reverting at author's request.
show more ...
|
#
eb1442d0 |
| 20-Jun-2023 |
Alexey Karyakin <akaryaki@quicinc.com> |
[llvm-objcopy] -O binary: do not align physical addresses
llvm-objcopy should not insert padding before a section if its physical addresses is not aligned to section's alignment. This behavior will
[llvm-objcopy] -O binary: do not align physical addresses
llvm-objcopy should not insert padding before a section if its physical addresses is not aligned to section's alignment. This behavior will match GNU objcopy and is important for embedded images where the physical address is used to store the initial data image. The loader typically will copy this image using a start symbol created by the linker. If llvm-objcopy inserts padding before such a section, the symbol address will not match the location in the image.
This commit refines the change in https://reviews.llvm.org/D128961 which intended to align sections which type changed from NOBITS and their offset may not be aligned. However, it affected all sections.
Fix https://github.com/llvm/llvm-project/issues/62636
Reviewed By: jhenderson, MaskRay
Differential Revision: https://reviews.llvm.org/D150276
show more ...
|
Revision tags: llvmorg-16.0.6 |
|
#
f3df0cf3 |
| 07-Jun-2023 |
David Blaikie <dblaikie@gmail.com> |
Remove unnecessary copy
|
Revision tags: llvmorg-16.0.5 |
|
#
744e589c |
| 17-May-2023 |
Andrew Ng <andrew.ng@sony.com> |
[llvm-objcopy][ELF] Preserve sh_link to .symtab when applicable
This change to llvm-objcopy preserves the ELF section sh_link to .symtab so long as none of the symbol table indices have been changed
[llvm-objcopy][ELF] Preserve sh_link to .symtab when applicable
This change to llvm-objcopy preserves the ELF section sh_link to .symtab so long as none of the symbol table indices have been changed. Previously, any invocation of llvm-objcopy including a "no-op" would clear any section sh_link to .symtab.
Differential Revision: https://reviews.llvm.org/D150859
show more ...
|
Revision tags: 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 |
|
#
bc6e10c9 |
| 17-Feb-2023 |
Moshe Berman <mosheberman@users.noreply.github.com> |
[ELF][llvm-objcopy] Reject duplicate SHT_SYMTAB sections
The gABI prohibits multiple SH_SYMTAB sections. As a result, llvm-objcopy was crashing in SymbolTableSection::removeSymbols(). This patch fix
[ELF][llvm-objcopy] Reject duplicate SHT_SYMTAB sections
The gABI prohibits multiple SH_SYMTAB sections. As a result, llvm-objcopy was crashing in SymbolTableSection::removeSymbols(). This patch fixes the issue by emitting an error if multiple SH_SYMTAB sections are encountered when building an ELF object.
Fixes: https://github.com/llvm/llvm-project/issues/60448
Differential Revision: https://reviews.llvm.org/D143508
show more ...
|
Revision tags: llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7 |
|
#
beae6bfa |
| 16-Dec-2022 |
David Spickett <david.spickett@linaro.org> |
[LLVM][objcopy] Fix update-section.test on 32 bit platforms
This used %zu to print a uint64_t type. z is for size_t so on 32 bit we tried to treat it as a 32 bit number.
Use PRIu64 instead to print
[LLVM][objcopy] Fix update-section.test on 32 bit platforms
This used %zu to print a uint64_t type. z is for size_t so on 32 bit we tried to treat it as a 32 bit number.
Use PRIu64 instead to print as 64 bit everywhere.
show more ...
|