[Ltrace-devel] mips/mips-64 status?

Petr Machata pmachata at redhat.com
Tue Nov 27 21:07:40 UTC 2012


Randy MacLeod <rwmacleod at gmail.com> writes:

> I tried to compile ltrace.git/HEAD for mips-64. See compile errors
> below. I guess this is the expected state.

Yeah, MIPS64 is utterly unsupported at the moment.

> I also built for mips-32 and found that it compiles but  doesn't run. See below. 
> This result contradicts the README so if other people confirm that mips is busted,
> then the README should be changed.

Could you please try plain 0.7.0 as well?  This should be about the
same, but chances are I broke something on master since 0.7.0.  Sedat
Dilek and Edgar Iglesias both reported that 0.7.0 worked on 32-bit MIPS.
I think they meant 32-bit MIPS CPU, not even MIPS64 running in 32-bit
mode (n32 ABI).

> HEAD = commit 4fb13f6aa2eb371a724e2e02e744cf993ddea8f2
>
>  mips64-wrs-linux-libtool: compile:  mips64-wrswrap-linux-gnu-gcc -meb -mabi=64 -mhard-float --sysroot=/home/rmacleod/wrs/5.0/b/ltrace-mips64/bitbake_build/tmp/sysroots/
> qemumips-64 -DHAVE_CONFIG_H -I. -I../../..
>  -I../../../sysdeps/linux-gnu/mips -I../../../sysdeps/linux-gnu -I../../../sysdeps -I../../.. -Wall -Wsign-compare -Wfloat-equal -Wformat-security -Werror -O2 -pipe -g
> -fno-omit-frame-pointer -fvisibility=default
>  -c plt.c  -fPIC -DPIC -o .libs/plt.o
> | plt.c: In function 'arch_elf_add_plt_entry':
> | plt.c:360:4: error: format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'GElf_Addr' [-Werror=format]
> | plt.c:369:3: error: format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'GElf_Addr' [-Werror=format]
> | cc1: all warnings being treated as errors
> | make[4]: *** [plt.lo] Error 1
>
> I added a (long long unsigned int) for both cases as a quick fix to
> see what else was broken.

I think this should be fixed like this (not tested though):

diff --git a/sysdeps/linux-gnu/mipsel/plt.c b/sysdeps/linux-gnu/mipsel/plt.c
index b277fbc..9dd003f 100644
--- a/sysdeps/linux-gnu/mipsel/plt.c
+++ b/sysdeps/linux-gnu/mipsel/plt.c
@@ -26,6 +26,7 @@
 #include <errno.h>
 #include <gelf.h>
 #include <sys/ptrace.h>
+#include <inttypes.h>
 
 #include "common.h"
 #include "debug.h"
@@ -356,8 +357,8 @@ arch_elf_add_plt_entry(struct Process *proc, struct ltelf *lte,
 
 	name = strdup(a_name);
 	if (name == NULL) {
-		fprintf(stderr, "%s: failed %s(%#llx): %s\n", __func__,
-			name, addr, strerror(errno));
+		fprintf(stderr, "%s: failed %s(%#"PRIx64"): %s\n",
+			__func__, name, addr, strerror(errno));
 		goto fail;
 	}
 
@@ -366,7 +367,8 @@ arch_elf_add_plt_entry(struct Process *proc, struct ltelf *lte,
 	if (library_symbol_init(libsym,
 				(arch_addr_t) (uintptr_t) addr,
 				name, 1, LS_TOPLT_EXEC) < 0) {
-		fprintf(stderr, "%s: failed %s : %llx\n", __func__, name, addr);
+		fprintf(stderr, "%s: failed %s : %"PRIx64"\n",
+			__func__, name, addr);
 		goto fail;
 	}
 

If you can verify that this fixes MIPS64 builds and doesn't break MIPS32
builds, I'll put this in.  The rest is more difficult though.

> | mips64-wrs-linux-libtool: compile:  mips64-wrswrap-linux-gnu-gcc -meb -mabi=64 -mhard-float --sysroot=/home/rmacleod/wrs/5.0/b/ltrace-mips64/bitbake_build/tmp/sysroots/
> qemumips-64 -DHAVE_CONFIG_H -I. -I../../..
>  -I../../../sysdeps/linux-gnu/mips -I../../../sysdeps/linux-gnu -I../../../sysdeps -I../../.. -Wall -Wsign-compare -Wfloat-equal -Wformat-security -Werror -O2 -pipe -g
> -fno-omit-frame-pointer -fvisibility=default
>  -c plt.c  -fPIC -DPIC -o .libs/plt.o
> | mips64-wrs-linux-libtool: compile:  mips64-wrswrap-linux-gnu-gcc -meb -mabi=64 -mhard-float --sysroot=/home/rmacleod/wrs/5.0/b/ltrace-mips64/bitbake_build/tmp/sysroots/
> qemumips-64 -DHAVE_CONFIG_H -I. -I../../..
>  -I../../../sysdeps/linux-gnu/mips -I../../../sysdeps/linux-gnu -I../../../sysdeps -I../../.. -Wall -Wsign-compare -Wfloat-equal -Wformat-security -Werror -O2 -pipe -g
> -fno-omit-frame-pointer -fvisibility=default
>  -c trace.c  -fPIC -DPIC -o .libs/trace.o
> | trace.c: In function 'arch_atomic_singlestep':
> | trace.c:269:16: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
> | trace.c:276:23: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> | cc1: all warnings being treated as errors
> | make[4]: *** [trace.lo] Error 1

This looks like it should be using arch_addr_t instead of uint32_t, but
this is a more involved fix that I don't have enough knowledge to just
whip up like that.

> I looked at this briefly but it really seems like the mips support is
> only for 32 bit targets.  I'm not in a position to add full mips-64
> support so I'll likely just omit it from the supported arches.
>
> ltrace --help works of course but
> ltrace echo a fails:
> root at qemu0:~# ltrace echo a
> --- SIGSEGV (Segmentation fault) ---
> +++ killed by SIGSEGV +++

Right, ltrace kills the process.  This usually means a misplaced
breakpoint, a mangled instruction or some such.

Unfortunately I can't even tell you how much work fixing MIPS64 would
be.  I never played with MIPS, dunno what all is missing.  Chances are
Edgar will have some insight here.

Thanks,
PM



More information about the Ltrace-devel mailing list