From: Twaik Yont <9674930+twaik@users.noreply.github.com> Commit message: Android NDK r22 changed LLD behavior for targets below API 29 (see NDK changelog, Issue 1196). For such targets clang passes -Wl,--no-rosegment implicitly to the linker to improve backtrace correctness on older devices. As a result, wine-preloader is linked with --no-rosegment semantics. Since wine-preloader uses -Wl,-Ttext=0x7d400000, the linker assigns a very large file offset to the PT_LOAD segment containing .text in order to preserve the required relationship between virtual addresses and file offsets within the segment. This introduces a large sparse gap (around 0x7d400000) and inflates the apparent ELF size to ~2GB. wine-preloader is a static binary and does not require unwind/backtrace correctness, so there is no benefit in inheriting --no-rosegment. Force -Wl,--rosegment for wine-preloader when supported to keep the segment layout sane and the resulting ELF size reasonable, without affecting other binaries. Signed-off-by: Twaik Yont <9674930+twaik@users.noreply.github.com> --- configure | 30 ++++++++++++++++++++++++++++++ configure.ac | 1 + 2 files changed, 31 insertions(+) diff --git a/configure b/configure index e2d2079746e..07ecd3054ac 100755 --- a/configure +++ b/configure @@ -11939,6 +11939,36 @@ then : WINELOADER_LDFLAGS="-Wl,--export-dynamic" fi WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7d400000" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Wl,--rosegment" >&5 +printf %s "checking whether the compiler supports -Wl,--rosegment... " >&6; } +if test ${ac_cv_cflags__Wl___rosegment+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_wine_try_cflags_saved=$CFLAGS +CFLAGS="$CFLAGS -Wl,--rosegment" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int main(int argc, char **argv) { return 0; } +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_cflags__Wl___rosegment=yes +else case e in #( + e) ac_cv_cflags__Wl___rosegment=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +CFLAGS=$ac_wine_try_cflags_saved ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags__Wl___rosegment" >&5 +printf "%s\n" "$ac_cv_cflags__Wl___rosegment" >&6; } +if test "x$ac_cv_cflags__Wl___rosegment" = xyes +then : + WINEPRELOADER_LDFLAGS="$WINEPRELOADER_LDFLAGS -Wl,--rosegment" +fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -lGLESv2" >&5 printf %s "checking for -lGLESv2... " >&6; } diff --git a/configure.ac b/configure.ac index 3137bc9a806..e3457400fdc 100644 --- a/configure.ac +++ b/configure.ac @@ -1001,6 +1001,7 @@ case $host_os in WINE_TRY_CFLAGS([-Wl,-z,defs],[UNIXLDFLAGS="$UNIXLDFLAGS -Wl,-z,defs"]) WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],[WINELOADER_LDFLAGS="-Wl,--export-dynamic"]) WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7d400000" + WINE_TRY_CFLAGS([-Wl,--rosegment], [WINEPRELOADER_LDFLAGS="$WINEPRELOADER_LDFLAGS -Wl,--rosegment"]) WINE_CHECK_SONAME(GLESv2,glFlush) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10067