addmoreice
February 17th, 2009, 02:09 AM
ok I'm compiling my 32 bit program on my 64 bit machine.
I was doing this in a virtual machine 32 bit environment but I'm tired of testing my kernel in Bochs IN another virtual machine.
So i used the -m32 switch for gcc and everything is working well there (I'm not using any standard library I'm turning all the pre-main stub stuff that is used to set up for a specific os work off etc etc etc).
So gcc _is_ working, I'm getting i386 object files. now over to ld, why am i using ld? because i'm also using nasm and a custom object generator tool from a custom language. _all_ object files are being outputted correctly, and link perfectly within the 32 bit environment.
when i switch to the 64 bit environment ld is not linking them together into an elf file. i've specified elf32_i386 as the output format with the
--oformat=elf32-i386
flag but ld just seems to be ignoring it. any hints?
gcc is using these flags.
-c -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra -Werror -nostartfiles -nodefaultlibs
Just to stem off the 'are you sure your compiling to 32bit and not using standard libraries' questions.
the ld error i get is:
ld: i386 architecture of input file `x' is incompatible with i386:x86-64 output
where x is every object file.
I'm even using the highest error level because I'm a masochist ](*,)
thank you for any suggestions or links to where i could possibly resolve this.
I have a feeling I'm just doing something very silly.
I was doing this in a virtual machine 32 bit environment but I'm tired of testing my kernel in Bochs IN another virtual machine.
So i used the -m32 switch for gcc and everything is working well there (I'm not using any standard library I'm turning all the pre-main stub stuff that is used to set up for a specific os work off etc etc etc).
So gcc _is_ working, I'm getting i386 object files. now over to ld, why am i using ld? because i'm also using nasm and a custom object generator tool from a custom language. _all_ object files are being outputted correctly, and link perfectly within the 32 bit environment.
when i switch to the 64 bit environment ld is not linking them together into an elf file. i've specified elf32_i386 as the output format with the
--oformat=elf32-i386
flag but ld just seems to be ignoring it. any hints?
gcc is using these flags.
-c -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra -Werror -nostartfiles -nodefaultlibs
Just to stem off the 'are you sure your compiling to 32bit and not using standard libraries' questions.
the ld error i get is:
ld: i386 architecture of input file `x' is incompatible with i386:x86-64 output
where x is every object file.
I'm even using the highest error level because I'm a masochist ](*,)
thank you for any suggestions or links to where i could possibly resolve this.
I have a feeling I'm just doing something very silly.