public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc-4.3.1 for mips linux failed to execute dynamically linked elf executables
@ 2008-09-02  1:46 hjksfw hjksfw
  2008-09-02 16:26 ` David Daney
  0 siblings, 1 reply; 4+ messages in thread
From: hjksfw hjksfw @ 2008-09-02  1:46 UTC (permalink / raw)
  To: gcc-help, lifang.wang

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=GB2312, Size: 4160 bytes --]

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

The cross-complied mips-linux-gcc is good for kernel building, and the
vmlinux  boots on the target board correctly, but the problem is that
all dynamically linked executable programs are failed to be executed
and statically linked executable programs are successful.
$ mips-linux-gcc -v
Using built-in specs.
Target: mips-linux
Configured with: ../post-gcc-4.3.1/configure --target=mips-linux
--with-float=soft --enable-cxx-flags=-msoft-float --enable-symvers=gnu
--prefix=/tools --disable-nls --enable-shared --enable-languages=c,c++
--enable-__cxa_atexit --enable-c99 --enable-long-long
--enable-threads=posix --with-arch=mips32r2 --with-tune=24kec
Thread model: posix
gcc version 4.3.1 (GCC)

when I compile linux-2.6.18 from mips-linux-gcc 4.3.1, there is an error:

$ make vmlinux.bin
  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  CC      arch/mips/kernel/asm-offsets.s
arch/mips/kernel/asm-offsets.c: In function 'output_mm_defines':
arch/mips/kernel/asm-offsets.c:228: error: invalid 'asm':
invalid use of '%X'
arch/mips/kernel/asm-offsets.c:229: error: invalid 'asm':
invalid use of '%X'
arch/mips/kernel/asm-offsets.c:230: error: invalid 'asm':
invalid use of '%X'
make[1]: *** [arch/mips/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2

the above error is due to the macro:
#define constant(string, member) \
        __asm__("\n@@@" string "%X0" : : "ri" (member))
in arch/mips/kernel/asm-offset.c
when I change the "%X0" to "%0":
#define constant(string, member) \
        __asm__("\n@@@" string "%0" : : "ri" (member))

the kernel compiled successfully.But mips-linux-gcc-4.1.1 have no such problem.
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 ¨Co test-dyn
Mips-linux-gcc test.c ¨Co test-static ¨Cstatic


$ 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?
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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc-4.3.1 for mips linux failed to execute dynamically linked  elf executables
  2008-09-02  1:46 gcc-4.3.1 for mips linux failed to execute dynamically linked elf executables hjksfw hjksfw
@ 2008-09-02 16:26 ` David Daney
  2008-09-03  5:56   ` hjksfw hjksfw
  0 siblings, 1 reply; 4+ messages in thread
From: David Daney @ 2008-09-02 16:26 UTC (permalink / raw)
  To: hjksfw hjksfw; +Cc: gcc-help, lifang.wang

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 篓Co test-dyn
> Mips-linux-gcc test.c 篓Co test-static 篓Cstatic
>
>
> $ 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc-4.3.1 for mips linux failed to execute dynamically linked elf executables
  2008-09-02 16:26 ` David Daney
@ 2008-09-03  5:56   ` hjksfw hjksfw
  2010-12-04  6:17     ` Coder_gate
  0 siblings, 1 reply; 4+ messages in thread
From: hjksfw hjksfw @ 2008-09-03  5:56 UTC (permalink / raw)
  To: ddaney, kai.ruottu; +Cc: gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=GB2312, Size: 3621 bytes --]

Thanks very much.
I change glibc from 2.4 to 2.7 and the resulted cross-compiled
mips-linux-gcc 4.3.1 worked well for both kernel and dynamically
linked elf executables.

ÔÚ 08-9-3£¬David Daney<ddaney@avtrex.com> дµÀ£º
> 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 ¨Co test-dyn
> > Mips-linux-gcc test.c ¨Co test-static ¨Cstatic
> >
> >
> > $ 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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc-4.3.1 for mips linux failed to execute dynamically linked elf executables
  2008-09-03  5:56   ` hjksfw hjksfw
@ 2010-12-04  6:17     ` Coder_gate
  0 siblings, 0 replies; 4+ messages in thread
From: Coder_gate @ 2010-12-04  6:17 UTC (permalink / raw)
  To: gcc-help


hi you, i use mips-linux-gnu-gcc 4.3.2 (Sourcery G++ Lite 4.3-51) 
and glibc 2.12.1-0ubuntu9 (libc6-dev) but when i build it error is:

make ARCH=mips CROSS_COMPILE=mips-linux-gnu-
http://old.nabble.com/file/p30366623/thientai.png 
CHK include/linux/version.h
CHK include/linux/utsrelease.h
CC arch/mips/kernel/asm-offsets.s
arch/mips/kernel/asm-offsets.c: In function 'output_mm_defines':
arch/mips/kernel/asm-offsets.c:232: error: invalid 'asm': invalid use of
'%X'
arch/mips/kernel/asm-offsets.c:233: error: invalid 'asm': invalid use of
'%X'
arch/mips/kernel/asm-offsets.c:234: error: invalid 'asm': invalid use of
'%X'
make[1]: *** [arch/mips/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2 
http://ngosylien.edu.vn/forum/showthread.php?482-3-12-2010-Port-Gcc-for-Mips-to-Gcc-for-x86&p=589&viewfull=1#post589




hjksfw hjksfw wrote:
> 
> Thanks very much.
> I change glibc from 2.4 to 2.7 and the resulted cross-compiled
> mips-linux-gcc 4.3.1 worked well for both kernel and dynamically
> linked elf executables.
> 
> 在 08-9-3,David Daney<ddaney@avtrex.com> 写道:
>> 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
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/gcc-4.3.1-for-mips-linux-failed-to-execute-dynamically-linked-elf-executables-tp19263040p30366623.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-04  6:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-02  1:46 gcc-4.3.1 for mips linux failed to execute dynamically linked elf executables hjksfw hjksfw
2008-09-02 16:26 ` David Daney
2008-09-03  5:56   ` hjksfw hjksfw
2010-12-04  6:17     ` Coder_gate

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).