Re: Editors

From: TS (nomailhere_at_deinmeister.de)
Date: 03/08/04


Date: Mon, 08 Mar 2004 00:00:32 GMT


>> > Hmmm ... Than why do standard PE-files still have fix-up (aka :
>> > relocation) tables ... :-)
>>
>> For DLL Data only. (And, i suppose for PE type Drivers as well,
>> but i really do not know, actually).
>
>To be *really* sure, I just checked a few files. For some reason my quick
>inspection gives you right on Windows own executables, but not on
>executables I generated myself . Have to look into that one ....

It depends on the linker: Some include relocation info into all kinds
of PE files, some strip them on exe files by default. You may also
strip relocation info from DLLs, but only if you can be 100% sure that
there won´t be any overlap in linear address space.

>> A "normal PE" _never_ need relocation, -not considering DLL Data-,
>> and not considering an irregular default upload Address (provided,
>> in the PE Header, on purpose, to force the loader to relocate at
>> the proper Address)

Any default base address below 4MB will force relocation. I´m not sure
if someone also used an executable also as a DLL - I´ve seen some
executables which export addresses, but these were still the first PE
to be loaded into address space.

>As far as I know there is an entry that get's called whenever the DLL is
>loaded or unloaded by an app, as well when a new thread within that app is
>created or closed (all with the correct arguments ofcourse, like
>DLL_PROCESS_ATTACH). That gives the DLL to chance to create or release
>data-storage for that app or thread.

It´s the normal program entry point, the same as used for starting an
executable.

>So, the DLL does not have to be reloaded, just mapped into the callers
>code-space, and it will allocate what it needs for data-storage in that
>callers data-space.

Yes, but this also depends on the flags used in the PE sections.
Basically, duplicating pages only as soon as a write occurs is a good
memory preserving strategy...



Relevant Pages

  • Re: Cannot activate sbcl
    ... but I think what happens is that Windows sees that your executable has a DATA section that might overlap a DLL's address space then it would reallocate that DLL to different address space. ... VirtualAlloc dynamically in your code is that your program and all its ... What can be done here is to have many tiny executables with different BSS sections in them, which then load a bigger executable in the form of a DLL. ...
    (comp.lang.lisp)
  • Re: Why do we need executables in certain formats ?
    ... > Can anybody explain me why do we need executables in certain formats? ... Modern virtual memory processors can locate to ... ..DLL files changed out from under them, ...
    (comp.lang.asm.x86)
  • Re: Dynamic linking with symbols
    ... And a dll which ... > two different executables. ... Try putting your "exported code" into a static library which your ... EXE links against. ...
    (microsoft.public.vc.language)
  • Re: Dynamic linking with symbols
    ... And a dll which ... IIUC, the executable exports an environment in which the plugin runs, right? ... > two different executables. ... I don't think the MS Windows runtime linker also resolves reverse ...
    (microsoft.public.vc.language)
  • Dynamic linking with symbols
    ... The idea is that the dll is a plugin for my exe and thus can use all of ... Now the problem is that in this case the dll has to link against a specific executable which in turn makes sure I can't use the same dll in two different executables. ... Now I could put all the exported code from my executables into a dll and let my plugin dll and both of my executables link against this dll. ...
    (microsoft.public.vc.language)