hi , I just using 64 bit linux with my powerfull desktop computer.
and I use Scientific linux as the destro,I use the RPM binary package to install
gcc. and I using nasm also.
I write simple example program in a nasm assembly (free) book.And the author
gives some library and include file for the assembly named 'asm_io.inc' and
'asm_io.o' so , they are linux 32 bit.
So what I need is to compile this to i386 targert. But my gcc doesn't allow this.
and I force the gcc linker using -m elf_i386 option. But it doesn't seems works.
[root@ZXDSL831CII ch01]# gcc -o first driver.o first.o asm_io.o
/usr/bin/ld: warning: i386 architecture of input file `first.o' is incompatible with i386:x86-64 output
/usr/bin/ld: warning: i386 architecture of input file `asm_io.o' is incompatible with i386:x86-64 output
driver.o: In function `main':
driver.c:(.text+0xe): undefined reference to `asm_main'
collect2: ld returned 1 exit status
[root@ZXDSL831CII ch01]# nasm -f aout first.asm
[root@ZXDSL831CII ch01]# gcc -o first driver.o first.o asm_io.o
/usr/bin/ld: warning: i386 architecture of input file `first.o' is incompatible with i386:x86-64 output
/usr/bin/ld: warning: i386 architecture of input file `asm_io.o' is incompatible with i386:x86-64 output
[root@ZXDSL831CII ch01]# ./first
Illegal instruction << see how much foolish is this gcc !
[root@ZXDSL831CII ch01]# gcc -m i386 -o first driver.o first.o asm_io.o
/usr/bin/ld: unrecognised emulation mode: i386
Supported emulations: elf_x86_64 elf_i386 i386linux
collect2: ld returned 1 exit status
[root@ZXDSL831CII ch01]# gcc -m i386linux -o first driver.o first.o asm_io.o
/usr/bin/ld: unrecognized option '--eh-frame-hdr'
/usr/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
[root@ZXDSL831CII ch01]# gcc -m elf_i386 -o first driver.o first.o asm_io.o
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: ld returned 1 exit status
[root@ZXDSL831CII ch01]#
and I wonder how the 'first' is built without the error at first time.
yes it was a 64 bit executable file.
[root@ZXDSL831CII ch01]# file first
first: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
[root@ZXDSL831CII ch01]#
see ,
any ideas ! I mean without installing or building back the gcc from the scratch ?
Anyway looks like I have to download the source tarball gcc and change the configurations to i386 and build it back. Please give me some advice , I mean
the configure options.
and I need to keep the 64-bit gcc also , but need the 32 bit one also , please
give me some nice idea here.
--Thanks in advance--