m4b / goblin

An impish, cross-platform binary parsing crate, written in Rust
MIT License
1.17k stars 156 forks source link

Note::type_to_str is only valid when n_name is "GNU" #410

Open glandium opened 2 months ago

glandium commented 2 months ago

This is what the manual page for elf(5) says:

Keep in mind that the interpretation of n_type depends on the namespace defined by the n_namesz field.

Then later:

n_type Depending on the value of the name field, this member may have any of the following values:

         Core files (e_type = ET_CORE)
              Notes used by all core files.  These are highly
              operating system or architecture specific and often
              require close coordination with kernels, C libraries,
              and debuggers.  These are used when the namespace is
              the default (i.e., n_namesz will be set to 0), or a
              fallback when the namespace is unknown.

              NT_PRSTATUS
                     prstatus struct
              NT_FPREGSET
                     fpregset struct

(etc.)

          n_name = GNU
              Extensions used by the GNU tool chain.

              NT_GNU_ABI_TAG
                     Operating system (OS) ABI information.  The
                     desc field will be 4 words:

                     [0]  OS descriptor (ELF_NOTE_OS_LINUX,
                          ELF_NOTE_OS_GNU, and so on)`
                     [1]  major version of the ABI
                     [2]  minor version of the ABI
                     [3]  subminor version of the ABI

(etc.)

         Default/unknown namespace (e_type != ET_CORE)
              These are used when the namespace is the default
              (i.e., n_namesz will be set to 0), or a fallback when
              the namespace is unknown.

              NT_VERSION
                     A version string of some sort.
              NT_ARCH
                     Architecture information.

Note that, for instance, NT_VERSION, NT_GNU_ABI_TAG and NT_PRSTATUS all have the same value.