delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:cc:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; q=dns; s= | |
default; b=xTdTtQeCv5CPcQjipgC1NayaV+8NKs20bueweuLkLkoW65U+/aeY4 | |
XDN7yrNMCgjiTf3b4efxbvoRv7Ho44gA9CQFJJr5WfgpDc7tcKKWu4MLe+TXlARy | |
tAjH3cDaSNJ7/Bts/WoJXk6gF8/GhxV5MFKoekarWoWgSHKI81zyyI= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:cc:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; s=default; | |
bh=i6Z2ZGdjavUxWA+ot8F0d2sCA0o=; b=YPJDBYPeKJ4eOnVjb1FJkFpuJb1d | |
h/Jh70uZjL8Zi+YqYOkk5LdTUxCr9MzdLnauU3TORG4s5yxERX7ijBQG4w6EMeza | |
MCn1b2//GILzsPmNb83F3WrKd9yJ+VaykgmV2M8Q69S1emj6oD+DwTyMkCzVVFCm | |
IQbIfP7VO1RuyKI= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Spam-SWARE-Status: | No, score=-104.2 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=80000000, 7000, 0001, HX-Languages-Length:1972 |
X-HELO: | mout.kundenserver.de |
Date: | Fri, 16 Aug 2019 10:26:03 +0200 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | Agner Fog <agner AT agner DOT org> |
Cc: | cygwin AT cygwin DOT com |
Subject: | Re: Clang is using the wrong memory model |
Message-ID: | <20190816082603.GR11632@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | Agner Fog <agner AT agner DOT org>, cygwin AT cygwin DOT com |
References: | <732305300 DOT 268416262 DOT 1565603129541 DOT JavaMail DOT root AT zimbra54-e10 DOT priv DOT proxad DOT net> <024ce5b5-6024-b371-e382-5eef5d1d4a90 AT agner DOT org> <075477ca-e031-39ea-3dfe-bc8bc2fc8fa6 AT agner DOT org> |
MIME-Version: | 1.0 |
In-Reply-To: | <075477ca-e031-39ea-3dfe-bc8bc2fc8fa6@agner.org> |
User-Agent: | Mutt/1.11.3 (2019-02-01) |
--mLgg01LDEvurRz8s Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Aug 16 08:06, Agner Fog wrote: > Cygwin Clang is using -mcmodel=3Dmedium as default for Win64, according t= o my > tests, while the right model is -mcmodel=3Dsmall -mcmodel=3Dsmall is *only* the right model if the target is native Windows. If the target is a Cygwin application it *must* at least be compiled with -mcmodel=3Dmedium. The reason is the standarized memory layout of Cygwin application and DLLs. > Linux Clang with --target=3Dx86_64-pc-cygwin gives the small memory model. Which is wrong. > I took this to the LLVM Bugzilla as you asked me to: > https://bugs.llvm.org/show_bug.cgi?id=3D42983 >=20 > This gave the following conclusion: >=20 > -mcmodel=3Dsmall does something different when the target is Windows. This > difference appears to be undocumented. The small memory model with a Linux > target puts everything below the 2GB limit so that 32-bit absolute addres= ses > can be used. The small memory model with a Windows target is using 32-bit > relative addresses instead, which is the correct thing to do in Windows. Yes, but not for Cygwin applications and DLLs. The reason is that Cygwin apps and DLLs reside in the memory beyond the first 2 Gigs in a standarized way so as not to collide with Windows code and datastructures. And that in turn was necessary to make fork() more reliable on 64 bit. Here's the memory layout: 0000:00000000 Windows 0000:80000000 Thread stacks 0001:00400000 Executable 0001:80000000 *The* Cygwin DLL 0002:00000000 Rebased Cygwin DLLs 0004:00000000 Unrebased Cygwin DLLs(*) 0006:00000000 Heap (up to Cygwin 3.0) 0008:00000000 Heap (starting with Cygwin 3.1) 0700:00000000 Top-down start address for mmaps up to Windows 8 or up to Cygwin 3.0 7000:00000000 Top-down start address for mmaps starting with Windows 8.1 and Cygwin 3.1 So there's a difference between non-Cygwin (-mcmodel=3Dsmall as default) and Cygwin (at least -mcmodel=3Dmedium). Corinna --=20 Corinna Vinschen Cygwin Maintainer --mLgg01LDEvurRz8s Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl1WaJsACgkQ9TYGna5E T6DlYw//USTrH/9Z2nRH+BSQIREUhDL/bQcrZcGG5UbrpTrk8Va8hPTD7pccfv7c hJk3G39CbiTYKHnYDC8/E0sTz/Ho6NogezTI0RyPNMfehVVyeIZC5At9W7KeNfTp cESJrDkxoG1na2USEDOGIpS0u4nB9OZ9JZrEdANkZAB0GQJdMfVHJoJO6XeGTKW5 ZK9U8w3bfZ1yGpt5KHYrFYXd1W+A7oIZY1LSXc/DI6ZbPWQ5xZyT6Oi70HUOE5V/ BRaCPbhha2nlWnupmyw4nx8r9stVEDomy9iVRdZuA+Z/QjotKl1+wcGVN5QUhKIn Ufjc9FSAXIL8RDp5xZqDfuqSx3DVXhbLJliuP3SYtXtmZIxLo3HDhLkHwPPnzuAs rNtcSvBN8BAYeLFOSd+1l3dG5mysMIAqojtz54T8y90kF1fsA8JOGdncaLi/XaHl XuSa9olsvODLoF7h5EIxWD67xr8WcT3j2x1jks3rnYGGhsZ/EHGwwHpjvf7tfMgi txjfgYpETtBlkHSPyJkmhNHqVJbZcJhM7aela7l931DLcF+wPZ2CGfIhpEVhq+B3 AY3uFMNzyiz1WyoFDBE6wRlZEzyeyGZwVPomNtERHiJpcPv07jDS2OVZhOZMpmjt m1ltWE2pLGWg7LWoz7w7GbSLh+Te7c+ZnnN3au5VlczF1VzTMRY= =MHnR -----END PGP SIGNATURE----- --mLgg01LDEvurRz8s--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |