Clang is using the wrong memory model

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Aug 16 11:25:00 GMT 2019


On Aug 16 12:38, Agner Fog wrote:
> 
> On 16/08/2019 11.52, Corinna Vinschen wrote:
> > 2 GB. Think errno accessed from another DLL. Your application works only
> > by chance.
> 
> Good example.
> 
> errno appears to be a global variable for historical reasons, but errno is
> implemented as a macro that translates to a call to the imported function
> __errno.
> 
> This function call goes through a 64-bit import table from cygwin1.dll
> 
> Works fine with -mcmodel=small
> 
> Static sharing of a global variable between exe and dll, or between
> different dll's is not possible.

So errno was a bad example but you can try accessing e.g. __ctype_ptr__,
__progname, optarg, h_errno, or use FE_DFL_ENV from another DLL, just
for kicks.

Just because lots of stuff works with the small mode doesn't mean it's
the right thing to do.  Mcmodels medium and large have been introduced
into GCC during the Cygwin 64 bit port for a reason.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20190816/caec54e8/attachment.sig>


More information about the Cygwin mailing list