[klibc] [klibc:master] Make typesize extraction more robust

klibc-bot for Ben Hutchings ben at decadent.org.uk
Tue Apr 27 18:12:12 PDT 2021


Commit-ID:  b068ef9740d586200c6507bd393095159ff324c9
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=b068ef9740d586200c6507bd393095159ff324c9
Author:     Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Wed, 28 Apr 2021 00:25:11 +0200
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Wed, 28 Apr 2021 00:25:11 +0200

[klibc] Make typesize extraction more robust

Petr writes:

> Problem: binary (typesize.bin) created from object file (typesize.o)
> with 'objcopy -O binary ... '. But typesize.o has relocatable objects that all
> copied with offset 0. This will lead to overlapping sections in binary.

Avoid this by telling objcopy that we only want the read-only data
(.rodata) section.

Reported-by: Petr Ovtchenkov <ptr at void-ptr.info>
References: https://lists.zytor.com/archives/klibc/2021-February/004582.html
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/klibc/syscalls/Kbuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/klibc/syscalls/Kbuild b/usr/klibc/syscalls/Kbuild
index 2430b9b4..3f567989 100644
--- a/usr/klibc/syscalls/Kbuild
+++ b/usr/klibc/syscalls/Kbuild
@@ -71,7 +71,7 @@ $(obj)/typesize.c: $(srctree)/$(KLIBCSRC)/syscalls.pl $(obj)/SYSCALLS.i     \
 
 # Convert typesize.o to typesize.bin
 quiet_cmd_mkbin = OBJCOPY $@
-      cmd_mkbin = $(KLIBCOBJCOPY) -O binary $< $@
+      cmd_mkbin = $(KLIBCOBJCOPY) -O binary --only-section .rodata $< $@
 
 $(obj)/typesize.bin: $(obj)/typesize.o FORCE
 	$(call if_changed,mkbin)


More information about the klibc mailing list