Subject: More stabs and ELF
To: None <>
From: Frank van der Linden <>
List: tech-toolchain
Date: 07/08/1999 11:16:07
After looking through some documentation (as pointed to by Todd) and source
code, I found the following relevant quotes:

Many object file formats allow tools to create object files with custom
sections containing any arbitrary data. For any such object file format,
stabs can be embedded in special sections. This is how stabs are used with
ELF and SOM, and aside from ECOFF and XCOFF, is how stabs are used with COFF.

[from the Cygnus stab documentation]
An N_SLINE symbol represents the start of a source line. The desc field
contains the line number and the value contains the code address for the
start of that source line. On most machines the address is absolute; for
stabs in sections (see section Using Stabs in Their Own Sections), it is
relative to the function in which the N_SLINE symbol occurs.

[from the Cygnus stab documentation]
  /* This is true for Solaris (and all other systems which put stabs
     in sections, hopefully, since it would be silly to do things
     differently from Solaris), and false for SunOS4 and other a.out
     file formats.  */
  block_address_function_relative =
    ((0 == strncmp (bfd_get_target (sym_bfd), "elf", 3))
     || (0 == strncmp (bfd_get_target (sym_bfd), "som", 3))
     || (0 == strncmp (bfd_get_target (sym_bfd), "coff", 4))
     || (0 == strncmp (bfd_get_target (sym_bfd), "pe", 2))
     || (0 == strncmp (bfd_get_target (sym_bfd), "nlm", 3)));

[block_address_function_relative is subsequently used to see if things like
 N_SLINE are relative or not; from dbxread.c in gdb]

In other words, for ELF it is normal (expected, even) to use relative
offsets for stab line number information. The sparc and i386 ports now
do this. The alpha port doesn't seem to do this, as far as I can tell,
but it seems to work there anyway. I can't really check what's going
on there, because objdump --stabs doesn't work on the alpha. At least,
not on the one alpha system that I have access to. Maybe someone
who knows more about the alpha toolchain configuration can look into
this; the alpha port seems to be somewhat non-standard here (or I
just don't understand it).

- Frank