From 574a285880a2bf1064a94e7058d24ff14e403aeb Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 2 May 2014 02:25:10 +0000 Subject: [PATCH] Code to detect gnu attributes, and start of parser. --- src/readelf.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/readelf.c b/src/readelf.c index b35bad29..08f81f5b 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readelf.c,v 1.101 2014/03/11 17:13:18 christos Exp $") +FILE_RCSID("@(#)$File: readelf.c,v 1.102 2014/03/11 21:00:13 christos Exp $") #endif #ifdef BUILTIN_ELF @@ -1005,6 +1005,36 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, file_badread(ms); return -1; } + if (cbuf[0] == 'A') { +#ifdef notyet + char *p = cbuf + 1; + uint32_t len, tag; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (memcmp("gnu", p, 3) != 0) { + if (file_printf(ms, + ", unknown capability %.3s", p) + == -1) + return -1; + break; + } + p += strlen(p) + 1; + tag = *p++; + memcpy(&len, p, sizeof(len)); + p += 4; + len = getu32(swap, len); + if (tag != 1) { + if (file_printf(ms, ", unknown gnu" + " capability tag %d", tag) + == -1) + return -1; + break; + } + // gnu attributes +#endif + break; + } (void)memcpy(xcap_addr, cbuf, xcap_sizeof); switch (xcap_tag) { case CA_SUNW_NULL: -- 2.49.0