On Apr 11, 2:33 am, Josh Grams <j...@[EMAIL PROTECTED]
> wrote:
....
> I'm still not quite clear whether you're having trouble getting Apple's
> toolchain to assemble and link a working lina binary, or if you need to
> learn the internals of ELF/Mach-O so you can port SAVE-SYSTEM, or both.
Both ultimately, I have managed to coax nasm and ld to produce a mach-
o but whether it's true to form of Albert's original I am unsure.
For example, if you look at the code, for me to get it to assemble/
link on OSX, Albert sections his code very nicely into 2 user defined
sections, forth and dictionary - dictionary being unitialized for
further additions, with the exec flag on.
This appears to build without a fuss on linux. On OSX, the tools give
out big stink about there not being a .text, data,
So I cheated and created an empty .text. Put the initial start
executable code / prebuilt dictionary in a .data - this is because I
realized forth needs to write back to the dictonary.
What is surprising is that it worked - there is executable code in the
dictionary after all. The start: is in the .data section.....
So that bit was done but the unitialized space remained a problem. If
I left the code as it were, it would generated a binary close to 64
megs. As I understand Albert's sectioning, he put all the unitialized
data in a custom section, with a directive to disallow allotting any
physicl space - I believe it might have been nobits.
How to build custom sections I do not yet know for the mach-o tools.
(or segments I still do not understand fully the difference - nasm
documentation is currently confusing me - I thought they were the
same).
So I had a look at what was available by default and .bss looked
possibly like my best option, tried it, and it seemed to assemble and
link, and run.
Now this assembles to something reasonable and runs, but I don't
completely understand what it's done to it's allotted virtual space of
memory.
So without this bit of understanding obviously a SAVE-SYSTEM is out.
And although it seems to work, I am not sure if there are any
conditions that will break it. So far, I've not had the kernel
complain about memory issues, ie bad writes but who knows.
> I don't know of a tutorial that covers more than one format. The first
> few pages of Apple's Mach-O File Format Reference (which I linked to a
> few messages back) give a pretty good overview of how an object file is
> put together.
I found that helpful, but I don't understand enough, I'll admit. It
will take a while and more reading.
It's also the case I am not fully aware on how to fully wield the
tools. I think I have a rough idea of what should be done as above,
but whether I am doing it the right way... ie You mention linker
scripts, they seem pretty arcane at the moment
If you have a mac/OSX, take a look and see, given your experience and
expertise you may be able to tell almost immediately what the best way
should be.
Thanks for all your help guys, learning lots :)
Robert Spykerman


|