Dynamic loading for SunOs
Oliver Laumann
net%TUB.BITNET at mitvma.mit.edu
Wed Nov 22 21:15:10 AEST 1989
> 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 at TUB.BITNET net at tub.UUCP
More information about the Comp.sys.sun
mailing list