Bug 204495 - 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
Summary: ld.bfd: arch/x86/boot/compressed/head_64.o: warning: relocation in read-only ...
Status: NEW
Alias: None
Product: Other
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: other_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-05 12:03 UTC by Mike Lothian
Modified: 2020-12-12 12:58 UTC (History)
2 users (show)

See Also:
Kernel Version: 5.3-rc3
Subsystem:
Regression: No
Bisected commit-id:


Attachments
.config (107.67 KB, text/plain)
2019-08-19 13:25 UTC, Mike Lothian
Details
Full output of make V=1 (102.62 KB, application/x-xz)
2019-08-19 15:57 UTC, Mike Lothian
Details
patch for linux/arch/x86/entry/vdso/Makefile (1.80 KB, patch)
2019-11-12 07:42 UTC, Arno Bauernöppel
Details | Diff
patch for linux/arch/x86/kernel/vmlinux.lds.S (983 bytes, patch)
2019-11-12 07:44 UTC, Arno Bauernöppel
Details | Diff

Description Mike Lothian 2019-08-05 12:03:55 UTC
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?
Comment 1 Mike Lothian 2019-08-19 13:25:07 UTC
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
Comment 2 Mike Lothian 2019-08-19 13:25:35 UTC
Created attachment 284505 [details]
.config
Comment 3 Mike Lothian 2019-08-19 15:57:26 UTC
Created attachment 284509 [details]
Full output of make V=1
Comment 4 Mike Lothian 2019-08-19 16:15:00 UTC
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
Comment 5 Mike Lothian 2019-08-19 16:17:49 UTC
Plus a report I totally forgot about here: https://bugzilla.kernel.org/show_bug.cgi?id=177741
Comment 6 Arno Bauernöppel 2019-11-12 07:36:40 UTC
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
Comment 7 Arno Bauernöppel 2019-11-12 07:42:01 UTC
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.
Comment 8 Arno Bauernöppel 2019-11-12 07:44:58 UTC
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.
Comment 9 Dwokfur 2020-12-12 10:44:49 UTC
Relevant set of patches:
https://lore.kernel.org/lkml/202007311612.78E132F3A1@keescook/
Comment 10 Mike Lothian 2020-12-12 12:58:34 UTC
Do you have that in git somewhere? Or a patchwork link

Note You need to log in before you can comment on or make changes to this bug.