POV-Ray : Newsgroups : povray.off-topic : Dynamic loading : Re: Dynamic loading Server Time
29 Jul 2024 20:13:27 EDT (-0400)
  Re: Dynamic loading  
From: Invisible
Date: 20 May 2011 04:12:32
Message: <4dd62270$1@news.povray.org>
>> is there some way to execute it?
>
> Yes. An assembly languge JSR will do the trick.

That's more or less what I thought.

> A COM file is raw machine code without any headers, at least on CP/M. A
> COM file was executed by reading it into 0x100 and branching to 0x100.

That appears to be the case for MS-DOS as well. (I know gasm has a "COM 
output" option which appears to match this description.)

> Again, what language are you talking about?

Presumably any language that lets you insert assembly or link to C ought 
to be able to handle this then.

>> Presumably this must be very hard to do, otherwise people wouldn't jump
>> through all the hoops required to get dynamic linking via the OS to work.
>
> No, the point of *that* is to (a) allocate the memory, (b) load the DLL,
> (c) link the DLL entry points into your own code so that (d) you don't
> have to recompile your code when the DLL gets replaced by a newer
> version. Also (e) multiple people can use the same code at the same time
> and only load it once.

I suppose (e) is the big one.

I imagine if you wanted to load a file containing *multiple* subroutines 
instead of just one, things would become more complicated. Still, it 
doesn't look *that* hard to get it right...

>> - According to Wikipedia, every Windows DLL in the entire system must
>> have a
>> unique base address. (I forget what happens if this isn't the case; I
>> believe it amounts to poor performance.)
>
> It means the DLL has to get relocated when it gets loaded in.

I have a vague feeling it also disables sharing it among processes.

>> - Obviously in both cases the actual machine code must also be
>> surrounded by
>> many miles of complex metadata too.
>
> No more than an EXE does.

Indeed, I gather that a Windows DLL is only different from a Windows EXE 
by a few bit flags. (No idea what Linux does. Then again, last I checked 
Linux has more than one format for executable programs, never mind 
libraries...)

> The expression you're looking for is PIC, "Position Independent Code".

Yeah, every system seems to have a different name for this concept.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.