Subject: Re: ddb line number support for ELF
To: None <tech-kern@netbsd.org>
From: John Hawkinson <jhawk@MIT.EDU>
List: tech-kern
Date: 07/27/2000 04:19:20
| One of the things I'd hoped to have ready for 1.5 was support for line
| numbers in DDB for ELF, since otherwise 1.5 would be a step backward
| for the kernel debugger, as a.out supports line numbers.

The silence has been less than heartening.

Thanks to soda-san for pointing me at the SCO-published SYS V ABI spec,
which is apparently the closest we have to an ELF specification:
"http://www.sco.com/developer/devspecs/".

| Assuming I have the above correct, it seems there are 2 choices,
| I'm not sure which one is right:
| 
|     i)	Modify biosboot to load .stab also; not sure what criteria to
|     use, though, perhaps by name explicitly?
| 
|     ii) Modify the toolchain to tag .stab as SYMTAB, rather than
|     PROGBITS. Possibly this could cause other problems?

ii) appears not to be viable, as chapter 4 (Object Files), under "Sections" reads:

  SHT_SYMTAB and SHT_DYNSYM
  These sections hold a symbol table. Currently, an object file may have
  only one section of each type, but this restriction may be relaxed in
  the future. Typically, SHT_SYMTAB provides symbols for link editing,
  though it may also be used for dynamic linking. As a complete symbol
  table, it may contain many symbols unnecessary for dynamic
  linking. Conse-quently, an object file may also contain a SHT_DYNSYM
  section, which holds a minimal set of dynamic linking symbols, to save
  space. See ''Symbol Table'' below for details.

  SHT_STRTAB
  The section holds a string table. An object file may have multi-ple
  string table sections. See ''String Table'' below for details.

Additionally, under Solaris, I note:

  [multics!jhawk] ~> uname -i
  SUNW,SPARCstation-5
  [multics!jhawk] ~> elfdump -c /platform/`uname -i`/kernel/unix
...  
  Section Header[18]:  sh_name: .stab.index
      sh_addr:      0               sh_flags:   0
      sh_size:      0xab0           sh_type:    [ SHT_PROGBITS ]
      sh_offset:    0x98bec         sh_entsize: 0xc
      sh_link:      0               sh_info:    0
      sh_addralign: 0x4
  Section Header[20]:  sh_name: .stab.indexstr
      sh_addr:      0               sh_flags:   0
      sh_size:      0x9074          sh_type:    [ SHT_STRTAB ]
      sh_offset:    0x99747         sh_entsize: 0
      sh_link:      0               sh_info:    0
      sh_addralign: 0x1

which is to say, PROGBITS actually seems to be correct.

No criteria seems to present itself by which loadfile should load
the .stab section, so at this point I will plan on loading it
explicitly, as in i).

Some have questioned whether .stab should be loaded by default at all;
since we already load .stabstr, which is 2x its size, loading .stab
seems the right choice. After all, if you don't want it loaded, strip
it out of your kernel...

Does anyone have any other changes that should be made to biosboot
or libsa at the same time? Should this change bump the biosboot version
number [I guess so.]? For which ports?

Thanks.

--jhawk