llvm / llvm/llvm-project

clang's --save-temps=obj creates writeable and mergeable section that ld.lld doesn't accept

Open
#211,500 0 comments 0 reactions 0 assignees View on GitHub
clang lld
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Using clang 22.1.8 with `--save-temps=obj` to build Linux kernel, I've noticed the following:
```
$ ld.lld -m elf_x86_64 -z noexecstack -r -o vmlinux.o -Map=vmlinux.o.map --whole-archive vmlinux.a --no-whole-archive --start-group --end-group
ld.lld: error: vmlinux.a(arch/x86/kvm/mmu/mmu.o):(.data..ro_after_init): writable SHF_MERGE section is not supported
```
As shown with `readelf -W -S`, the section is:
```
[610] .data..ro_after_init PROGBITS 0000000000000000 04a818 000008 08 WAM 0 0 8
```
Use attached files to reproduce (uncompress `mmu.i` first). It can be reproduced on current upstream (`clang-24`) as of https://github.com/llvm/llvm-project/commit/3b7447e00baff23660b49fdcb67ce83a3bf94605 as well.

[mmu.i.gz](https://github.com/user-attachments/files/30299707/mmu.i.gz)
[run.sh](https://github.com/user-attachments/files/30299708/run.sh)

Contributor guide

Open the contributing guide

Research direction

Uncompress mmu.i.gz and run the attached run.sh to reproduce the ld.lld diagnostic, then inspect the generated object with readelf -W -S as shown in the issue. Trace whether clang or ld.lld is responsible for the writable SHF_MERGE section; done means the supplied reproduction no longer produces the unsupported-section error.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.