Skip to contentSkip to conversation

ARM in big endian mode?

Qemu-devel Lennert Buytenhek 4 participants 11 messages Jul 3, 2004 – Aug 6, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

For a project I'm working on, I would love to be able to simulate an ARM in big endian mode (such as the intel xscale core). If I try to run an MSB executable on qemu current, I just get this:

# file init
init: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, stripped
# qemu-arm ./init
Error loading ./init
# 

Would it be a lot of effort to add this?

cheers,
Lennert

#1 lore raw
Quoted 6 lines · Lennert Buytenhek

Hi,

For a project I'm working on, I would love to be able to simulate an ARM in big endian mode (such as the intel xscale core). If I try to run an MSB executable on qemu current, I just get this:

Quoted 7 lines
# file init
init: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, stripped
# qemu-arm ./init
Error loading ./init
# 

Would it be a lot of effort to add this?

Compile with TARGET_WORDS_BIGENDIAN 1 ought to do it.

Signature · 3 lines
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D
#2 lore raw
Quoted 10 lines · Gianni Tedesco
Quoted 10 lines

For a project I'm working on, I would love to be able to simulate an ARM in big endian mode (such as the intel xscale core). If I try to run an MSB executable on qemu current, I just get this:

# file init
init: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, stripped
# qemu-arm ./init
Error loading ./init
# 
Quoted 3 lines
Quoted 1 line

Would it be a lot of effort to add this?

Compile with TARGET_WORDS_BIGENDIAN 1 ought to do it.

That didn't go very well..

% pwd
/data/qemu/qemu_cvs/arm-user
% cat x.c
#include <stdio.h>
#include <stdlib.h>

int main()

{
	return 0;
}

% armv5b-softfloat-linux-gcc -Wall -o x x.c -static
% file x
x: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, not stripped % tail -1 config.h
#define TARGET_WORDS_BIGENDIAN 1
% ./qemu-arm ./x
qemu: uncaught target signal 11 (Segmentation fault) - exiting
%

Same binary works fine on my target board.

--L

#3 lore raw
Quoted 2 lines · Lennert Buytenhek

% ./qemu-arm ./x
qemu: uncaught target signal 11 (Segmentation fault) - exiting

Are you sure that's happening only for BE ARM binaries? I have a vague recollection that last time I tried qemu-arm it was doing that even for LE executables.

Signature · 1 line
dwmw2
#4 lore raw
Quoted 6 lines · David Woodhouse
Quoted 2 lines

% ./qemu-arm ./x
qemu: uncaught target signal 11 (Segmentation fault) - exiting

Are you sure that's happening only for BE ARM binaries? I have a vague recollection that last time I tried qemu-arm it was doing that even for LE executables.

Just checked, and indeed, LE binaries segfault too.

That's strange, since I remember checking LE ARM binaries a while ago, and after patching qemu to correct some O_* flags (I think it had O_DIRECT and O_DIRECTORY mixed up, or something like that), things seemed to work okay. I even built a small debian ARM chroot, fully emulated with qemu, with an sshd running in there, etc.

So it looks like it (might have) worked in the past but broke somewhere between then and now.

--L

#5 lore raw
Quoted 4 lines · Lennert Buytenhek
Quoted 2 lines · David Woodhouse
Quoted 2 lines

% ./qemu-arm ./x
qemu: uncaught target signal 11 (Segmentation fault) - exiting

<...>

Quoted 1 line

Just checked, and indeed, LE binaries segfault too.

<...>

Quoted 2 lines

So it looks like it (might have) worked in the past but broke somewhere between then and now.

Are you using a newer glibc now than the one you were using before?

Signature · 1 line
dwmw2
#6 lore raw

[PROBLEM FOUND] qemu-arm on FC2 (was: Re: [Qemu-devel] ARM in big endian mode?)

Quoted 9 lines · David Woodhouse
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

% ./qemu-arm ./x
qemu: uncaught target signal 11 (Segmentation fault) - exiting

<...>

Quoted 1 line

Just checked, and indeed, LE binaries segfault too.

<...>

Quoted 2 lines

So it looks like it (might have) worked in the past but broke somewhere between then and now.

Are you using a newer glibc now than the one you were using before?

Yes. Now I'm using Fedora Core 2, but Red Hat 9 back then, I think.

I just found some time for some more testing, and it's FC2's noexecstack messing up in this particular case. If I create, using gcc 2.95.3 and glibc 2.1.3 vanilla, a static ARM little-endian "Hello world" binary, and run it with qemu-arm latest CVS, it works if I specify -Wl,-z,execstack when linking qemu-arm, and crashes with sig11 if I do not.

--L

#7 lore raw

Re: [PROBLEM FOUND] qemu-arm on FC2 (was: Re: [Qemu-devel] ARM in big endian mode?)

Quoted 5 lines · Lennert Buytenhek
Quoted 3 lines · David Woodhouse
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

% ./qemu-arm ./x
qemu: uncaught target signal 11 (Segmentation fault) - exiting

<...>

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Just checked, and indeed, LE binaries segfault too.

<...>

Quoted 2 lines

So it looks like it (might have) worked in the past but broke somewhere between then and now.

Are you using a newer glibc now than the one you were using before?

Yes. Now I'm using Fedora Core 2, but Red Hat 9 back then, I think.

Hmm. I meant the ARM glibc, not the host. I have a vague recollection that using an older ARM libc made it work OK. Using statically linked ARM binaries also made it work.

Quoted 5 lines

I just found some time for some more testing, and it's FC2's noexecstack messing up in this particular case. If I create, using gcc 2.95.3 and glibc 2.1.3 vanilla, a static ARM little-endian "Hello world" binary, and run it with qemu-arm latest CVS, it works if I specify -Wl,-z,execstack when linking qemu-arm, and crashes with sig11 if I do not.

With 0.6.0 this doesn't do it for me. This is a Familiar 0.7.2 image with glibc 2.3.2

shinybook /home/dwmw2/working/pkgs/qemu/qemu-0.6.0/arm-user $ gcc -g -Wl,-T,/home/dwmw2/working/pkgs/qemu/qemu-0.6.0/ppc.ld -o qemu-arm elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o nwfpe/double_cpdo.o nwfpe/extended_cpdo.o libqemu.a -lm -Wl,-z,execstack shinybook /home/dwmw2/working/pkgs/qemu/qemu-0.6.0/arm-user $ ./qemu-arm /usr/qemu-arm/bin/echo hello
qemu: uncaught target signal 11 (Segmentation fault) - exiting

Signature · 1 line
dwmw2
#8 lore raw

Re: [PROBLEM FOUND] qemu-arm on FC2 (was: Re: [Qemu-devel] ARM in big endian mode?)

Quoted 10 lines · David Woodhouse
Quoted 10 lines · David Woodhouse
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

% ./qemu-arm ./x
qemu: uncaught target signal 11 (Segmentation fault) - exiting

<...>

Quoted 1 line

Just checked, and indeed, LE binaries segfault too.

<...>

Quoted 2 lines

So it looks like it (might have) worked in the past but broke somewhere between then and now.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Are you using a newer glibc now than the one you were using before?

Yes. Now I'm using Fedora Core 2, but Red Hat 9 back then, I think.

Hmm. I meant the ARM glibc, not the host. I have a vague recollection that using an older ARM libc made it work OK. Using statically linked ARM binaries also made it work.

Ooooh, sorry, yes. This is what I get on an FC2 host:

qemu-arm default (noexecstack) qemu-arm execstack

hello world
compiled with
gcc 2.95.3 sig11 works
and glibc
2.1.3

hello world
compiled with
gcc 3.3.3 sig11 sig11
and glibc
2.3.2

Now testing various permutations of host toolchain and target toolchain.

--L

#9 lore raw
In reply to Gianni Tedesco
Quoted 14 lines · Gianni Tedesco
Quoted 12 lines · Lennert Buytenhek

Hi,

For a project I'm working on, I would love to be able to simulate an ARM in big endian mode (such as the intel xscale core). If I try to run an MSB executable on qemu current, I just get this:

# file init
init: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, stripped
# qemu-arm ./init
Error loading ./init
# 
Quoted 4 lines
Quoted 1 line

Would it be a lot of effort to add this?

Compile with TARGET_WORDS_BIGENDIAN 1 ought to do it.

There may be some problems left with the floats. But basically it should work. Send me a statically linked executable so that I can test.

Fabrice.

#10 lore raw
Quoted 4 lines · Fabrice Bellard
Quoted 1 line

Compile with TARGET_WORDS_BIGENDIAN 1 ought to do it.

There may be some problems left with the floats. But basically it should work. Send me a statically linked executable so that I can test.

Hi,

I generated a few testcases, but because they are rather big, I put them (bzipped) online at: http://www2.wantstofly.org/arm_big_endian/

Thanks in advance!

cheers,
Lennert