hjksfw hjksfw wrote: > Hi all, I have build mips-linux-gcc on debian i486 pc from following sources: > Gcc-4.3.1 > Binutils-2.18 > Glibc-2.4 > Kernel-headers-2.6.18 . . . > when I compile linux-2.6.18 from mips-linux-gcc 4.3.1, there is an error: > . . . > > the kernel compiled successfully.But mips-linux-gcc-4.1.1 have no such problem. Perhaps you should stick to gcc-4.1.1 for your kernel. > And the following is problems for dynamically linked elf. > A simplest test program: > #include > int main() > { > printf("hello mips\n"); > return 0; > } > > > mips-linux-gcc test.c ?o test-dyn > Mips-linux-gcc test.c ?o test-static ?static > > > $ file ./test-dyn > ./test-dyn: ELF 32-bit MSB MIPS64 executable, MIPS, version 1 (SYSV), > for GNU/Linux 2.0.0, dynamically linked (uses shared libs), not > stripped > $ file ./test-static > ./test-static: ELF 32-bit MSB MIPS64 executable, MIPS, version 1 > (SYSV), for GNU/Linux 2.0.0, statically linked, not stripped > > The strace results on the target mips board are following,(strace is > statically linked, so it can be executed): > Strace the program: > / # strace ./test-dyn > execve("./test-dyn", ["./test-dyn"], [/* 6 vars */]) = 0 > do_page_fault() #2: sending SIGSEGV to test-dyn for invalid read access from > 0002e258 (epc == 2aabf140, ra == 2aab4f70) > uname({sys="Linux", node="192.168.172.44", ...}) = 0 > old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, > -1, 0) = 0x2aac5000 > access("/etc/ld.so.preload", R_OK) = 0 > open("/etc/ld.so.preload", O_RDONLY) = 3 > fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 > close(3) = 0 > --- SIGSEGV (Segmentation fault) @ 0 (0) --- > +++ killed by SIGSEGV +++ > Process 98 detached > / # strace ./test-static > execve("./test-static", ["./test-static"], [/* 6 vars */]) = 0 > svr4_syscall() = 4122 > svr4_syscall() = 4045 > brk(0x494c98) = 0x494c98 > set_thread_area(0x49b460) = -2143376080 > brk(0x4b5c98) = 0x4b5c98 > brk(0x4b6000) = 0x4b6000 > fstat64(1, {st_mode=S_IFCHR|0646, st_rdev=makedev(5, 1), ...}) = 0 > ioctl(1, TIOCNXCL, {B115200 opost isig icanon echo ...}) = 0 > old_mmap(NULL, 131072, PROT_READ|PROT_WRITE, > MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aaa8000 > write(1, "hello mips\n", 11hello mips > ) = 11 > exit_group(0) = ? > Process 100 detached > > I don't know what's wrong with the mips-linux-gcc 4.3.1, would you > help me please? I don't think gcc-4.3.x is supported by any version of glibc prior to 2.8. Best to use a supported version of gcc when building glibc. I have successfully used gcc-4.3.x on several different mips platforms. But I only build glibc with supported compiler versions. You could try upgrading to glibc 2.7 or 2.8. Or ... > And I have also tried to cross-compile gcc for mips-linux from: > Gcc-4.1.1 > Binutils-2.17 > Glibc-2.4 > kernel-headers-2.6.18 > This cross-compiled gcc worked fine for both kernel and programs. ...Use these versions as they seem to work for you. David Daney