From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10319 Path: news.gmane.org!not-for-mail From: Aidan Hobson Sayers Newsgroups: gmane.linux.lib.musl.general Subject: Re: Regarding whole-archive linking libc.a into a shared lib Date: Thu, 14 Jul 2016 11:17:27 +0100 Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c18aaa2170e20053795cff2 X-Trace: ger.gmane.org 1468491474 5382 80.91.229.3 (14 Jul 2016 10:17:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Jul 2016 10:17:54 +0000 (UTC) Cc: Jason Ramapuram To: musl@lists.openwall.com Original-X-From: musl-return-10332-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jul 14 12:17:44 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1bNdiA-0003JA-SG for gllmg-musl@m.gmane.org; Thu, 14 Jul 2016 12:17:43 +0200 Original-Received: (qmail 17774 invoked by uid 550); 14 Jul 2016 10:17:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 17750 invoked from network); 14 Jul 2016 10:17:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=EVLYVgJIxDWdc0Dp+d9R228e2RDp6B3mJ+Cnn0jMzYE=; b=Hpe6/ILwyEci1I3iuBjoK3Axk8Yjt8fqwU3YtEEnAFOpzZixIPl10bRIi863FOGbJa 7/BUQUPWS0eLosDxc4USRBUo+e7CeZWhI/XGxS/V7xoauN00Nysjnrg89SCXbPSnBgsq YghBa1hF0taHZZr1+jpojTcfYErt32DI2FlMGqo/KnsObLGSUvuKxX8JdqvyyUaX+mA0 3Bi5SbvWGEN8+S59uWqB51/IViBYnIQ2PkWwh4o6jNQF59QBBEm2eEUI2FF3UhuE7+oY LVmAFkwfQ/nIklf9TDBIYKspgmE+jMfeUImLBlR4iEnzGKF/ZYdWERuJiVCcBJHbH9C/ fuKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=EVLYVgJIxDWdc0Dp+d9R228e2RDp6B3mJ+Cnn0jMzYE=; b=iQcJ/4r9jDY+foSlBhpglVpYlh0NE0k3MLi15JjqTZjNmuqYaNFySKk3eUb6KWPrhS pqQ/0pu8g0iQOgmPqWxv8QrzbX0Si7IVT5fMb1LxDgGXsgrxYY5kZnRIuhZN2v1dQ69n Ya9u5JGssTs1aGTKLhUaBGfnOl/7XDEq3C5+S65GqctkiI6QvHBS5wAIrlkXlFch4bGn M88rFrX34/sIsJj6rg3ZZdo9Ji2ZqbxofrqtbsjeCP5aFluYc7LtzZ/MqPzDzMFaqwJF FKYJAmsLUtMR4zoS9zyqBDmWUzoh6fkJM5tRdFq43KUJpgKA6ThhsqyWghOa4nJaKRrG 50HQ== X-Gm-Message-State: ALyK8tKlJ3/mxgtB7dN9WFCqpAevnjXS/wtgDnrrV7onxBi2Dh/d9GwAKpNGDlAWIMiIio4Mv7Fwe9MwYlvb4Q== X-Received: by 10.107.197.134 with SMTP id v128mr12978056iof.178.1468491447591; Thu, 14 Jul 2016 03:17:27 -0700 (PDT) In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:10319 Archived-At: --94eb2c18aaa2170e20053795cff2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable There's a brief coverage of some of the problems with this idea in http://www.openwall.com/lists/musl/2012/12/08/4 The relevant part is this bit: "But now you're potentially using two different versions of libc in the same program; if implementation-internal data structures like FILE or the pthread structure are not identical between the 2 versions, you'll hit an ABI incompatibility, despite the fact that these data structures were intended to be implementation-internal and never affect ABI. Even without that issue, you have issues like potentially 2 copies of malloc trying to manage the heap without being aware of one another, and thus clobbering it." It's worth reading the whole thread as there a couple of other directly relevant bits. I've wanted to do the same as you in the past, but the number of possible (/probable) issues was quite discouraging. On 14 Jul 2016 11:04 am, "Jason Ramapuram" wrote: > Hello there, > > Is it at all possible to link musl's libc.a statically into a shared lib? > After a lot of trying I either get relocation errors (when using musl-gcc > built on say centos7) as such ( > http://stackoverflow.com/questions/38251344/musl-fails-to-link-libc-a-int= o-shared-library) > or hidden symbols not being defined like below (when using Alpine linux) = : > > /home/buildozer/aports/main/musll/src/musl-1.1.12/src/ldso/x86_64/tlsdesc= .s:36: > undefined reference to `__tls_get_new' > /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-lin= ux-musl/bin/ld: > tgt/Linux-x86_64/mylib/lib/mylib.so: hidden symbol `__tls_get_new=E2=80= =99 isn't > defined > /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-lin= ux-musl/bin/ld: > final link failed: Bad value > collect2: error: ld returned 1 exit status > Makefile:58: recipe for target =E2=80=98tgt/Linux-x86_64/mulib/lib/mylib.= so=E2=80=99 failed > make: *** [tgt/Linux-x86_64/mylib/lib/mylib.so] Error 1 > > I understand this might conflict when someone tries to link against this > and libc.so from a binary, however would it be possible somehow to mangle > all the libc calls internally inside the shared lib? Is there a tool that > would be able to do this? It would be really nice to have a portable shar= ed > lib that has libc built in. > > > --94eb2c18aaa2170e20053795cff2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

There's a brief coverage of some of the problems with th= is idea in http= ://www.openwall.com/lists/musl/2012/12/08/4

The relevant part is this bit: "But now you're pote= ntially using two different versions of libc in the same program; if implem= entation-internal data structures like FILE or the pthread structure are no= t identical between the 2 versions, you'll hit an ABI incompatibility, = despite the fact that these data structures were intended to be implementat= ion-internal and never affect ABI. Even without that issue, you have issues= like potentially 2 copies of malloc trying to manage the heap without bein= g aware of one another, and thus clobbering it."

It's worth reading the whole thread as there a couple of= other directly relevant bits. I've wanted to do the same as you in the= past, but the number of possible (/probable) issues was quite discouraging= .


On 14 Jul 2016 11= :04 am, "Jason Ramapuram" <jason.ramapuram@gmail.com> wrote:
=

Hello there,

Is it at all possible to link musl's libc.a statically into a shared= lib? After a lot of trying I either get relocation errors (when using musl= -gcc built on say centos7) as such (http://stackoverflow.com/questions/38251344/musl-fails-to-link-libc-a= -into-shared-library) or hidden symbols not being defined like below (w= hen using Alpine linux) :

/home/buildozer/aports/main/musll/src/musl-1.1.12/src/lds= o/x86_64/tlsdesc.s:36: undefined reference to `__tls_get_new'
/usr/l= ib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/= bin/ld: tgt/Linux-x86_64/mylib/lib/mylib.so: hidden symbol `__tls_get_new= =E2=80=99 isn't defined
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/= ../../../../x86_64-alpine-linux-musl/bin/ld: final link failed: Bad valuecollect2: error: ld returned 1 exit status
Makefile:58: recipe for tar= get =E2=80=98tgt/Linux-x86_64/mulib/lib/mylib.so=E2=80=99 failed
make: *= ** [tgt/Linux-x86_64/mylib/lib/mylib.so] Error 1

I understand this might conflict when someone tries t= o link against this and libc.so from a binary, however would it be possible= somehow to mangle all the libc calls internally inside the shared lib? Is = there a tool that would be able to do this? It would be really nice to have= a portable shared lib that has libc built in.


--94eb2c18aaa2170e20053795cff2--