This is the mail archive of the gcc-bugs@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: other/9830: [pch] not working on Solaris 9


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>


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