[Bug 49139] Regression: Wine crashes on startup on FreeBSD >= 5.7

WineHQ Bugzilla wine-bugs at winehq.org
Sun May 17 06:07:19 CDT 2020


https://bugs.winehq.org/show_bug.cgi?id=49139

Damjan Jovanovic <damjan.jov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|-unknown                    |ntdll

--- Comment #9 from Damjan Jovanovic <damjan.jov at gmail.com> ---
(In reply to Gen Otsuji from comment #8)
> (In reply to Damjan Jovanovic from comment #7)
> Hi Damjan, it's great work, and very difficult for me.
> my question is in Makefile.in how the option of
> "-Wl,--image-base,0x7bc00000" works?
> The dlls without this option, not summed.
> The dlls with this option, already summed.
> I'm wondering this difference.

I finally found a way to fix this purely within Wine, without changes to
FreeBSD's rtld-elf. Patch sent: https://source.winehq.org/patches/data/185377

Let me explain it with a worked example.

A binary won't know which memory address it will be loaded at. So it generates
pointers to addresses from some offset it would prefer, and if it gets loaded
at a different address, the offset between its preferred offset and the one it
actually got can be added to these pointers to go to the right place.

So the binary might prefer starting address 20000, and there's a pointer eg.
from DT_INIT pointing to 20150. But it gets loaded at address 30000, which is
10000 bytes above what it preferred. So we can add 20150 + 10000 = 30150.

On Linux and NetBSD, l_addr == 10000, the difference from what it wanted to
what it got.
On FreeBSD, l_addr == 30000, the absolute address where it actually got loaded.

Now what "l_addr + d_un.d_ptr" does on FreeBSD, is add 30000 + 20150 = 50150,
which is always wrong. We have to add the relocation offset to d_un.d_ptr, not
the absolute addresses where the binary was loaded.

-Wl,--image-base,0x7bc00000 just tells the linker to use that as the preferred
address instead of some default, probably because some applications expect DLLs
at certain addresses. It doesn't really matter in this discussion.

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list