As some of know, I've been working on a linker for the eZ80 model calcs, whose source code you can find on GitHub. Right now, the linker only supports parsing Zilog's object files; it can't actually link yet. However, since I can fully parse object files, it's time write the actual linking code. There's also been a request to port the linker into C. Since Zilog's own compiler is Windows-only, I don't see the advantage. But it's something I'm considering.
There are three main goals here: First, to allow LibLoad libraries to be written in C. Second, to allow the production of relocatable programs. This would allow programs to relocated into flash for execution. It would also writing programs larger than 64 K; the on-calc loader would resolve the references between subprograms automatically (think Lua). Finally, it would allow the production of apps. (I still haven't sent that email. There will be no patches until TI gets a chance to respond.)
EDIT: Apparently, Mateo thought I was re-doing the calculator-side stuff. Not at all. The current calculator-side stuff is fine. But, the current system of building libraries has some convoluted hacks in it, and a hack is also used to allow C and assembly programs to consume LibLoad libraries. The first goal of the new linker is to simplify the linking process and provide more flexibility by having the linker natively support our formats. With a linker that natively supports our formats, we can also consider implementing shells (maybe DCSE, Kerm :p) that support relocatable programs and programs larger than 64 K.
As I understand it, the linking process is conceptually simple: Load the object files, collate the sections from individual object files, order the sections, fix their final addresses, resolve intramodule relocations, resolve intermodule relocations, and package the data into the proper output format. If the desired output itself should be relocatable, then the resolved references will be relative.
The IEEE695 OMF format Zilog uses is very flexible. In fact, it's far more flexible than is useful to us. Mercifully, although the OMF format allows data records to occur out-of-order, it appears that Zilog doesn't do that. If that were the case, I'd have to build a database of data records to be able to collate them. But cheating and just assuming records come in-order is much easier. I plan on cheating.
I'm going to have to study the LibLoad format in more detail so I can generate it. I also don't feel like figuring out the details of Zilog's .LIB format, because it looks like the .LIB generator has its own special hacked-together code for generating OMF files, and it's ugly. So I'd like to just parse the object files from a library, link them myself (and skip that awkward Spasm step), and generate my own dummy format for use with my linker so it can add the correct LibLoad information to programs using LibLoad. Essentially, generating a library would be exactly like generating a regular program, except that in addition to a .8xv LibLoad appvar, you also get a library file for use with my linker.
I'm told that jacobly knows how the current library building system works. Mateo seemed to indicate that the .LIB file was critical to programs using LibLoad (something about generating the right jump table for the program using the library), but since I'm writing my own linker, I don't see why it wouldn't be desirable to use my own format. Maybe I don't understand things well-enough.
Comments and guidance would be helpful.
There are three main goals here: First, to allow LibLoad libraries to be written in C. Second, to allow the production of relocatable programs. This would allow programs to relocated into flash for execution. It would also writing programs larger than 64 K; the on-calc loader would resolve the references between subprograms automatically (think Lua). Finally, it would allow the production of apps. (I still haven't sent that email. There will be no patches until TI gets a chance to respond.)
EDIT: Apparently, Mateo thought I was re-doing the calculator-side stuff. Not at all. The current calculator-side stuff is fine. But, the current system of building libraries has some convoluted hacks in it, and a hack is also used to allow C and assembly programs to consume LibLoad libraries. The first goal of the new linker is to simplify the linking process and provide more flexibility by having the linker natively support our formats. With a linker that natively supports our formats, we can also consider implementing shells (maybe DCSE, Kerm :p) that support relocatable programs and programs larger than 64 K.
As I understand it, the linking process is conceptually simple: Load the object files, collate the sections from individual object files, order the sections, fix their final addresses, resolve intramodule relocations, resolve intermodule relocations, and package the data into the proper output format. If the desired output itself should be relocatable, then the resolved references will be relative.
The IEEE695 OMF format Zilog uses is very flexible. In fact, it's far more flexible than is useful to us. Mercifully, although the OMF format allows data records to occur out-of-order, it appears that Zilog doesn't do that. If that were the case, I'd have to build a database of data records to be able to collate them. But cheating and just assuming records come in-order is much easier. I plan on cheating.
I'm going to have to study the LibLoad format in more detail so I can generate it. I also don't feel like figuring out the details of Zilog's .LIB format, because it looks like the .LIB generator has its own special hacked-together code for generating OMF files, and it's ugly. So I'd like to just parse the object files from a library, link them myself (and skip that awkward Spasm step), and generate my own dummy format for use with my linker so it can add the correct LibLoad information to programs using LibLoad. Essentially, generating a library would be exactly like generating a regular program, except that in addition to a .8xv LibLoad appvar, you also get a library file for use with my linker.
I'm told that jacobly knows how the current library building system works. Mateo seemed to indicate that the .LIB file was critical to programs using LibLoad (something about generating the right jump table for the program using the library), but since I'm writing my own linker, I don't see why it wouldn't be desirable to use my own format. Maybe I don't understand things well-enough.
Comments and guidance would be helpful.