<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 06.09.2011 23:05, Rainer Schuetze wrote:
<blockquote cite="mid:4E668B34.2010005@gmx.de" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
On 06.09.2011 22:51, Rainer Schuetze wrote:
<blockquote cite="mid:4E6687C7.5000109@gmx.de" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
On 06.09.2011 22:45, Walter Bright wrote:
<blockquote cite="mid:4E668665.6050704@digitalmars.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
<br>
<br>
On 9/6/2011 12:13 PM, Rainer Schuetze wrote:
<blockquote cite="mid:4E6670DC.1020106@gmx.de" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<br>
I can reproduce the issue on Win7 64, but not on XP. I have
debugged it a little until I noticed that the generated code
for TLS access seems broken:<br>
<br>
dmd 2.054 generated this code for the append operation<br>
<br>
push 1 <br>
1000207D mov ecx,dword ptr [__tls_index
(1006BF98h)] <br>
10002083 mov edx,dword ptr fs:[2Ch] <br>
1000208A mov ebx,dword ptr [edx+ecx*4] <br>
1000208D lea esi,[ebx+4] <br>
10002093 push esi <br>
10002094 mov eax,offset TypeInfo_Ai@__init
(1005E9A0h) <br>
10002099 push eax <br>
1000209A call __d_arrayappendcT (10004D68h) <br>
<br>
while the beta generates<br>
<br>
push 1 <br>
10002076 mov ecx,dword ptr fs:[2Ch] <br>
1000207D mov edx,dword ptr [ecx] <br>
1000207F lea ebx,[edx+4] <br>
10002085 push ebx <br>
10002086 mov esi,offset TypeInfo_Ai@__init
(10067A90h) <br>
1000208B push esi <br>
1000208C call __d_arrayappendcT (10004F9Ch) <br>
<br>
so it completely ignores the tls_index. I guess it works on
XP because there are less DLLs that use TLS, so the DLLs
index ends up as 0.<br>
<br>
</blockquote>
<br>
Very interesting. Can you provide the source code for that?<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
dmd-beta mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:dmd-beta@puremagic.com">dmd-beta@puremagic.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.puremagic.com/mailman/listinfo/dmd-beta">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a></pre>
</blockquote>
it seems to happen with any code:<br>
<br>
int x;<br>
<br>
int main()<br>
{<br>
return x;<br>
}<br>
<br>
generates<br>
<br>
__Dmain comdat<br>
assume CS:__Dmain<br>
mov EAX,FS:__tls_array<br>
mov ECX,[EAX]<br>
mov EAX,_D1m1xi[ECX]<br>
ret<br>
__Dmain ends<br>
<br>
</blockquote>
<br>
Sorry, this is wrong. This is the usual exe-only optimization that
assumes tls_index==0. It seems the command line options do not
suggest that a DLL is generated. I'll try to reduce it...<br>
<br>
</blockquote>
<br>
A simple example is this:<br>
<br>
module dllmain;<br>
import std.c.windows.windows;<br>
<br>
int test;<br>
<br>
extern (Windows)<br>
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
<br>
{ <br>
test = 1;<br>
return true;<br>
}<br>
<br>
to be compiled with<br>
dmd -g -v -oftest.dll dll.def -L/SUBSYSTEM:WINDOWS dllmain.d<br>
<br>
<br>
The problem is, that backend_init() is called before the files on
the command line are processed. So, global.params.deffile is always
0 when config.wflags is set in out_config_init(), and the code
generation thinks it is generating an executable.<br>
<br>
Though unused by dmd, the deffile looks like this for completeness:<br>
LIBRARY "test.dll"<br>
EXETYPE NT<br>
SUBSYSTEM WINDOWS<br>
CODE SHARED EXECUTE<br>
DATA WRITE<br>
</body>
</html>