On Tuesday 03 December 2024 16:19:58 Martin Storsjö wrote:
> On Wed, 27 Nov 2024, Pali Rohár wrote:
> 
> > For EXE builds __mingw_init_ehandler() function is called after the
> > _pei386_runtime_relocator() from the __tmainCRTStartup() (and not from the
> > WinMainCRTStartup() function).
> > 
> > Do same for DLL builds and call __mingw_init_ehandler() from
> > __DllMainCRTStartup() instead of DllMainCRTStartup().
> > ---
> > mingw-w64-crt/crt/crtdll.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> 
> I think this change might be ok, but it would be nice to explain a bit about
> the motivation for the change; is this something that you've functionally
> noticed that needs to be tweaked, or just that you noticed that it was
> inconsistent? (And in this case, explain your reasoning why you think this
> is the wrong location to call it and why crtexe.c's place is more correct.)

Originally I just notices that it is inconsistent and did not understand
why it is called before anything else and on moreover strange place. I
looked into git history but there is no information or comment about it.

But I think that in some case, if the __mingw_init_ehandler is calling
some function which depends on runtime-pseudo-reloc then it is needed to
be called after the _pei386_runtime_relocator().

So I think that it is better to call any additional functions after
doing basic init and after the executable image is correctly relocated.

> It's also good to point out that this is called within "x86_64 && !SEH",
> i.e. x86_64 builds with DWARF instead of SEH - which I would believe are
> rather rare nowadays. (So I think practically that very few toolchains would
> have even compile tested this codepath in recent years.)
> 
> // Martin


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to