public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* mudflap and dlopen
@ 2010-01-28 15:02 Rainer Gerhards
  2010-01-29 15:13 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Rainer Gerhards @ 2010-01-28 15:02 UTC (permalink / raw)
  To: gcc-help

Hi all,

I hope this is the right mailing list. I am the author of rsyslog, a
modular and multi-threaded syslogd. I try to hunt down a memory
adressing problem with mudflap, but I get some reports that I really
can't understand.

What happens is that these reports come up from inside a dlload()'ed
module which is called from the main binary. The main program passes
in two paramaters, a string (pointer to unsigned char) and a pointer
to a function pointer. The module's entry point compares the string
and writes the correct function address to the function pointer. All
accesses to these two variables seem to trigger mudflap violations.

I have checked the pointer sizes are correctly.

I have compiled and linked the main program with -fmudflapth
-lmudflapth and have compiled the module with -fmudflapth, but not
linked it with any special directive (my understanding is that
load-time linking will then link the module to the main program's
mudflap libraries, what I think it is the correct thing to do).

To double-check, I have then linked both the main program and the
module against libmudflapth, and these problems disappear then. So the
conclusion is probably straightforward. However, I still have a hang
condition on some module loads when mudflap is enabled (and only
then).

So I wonder if I am doing something wrong and if there are any known
problems with dlload(). Any feedback would be appreciated.

Thanks,
Rainer

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: mudflap and dlopen
  2010-01-28 15:02 mudflap and dlopen Rainer Gerhards
@ 2010-01-29 15:13 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2010-01-29 15:13 UTC (permalink / raw)
  To: Rainer Gerhards; +Cc: gcc-help

Rainer Gerhards <rgerhards@gmail.com> writes:

> What happens is that these reports come up from inside a dlload()'ed
> module which is called from the main binary. The main program passes
> in two paramaters, a string (pointer to unsigned char) and a pointer
> to a function pointer. The module's entry point compares the string
> and writes the correct function address to the function pointer. All
> accesses to these two variables seem to trigger mudflap violations.
>
> I have checked the pointer sizes are correctly.
>
> I have compiled and linked the main program with -fmudflapth
> -lmudflapth and have compiled the module with -fmudflapth, but not
> linked it with any special directive (my understanding is that
> load-time linking will then link the module to the main program's
> mudflap libraries, what I think it is the correct thing to do).
>
> To double-check, I have then linked both the main program and the
> module against libmudflapth, and these problems disappear then. So the
> conclusion is probably straightforward. However, I still have a hang
> condition on some module loads when mudflap is enabled (and only
> then).
>
> So I wonder if I am doing something wrong and if there are any known
> problems with dlload(). Any feedback would be appreciated.

The mudflap library requires registering all global variables.  This
is normally done automatically via a global constructor.  So one thing
to check would be to make sure that that global constructor is being
run when you dlopen the shared library.  That should normally happen
automatically when you call dlopen, at least on GNU/Linux, but perhaps
something has gone wrong.

You mention dlload several times but I'm not familiar with that
function.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-29 15:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-28 15:02 mudflap and dlopen Rainer Gerhards
2010-01-29 15:13 ` Ian Lance Taylor

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).