Subject: Re: loadfile/ELF fixes, take 2
To: None <jhawk@netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: tech-kern
Date: 08/18/2001 21:13:39
In article <20010817184128.A23523@mail.netbsd.org> you write:
>Wow. I had no idea I was quite this far behind on my mail. It looks like
>this hasn't been comitted yet, at least not to loadfile.

In that case, you missed loadfile.c 1.14 and db_elf.c 1.15 (both
2001-07-31).

>Ben Harris <bjh21@netbsd.org> wrote on Mon, 30 Jul 2001
>at 01:11:06 +0100 in <Pine.SOL.4.33.0107300051220.5162-100000@draco.cus.cam.ac.uk>:
>
>> This patch basically causes both loadfile and DDB to use the sh_link
>> member of the symbol table's section header to find the string table,
>> rather than having loadfile load all the STRTABs and having DDB ignore all
>> the ones not called ".strtab".
>
>So, is it not the case that this violates the ABI?

Can you be more precise?  It changes the interface between the loader and
DDB slightly, such that old kernels won't be able to find the symbols passed
by new loaders.  It doesn't stop them working otherwise, though.  I'm not
sure there is a defined ABI for this area.

>It seems to me that there are two ways to solve this problem -- one is to
>have loadfile and ddb and so-on "cheat" and make the presumption.

What presumption?  I don't see it as cheating to use something (sh_link)
that's defined in the ELF spec.

>The other is to change the way the linker works so that the .shstrtab
>is earlier in the executable. I'm not sure how tough this is.

That isn't what would be needed either.  The problem was that .shstrtab was
before the section headers, i.e. that it was too early and needed to appear
later.

>At the moment, on the i386 port,

Is that before or after my changes?

> we have the broken state where
>ddb cannot read netbsd.gdb debugging symbols. I last thought
>about this in July of last year and didn't really finish up, so
>my memory is a bit tough, but I worry that not using shstrtab
>means we won't be able to load that table properly.

By "debugging symbols", do you mean the .stab and .stabstr sections? 
Looking at a sample executable with them present here, it's true that
loading them will require loading .shstrtab, which is a pity.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/arm26               <URL:http://www.netbsd.org/Ports/arm26/>