From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fcc2d88d867060e8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-18 17:51:39 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!elnk-pas-nf1!elnk-nf2-pas!newsfeed.earthlink.net!attbi_feed3!attbi.com!attbi_s54.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: load and use a ".o" file? References: X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 24.6.133.123 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s54 1071798699 24.6.133.123 (Fri, 19 Dec 2003 01:51:39 GMT) NNTP-Posting-Date: Fri, 19 Dec 2003 01:51:39 GMT Organization: Comcast Online Date: Fri, 19 Dec 2003 01:51:39 GMT Xref: archiver1.google.com comp.lang.ada:3545 Date: 2003-12-19T01:51:39+00:00 List-Id: >Let's say it is very simple function which was compiled from this: > >function HiThere return String is >begin > return "Hi there!"; >end HiThere; > >Instead of linking this into an executable, it is just compiled with >say, "gnatmake -c hithere", to get the "hithere.o" file we're interested in. > >Now, how can I load this "hithere.o" file into an already running >program (without linking it in beforehand) and then call the "HiThere" >... >I'm not talking about using a .dll or .so file, just the .o file. If you are not talking about using an existing dynamic linker/loader, then you are clearly talking about developing your own. In your example, HiThere may need to make calls (for memory allocation for the string, for instance) on the Ada Run Time System of the main program. So you will need to load the code from the .o file and then modify call addresses, ie, link, the loaded HiThere function. You should be able to find the information you need by looking at the Gnat source code. What problem are you trying to solve? Perhaps there's an easier way.