You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
llvm-readelf "invalid PT_DYNAMIC size" for RISC-V after getrandom() vDSO implementation #2093
After commit 89079520cef6 ("RISC-V: vDSO: Wire up getrandom() vDSO implementation") in -next, I see a warning from llvm-readelf with ARCH=riscv allmodconfig. As of next-20250527, a tangential fix is needed for LLVM=1 to work.
$ make -skj"$(nproc)" ARCH=riscv LLVM=1 mrproper allmodconfig arch/riscv/kernel/vdso/
llvm-readelf: warning: 'arch/riscv/kernel/vdso/vdso.so.dbg': invalid PT_DYNAMIC size (0xb8)
llvm-readelf: warning: 'arch/riscv/kernel/vdso/vdso.so.dbg': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used
I was able to narrow this down to CONFIG_INIT_STACK_ALL_PATTERN (which enables -ftrivial-auto-var-init=pattern) on top of defconfig, which is different from the default of CONFIG_INIT_STACK_ALL_ZERO:
$ printf 'CONFIG_%s\n' INIT_STACK_ALL_{PATTERN=y,ZERO=n} >kernel/configs/init_stack_pattern.config
$ make -skj"$(nproc)" ARCH=riscv LLVM=1 clean defconfig init_stack_pattern.config arch/riscv/kernel/vdso/
llvm-readelf: warning: 'arch/riscv/kernel/vdso/vdso.so.dbg': invalid PT_DYNAMIC size (0xb8)
llvm-readelf: warning: 'arch/riscv/kernel/vdso/vdso.so.dbg': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used
@MaskRay have you ever seen anything like this? There are a few times this warning has shown up before but I have never seen it until this point. Are there any recommendations for debugging this?
Thanks for the detailed reproduce instructions! My git-fu is not that good. As I got a merge conflict when I invoked git pull, I went with the old way: git remote add riscv https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git ...
Here is a commit that resolves the issue. The issue arose since 8f8c1ff (in 2023)
("riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr"), which placed .rodata directly after .dynamic by removing .eh_frame.
Looks good to me! If you have not tried b4 for sending kernel changes, I would recommend giving it a try. Here is how I would do it (this is distilled down from that documentation):
# I usually base off of the maintainer's tree, you can use your remote and adjust FETCH_HEAD below
$ git fetch https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git/ for-next
# 'b4 prep' creates a fresh branch to work off of, which allows you to reuse your# cover letter (including your To: and Cc:) across various revisions
$ b4 prep -f FETCH_HEAD -n riscv-vdso-fix-rodata-segment
# cherry-pick your local commit to the new b4/ branch# normally you would create your series here# '--auto-to-cc' automatically runs scripts/get_maintainer.pl# '--check' automatically runs scripts/checkpatch.pl
$ b4 prep --auto-to-cc --check
# '--edit-cover' allows you to edit the cover letter. Since this is a single patch,# you do not need to add any content here (just delete the commented lines and the# signoff line, adjust the title to something for you locally, leaving the previously# added To: and Cc: lines alone). For series that include multiple patches, you would# add some executive summary above the To: and Cc: lines.
$ b4 prep --edit-cover
# Check that the patch and recipients generally looks okay
$ b4 send --dry-run
# Actually send it, using your .gitconfig values if available
$ b4 send
Activity
nathanchance commentedon May 27, 2025
Also, this hack hides the issue for me:
MaskRay commentedon May 29, 2025
This diagnostic specifies that the
.dynamicsection is invalid, probably out-of-bounds sh_offset or sh_size%sh_entsize!=0.However, I cannot reproduce the issue at commit 90b83ef
nathanchance commentedon May 29, 2025
You'll need to merge the pending RISC-V tree into mainline to see this.
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
MaskRay commentedon May 31, 2025
Thanks for the detailed reproduce instructions! My git-fu is not that good. As I got a merge conflict when I invoked
git pull, I went with the old way:git remote add riscv https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git...Here is a commit that resolves the issue. The issue arose since 8f8c1ff (in 2023)
("riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr"), which placed .rodata directly after .dynamic by removing .eh_frame.
This patch resolves the issue: https://github.com/MaskRay/linux/commits/riscv-vdso If it looks good, perhaps you could help me send it to the RISC-V tree? Thanks!
nathanchance commentedon Jun 2, 2025
Looks good to me! If you have not tried
b4for sending kernel changes, I would recommend giving it a try. Here is how I would do it (this is distilled down from that documentation):MaskRay commentedon Jun 3, 2025
Thanks for the detailed instructions! This is the first time I used
b4 send. OK, here is the message: https://lore.kernel.org/linux-riscv/20250602-riscv-vdso-v1-1-0620cf63cff0@maskray.me/T/#uriscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
6 remaining items
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
nathanchance commentedon Aug 13, 2025
https://git.kernel.org/linus/e0eb1b6b0cd29ca7793c501d5960fd36ba11f110
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment