On Saturday 19 November 2022 17:12:12 LIU Hao wrote:
> 在 2022-11-18 23:40, Pali Rohár 写道:
> > GNU LD provides __ImageBase symbol since 2.19. This is standard windows
> > symbol and should be used instead of custom gnu _image_base__ symbol.
> > 
> > For compatibility with older GNU LD versions, define __ImageBase as weak
> > alias to _image_base__ symbol.
> > 
> > This allows to remove all #ifdef hacks for older GNU LD versions as with
> > this change __ImageBase works correctly with all GNU LD versions.
> > ---
> 
> Generally speaking, one shouldn't use weak symbols when targeting Windows. I
> haven't investigated though, but many times weak symbols result in null or
> faulty addresses.

Interesting, I did not know that there are issues with weak symbols. All
my tests with weak symbols passed, I have not spotted any issue.

> Thus, weak symbols are unacceptable; but removal of references to
> `__image_base__` seems fine, if dropping support for binutils 2.18 is
> acceptable. BTW 2.19 was released in 2008 [1].
> 
> [1] https://lists.gnu.org/archive/html/info-gnu/2008-10/msg00014.html

Another option is to detect at ./configure time if linker accepts
__ImageBase symbol. And if not then define __ImageBase as normal
(non-weak) symbol. Should be pretty simple.


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to