From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZPW4-0005nA-4p for qemu-devel@nongnu.org; Fri, 16 Nov 2012 12:15:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TZPW1-0001Aj-2T for qemu-devel@nongnu.org; Fri, 16 Nov 2012 12:15:44 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:34711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZPW0-0001Ab-Nf for qemu-devel@nongnu.org; Fri, 16 Nov 2012 12:15:40 -0500 Message-ID: <50A674BA.1010204@weilnetz.de> Date: Fri, 16 Nov 2012 18:15:38 +0100 From: Stefan Weil MIME-Version: 1.0 References: <1351697456-16107-1-git-send-email-pbonzini@redhat.com> <1351697456-16107-6-git-send-email-pbonzini@redhat.com> <50A52E14.2070106@weilnetz.de> <50A55615.1040003@redhat.com> <50A56A1F.30907@weilnetz.de> <50A608C6.1080804@redhat.com> In-Reply-To: <50A608C6.1080804@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 05/39] fdsets: use weak aliases instead of qemu-tool.c/qemu-user.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Blue Swirl , aliguori@us.ibm.com, qemu-devel@nongnu.org, stefanha@redhat.com Am 16.11.2012 10:35, schrieb Paolo Bonzini: > Il 15/11/2012 23:18, Stefan Weil ha scritto: >> Am 15.11.2012 21:52, schrieb Paolo Bonzini: >>> Il 15/11/2012 19:01, Stefan Weil ha scritto: >>>> Hi Paolo, >>>> >>>> this patch breaks QEMU on 32 and 64 bit hosts, native and with Wine. >>>> It's easy to reproduce the SIGSEGV crash: just add a -snapshot option. >>>> Obviously the critical code is executed only when this option was used. >>> >>> I cannot reproduce this, so it must be an assembler or linker bug. >>> >>> Can you try the alternative code that is used for Mac OS X? >> >> The code which is used for Mac OS X also compiles and >> results in the same run-time bug with Wine: > > Ok, I reproduced the original binutils bug, and found a typo in the > weakrefs implementation. Does this work for you? > > diff --git a/compiler.h b/compiler.h > index 55d7d74..d552757 100644 > --- a/compiler.h > +++ b/compiler.h > @@ -50,11 +50,12 @@ > # define __printf__ __gnu_printf__ > # endif > # endif > -# if defined(__APPLE__) > +# if defined(__APPLE__) || defined(_WIN32) > # define QEMU_WEAK_ALIAS(newname, oldname) \ > - static typeof(oldname) weak_##newname __attribute__((unused, weakref(#oldname))) > + static typeof(oldname) weak_##newname __attribute__((unused, weakref(#newname))) > # define QEMU_WEAK_REF(newname, oldname) (weak_##newname ? weak_##newname : oldname) > # else > +#error > # define QEMU_WEAK_ALIAS(newname, oldname) \ > typeof(oldname) newname __attribute__((weak, alias (#oldname))) > # define QEMU_WEAK_REF(newname, oldname) newname > > > If it still doesn't work, let's make sure that this reduced testcase works > for you: Tested-by: Stefan Weil Great, the above patch fixes w32/w64 (native and with Wine). Is this modification needed / does it work with MacOS X, too? With the reduced testcase, I get the same results as in your test. Regards Stefan > > g1.c: > #include > int f() { printf("strong"); return 82; } > int g() { printf("strong"); return 83; } > > g2.c: > #include > static int weak_f() { return 42; } > static int weak_g() { return 43; } > typeof(weak_f) f __attribute__((__weak__, __alias__("weak_f"))); > typeof(weak_g) g __attribute__((__weak__, __alias__("weak_g"))); > int main() { printf("%d/%d\n", f(), g()); } > > g3.c: > #include > static int default_f() { return 42; } > static int default_g() { return 43; } > static typeof(default_f) weak_f __attribute__((__weakref__("f"))); > static typeof(default_g) weak_g __attribute__((__weakref__("g"))); > int main() { printf("%d/%d\n", (weak_f?:default_f)(), (weak_g?:default_g)()); } > > Output should be: > - 42/43 for "gcc g2.c" > - 42/43 for "gcc g3.c" > - strongstrong82/83 for "gcc g1.c g2.c" > - strongstrong82/83 for "gcc g1.c g3.c" > > Output on Windows is: > - 42/42 for "gcc g2.c" > - 42/43 for "gcc g3.c" > - segfault for "gcc g1.c g2.c" > - strongstrong82/83 for "gcc g1.c g3.c" > > So, indeed "normal" weak symbols are broken, but weakrefs seem to work. > > If the above patch doesn't work, and/or the reduced testcase fails, > please send to me: > > - the .exe for "gcc g1.c g3.c" > - the .s file for g3.s > - the .o file for osdep.o > - the linked .exe (I assume both the windows and console versions fail) > - perhaps the .s file for osdep too; add --save-temps to the compiler command line to get it > > Paolo