geoff@desint.UUCP (Geoff Kuenning) (10/21/88)
In article <23314@amdcad.AMD.COM> tim@crackle.amd.com (Tim Olson) writes: > It is very hard to create a truly portable object file format that can > work on all machines. The problem is the relocation info... > ... > Now we need a relocation type that can take a 32-bit absolute address > and stuff the upper half into an instruction. > > Because of this, most vendors extend a.out or COFF to fit their > requirements. A fully portable object file format would require a > general-purpose linker "evaluation language" which allows not only +/-, > but also <<, >>, &, |, etc. And a lot of linkers have this. Check out the DEC linkers, for example, if I remember correctly. It's not very hard to implement a stack machine that can load from and store to arbitrary places in the object file or the linked image. The real advantage of such a linker is not portability, but the fact that you are no longer restricted in the sort of link-time expressions you can use in your code. For example, you could write: int number_of_shorts = ((int) &a - (int) &b) / 2; (Admittedly a contrived and stupid example, but when you *really* need to do such a thing, it's a pain to have the linker prohibit it). -- Geoff Kuenning geoff@ITcorp.com uunet!desint!geoff
fnf@fishpond.UUCP (Fred Fish) (10/22/88)
In article <1805@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes: >In article <23314@amdcad.AMD.COM> tim@crackle.amd.com (Tim Olson) writes: >> Because of this, most vendors extend a.out or COFF to fit their >> requirements. A fully portable object file format would require a >> general-purpose linker "evaluation language" which allows not only +/-, >> but also <<, >>, &, |, etc. > >The real advantage of such a linker is not portability, but the fact >that you are no longer restricted in the sort of link-time expressions you >can use in your code. This really doesn't have much to do with NeXT, but I just thought I'd mention that the MC88000 linker has such an extension. The expressions are parsed into an RPN-like format and placed in a special COFF section called ".expr", and the r_symndx relocation entry fields are hijacked to no longer point into the symbol table, but instead contain an offset into this expression section. The expressions can contain arbitary operators, constants, and indices into the symbol table. This only took a couple days of work to implement (although only a few operators are supported, the basic framework is there to support more). If you start with the AT&T linker though, you better be ready for lots more work. The only piece of AT&T code I can think of that is uglier than the linker has got to be sdb... -Fred -- # Fred Fish, 1346 West 10th Place, Tempe, AZ 85281, USA # noao!nud!fishpond!fnf (602) 921-1113