OS Development With Mac OS X

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
zachogden
Posts: 5
Joined: Fri Nov 04, 2005 12:00 am

OS Development With Mac OS X

Post by zachogden »

Hi all,

I'm beginning OS development on my new Intel iMac, and I've run into some issues with the included ld linker program. ld doesn't seem to want to link flat-binary files that I produce with NASM and/or GCC, which is a big problem. Does anyone know of a way around this, or where I could get an ld that will work for me?

Thanks,
Zach
osprogram
Posts: 16
Joined: Tue May 09, 2006 11:00 pm

Re: OS Development With Mac OS X

Post by osprogram »

Linux Warning: There is a problem with ld on Linux. The problem is that the "ld" that comes with linux distros lists support for the coff object format, but apparently you have to rebuilt binutils from gnu.org to get it working. I found two possible solutions. Recompile ld or edit your assembly files and remove all the leading underscores. Then when you assemble with nasm use the -f aout option instead of coff. I've tested the second method briefly and it works.

I think the problem is the same for Mac OS as well.
zachogden
Posts: 5
Joined: Fri Nov 04, 2005 12:00 am

Re: OS Development With Mac OS X

Post by zachogden »

The problem isn't with coff files, it's the fact that just invoking ld with flat binaries gives me a message similar to the following:
Error: File is not a Mach-O binary or is missing Mach-O magic number
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: OS Development With Mac OS X

Post by carbonBased »

What if you produce a Mac OsX binary object, and use 'objcopy' to extract out the appropriate sections and concatenate them together with 'cat'

That way you can structure your binary however you'd like.

--Jeff
zachogden
Posts: 5
Joined: Fri Nov 04, 2005 12:00 am

Re: OS Development With Mac OS X

Post by zachogden »

I ended up making a cross-compile toolchain by configuring ld and gcc with --target=i686-elf . Everything works fine now, did a test this morning.
Post Reply