Path: utzoo!attcan!uunet!wuarchive!cs.utexas.edu!rice!sun-spots-request From: net%TUB.BITNET@mitvma.mit.edu (Oliver Laumann) Newsgroups: comp.sys.sun Subject: Re: Re: Dynamic loading for SunOs Keywords: SunOS Message-ID: <3314@brazos.Rice.edu> Date: 22 Nov 89 10:15:10 GMT Sender: news@rice.edu Organization: Sun-Spots Lines: 18 Approved: Sun-Spots@rice.edu X-Refs: Original: v8n190, Replies: v8n190 v8n197 X-Sun-Spots-Digest: Volume 8, Issue 208, message 5 of 19 > 1) My experience with dynamic loading is that the ld -A > requires 2 passes. The first pass allows you to determine the size > of the resultant `.o' file so that you can malloc() space. The second pass > uses the result of your malloc() for relocation of the code. This can > be very time consuming. Is there a `trick' to accomplish this in 1 pass. Yes, there is. Don't malloc() the space; use sbrk() instead. You can use the result of a call to sbrk(0) as the value for the -T option of /bin/ld and call sbrk() again after the linker has finished to really allocate the space. Of course, this is not portable, since sbrk() is not guaranteed to exist in all environments. But then, dynamic loading is non-portable anyway (e.g. your linker may not support the -A option)... Regards, Oliver Laumann net@TUB.BITNET net@tub.UUCP