From: Shaun Jackman <sjackman@bcgsc.ca>
To: Nick Clifton <nickc@redhat.com>
Cc: "binutils@sourceware.org" <binutils@sourceware.org>
Subject: Re: ld --wrap and zcat
Date: Wed, 26 Aug 2009 19:35:00 -0000 [thread overview]
Message-ID: <4A956F61.4080602@bcgsc.ca> (raw)
In-Reply-To: <4A94E33C.7010107@redhat.com>
Neat, I didn't think of that. Thanks, Nick.
The solution I settled didn't require LD_PRELOAD, which I'm happy
about, but did use -ldl and dlsym. I created a function `fopen' in my
application, which -- and I don't entirely understand why this is --
libstdc++ does call. Within my fopen, I used dlsym(RTLD_NEXT, "fopen")
to call the fopen of libc.
Cheers,
Shaun
Nick Clifton wrote:
> Hi Shaun,
>
>> fstream::open in libstdc++ calls fopen in libc. I'd like to use ld
>> --wrap to hook the fopen call to call popen to decompress a .gz file
>> using zcat. Is this possible with ld --wrap? From my experimentation, it
>> seems not. Is this possible using LD_PRELOAD and dlsym?
>
> Do you have access to the linker command line used to build your
> executable ? If so you can just create your own custom library that
> contains its own implementation of fopen (which calls popen as you
> desire) and then insert the name of this library in between the
> libstdc++-v3 library and the libc library on the linker command line.
>
> Cheers
> Nick
prev parent reply other threads:[~2009-08-26 17:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-25 0:15 Shaun Jackman
2009-08-26 9:02 ` Nick Clifton
2009-08-26 19:35 ` Shaun Jackman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A956F61.4080602@bcgsc.ca \
--to=sjackman@bcgsc.ca \
--cc=binutils@sourceware.org \
--cc=nickc@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).