Daniel Borce has shed some light:
On 2/16/23, Daniel Borca <
dbo...@yahoo.com> wrote:
>
> I believe this is because of how variables are exported (as opposed to
> functions).
>
> Things are quite foggy after all those years, but for COFF, you are actually
> getting a _pointer_ to a variable. That is, in your case a _pointer_ to the
> desired pointer (that's why having a getter for the pointer solves it). I
> know this is *not* how it works when you are compiling statically, but it is
> a limitation of the executable format. I also think this limitation applies
> to the original DXE (as designed by Charles W Sandmann) not only for my
> DXE3. BTW, the COFF used by DJGPP is not even Windows COFF.
>
> TL;DR: you have to dereference that pointer twice. I am not sure it can be
> handled transparently as long as DJGPP was COFF-based.
>
> That's why I "invented" DJELF back then. The ELF executable format has a
> special kind of relocation (perhaps it was called R_<arch>_COPY or something
> like that) which would solve this issue magically, but then you are
> restricted to ELF.
>
> -dborca
Thanks Daniel.