ARM gcj 4.2.x produces non working executables
Andreas Bürgel
mail@andreas-buergel.de
Tue Mar 18 14:44:00 GMT 2008
Hi folks,
I built a cross-compile toolchain for ARM Linux using crosstool-0.43 (getandpatch.sh slightly modified so it doesn't look for glibc-linuxheaders but for glibc-ports) with the following configuration (host was x86-linux with openSUSE 10.3):
BINUTILS_VERSION=2.18
GCC_VERSION=4.2.3
LINUX_VERSION=2.6.22
GLIBC_VERSION=2.6.1
GDB_VERSION=6.7.1
BINUTILS_DIR=binutils-$BINUTILS_VERSION
BINUTILS_EXTRA_CONFIG=" --with-tls "
GCC_CORE_DIR=
GCC_DIR=gcc-$GCC_VERSION
GCC_LANGUAGES=c,c++,java
GCC_EXTRA_CONFIG=" --enable-shared --with-tls --enable-languages=c,c++,java --with-gmp=/opt/gnu --with-mpfr=/opt/gnu " LINUX_DIR=linux-$LINUX_VERSION GLIBC_DIR=glibc-$GLIBC_VERSION GLIBC_PORTS=glibc-ports-$GLIBC_VERSION
GLIBC_EXTRA_CONFIG=" $GLIBC_EXTRA_CONFIG --with-tls --with-__thread --enable-kernel=2.6" GLIBC_ADDON_OPTIONS="=nptl,glibc-ports-$GLIBC_VERSION"
GDB_DIR=gdb-$GDB_VERSION
PREFIX=/opt/gnu/arm-unknown-linux-gnu
KERNELCONFIG=/home/andreas/tmp/crosstool-0.43/arm.config
TOP_DIR=/home/andreas/tmp/crosstool-0.43
TARBALLS_DIR=/home/andreas/downloads
SHARED_MODE=" --enable-shared "
PARALLELMFLAGS=" -j 2 "
TARGET_FLAGS=" -O3 -D__ARM_ARCHITECTURE__"
The single major problem I encountered while building the toolchain are missing defines like ERANGE or EINTR and erros while compiling natPlainDatagramSocketImpl.cc and natPlainSocketImpl.cc when the libjava sub-directory is compiled. This is induced by picking the wrong headers from /usr/include/asm and /usr/include/bits
(WORKAROUND, temporarily link asm and bits to directories for the ARM-architecture, build the libjava sub-dir by hand and restore old state in /usr/include:
cd /usr/include;
rm asm;
mv bits bits.i386;
ln -s asm-arm asm;
ln -s <PREFIX>/<TARGET>/include/bits;
cd <CROSSTOOL>/build/<TARGET>/<BUILD_NAME>/build-gcc/<TARGET>/libjava;
make clean;
make;
cd /usr/include;
rm asm bits;
ln -s asm-bi-x86_64 asm;
ln -s bits.i386 bits;
cd <CROSSTOOL>;
./demo-arm.sh).
This produced a full toolchain with arm-unknown-linux-gnu-gcj, libc-2.6.1 and libgcj.so.8.0.0. I compiled a simple hello-world java-program and produced a correct looking binary:
arm-unknown-linux-gnu-gcj -O6 -classpath ../bin --main=com.bucyrus.automation.mmc.benchmark.Hello -o Hello.arm ../bin/com/bucyrus/automation/mmc/benchmark/Hello.class
I copied the contents of <PREFIX>/<TARGET>/lib (contains libc, libcj, ld-linux and so on) and Hello.arm into a temporary directory on my target and started the executable with ./ld-2.6.1.so --library-path ./ ./Hello.arm
The executable starts, eats up all free memory and is then killed by the linux-kernel. Parts of the output of strace -f follow
(command line was: "./ld-2.6.1.so --library-path ./ ./strace -f ./ld-2.6.1.so --library-path ./ ./Hello.arm > fred 2>&1")
[... shortly after this point the problems seems to begin ...]
---------------------------------------8<-------------------------------------------------------
mprotect(0x41d85000, 4096, PROT_READ) = 0
open("/etc/passwd", O_RDONLY) = 3
fcntl64(3, F_GETFD) = 0
fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
fstat64(3, {st_mode=S_IFREG|0755, st_size=30, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x41d87000
read(3, "root:x:0:0:root:/root:/bin/sh\n", 4096) = 30
close(3) = 0
munmap(0x41d87000, 4096) = 0
getcwd("/mmc/arm_java", 250) = 14
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/gconv/gconv-modules", O_RDONLY) = -1 ENOENT (No such file or directory)
futex(0x41d10b6c, FUTEX_WAKE, 2147483647) = 0
gettimeofday({883614662, 579890}, NULL) = 0
access("/opt/gnu/arm-unknown-linux-gnu/share/java/ext", F_OK) = -1 ENOENT (No such file or directory)
access(".", F_OK) = 0
stat64(".", {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0 lstat64("/mmc", {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0 lstat64("/mmc/arm_java", {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0 stat64("/mmc/arm_java", {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0
access("/opt/gnu/arm-unknown-linux-gnu/share/java/gcj-endorsed", F_OK) = -1 ENOENT (No such file or directory)
rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0
mmap2(0x41d75000, 69632, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x41d87000 mmap2(0x41d98000, 65536, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x41d98000
rt_sigprocmask(SIG_BLOCK, [CHLD], NULL, 8) = 0
mmap2(NULL, 8388608, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x41da8000
mprotect(0x41da8000, 4096, PROT_NONE) = 0
clone(Process 2904 attached
child_stack=0x425a7088, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED, parent_tidptr=0x425a7528, tls=0x425a7930, child_tidptr=0x425a7528) = 2904
[pid 2879] futex(0x41d55cec, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 2904] futex(0x41d55cec, FUTEX_WAKE, 1 <unfinished ...>
[pid 2879] <... futex resumed> ) = 0
[pid 2904] <... futex resumed> ) = 1
[pid 2879] futex(0x41bf20bc, FUTEX_WAKE, 2147483647) = 0
[pid 2904] rt_sigprocmask(SIG_BLOCK, [CHLD], NULL, 8) = 0
[pid 2904] futex(0x2a026400, FUTEX_WAIT, 1, NULL <unfinished ...>
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
--------------------------------------->8-------------------------------------------------------
[... end of strace output ...]
---------------------------------------8<-------------------------------------------------------
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2879] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
[pid 2879] rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0
[pid 2904] <... futex resumed> ) = -1 EINTR (Interrupted system call)
[pid 2904] +++ killed by SIGKILL +++
PANIC: handle_group_exit: 2904 leader 2879
Process 2904 detached
+++ killed by SIGKILL +++
Process 2879 detached
---------------------------------------8<-------------------------------------------------------
I tested it with gcc-4.2.1 and gcc-4.2.3 using a real piece of ARM-hardware (taskit portux) with kernel 2.6.18 and libc-2.2.5 and using qemu-0.9.1 with kernel 2.6.16 and libc-2.3.5. Result was the same for all combinations.
I retried using gcc-4.1.2 and did _not_ have the problem. I did the same test on my target with the same files as with the 4.2.x test, only adding libgcj.so.7.0.0 and using the executable produced by arm-unknown-linux-gcj (4.1.2). This works fine, so the problem must be in libgcj.so.8 or in arm-unknown-linux-gcj (4.2.x) itself.
Keywords: gcc gcj cross-compiler crossgcj arm-linux 4.2.3 4.2.1 segmentation fault libgcj java
--
Mit freundlichen Grueszen, / With kind regards,
Bucyrus DBT Europe GmbH
i.A. Andreas Bürgel
ECC Automation
Industriestr. 1, D-44534 Lünen
Tel: +49 (2306) 709 2509
Fax: +49 (2306) 709 1315 2509
mailto: andreas.buergel@de.bucyrus.com
mailto: mail@andreas-buergel.de
http://www.bucyrus.com
A Bucyrus International, Inc. company
_________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list