Skip to content

ELF merge section handling#808

Open
bsdjhb wants to merge 5 commits intoCTSRD-CHERI:c18n_policyfrom
bsdjhb:c18n_merge_sections
Open

ELF merge section handling#808
bsdjhb wants to merge 5 commits intoCTSRD-CHERI:c18n_policyfrom
bsdjhb:c18n_merge_sections

Conversation

@bsdjhb
Copy link
Contributor

@bsdjhb bsdjhb commented Feb 16, 2026

The first three commits here are small fixups to the base c18n commit that that I think could be squashed down into that first. The last commit I am unsure if it is better or worse. (Can you even have SHF_COMPRESS on a SHF_MERGE section?)

I was able to boot CheriBSD on both RISC-V and Morello when built with this, and all the cheribsdtest tests still pass (including my simple non-ACL c18n tests still pending in a CheriBSD PR).

One odd thing I haven't tracked down is that the per-compartment output sections (e.g. .rodata.one and .rodata.two) have higher alignment than .rodata (8 vs 4) for, e.g. the shared_merge_sections.so.

For each SHF_MERGE section not assigned to an explicit compartment,
leave the original section in the default compartment but create
duplicate sections with the same content for each compartment.  For
each symbol defined in the original merge section, a duplicate symbol
is created for each compartment's copy.

InputFile::getRelocTargetSym now accepts a compartment reference.  If
the symbol index names a symbol from a merge section, the
corresponding symbol from the compartment's copy of the merge section
is returned.

Note that without --gc-sections, each compartment is allocated an
entire copy of each merge section, even if a compartment does not use
any symbols from that section.
In particular, this forces decompression only once.
@bsdjhb bsdjhb requested a review from jrtc27 February 16, 2026 21:34
@bsdjhb
Copy link
Contributor Author

bsdjhb commented Feb 16, 2026

So the .rodata.one/two alignment is from PCC alignment, and it's not applied to .rodata as .text is empty so we don't do a PT_CHERI_PCC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments