Description
Hi All,
when building kpatch module for 5.19+ kernel with -ffunction-sections,
the vmlinux build could fail during link stage.
Reason:
s390 kernel is built with -fPIE and for kpatch purpose built with ARCH_KCFLAGS "-ffunction-sections -fdata-sections"
Output:
ld: .tmp_vmlinux.btf: too many sections: 65614 (>= 65280)
ld: final link failed: nonrepresentable section on output
BTF .btf.vmlinux.bin.o
In this scenario:
-
gABI doesn't support dynamic symbols in output sections beyond 64k.
Ref: binutils : check_dynsym (bfd *abfd, Elf_Internal_Sym *sym)
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elflink.c;h=2b1450fa4e146936ba4fd6d02691a863f26a88b6;hb=HEAD#l10183 -
s390 kernel
readelf --dyn-syms vmlinux | wc
1556 -
x86 kernel doesn't seems to have dynamic symbols and hence does not create this problem.
readelf --dyn-syms vmlinux | wc -l
0
Possible fix:
-
Provide the explicit TARGETS eg:
TARGETS="fs/proc/" KPATCHBUILD_OPTS="-v $vmlinux -s $linux_src -d" ./kpatch-test rhel-9.0/data-new.patch -
Change linker script like:
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index 2e526f11b91e..1d3d2d878acb 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -48,7 +48,7 @@ SECTIONS
IRQENTRY_TEXT
SOFTIRQENTRY_TEXT
FTRACE_HOTPATCH_TRAMPOLINES_TEXT
- *(.text.*_indirect_*)
+ *(.text.*)
*(.gnu.warning)
. = ALIGN(PAGE_SIZE);
_etext = .; /* End of text section */
- Create custom target in kernel top Makefile. This target would build only kernel objects without linking vmlinux target.
Question:
Could you please provide me suggestions, how this could be handled better in kpatch?
- without generating vmlinux in (original build) and (patched build).
Thank you
Best Regards
Sumanth