Commit graph

19 commits

Author SHA1 Message Date
Brendan Shanks 4e6dbf3b9e loader: In macOS preloader, add __program_vars section.
This is needed to be a correct macOS 10.7 binary.
2023-07-18 15:16:12 +02:00
Brendan Shanks cfa0dd9dd9 loader: On 64-bit macOS, reserve the low 8GB using a zerofill section.
A zerofill section is the only way to reserve address space and prevent
system frameworks from using it, including preventing allocations
before any preloader code runs:
- starting with Ventura, dyld allocates private memory from 0x1000-0x81000.
  This breaks EXEs that have an image base of 0x10000.
- Rosetta allocates memory starting at 0x100000000, which breaks EXEs based there.
- starting with Monterey, for proper 10.7 binaries (which include a __program_vars section),
  libSystem initializes itself before the preloader runs. This fragments the <4GB
  address space which is needed for Wow64.

This will need to be adjusted if any EXEs based at 0x200000000 or higher
are found.
2023-07-18 15:16:12 +02:00
Tim Clem 6b0836e3f1 loader: Reserve some space for 32-bit top-down allocations on 64-bit. 2023-05-31 22:50:10 +02:00
Brendan Shanks 93941d6ec6 loader: In macOS preloader, stop using mincore() to test if a region is empty. 2023-03-06 11:09:29 +01:00
Brendan Shanks c10207e2a7 loader: In macOS preloader, move the top-down allocations area down.
On Ventura, the Rosetta runtime and dyld shared cache now reach down
to 0x7ff7fffb8000 on my system.
2023-03-06 11:09:21 +01:00
Brendan Shanks 36bb7175c1 loader: In macOS preloader, fix an environment variable sometimes being lost. 2023-02-08 09:01:34 +01:00
Brendan Shanks f99eef6847 loader: In macOS preloader, set NXArgc, NXArgv, and environ on i386 and x86_64. 2022-12-07 23:20:39 +01:00
Brendan Shanks 9ab93415f7 loader: In macOS preloader, manually set 'environ' to work around a bug in macOS 12 and later.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54009
2022-12-01 10:25:19 +01:00
Brendan Shanks 588e555425 loader: In macOS preloader, fix up argc/argv in C rather than asm. 2022-12-01 10:25:19 +01:00
Brendan Shanks 4ec770a139 loader: Add comments to 'start' in macOS preloader. 2022-12-01 10:25:19 +01:00
Alexandre Julliard e3001b6a7c configure: Assume that sys/mman.h is available on Unix.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Alexandre Julliard 28d7d5ba93 loader: Avoid including wine/port.h.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-20 16:16:07 +02:00
Brendan Shanks 307f5d00f1 loader: On Mac, reserve an area starting at 4GB to force Rosetta's allocations higher.
On Apple Silicon, Rosetta allocates memory starting at 0x100000000
(the 4GB line) before the preloader runs.
The .NET 3.5 installer and DirectX Jun2010 redistributable both contain
non-relocatable EXEs with that base address, which fail to run.

The workaround is to create an empty linker section at that address,
which is mapped by the kernel before Rosetta runs and forces Rosetta's
allocations higher in memory.
The linker section runs from 0x100000000-0x114000000.
Rosetta's allocations are ~132MB, and should end below 0x120000000.

This is not an exact science: a non-relocatable EXE with base address
between 0x114000000-0x120000000 will fail to run. If one is discovered,
the section size will need to be changed.

Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-01-29 10:16:48 +01:00
Brendan Shanks 720611e28e loader: On Mac, move the top-down allocations area down to avoid Rosetta regions.
On Apple Silicon, Rosetta's shared cache starts at 0x7ffe00000000 and
the runtime is mapped below that.
Put the top-down allocation area below the runtime with plenty of room
to spare.

Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-01-29 10:16:42 +01:00
Alexandre Julliard d5a372abbb include: Move inline assembly definitions to a new wine/asm.h header.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-05-14 13:45:07 +02:00
Ken Thomases 07d80641d0 loader: On Mac, move the top-down allocations area down to avoid regions reserved by the system.
On macOS 10.14 (Mojave), there's a system-wide VM mapping for common system
libraries starting at 0x00007fff00000000.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-02-04 15:39:43 +01:00
Ken Thomases cc24255da4 loader: Check if the preloader overlaps the reserved range on the Mac.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-12-06 08:57:52 +01:00
Alexandre Julliard df8c5a37ec loader: Duplicate some preloader code instead of trying to share it.
This mostly reverts bd2d795240.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-12-05 22:33:43 +01:00
Sebastian Lackner a0ab2a7b0c loader: Implement preloader for macOS.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-12-04 11:10:09 +01:00