tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: ELF sections vs. segments



In article <20170122012523.GA18557%pony.stderr.spb.ru@localhost>,
Valery Ushakov  <uwe%stderr.spb.ru@localhost> wrote:
>On Thu, Jan 19, 2017 at 19:02:15 +0300, Valery Ushakov wrote:
>
>> The question I have can probably be classified as a platonic
>> essentialism problem, but it has some practical conseqeunces too.
>> 
>> I've noticed that netbsd native elf signature check looks for a netbsd
>> note _section_.
>> 
>>   sys/kern/exec_elf.c
>>   - netbsd_elf_signature
>> 
>> 
>> OTOH, linunx compat looks for a linux note _segment_.
>> 
>>   sys/compat/linux/common/linux_exec_elf32.c
>>   - ELFNAME2(linux,signature)
>> 
>> 
>> Normally, it doesn't matter, as there's a note segment for each note
>> section.  However I'm playing with a forth system that cross-compiles
>> and writes out its own ELF image and that standalone image only has
>> segments, but no sections.
>> 
>> I'm inclined to think that a standalone ELF binary should be able to
>> get away with this kind of arrangement.  Sections are for linkers,
>> segments are for loaders.  The binary is intended to be loaded, so it
>> provides info about its segments and that should be enough.
>> 
>> Comments?  Shall we fix the check to look for note segments?
>
>I have put the patches for current, -7 and -6 up at
>
>  http://www.stderr.spb.ru/~uwe/netbsd/elf-notes/
>
>The old code to process the note is moved out to a new function
>netbsd_elf_note.  To make these patches easier to review the
>switch(np->n_type) code was intentionally not reindented.  I'll KNF
>them before commit.
>
>I did some minimal testing, verifying that e.g. pax notes (which is
>the second note in the note segment) are correctly processed, but
>haven't tried to throw any kind of bad notes at this code.
>
>BTW, paxctl(8) has the same problem, it operates on note sections
>instead of segments.

LGTM... We should fix paxctl too.

christos



Home | Main Index | Thread Index | Old Index