Linking as elf32-i686

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
therll
Posts: 7
Joined: Sat Sep 28, 2013 10:29 pm

Linking as elf32-i686

Post by therll »

I've been trying to link my kernel as i686 however even running

Code: Select all

i686-elf-objdump -i
doesn't show an option to link as elf32-i686, only as elf32-i386. Is it possible to link as elf32-i686?
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Linking as elf32-i686

Post by alexfru »

Is objdump even supposed to link anything?

What's the difference between elf32-i386 and elf32-i686? I'm working on an ELF linker and I can't recall there being multiple 32-bit x86 formats.
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Linking as elf32-i686

Post by Nessphoro »

Well, are you using a cross-compiler? If so then you should recompile your toolchain for i686.
therll
Posts: 7
Joined: Sat Sep 28, 2013 10:29 pm

Re: Linking as elf32-i686

Post by therll »

@alexfru objdump can list the available formats just like ld. And I don't know if elf32-i686 exists but since i686 and i386 are different I assume it does.
@Nessphoro I am using a cross compiler for i686-elf which is why I'm confused about why I have to link as elf32-i386.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Linking as elf32-i686

Post by thepowersgang »

Actually, the only option is elf32-i386 because that's the name used for elf32 for 32-bit intel machines. This format can contain any code you want (targeting i386, i686, or even x86-64)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Linking as elf32-i686

Post by sortie »

elf32-i386 is a BFD target. This is distinct from i686-elf which is a Target Triplet. The BFD target here is a container format, the same container format is used for all the ix86-elf targets. Thus there is no elf32-i486 / elf32-i586 / elf32-i686 and such. i386-elf and i686-elf is basically the same thing, except i686-elf has a few more instructions enabled by default I'd assume. However, the same BFD target is used for both of them. Thus you use the i686-elf target triplet but the elf32-i386 bfd target.

Actually, elf32-i386 isn't usable for x86_64 in general due to pointers being larger and the fact it would confuse the hell out of debugging tools. Though, if all the addresses are below 4 GiB and you accept debugging stuff will be confused, you can convert a elf64-x86_64 (or whatever is it called, I forgot) into a elf32-i386 container. I actually do that when feeding GRUB my x86-64 kernel as a 32-bit kernel.
Post Reply