diff options
Diffstat (limited to 'usr/src/tools/ctf/cvt/util.c')
-rw-r--r-- | usr/src/tools/ctf/cvt/util.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/usr/src/tools/ctf/cvt/util.c b/usr/src/tools/ctf/cvt/util.c index c7857fb1ab..799ca1279c 100644 --- a/usr/src/tools/ctf/cvt/util.c +++ b/usr/src/tools/ctf/cvt/util.c @@ -47,7 +47,7 @@ static void (*terminate_cleanup)() = NULL; /* returns 1 if s1 == s2, 0 otherwise */ int -streq(char *s1, char *s2) +streq(const char *s1, const char *s2) { if (s1 == NULL) { if (s2 != NULL) @@ -93,6 +93,27 @@ findelfsecidx(Elf *elf, const char *file, const char *tofind) return (-1); } +size_t +elf_ptrsz(Elf *elf) +{ + GElf_Ehdr ehdr; + + if (gelf_getehdr(elf, &ehdr) == NULL) { + terminate("failed to read ELF header: %s\n", + elf_errmsg(-1)); + } + + if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) + return (4); + else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) + return (8); + else + terminate("unknown ELF class %d\n", ehdr.e_ident[EI_CLASS]); + + /*NOTREACHED*/ + return (0); +} + /*PRINTFLIKE2*/ static void whine(char *type, char *format, va_list ap) |