Subject: Re: Why mark our .note.netbsd signature LOADable?
To: Martin Husemann <martin@duskware.de>
From: Richard Earnshaw <rearnsha@arm.com>
List: tech-toolchain
Date: 12/06/2006 14:05:46
On Wed, 2006-12-06 at 14:44 +0100, Martin Husemann wrote:
> After playing with .note sections to mark the kernel as a NetBSD binary
> yesterday, I commited a change to the .note section generating code
> for the kernel. At this time I was a bit confused, and did not fully 
> understand what this caused.
> 
> When thinking about it later, I wondered if we should do the same change to
> the userland .note section. A patch that does this, and also changes 
> exec_elf32.c to cope with it is attached.
> 
> I am not sure we want to do this - so let me try to explain the change:
> 
> What is the difference?
> 
> Our current note mark is a PT_NOTE PHDR:
> 
>     NOTE off    0x00000000000001a4 vaddr 0x00000000001001a4 paddr 0x00000000001001a4 align 2**2
>          filesz 0x0000000000000018 memsz 0x0000000000000018 flags r--
> 
> It creates a SHT_NOTE section too:
> 
>   1 .note.netbsd.ident 00000018  00000000001001a4  00000000001001a4  000001a4  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA

I really don't think it makes any practical difference.  For starters,
sections aren't read by a loader, only PHDRs.  Secondly, PHDRs can (and
do) overlap.  This particular one is part of the first page of the image
and is thus always loaded regardless (we map images page at a time)
since other parts of that page are loaded.

It IS important that this PHDR is in the first page so that we can
quickly determine the type of image we are dealing with.

R.