1From 911130ce429cbf6a92d0fbd17f0ff638ec941df2 Mon Sep 17 00:00:00 2001
2From: Petr Ovtchenkov <ptr@void-ptr.info>
3Date: Sun, 7 Feb 2021 00:04:36 -0800
4Subject: [PATCH] workaround for overlapping sections in binary
5
6Problem: binary (typesize.bin) created from object file (typesize.o)
7with 'objcopy -O binary ... '. But typesize.o has relocatable objects that all
8copied with offset 0. This will lead to overlapping sections in binary.
9By fortunate syscalls.pl check magic bytes and ring the bell.
10
11This is naive workaround: skip .note.gnu.property section that overlap
12.rodata section.
13
14This not a bug of objcopy, https://sourceware.org/bugzilla/show_bug.cgi?id=27314
15
16Related commit:
17
18  commit de6f630e6be90d6d32d8bf2fed3f856b0c32f7ba
19  Author: H. Peter Anvin <hpa at zytor.com>
20  Date:   Sat Jun 10 11:15:19 2006 -0700
21
22      [klibc] Detect the sizes of various types, and make available to sysstub.ph.
23
24      This additional code effectively queries the C compiler for the sizes of
25      various types, and makes an associative array %typesize available to
26      sysstub.ph.  This is currently not used, but it's expected that some
27      architectures, e.g. s390, will need this to determine which registers
28      go where, and how many registers are needed.
29
30Upstream-Status: Submitted [https://lists.zytor.com/archives/klibc/2021-February/004583.html]
31
32Signed-off-by: Khem Raj <raj.khem@gmail.com>
33---
34 usr/klibc/syscalls/Kbuild | 2 +-
35 1 file changed, 1 insertion(+), 1 deletion(-)
36
37--- a/usr/klibc/syscalls/Kbuild
38+++ b/usr/klibc/syscalls/Kbuild
39@@ -71,7 +71,7 @@ $(obj)/typesize.c: $(srctree)/$(KLIBCSRC
40
41 # Convert typesize.o to typesize.bin
42 quiet_cmd_mkbin = OBJCOPY $@
43-      cmd_mkbin = $(KLIBCOBJCOPY) -O binary --only-section .rodata $< $@
44+      cmd_mkbin = $(KLIBCOBJCOPY) -O binary --remove-section .note.gnu.property $< $@
45
46 $(obj)/typesize.bin: $(obj)/typesize.o FORCE
47 	$(call if_changed,mkbin)
48