diff options
Diffstat (limited to 'libelf/libelf_data.c')
-rw-r--r-- | libelf/libelf_data.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libelf/libelf_data.c b/libelf/libelf_data.c index 809002f..f078c36 100644 --- a/libelf/libelf_data.c +++ b/libelf/libelf_data.c @@ -30,11 +30,14 @@ #include "_libelf.h" -ELFTC_VCSID("$Id: libelf_data.c 2225 2011-11-26 18:55:54Z jkoshy $"); +ELFTC_VCSID("$Id: libelf_data.c 3080 2014-07-28 08:46:17Z jkoshy $"); int _libelf_xlate_shtype(uint32_t sht) { + /* + * Look for known section types. + */ switch (sht) { case SHT_DYNAMIC: return (ELF_T_DYN); @@ -83,6 +86,18 @@ _libelf_xlate_shtype(uint32_t sht) case SHT_SUNW_versym: /* == SHT_GNU_versym */ return (ELF_T_HALF); default: + /* + * Values in the range [SHT_LOOS..SHT_HIUSER] (i.e., + * OS, processor and user-defined section types) are + * legal, but since we do not know anything more about + * their semantics, we return a type of ELF_T_BYTE. + */ + if (sht >= SHT_LOOS && sht <= SHT_HIUSER) + return (ELF_T_BYTE); + + /* + * Other values are unsupported. + */ return (-1); } } |