richard@paideia.uchicago.edu (Richard Congdon) (11/16/89)
Here's a problem I have been hung on for quite a while and any help from "out there" would be greatly appreciated. I am trying to link a normal .o file with an already compiled program (a Lisp interpreter) that has hooks for calling "foreign procedures" located in its image. I have tried to use "ld" but it complains that the exec file is not of the correct type. I know about ld's"-A" flag but can't seem to get it to work. Thanks Marc Feeley (feeley@cs.brandeis.edu) Richard Congdon Brandeis Computer Science Dept. richard@cs.brandeis.edu
mjs@hpfcso.HP.COM (Marc Sabatella) (11/17/89)
>I am trying to link a normal .o file with an already >compiled program (a Lisp interpreter) that has hooks >for calling "foreign procedures" located in its image. > >I have tried to use "ld" but it complains that the exec >file is not of the correct type. I know about ld's"-A" flag >but can't seem to get it to work. An executable file has no relocation information, thus it is (normally) useless to ld(1). How did you get the "hooks" into your Lisp interpreter? The solution to your problem depends a great deal on that. An aside on the -A option to ld(1): normally it is used to create an object file which can be loaded into your program dynamically - ie, you malloc space for it, invoke "ld -A <current program> -R <address returned by malloc> ..." from within your program, then fread(3) or read(2) the resultant object file's text and data segments into memory (and allocate space for BSS as well). You can then look up symbol addresses in the resultant file's symbol table and call the loaded file's functions indirectly. The exact details of this differ between the Series 300 and 800. There are somewhat clever ways of using -A statically, and again, depending on the details of your "hooks", you may be able to get it to work. By the way, there is a known bug in the -A option which makes it incompatible with -e, -h, and -u on the Series 300. This has been fixed for 7.0 -------------- Marc Sabatella HP Colorado Language Lab marc%hpfcrt@hplabs.hp.com