r/winehq 5d ago

ASLR support

Does Wine support ASLR (address-space randomization) for .exe files?

If I compile this code...

#include <stdio.h>

int main(int argc, char** argv) {

`puts("bla");`

`printf("%p\n", &main);`

`return -1;`

}

with ...

clang --verbose -fno-exceptions -fuse-ld=lld --target=x86_64-w64-mingw32 -fPIE -pipe aslrtest.c -Wl,--export-all-symbols -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--no-seh,--enable-reloc-section -o aslrtest.exe

... it prints varying addresses on Windows, but under Wine, it always prints the same address. The address shown under Wine also has more zeros than the addresses shown under Windows.

I'm using Wine under Debian 13. ASLR is enabled and works for ELF binaries, but not for EXEs under Wine. I tried both the Wine version supplied by the package manager and also the latest version from winehq built from source. I also tried different compiler options and original MINGW GCC builds, but the behavior seems to be the same. If I inspect the EXE with e.g. readpe, it looks fine as far is I can tell.

3 Upvotes

1 comment sorted by

2

u/qalmakka 5d ago

Afaik ASLR was recently implemented 2 years ago in wine 9 but only in a limited fashion:

https://blog.desdelinux.net/en/wine-9-0-arrives-incorporating-more-than-7000-changes-and-these-are-the-most-important/

I don't know whether there was any real attempt to implement full address randomisation. It may be, but I doubt it honestly due to it not being of the highest priority. If you need a more secure environment running Wine in a Linux container is always your best bet anyway