This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: other/9830: [pch] not working on Solaris 9
- From: "Michael Teske" <mteske at csksoftware dot com>
- To: Geoff Keating <geoffk at geoffk dot org>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 25 Feb 2003 13:03:51 +0100
- Subject: Re: other/9830: [pch] not working on Solaris 9
- Organization: CSK Software AG
- References: <20030224132612.26862.qmail__21143.0731149905$1046093758@sources.redhat.com> <jmznolwi89.fsf@desire.geoffk.org> <200302251041.07480.mteske@csksoftware.com>
On Tuesday 25 February 2003 10:41, Michael Teske wrote:
> As I saw it in gdb, Solaris seems to always return
> (mmi.preferred_base + mmi.offset) as addr. I'll try what happens if I pass
> mmi.preferred_base-mmi.offset as the first parameter (if MAP_FIXED is not
> given).
Hmm, this all doesn't help. Here's what the man page says:
When MAP_FIXED is not set, the system uses addr to arrive at
pa. The pa so chosen will be an area of the address space
that the system deems suitable for a mapping of len bytes to
the file. The mmap() function interprets an addr value of 0
as granting the system complete freedom in selecting pa,
subject to constraints described below. A non-zero value of
addr is taken to be a suggestion of a process address near
which the mapping should be placed. When the system selects
a value for pa, it will never place a mapping at address 0,
nor will it replace any extant mapping, nor map into areas
considered part of the potential data or stack "segments".
So it takes it as a suggestion _near_ where the data should arrive, it doesn't
even try to use the exact address :-( My test program confirm this.
Consider this small little test program:
#include <stdio.h>
#include <sys/mman.h>
int main(void) {
void* base = 0xff3A0000;
long size = 0x2000;
long offset = 0x16000;
void* addr;
FILE *f = fopen ("mmaptest.bigfile", "r+");
if (f==NULL) return 1;
addr = mmap (base, size,
PROT_READ | PROT_WRITE, MAP_PRIVATE,
fileno (f), offset);
printf("base: %p, addr: %p\n", base, addr);
/* cleanup omitted */
return 0;
}
It always gives me 0xff396000 as addr back, regardless if I feed in
0xff3A0000, 0xff380000, or even 0xff000000 as base :-(((
If I set offset to 0, it returns 0xff390000, regardless of input, so this is
not a solution, either :-(
The only way seems to be MAP_FIXED or a correct implementation of relocation a
PCH file.
And I just tested on a different machine with Solaris 8, same there, just the
fixed value is another one.
Greetings, Michael
--
Michael Teske
<This space is left blank intentionally>