Subject: Re: Add a MAP_ALIGNED flag for mmap(2).
To: None <tech-kern@netbsd.org>
From: Matt Thomas <matt@3am-software.com>
List: tech-kern
Date: 03/02/2003 01:13:28
--=====================_1994392414==_
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 06:01 PM 2/28/2003, Matt Thomas wrote:
>Currently, ld.elf_so doesn't honor the alignment specified in a
>ELF file's psections.  This is due to the lack of ability to request
>an aligned block of addresses from mmap(2).  I propose we add a
>MAP_ALIGNED flag which would mean that the addr argument to mmap(2)
>would be the required alignment of the block.  Supplying both
>MAP_ALIGNED|MAP_FIXED would cause an error EINVAL to be returned.
>
>Any thought on this proposal?

Taking Andrew Brown's idea, I stole the top 8 bit of the flags argument
to mmap(2) to inside a log2 value of alignment desired.  The attach
patch implements the proposal and (after a few bugs in uvm) works fine.


-- 
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt/
Cupertino, CA             Disclaimer: I avow all knowledge of this message
--=====================_1994392414==_
Content-Type: text/plain; name="map.txt";
 x-mac-type="42494E41"; x-mac-creator="74747874"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="map.txt"

SW5kZXg6IHN5cy9tbWFuLmgKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpSQ1MgZmlsZTogL2N2c3Jvb3Qvc3JjL3N5cy9z
eXMvbW1hbi5oLHYKcmV0cmlldmluZyByZXZpc2lvbiAxLjI4CmRpZmYgLXUgLXIxLjI4IG1tYW4u
aAotLS0gc3lzL21tYW4uaAkyMDAwLzEwLzE4IDAxOjQzOjE4CTEuMjgKKysrIHN5cy9tbWFuLmgJ
MjAwMy8wMy8wMiAwOToxNjo1MwpAQCAtMTAwLDYgKzEwMCwxOSBAQAogI2RlZmluZQlNQVBfQU5P
TgkweDEwMDAJLyogYWxsb2NhdGVkIGZyb20gbWVtb3J5LCBzd2FwIHNwYWNlICovCiAK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