Building the kernel with ld.bfd gives the following error when building ld.bfd: arch/x86/boot/compressed/head_64.o: warning: relocation in read-only section `.head.text' ld.bfd: warning: creating a DT_TEXTREL in object Can this be safely ignored?
I'm using GCC 9.2, binutils 2.32. I used to use the gold linker but I've just switched back to using ld.bfd My .config can be found at https://raw.githubusercontent.com/FireBurn/KernelStuff/master/dot_config_tip
Created attachment 284505 [details] .config
Created attachment 284509 [details] Full output of make V=1
So it looks like this might have been around for a while: https://forums.grsecurity.net/viewtopic.php?f=3&t=4622 I've been using Gold for years so I've never seen this
Plus a report I totally forgot about here: https://bugzilla.kernel.org/show_bug.cgi?id=177741
I have found a workaround that is bootable. A separate linker script is needed by ld.gold. I am creating it on the fly from the scripts arch/x86/entry/vdso/vdso.lds.S and arch/x86/entry/vdso/vdso.lds and then strip the GOT (global object table) created by ld.gold from the linked binary. The other problem is a different behaviour of ld.bfd and ld.gold regarding the linker script inux/arch/x86/kernel/vmlinux.lds.S. The symbol '__end_of_kernel_reserve' is not placed in .bss by ld. gold so I had to move it in the right section. I am to uncertain about the portability and stability of those two patches. But I think they are pointing in the right direction. Especialy the different placement of '__end_of_kernel_reserve' seems very odd to me. So please make sure to clarify those problems before using the patches. Best regards
Created attachment 285873 [details] patch for linux/arch/x86/entry/vdso/Makefile This patch moves the symbol '__end_of_kernel_reserve' to .bss it prevents a different interpretation of the placement of the symbol by ld.bfd and ld.gold.
Created attachment 285875 [details] patch for linux/arch/x86/kernel/vmlinux.lds.S This patch separates the version part from the linker script with sed into two different files and makes use of the required parameter '--version-script' of ld.gold. It then strips the GOT from the binary to prevent failing sanity checks because of this symbol.
Relevant set of patches: https://lore.kernel.org/lkml/202007311612.78E132F3A1@keescook/
Do you have that in git somewhere? Or a patchwork link