Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!Teknowledge.COM!unix!hplabs!hpfcso!mjs From: mjs@hpfcso.HP.COM (Marc Sabatella) Newsgroups: comp.sys.hp Subject: Re: Linking into an exec file Message-ID: <7370034@hpfcso.HP.COM> Date: 16 Nov 89 16:56:51 GMT References: <6281@tank.uchicago.edu> Organization: Hewlett-Packard, Fort Collins, CO, USA Lines: 30 >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 -R
..." 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