Skip to content

create-diff-object: handle R_X86_64_32 in rela_target_offset - #1516

Open
benjamindonnachie wants to merge 1 commit into
dynup:masterfrom
benjamindonnachie:fix-rela-32
Open

create-diff-object: handle R_X86_64_32 in rela_target_offset#1516
benjamindonnachie wants to merge 1 commit into
dynup:masterfrom
benjamindonnachie:fix-rela-32

Conversation

@benjamindonnachie

Copy link
Copy Markdown

Part of #1514.

rela_target_offset() treats R_X86_64_64 and R_X86_64_32S as
absolute (non-PC-relative) relocations needing no
instruction-decode-based offset adjustment, but was missing
R_X86_64_32 (ELF reloc type 10). Any file containing one hits
ERROR: unhandled rela type 10 and aborts the whole build.

R_X86_64_32 and R_X86_64_32S are both absolute relocations; per
the x86-64 psABI they differ only in how the linker
validates/truncates the value during relocation application
(zero- vs sign-extension), which has no bearing on add_off here —
the instruction-decode adjustment this function computes only
matters for PC-relative encodings. So R_X86_64_32 belongs in the
same branch as R_X86_64_32S.

R_X86_64_32 shows up in low-level x86 code that still executes in
32-bit protected mode before the switch to long mode (observed in
arch/x86/platform/pvh/head.o, Xen PVH boot entry — see #1515 for a
targeted exclusion of that file from diffing entirely, since it can
never be livepatchable, but this relocation-type gap is real and
independent of that).

Testing

Reproduced and fixed while building a real cumulative EL9 5.14
kernel livepatch. See #1514 for full context.

Co-authored-by: Claude noreply@anthropic.com

rela_target_offset() treats R_X86_64_64 and R_X86_64_32S as absolute
(non-PC-relative) relocations needing no instruction-decode-based
offset adjustment, but was missing R_X86_64_32 (ELF reloc type 10).
Any file containing one hits "ERROR: unhandled rela type 10" and
aborts the whole build.

R_X86_64_32 and R_X86_64_32S are both absolute relocations; per the
x86-64 psABI they differ only in how the linker validates/truncates
the value during relocation *application* (zero- vs sign-extension),
which has no bearing on add_off here -- the instruction-decode
adjustment this function computes only matters for PC-relative
encodings. So R_X86_64_32 belongs in the same branch as R_X86_64_32S.

R_X86_64_32 shows up in low-level x86 code that still executes in
32-bit protected mode before the switch to long mode (observed in
arch/x86/platform/pvh/head.o, Xen PVH boot entry), where the usual
64-bit-oriented relocations don't apply. Reproduced and fixed while
building a real cumulative EL9 5.14 kernel livepatch.

Co-authored-by: Claude <noreply@anthropic.com>
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