pmachata / dwgrep

a tool for querying Dwarf (debuginfo) graphs
http://pmachata.github.io/dwgrep/
GNU General Public License v3.0
53 stars 10 forks source link

Add symbol table support #11

Closed pmachata closed 9 years ago

pmachata commented 9 years ago

This needs a new value type, T_ELFSYM. The following words are related:

symbol :: T_DWARF ->* T_ELFSYM
  Yields symbols from all symbol tables (.dynsym, .symtab, minisymtab).

label :: T_ELFSYM -> T_CONST
  Yields a constant from domain STT_*.  That domain needs to be added.

value, address :: T_ELFSYM -> T_ASET
  Yields a constant with address domain identifying symbol address.

name :: T_ELFSYM -> T_STR
  Yields symbol name.

size :: T_ELFSYM -> T_CONST
  Yields symbol size.

bind :: T_ELFSYM -> T_CONST
  Yields symbol binding as a constant with domain STB_*.  That domain needs to be added.

visibility :: T_ELFSYM -> T_CONST
  Yields symbol visibility as a constant with domain STV_*.  That domain needs to be added.

Missing in that list is at least access to section index. That probably makes no sense to add on its own, but if we ever support ELF sections as value types, there would be a word section that yields the associated section.

pmachata commented 9 years ago

Supporting some of the ELF-related constants properly in the current framework is not straightforward. There really needs to be a number of domains, one per architecture, and sometimes possibly one per OS. E.g. STT_SPARC_REGISTER, STT_PARISC_MILLICODE and STT_ARM_TFUNC all have value of 13, but they need to be distinct constants. These issues exist with other constant domains as well.

pmachata commented 9 years ago

There is now known-elf.awk which extracts defines from elf.h to X-macro tables. This was used to autogenerate the arch-specific const support for STT_ domain. The API to obtain the domain was changed to pass a parameter with machine to use. The other domains are yet to be made machine-dependent.

Also, the domains from different machines are not comparable. Pretty sure a test case that opens two ELF's from different architectures and proceeds to compare STT_'s from them can be constructed.

pmachata commented 9 years ago

You forgot to add the docstrings.