lzloader: give .rodata its own output section#1405
Conversation
The decompressor stub's linker script placed .data at a fixed OSV_LZKERNEL_BASE + 0x3000 offset and never emitted an output section for .rodata, so read-only data (string literals, jump tables) emitted by the compressor stub had no defined home and was silently folded into the gap before .data. Emit an explicit .rodata output section between .text and .data so the stub's read-only data is laid out deterministically instead of depending on the 0x3000 fudge factor.
|
@wkozaczuk can you please review this patch? It makes sense and I don't know where this 0x3000 (which you added many years ago in commit baf5c30) comes from. The same commit has other explanations for the number 0x3000 (three pages) so I am not sure why it was really there, or if the other mentions 0f 0x3000 in that commit are justified. |
There was a problem hiding this comment.
Pull request overview
This PR updates the x64 lzloader linker script to explicitly place read-only data into its own output section, separating it from writable data during the kernel decompressor link.
Changes:
- Add an explicit
.rodataoutput section to capture.rodataand.rodata.*input sections. - Remove the fixed location-counter jump (
OSV_LZKERNEL_BASE + 0x3000) that previously separated.textfrom subsequent sections.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
To answer where the It's not arbitrary. It was introduced in /* ... first 3 pages (0x3000) in lzloader.elf are occupied by fastlz
* decompression code and next 4 bytes store offset of the segments
* info table. ... */
#define MAX_COMPRESSED_SEGMENT_SIZE (SEGMENT_SIZE - sizeof(int) - 0x3000)So the decompressor's worst-case overlap math assumes the stub (its own code + read-only + writable data) fits within the first What the old linker line actually did, and why it's fragile: the script never gave This patch gives The @wkozaczuk — you wrote the original; does this match your intent for the |
Split out of #1399 per review.
This was the unrelated linker-script change flagged in review on the io_uring
commit (
arch/x64/lzloader.ld:13). It gives.rodataits own output section inthe lzloader (kernel decompressor) link and is not part of the io_uring change,
so it is submitted on its own here.
Build-qualified (kernel compile+link,
image=empty) on a binutils 2.44 /g++ 14.3.0 host.