From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4465 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: libgcc --disable-shared test case Date: Sat, 11 Jan 2014 16:51:06 -0500 Message-ID: <20140111215106.GV24286@brightrain.aerifal.cx> References: <20131017060913.GA1957@brightrain.aerifal.cx> <1389462032.1176.18@driftwood> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1389477073 31226 80.91.229.3 (11 Jan 2014 21:51:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Jan 2014 21:51:13 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4469-gllmg-musl=m.gmane.org@lists.openwall.com Sat Jan 11 22:51:22 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1W26Sf-0003Yv-Hk for gllmg-musl@plane.gmane.org; Sat, 11 Jan 2014 22:51:21 +0100 Original-Received: (qmail 17970 invoked by uid 550); 11 Jan 2014 21:51:20 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 17960 invoked from network); 11 Jan 2014 21:51:19 -0000 Content-Disposition: inline In-Reply-To: <1389462032.1176.18@driftwood> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:4465 Archived-At: On Sat, Jan 11, 2014 at 11:40:32AM -0600, Rob Landley wrote: > On 10/17/2013 01:09:13 AM, Rich Felker wrote: > >On i386 or any arch where libgcc functions are needed for 64-bit > >division, the following should reproduce the failure if libgcc was > >built with --disable-shared (which disables visibility): > > > >gcc -O2 -shared -o libfoo.so lib_v1.c > >gcc -O2 main.c ./libfoo.so > >./a.out # ok > >gcc -O2 -shared -o libfoo.so lib_v2.c > >./a.out # fails with symbol errors > > > >Rich > > lib_v1.c: > long long foo(long long x) { return x/10; } > > lib_v2.c: > long long foo(long long x) { return x/16; } > > main.c: > #include > extern long long foo(long long); > int main() { printf("%lld\n", foo(100)/10); } > > Ok, I just tested this again. With lib_v1.c, the one built with my > simple-cross-compiler toolchain printed 1, and the lib_v2.c printed > 0. (I believe you said the error was a link failure?) > > I had to copy the resulting a.out and libfoo.so into > simple-root-filesystem (which was built with the simple cross > compiler and doesn't contain a native compiler) to run it in a > chroot because the host hasn't got uClibc libraries installed in it, > hence no libc.so.0 for the dynamic link... > > Looks like my toolchain doesn't exhibit this behavior? (Not after I > hacked the hell out of the libgcc.a build, anyway...) What arch? I would expect this to show up on i386 but not x86_64, since the latter has native division and libgcc functions won't be needed. It could also be an issue of -O level if gcc decided to use long division instead of bitshift to implement /16. Or it might be something completely different. If you could share the two versions of libfoo.so, a.out, and maybe even libgcc.a, I can probably figure out what's going on. Rich