This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

known-elf.awk/known-elf.h


Hi there,

dwgrep needs to programmatically work with ELF constants, so I put
together the attached script.

The basic idea is the same as with known-dwarf, but elf.h has some extra
challenges to address:

- It's not entirely predictable which constants are bona fide values,
  and which are metavalues that e.g. count numbers of other constants,
  or e.g. flags.  The script handles this by having a whitelist of
  constant types to admit, and then some heuristics to remove the
  non-values.

- Arch- and OS-specific values are rather the norm in ELF.  I didn't
  find any collisions in per-OS ranges, but plenty of them in per-PROC
  ranges, so the latter is actually addressed in the generated headers.
  The following example illustrates how the facility is used.

    /* Per-constant executor.  */
    #define ELF_ONE_KNOWN_STB(SHORT, LONG) /* ... */

      /* Visit generic constants.  */
      ELF_ALL_KNOWN_STB

    /* STB_ per-arch executor.  */
    #define ELF_ONE_KNOWN_STB_ARCH(ARCH)          \
              /* ... */                           \
              /* Visit STB_ARCH_* constants.  */  \
              ELF_ALL_KNOWN_STB_##ARCH            \
              /* ... */

      /* Visit arches known for STB_ constants.  */
      ELF_ALL_KNOWN_STB_ARCHES

    #undef ELF_ONE_KNOWN_STB_ARCH
    #undef ELF_ONE_KNOWN_STB

I'm attaching the script as well as the generated .h for preliminary
assesment.  Let me know if you think this would be a good addition to
elfutils, and any comments that you might have.  If this seems
acceptable, I'll send a full-fledged patch.

Thanks,
Petr

Attachment: known-elf.awk
Description: Text document

Attachment: known-elf.h
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]