On Sun, 20 Nov 2022, LIU Hao wrote:

在 2022-11-20 19:23, 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.

Detect non-existence of __ImageBase symbol at ./configure time and for
compatibility with older GNU LD versions, define __ImageBase symbol as
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.
---
  mingw-w64-crt/Makefile.am          |  4 ++++
  mingw-w64-crt/configure.ac         |  6 ++++++
  mingw-w64-crt/crt/__imagebase.c    | 18 ++++++++++++++++++
  mingw-w64-crt/crt/crtexe.c         |  5 -----
  mingw-w64-crt/crt/crtexewin.c      |  3 ---
  mingw-w64-crt/crt/pesect.c         |  9 ---------
  mingw-w64-crt/crt/pseudo-reloc.c   |  6 +-----
  mingw-w64-crt/libsrc/dloadhelper.c |  1 -
  mingw-w64-crt/misc/delayimp.c      |  1 -
  9 files changed, 29 insertions(+), 24 deletions(-)
  create mode 100644 mingw-w64-crt/crt/__imagebase.c



Thanks for the patched. Pushed.

Building when bootstrapping a toolchain now fails with the following error:

checking whether the linker provides __ImageBase symbol... configure: error: link tests are not allowed after AC_NO_EXECUTABLES

The problem is that when bootstrapping a toolchain (i.e. building mingw-w64-crt from scratch in a sysroot where there is no preexisting mingw-w64-crt), regular linking tests will fail (since the compiler defaults to linking in a bunch of libraries, and those don't exist yet).

One can do linking tests with -nostdlib, but it requires _a lot_ of hackery to get working robustly. We had a similar linker test before, added in the first naive version in baaf945d53f7dedb15b6f5342bd04e8fd4952211 (similar to this one, but with -nostdlib), reverted in 30af18252d4e965e98612e215b8cf6b7ae42c01a since it broke things, reapplied with one fix in ccda8b5229e428a6fa7036140778b23d11b554e8, then tweaked further in bda8fc0064e12d07e0f0e0c696dc0568b13c096f.

At that point the test was in a working form and stayed in place from 2018 until early 2021, when I concluded that we could drop support for the older versions of LLD that the test tried to detect, and removed it in 6f53dbf6d423fab5a9fc6b3e4b07bdcf66d253b5.

So at this point, do you think it's worth to add the complexity of manually expanding the linker test (like what was removed in 6f53dbf6d423fab5a9fc6b3e4b07bdcf66d253b5), or should we just drop the test? (Alternatively, a manually set --enable-image-base-compat or something like that, can add the helper without a linker check.)

What do you think?

// Martin

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

Reply via email to