Bug 48004 - doesn't work with randomize_va_space
Summary: doesn't work with randomize_va_space
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: pch (show other bugs)
Version: 4.5.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-06 12:42 UTC by wbrana
Modified: 2012-07-19 18:57 UTC (History)
0 users

See Also:
Host: x86_64-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-03-07 10:24:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wbrana 2011-03-06 12:42:06 UTC
If address space randomization is enabled
echo 1 > /proc/sys/kernel/randomize_va_space
pch isn't used - warning: had text segment at different address
Comment 1 Andrew Pinski 2011-03-06 21:07:04 UTC
Which host is this on?
Comment 2 wbrana 2011-03-06 21:11:50 UTC
x86_64-pc-linux-gnu
Comment 3 Richard Biener 2011-03-07 10:24:39 UTC
It should work, we use fixed mappings for this.
Comment 4 wbrana 2011-03-07 10:54:43 UTC
It is possible that this bug is related to PaX, which I'm using
http://bugs.gentoo.org/show_bug.cgi?id=301299#c31
I tried to disable PaX with "paxctl -pemrxs cc1plus", but warning disappear only if randomize_va_space is 0
Comment 5 Richard Biener 2011-03-07 11:07:33 UTC
We can't simply use MAP_FIXED, as that will discard existing overlapping mappings.

       MAP_FIXED
              Don't interpret addr as a hint: place  the  mapping  at  exactly
              that address.  addr must be a multiple of the page size.  If the
              memory region specified by addr and len overlaps  pages  of  any
              existing  mapping(s),  then  the overlapped part of the existing
              mapping(s) will be discarded.  If the specified  address  cannot
              be  used,  mmap()  will fail.  Because requiring a fixed address
              for a mapping is less portable, the use of this option  is  dis-
              couraged.

So we'd need to portably check for existing mappings in the range we want
to request.  I don't think that is desirable (if only from a performance
perspective).  The only way to do this that I can think of is parsing
/proc or installing a SIGSEGV/SIGBUS handler and poking every page ...
Comment 6 wbrana 2011-03-07 11:20:55 UTC
I can see warning also when PaX is disabled with kernel 2.6.37.2
randomize_va_space is 1 by default.
Comment 7 wbrana 2011-03-07 12:35:23 UTC
Parsing /proc doesn't have to work with PaX kernel. 
PaX removes some info from e.g. maps file.
Comment 8 wbrana 2012-07-19 18:57:26 UTC
I have tested GCC 4.5.4 and 4.7.1. It seems to be fixed.