Hi, Running glibc 2.38 system in qemu-system-m68k (machine virt, cpu m68040). Patch from here is applied https://sourceware.org/bugzilla/show_bug.cgi?id=30740. There is one issue, this oneliner does not work, I use it to show the ip address of the system: ipaddr=$(ip addr show $(ip route show|awk '/default/ { print $5 }')|awk '/inet / { print $2 }'|tail -1) With strace I get: Fatal glibc error: printf_fp.c:501 (__printf_fp_buffer_1): assertion failed: cy == 1 || (p.frac[p.fracsize - 2] == 0 && p.frac[0] == 0) Aborted Removing sysdeps/m68k/m680x0/lshift.S fixes the issue. best regards Waldemar
Please provide a self-contained test case. What exactly does gawk pass to printf?
root@openadk:~ # ip route show default via 10.0.2.2 dev eth0 10.0.2.0/24 dev eth0 scope link src 10.0.2.15 root@openadk:~ # ip route show|awk '/default/ { print $5 }' dev This normally should give eth0 instead of dev. It is not gawk, it is busybox awk, which is failing here. But I now checked with gawk, and it has the same problem. Does that help? best regards Waldemar
Worksforme. Most probably an emulation bug.
Waldemar forgot to said his build was done with -mcpu=68040. And this option gcc does not define __mc68020__, which makes sysdeps/m68k/m680x0/lshift.S and sysdeps/m68k/m680x0/rshift.S use a code path for not m68000 (which does seem wrong). This following fix does make the m68040 build prints the expected value: diff --git a/sysdeps/m68k/m680x0/lshift.S b/sysdeps/m68k/m680x0/lshift.S index 2aee10348e..bfb6d5580a 100644 --- a/sysdeps/m68k/m680x0/lshift.S +++ b/sysdeps/m68k/m680x0/lshift.S @@ -57,7 +57,7 @@ ENTRY(__mpn_lshift) bne L(Lnormal) cmpl R(s_ptr),R(res_ptr) bls L(Lspecial) /* jump if s_ptr >= res_ptr */ -#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) +#if defined (__mc68020__) || defined (__mc68040__) lea MEM_INDX1(s_ptr,s_size,l,4),R(a2) #else /* not mc68020 */ movel R(s_size),R(d0) @@ -71,7 +71,7 @@ L(Lnormal:) moveql #32,R(d5) subl R(cnt),R(d5) -#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) +#if defined (__mc68020__) || defined (__mc68040__) lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr) lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr) #else /* not mc68000 */ diff --git a/sysdeps/m68k/m680x0/rshift.S b/sysdeps/m68k/m680x0/rshift.S index d16bca9307..c8735c3bf1 100644 --- a/sysdeps/m68k/m680x0/rshift.S +++ b/sysdeps/m68k/m680x0/rshift.S @@ -56,7 +56,7 @@ ENTRY(__mpn_rshift) bne L(Lnormal) cmpl R(res_ptr),R(s_ptr) bls L(Lspecial) /* jump if res_ptr >= s_ptr */ -#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) +#if defined (__mc68020__) || defined (__mc68040__) lea MEM_INDX1(res_ptr,s_size,l,4),R(a2) #else /* not mc68020 */ movel R(s_size),R(d0) @@ -121,7 +121,7 @@ L(Lend:) cfi_restore_state L(Lspecial:) -#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) +#if defined (__mc68020__) || defined (__mc68040__) lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr) lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr) #else /* not mc68000 */
diff --git a/sysdeps/m68k/m680x0/lshift.S b/sysdeps/m68k/m680x0/lshift.S index 2aee10348e..4240738959 100644 --- a/sysdeps/m68k/m680x0/lshift.S +++ b/sysdeps/m68k/m680x0/lshift.S @@ -77,8 +77,8 @@ L(Lnormal:) #else /* not mc68000 */ movel R(s_size),R(d0) asll #2,R(d0) - addl R(s_size),R(s_ptr) - addl R(s_size),R(res_ptr) + addl R(d0),R(s_ptr) + addl R(d0),R(res_ptr) #endif movel MEM_PREDEC(s_ptr),R(d2) movel R(d2),R(d0)
Ok, but this is a different issue I think. Since this code is originally copied from gmplib, mpn/m68k/m68k-defs.m4 has: define(scale_available_p, `m4_ifdef_anyof_p( `HAVE_HOST_CPU_m68360' `HAVE_HOST_CPU_m68020' `HAVE_HOST_CPU_m68030' `HAVE_HOST_CPU_m68040' `HAVE_HOST_CPU_m68060')') So glibc should also checks for __mc68030__, __mc68040__, __mc68060__, instead of just __mc68020__.
It was correct when it was copied verbatim from gmp. The problem is that gcc has changed in the mean time.
ftr: andreas fixed that part in https://sourceware.org/git/?p=glibc.git;a=commit;h=464fd8249e8b791248cab7b0e0cd91757435fa9e.
thanks. That is working!