Date: Tue, 01 Sep 1998 17:42:48 -0700 From: John Polstra <jdp@polstra.com> To: "Andrew Reilly" <reilly@zeta.org.au> Cc: current@FreeBSD.ORG Subject: Re: ELF binaries size Message-ID: <199809020042.RAA16383@austin.polstra.com> In-Reply-To: Your message of "Wed, 02 Sep 1998 09:06:45 %2B1000." <19980902090645.A1965@reilly.home>
next in thread | previous in thread | raw e-mail | index | archive | help
> > Yes. That's because a.out rounds the text and data segments up to > > page boundaries, but ELF does not. > > Does that mean that the last page in a text segment is treated > differently (wrt vm paging) than the rest of the image, or is > garbage loaded plast the end, along with the last page? In the executable file, the data immediately follows the text, which means that the boundary between the two will be somewhere in the middle of a page, most likely. ELF handles this by mapping the boundary page twice, once into the text segment and once into the data segment. Here is the view relative to the executable file: +---+---+---+---+ text | | | | : | +---+---+---+---+ +---+---+---+---+ data | : | | | | +---+---+---+---+ Here, the underlying file advances horizontally, and the text and data mappings are shown as they overlay it. The `:' represents the boundary between text and data. The mapping of the data in the address space is such that the first data page is mapped after the last text page. So in the address space, it looks like this: +---+---+---+---+ text | | | | : | +---+---+---+---+ +---+---+---+---+ data | : | | | | +---+---+---+---+ Here, addresses as seen from the program advance horizontally. The tail end of the last text page in your address space will contain the beginning of the data. The beginning of the first data page will likewise contain the end of the text. This does not imply that the program can modify its text. Remember, the pages are mapped copy-on-write. The data segment can write into the leading portion of its first page, but any changes it makes will remain invisible to the text segment. > Is this a security problem? I don't think so. Do you? John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Self-knowledge is always bad news." -- John Barth To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809020042.RAA16383>