From owner-freebsd-hackers Thu Jan 11 11: 5:47 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from bingnet2.cc.binghamton.edu (bingnet2.cc.binghamton.edu [128.226.1.18]) by hub.freebsd.org (Postfix) with ESMTP id EDA4337B400 for ; Thu, 11 Jan 2001 11:05:27 -0800 (PST) Received: from jade (jade.cs.binghamton.edu [128.226.140.161]) by bingnet2.cc.binghamton.edu (8.11.2/8.11.2) with ESMTP id f0BJ5Op00864; Thu, 11 Jan 2001 14:05:24 -0500 (EST) Date: Thu, 11 Jan 2001 14:03:27 -0500 (EST) From: Zhiui Zhang X-Sender: zzhang@jade To: John Polstra Cc: hackers@freebsd.org Subject: Re: Process virtual memory question In-Reply-To: <200101111742.f0BHgMt10004@vashon.polstra.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Thanks. It just occurs to me that Linux kernel used to have something like this in routine BUG(): * ((char *) 0) = 0; It is called when there is a kernel bug. So address 0 should not be mapped writable, otherwise all C statements " char * p = NULL; * p = value; " would be legal. The book "Unix Internals - A Practical Approach" by S.D. Pate has a figure showing in ELF format, the stack lies BELOW the code segment and grows downwards. This might have something to do with code starting from 0x8048000. -Zhihui On Thu, 11 Jan 2001, John Polstra wrote: > In article , Zhiui > Zhang wrote: > > > Although the 4.4 BSD design and implementation book says the text > > part of a process starts from 0x0000,0000, it actually starts from > > some place around 0x800,0000 (or 0x8048000 to be exact). What's in > > the area between 0 - 0x800,0000? Why do we not use it if it is left > > empty as shown by /proc/pid/map? How is the magic number 0x8048000 > > determined? Thanks. > > Processes used to be mapped at address 0 when we used the a.out object > file format. We changed the starting address to 0x8048000 when we > switched to the ELF format. That magic address came from SVR4, the > first system to use ELF. > > I am not 100% sure why the SVR4 developers chose that address. I > think it may have been so that they could map libc and the dynamic > linker at the fixed address 0, thereby avoiding the need to do any > run-time relocations on them. > > In any case, all ELF-based systems on the x86 architecture seem to > use this same address. On other architecutures such as the Alpha > it is entirely different, of course. > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message