Re: mprotect reports ENOMEM under -O2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Amittai Aviram <amittai.aviram@xxxxxxxx> writes:

> Hi!  I have a modification of GCC that includes a call to mprotect
> from a signal handler.  Applications compiled with the altered GCC
> work fine (at least as far as I can tell) if I edit my GCC Makefile
> before compiling GCC so as to eliminate the default "-O2" flag.  If I
> restore the optimization, however, and recompile GCC and then the
> application under that GCC, the application fails: mprotect reports
> ENOMEM.  Any ideas, either on this problem or on how I should go about
> investigating it?

To be clear, if I understand your background correctly, your
modification of gcc is intended to modify the generated code.  That is,
you mhave not modified gcc such that gcc itself calls mprotect from a
signal handler.  You have modified gcc such that it generates code which
calls mprotect from a signal handler.

Your problem is that when gcc is compiled with -O2, the code that it
generates does not work correctly.

If that is correct, then you should look closely at the code you have
added to gcc, and make sure that you have not introduced undefined
behaviour into gcc itself.  It may help to use the -Wstrict-aliasing and
-Wstrict-overflow options.  It would be interesting to learn whether
your gcc also fails if you compile with -O2 -fno-strict-aliasing and/or
-O2 -fno-strict-overflow.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux