Subject: Re: warning: src/x11 broken
To: None <port-amd64@NetBSD.org>
From: Matthias Scheler <tron@zhadum.de>
List: port-amd64
Date: 04/11/2004 08:37:17
In article <20040405115023.GA27209@vaasje.org>,
	Frank van der Linden <fvdl@NetBSD.org> writes:
> The XFree86 loader is broken, and only works on Linux because they
> added a hack to mmap to specify memory below the 32bit boundary.

So IIUC the loader doesn't work if the address returned by mmap() is
above 4GB. Correct?

> I've looked at it a while ago, and I don't think this can be fixed,
> unless they switch to a normal dlopen() scheme.

A possible fix would be a change like this to
"xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c":

#if defined(__NetBSD__) && (__AMD64__)
	static char *mm_addr = (char *)(1L << 30);
#else
	char *mm_addr = NULL;
#endif

    ret = (unsigned long)mmap(mm_addr, new_size, MMAP_PROT, MAP_PRIVATE
#  if !defined(_NetBSD__) && defined(__AMD64__)
                              | MAP_32BIT
#  endif
                              , fd, new_off);
    if (ret == -1)
        FatalError("mmap() failed: %s\n", strerror(errno));
#if defined(__NetBSD__) && (__AMD64__)
    mm_addr += new_size;
#endif

    return (void *)(ret + new_off_bias);

That's not pretty but should work.

	Kind regards

-- 
Matthias Scheler                                  http://scheler.de/~matthias/