This is the mail archive of the 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]


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

- 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.  */

    /* 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.  */

    #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.


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]