[all-commits] [llvm/llvm-project] cc91bf: Reland "[llvm-objcopy] Handle SHF_ALLOC relocation...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Fri Oct 2 20:58:18 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cc91bfe65be0b65700fa26b01ff00a9e3528f03d
https://github.com/llvm/llvm-project/commit/cc91bfe65be0b65700fa26b01ff00a9e3528f03d
Author: Fangrui Song <i at maskray.me>
Date: 2026-10-02 (Fri, 02 Oct 2026)
Changed paths:
M llvm/lib/ObjCopy/ELF/ELFObject.cpp
M llvm/lib/ObjCopy/ELF/ELFObject.h
A llvm/test/tools/llvm-objcopy/ELF/reloc-alloc-symtab.test
M llvm/test/tools/llvm-objcopy/ELF/reloc-no-symtab.test
Log Message:
-----------
Reland "[llvm-objcopy] Handle SHF_ALLOC relocation sections in relocatable files" (#228654)
This relands #227204, reverted by #228572 due to a UBSan failure in
compress-sections.s:
```
ELFObject.h:887:35: runtime error: load of value 190, which is not a valid value for type 'const bool'
```
--compress-sections on a relocation section creates a CompressedSection
that incorrectly keeps OriginalType SHT_RELA, so
RelocationSection::classof cast it and read
RelocationSectionBase::Dynamic. Set its OriginalType to SHT_PROGBITS,
which also fixes a TODO in Object::removeSections
Original description:
llvm-objcopy treats every SHF_ALLOC relocation section as dynamic and
requires its sh_link to refer to .dynsym. Linux livepatch modules
(ET_REL) contain SHF_ALLOC .klp.rela.* sections linked to .symtab
(SHF_ALLOC keeps them in module memory until the patched module loads),
so llvm-objcopy rejects them:
```
error: Link field value 4 in section .klp.rela.vmlinux.text is not a symbol table
```
A relocatable file has no dynamic symbol table, so treat all of its
relocation sections as static, as BFD does. Their symbol indexes are
then updated when the symbol table changes. Since SHF_ALLOC no longer
distinguishes RelocationSection from DynamicRelocationSection, record
the kind in RelocationSectionBase.
LLM-aided
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list