This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Comments on mudflap


Doug Graham wrote:
Frank Eigler suggested that I send this to the list.  His comments
follow mine.

[trimmed]


One other minor thing.  On the Fedora Core 1 Linux system that I'm
using for testing (with GLIBC 2.3.2), I get a mudflap violation every
time I use one of the ctype routines (isdigit, isupper, islower, etc.)
I assume that's because there is some array in the library that is
accessed by the ctype macros, but which hasn't been registered with
the mudflap runtime.  For the tests above, I've been using my own ctype
replacement so as to avoid this problem.

Regards,
Doug.

--------------------

From: "Frank Ch. Eigler" <fche@redhat.com>

Hi, Doug -

[trimmed]


With respect to ctype, yes, these types of static arrays used by
libc macros pose a problem.  One solution would require adding a few
autoconf-sensitive lines to mf-runtime.c to register these during
initialization much as environment variables and std* FILE objects are.

- FChE

The abovementioned patch should be simple, just add the last three __mf_register call statements to this function in gcc/libmudflap/mf-runtime.c. Do include <ctype.h> somewhere at the top.

int
__wrap_main (int argc, char* argv[])
{
  extern char **environ;
  extern int main ();
  static int been_here = 0;

  if (__mf_opts.heur_std_data && ! been_here)
    {
      unsigned i;

      been_here = 1;
      __mf_register (argv, sizeof(char *)*(argc+1), __MF_TYPE_STATIC, "argv[]");
      for (i=0; i<argc; i++)
        {
          unsigned j = strlen (argv[i]);
          __mf_register (argv[i], j+1, __MF_TYPE_STATIC, "argv element");
        }

      for (i=0; ; i++)
        {
          char *e = environ[i];
          unsigned j;
          if (e == NULL) break;
          j = strlen (environ[i]);
          __mf_register (environ[i], j+1, __MF_TYPE_STATIC, "environ element");
        }
      __mf_register (environ, sizeof(char *)*(i+1), __MF_TYPE_STATIC, "environ[]");

__mf_register (& errno, sizeof (errno), __MF_TYPE_STATIC, "errno area");

      __mf_register (stdin,  sizeof (*stdin),  __MF_TYPE_STATIC, "stdin");
      __mf_register (stdout, sizeof (*stdout), __MF_TYPE_STATIC, "stdout");
      __mf_register (stderr, sizeof (*stderr), __MF_TYPE_STATIC, "stderr");

      /* ctype.h tables */
      __mf_register (__ctype_b, sizeof (unsigned short int)*256,
                __MF_TYPE_STATIC, "__ctype_b");
      __mf_register (__ctype_tolower, sizeof (__int32_t)*256,
                __MF_TYPE_STATIC, "__ctype_tolower");
      __mf_register (__ctype_toupper, sizeof (__int32_t)*256,
                __MF_TYPE_STATIC, "__ctype_toupper");
    }

#ifdef PIC
  return main (argc, argv, environ);
#else
  return __real_main (argc, argv, environ);
#endif
}




-- -- Eyal Lebedinsky (eyal@eyal.emu.id.au) <http://samba.org/eyal/>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]