public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* target/10431: improper __attribute__((dllimport)) handling
@ 2003-04-18  9:47 xtrochu
  0 siblings, 0 replies; 4+ messages in thread
From: xtrochu @ 2003-04-18  9:47 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10431
>Category:       target
>Synopsis:       improper __attribute__((dllimport)) handling
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 18 09:46:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     xtrochu@yahoo.com
>Release:        mainline, 3.3
>Organization:
>Environment:
i686-pc-mingw32
>Description:
When using the __attribute__((dllimport)) on a extern variable, the compiler generate a invalid opcode.

See rtest.ori.s for the correct output, given by gcc 3.2.2
and rtest.new.s for the invalid output generated by mainline gcc.

commandline used: 
gcc -S -s -O0 -o rtest.ori.s rtest.i
gcc/stage1/xgcc -Bgcc/stage1 -S -s -O0 -o rtest.new.s rtest.i
(note: Because of the bug, the mainline does not bootstrap, that's why I used stage1)

The same behaviour can be observed when building GCC as a cross-compiler to mingw32.

>How-To-Repeat:

>Fix:
The problem seems to come from the latest modification to winnt.c by mmitchell. (FIX PR c++/7910).

Reverting to version 1.42 of winnt.c fix the behaviour.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test"

PT09PT09PT09PT09PT09PT0gcnRlc3QuaSA9PT09PT09PT09PT09DQoNCmV4dGVybiBfX2F0dHJp
YnV0ZV9fKChkbGxpbXBvcnQpKSBpbnQgZm9vOw0KZXh0ZXJuIF9fYXR0cmlidXRlX18oKGRsbGlt
cG9ydCkpIGludCBmb28yW107DQoNCmludCBiYXIoKSB7DQoJcmV0dXJuIGZvbzsNCn0NCg0KaW50
IGJhcjIoaW50IGkpICB7DQoJaW50ICogcCA9ICZmb28yW2ldOw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JOCglZWJwKSwgJWVheA0KCWxl
YWwJMCgsJWVheCw0KSwgJWVkeA0KCW1vdmwJJF9faW1wX19mb28yLCAlZWF4DQoJYWRkbAklZWR4
LCAlZWF4DQoJbW92bAklZWF4LCAtNCglZWJwKQ0KCW1vdmwJLTQoJWVicCksICVlYXgNCgltb3Zs
CSglZWF4KSwgJWVheA0KCWxlYXZlDQoJcmV0DQo=


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: target/10431: improper __attribute__((dllimport)) handling
@ 2003-04-21 22:26 TROCHU Xavier
  0 siblings, 0 replies; 4+ messages in thread
From: TROCHU Xavier @ 2003-04-21 22:26 UTC (permalink / raw)
  To: mmitchel; +Cc: gcc-prs

The following reply was made to PR target/10431; it has been noted by GNATS.

From: TROCHU Xavier <xtrochu@yahoo.com>
To: <mmitchel@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>,
  <gcc-gnats@gcc.gnu.org>
Cc:  
Subject: Re: target/10431: improper __attribute__((dllimport)) handling
Date: Mon, 21 Apr 2003 15:17:58 -0700 (PDT)

 I checked your patch and it shows the same behaviour
 as the previous one 
 (i.e. an incorrect behaviour).
 
 mainline can't be bootstrapped under mingw with this
 patch. Notice that
 stdout under mingw is declared really like this :
 extern __attribute__((dllimport)) FILE * _iob[1];
 and obviously,  this bug
 
 This is the test I tried again :
 ================= rtest.i =============
 
 extern __attribute__((dllimport)) int foo;
 extern __attribute__((dllimport)) int foo2[];
 
 int bar() {
     return foo;
 }
 
 int bar2(int i)  {
     int * p = &foo2[i];
     return *p;
 }
 ==================================
 with winnt.c reverted to version 1.42 (but with patch
 from 1.43 to 1.44 
 inserted) I get the following output,
 which is correct and the same as gcc 3.2.2
 ================= rtest.ori.s =========
     .file    "rtest.i"
     .text
 ..globl _bar
     .def    _bar;    .scl    2;    .type    32;   
 .endef
 _bar:
     pushl    %ebp
     movl    %esp, %ebp
     movl    __imp__foo, %eax
     movl    (%eax), %eax
     popl    %ebp
     ret
 ..globl _bar2
     .def    _bar2;    .scl    2;    .type    32;   
 .endef
 _bar2:
     pushl    %ebp
     movl    %esp, %ebp
     subl    $4, %esp
     movl    8(%ebp), %eax
     sall    $2, %eax
     addl    __imp__foo2, %eax
     movl    %eax, -4(%ebp)
     movl    -4(%ebp), %eax
     movl    (%eax), %eax
     leave
     ret
 ====================================
 with winnt.c version 1.45 (current) or 1.44 the output
 is as the following.
 ================== rtest.new.s ==========
     .file    "rtest.i"
     .text
 ..globl _bar
     .def    _bar;    .scl    2;    .type    32;   
 .endef
 _bar:
     pushl    %ebp
     movl    %esp, %ebp
     movl    __imp__foo, %eax
     popl    %ebp
     ret
 ..globl _bar2
     .def    _bar2;    .scl    2;    .type    32;   
 .endef
 _bar2:
     pushl    %ebp
     movl    %esp, %ebp
     subl    $4, %esp
     movl    8(%ebp), %eax
     leal    0(,%eax,4), %edx
     movl    $__imp__foo2, %eax
     addl    %edx, %eax
     movl    %eax, -4(%ebp)
     movl    -4(%ebp), %eax
     movl    (%eax), %eax
     leave
     ret
 ======================================
 
 I really would like to be able to help correcting this
 bug, but I really 
 lack a lot of knowledge of GCC internal for that.
 But if you think I can help you testing thing, don't
 hesitate to ask.
 
 Greetings,
 
 Xavier
 
 mmitchel@gcc.gnu.org wrote:
 
 >Synopsis: improper __attribute__((dllimport))
 handling
 >
 >State-Changed-From-To: open->closed
 >State-Changed-By: mmitchel
 >State-Changed-When: Mon Apr 21 20:59:27 2003
 >State-Changed-Why:
 >    Fixed in GCC 3.3, GCC 3.4.
 >
 >http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10431
 >
 >  
 >
 
 
 __________________________________________________
 Do you Yahoo!?
 The New Yahoo! Search - Faster. Easier. Bingo
 http://search.yahoo.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: target/10431: improper __attribute__((dllimport)) handling
@ 2003-04-21 20:59 mmitchel
  0 siblings, 0 replies; 4+ messages in thread
From: mmitchel @ 2003-04-21 20:59 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mmitchel, xtrochu

Synopsis: improper __attribute__((dllimport)) handling

State-Changed-From-To: open->closed
State-Changed-By: mmitchel
State-Changed-When: Mon Apr 21 20:59:27 2003
State-Changed-Why:
    Fixed in GCC 3.3, GCC 3.4.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10431


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: target/10431: improper __attribute__((dllimport)) handling
@ 2003-04-18 10:02 ebotcazou
  0 siblings, 0 replies; 4+ messages in thread
From: ebotcazou @ 2003-04-18 10:02 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mmitchel, nobody, xtrochu

Synopsis: improper __attribute__((dllimport)) handling

Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-By: ebotcazou
Responsible-Changed-When: Fri Apr 18 10:02:21 2003
Responsible-Changed-Why:
    Your patch for PR c++/7910.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10431


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-04-21 22:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-18  9:47 target/10431: improper __attribute__((dllimport)) handling xtrochu
2003-04-18 10:02 ebotcazou
2003-04-21 20:59 mmitchel
2003-04-21 22:26 TROCHU Xavier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).