Building gdbserver on m68k Coldfire
Waldemar,
As you know, gdbserver currently fails to build on m68k Coldfire due to the use of fork(). I've investigated this, and it's due to the fact that gdbserver looks at uClibc __UCLIBC_HAS_MMU__ define (see
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/nat/linux-ptrace.h;h=59549452c0990204ef48451dc2c902c85ee48215;hb=HEAD#l25)
to decide whether to define HAS_NOMMU. If HAS_NOMMU is defined, it uses vfork().
So, I've fixed this with:
package/uclibc/uclibc.mk +2 -0
@@ -260,10 +260,12 @@ endif ifeq ($(BR2_USE_MMU),y) define UCLIBC_MMU_CONFIG $(call KCONFIG_ENABLE_OPT,ARCH_USE_MMU,$(@D)/.config) + $(call KCONFIG_ENABLE_OPT,ARCH_HAS_MMU,$(@D)/.config) endef else define UCLIBC_MMU_CONFIG $(call KCONFIG_DISABLE_OPT,ARCH_USE_MMU,$(@D)/.config) + $(call KCONFIG_DISABLE_OPT,ARCH_HAS_MMU,$(@D)/.config) endef endif
With this fix, the build goes a little bit further, but then fails with:
../nat/linux-ptrace.c: In function 'linux_fork_to_function':../nat/linux-ptrace.c:282:19: warning: implicit declaration of function 'clone' [-Wimplicit-function-declaration]
child_pid = clone (function, child_stack + STACK_SIZE,
^../nat/linux-ptrace.c:283:5: error: 'CLONE_VM' undeclared (first use in this function)
CLONE_VM | SIGCHLD, child_stack + STACK_SIZE * 2);
^../nat/linux-ptrace.c:283:5: note: each undeclared identifier is reported only once for each function it appears in
It's weird, because this piece of code in linux-ptrace is specifically written for uClibc/noMMU systems:
Is uClibc/noMMU supposed to support clone() and CLONE_VM ?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Hi Thomas,
Thomas Petazzoni wrote,
Quoted 37 lines
Waldemar,
As you know, gdbserver currently fails to build on m68k Coldfire due to the use of
fork(). I've investigated this, and it's due to the fact that gdbserver looks at uClibc__UCLIBC_HAS_MMU__define (see
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/nat/linux-ptrace.h;h=59549452c0990204ef48451dc2c902c85ee48215;hb=HEAD#l25)
to decide whether to defineHAS_NOMMU. IfHAS_NOMMUis defined, it usesvfork().So, I've fixed this with:
package/uclibc/uclibc.mk +2
-0@@ -260,10 +260,12 @@ endif ifeq ($(BR2_USE_MMU),y) define UCLIBC_MMU_CONFIG $(call KCONFIG_ENABLE_OPT,ARCH_USE_MMU,$(@D)/.config) + $(call KCONFIG_ENABLE_OPT,ARCH_HAS_MMU,$(@D)/.config) endef else define UCLIBC_MMU_CONFIG $(call KCONFIG_DISABLE_OPT,ARCH_USE_MMU,$(@D)/.config) + $(call KCONFIG_DISABLE_OPT,ARCH_HAS_MMU,$(@D)/.config) endef endifWith this fix, the build goes a little bit further, but then fails with:
../nat/linux-ptrace.c: In function 'linux_fork_to_function':../nat/linux-ptrace.c:282:19: warning: implicit declaration of function 'clone' [-Wimplicit-function-declaration]
child_pid= clone (function,child_stack+STACK_SIZE,
^../nat/linux-ptrace.c:283:5: error: 'CLONE_VM' undeclared (first use in this function)CLONE_VM | SIGCHLD, child_stack + STACK_SIZE * 2); ^
Quoted 8 lines
../nat/linux-ptrace.c:283:5: note: each undeclared identifier is reported only once for each function it appears inIt's weird, because this piece of code in linux-ptrace is specifically written for uClibc/noMMU systems:
Is uClibc/noMMU supposed to support
clone()andCLONE_VM?
Yes, just add this patch:
https://cgit.openadk.org/cgi/cgit/openadk.git/tree/package/gdbserver/patches/nommu.patch
best regards
Waldemar