[PATCH v2 1/2] Cygwin: cache IsWow64Process2 host arch in wincap.
Jeremy Drake
cygwin@jdrake.com
Tue Nov 26 18:16:39 GMT 2024
On Tue, 26 Nov 2024, Corinna Vinschen wrote:
> On Nov 25 11:21, Jeremy Drake via Cygwin-patches wrote:
> > +extern const IMAGE_DOS_HEADER
> > +dosheader __asm__ ("__image_base__");
>
> On second thought, shouldn't we just use GetModuleHandle ("cygwin1.dll")
> instead of going asm here?
I was hoping to avoid another place where MSYS2 would have to patch the
name change to msys-2.0.dll. I almost went with GetModuleHandleEx
(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT)
but the overhead of either call seemed silly when the linker already knows
the address...
If the __asm__ setting the symbol name is an issue, pseudo-reloc.cc also
accesses __image_base__ like so:
#ifndef __MINGW_LSYMBOL
#define __MINGW_LSYMBOL(sym) sym
#endif
extern char __MINGW_LSYMBOL(_image_base__);
&__MINGW_LSYMBOL(_image_base__)
I found the __asm__ method cleaner. But I could name the extern
__MINGW_LSYMBOL(_image_base__) instead of dosheader to avoid __asm__.
More information about the Cygwin-patches
mailing list