Re: Choosing a default text address for user programs for a new port
"Toru Nishimura" <[email protected]> Sat, 27 Apr 2002 12:20:07 +0900
| Newsgroups | gmane.os.netbsd.devel.ports |
|---|---|
| Message-ID | <000701c1ed9a$6f0aa680$2900a8c0@nicol> |
Glenn Serre <[email protected]> > I'm trying to get a new port running (I'm currently trying to exec init > for the first time) and I'm wondering what I should use as the default > text address for user programs. I searched the list archives a bit, but > didn't see anything particularly informative. > > It seems like 0 is a bad choice, since it would make it hard to detect > NULL pointer reads. I note that /sbin/init on my i386 box has text > starting at 0x08048100, but I don't know why it leaves all that space > after 0. > > Suggestions, tips, or pointers to docs would be much appreciated. Vast majority of NetBSD VM has 10+10+12 bit address decoding w/ 4KB page. This arranges "sorta i386-style" in two level structure composed by one page directory and multiple page tables. Such arrangement groups 4MB address space in a chunk So, 4MB boundary is natural choice to align "memory objects." And, some CPU MMU architectures impose programs to layout so to take advantage of natural alignment. Some OSes protect NULL pointer references by placing "guard page" there. During the raise of M68K UNIX machines, some of UNIX vendors practiced a small effort in which NULL pointer reference makes a string reference to "(null)" So, printf("%s", NULL) prints (null). This was far from a perfect guard, however, made UNIX application porting far less troublesome simply because VAX did not make SEGV for such the programming errors and many of Berkeley distributed applications (at that time) were suffered from the careless programmers. Just a tip from old-timer... Toru Nishimura