From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8110 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Making a shared library that intercepts call to main work with musl compiled binary Date: Mon, 6 Jul 2015 13:32:59 -0400 Message-ID: <20150706173259.GX1173@brightrain.aerifal.cx> References: 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 1436203997 31891 80.91.229.3 (6 Jul 2015 17:33:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Jul 2015 17:33:17 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8123-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jul 06 19:33:16 2015 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 1ZCAGa-00009l-4Q for gllmg-musl@m.gmane.org; Mon, 06 Jul 2015 19:33:16 +0200 Original-Received: (qmail 30029 invoked by uid 550); 6 Jul 2015 17:33:13 -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 30008 invoked from network); 6 Jul 2015 17:33:12 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:8110 Archived-At: On Mon, Jul 06, 2015 at 01:00:52PM -0400, Riyad Parvez wrote: > Hi All, > > I've shared library [1] which intercepts loading of a binary and does some > pre-processing with the command-line arguments via "LD_PRELOAD" technique. > The shared library works fine with glibc compiled binary i.e., it can > intercept the call to main and does some preprocessing. But it can't > intercept call to "main" in musl-compiled binary. I've compiled my binary > in static mode with musl "CC=/musl-gcc -static". How can I make the shared > library work with musl-compiled binary? > > Thanks > Riyad > > [1]: https://github.com/dslab-epfl/s2e/blob/master/guest/init_env/init_env.c I haven't read this code in detail, so I don't have any advice on whether there are other problems, but the basic issue seems to be that you're static linking. The same would happen if you use glibc and static link. If you want the ability to use LD_PRELOAD you need to link dynamically. Rich