From 128d2c23b34dce3c24daeee5dc619f6cda93cc5c Mon Sep 17 00:00:00 2001 From: Johann Date: Wed, 2 Mar 2011 09:44:39 -0500 Subject: obj_int_extract for Visual Studio Enable extraction of assembly offsets from compiled examples in MSVS. This will allow us to remove some stub functions from x86 assembly since we will be able to reliably determine structure offsets at compile time. see ARM code for examples: vp8/encoder/arm/armv5te/ vpx_scale/arm/neon/ Change-Id: I1852dc6b56ede0bf1dddb5552196222a7c6a902f --- build/make/obj_int_extract.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'build/make/obj_int_extract.c') diff --git a/build/make/obj_int_extract.c b/build/make/obj_int_extract.c index 22c5cf2ab..01b3129d7 100644 --- a/build/make/obj_int_extract.c +++ b/build/make/obj_int_extract.c @@ -840,9 +840,18 @@ int parse_coff(unsigned __int8 *buf, size_t sz) strtab_ptr = symtab_ptr + symtab_sz * 18; if (nsections > 96) - goto bail; + { + log_msg("Too many sections\n"); + return 1; + } - sectionlist = malloc(nsections * sizeof * sectionlist); + sectionlist = malloc(nsections * sizeof(sectionlist)); + + if (sectionlist == NULL) + { + log_msg("Allocating first level of section list failed\n"); + return 1; + } //log_msg("COFF: Found %u symbols in %u sections.\n", symtab_sz, nsections); @@ -860,6 +869,12 @@ int parse_coff(unsigned __int8 *buf, size_t sz) //log_msg("COFF: Parsing section %s\n",sectionname); sectionlist[i] = malloc(strlen(sectionname) + 1); + + if (sectionlist[i] == NULL) + { + log_msg("Allocating storage for %s failed\n", sectionname); + goto bail; + } strcpy(sectionlist[i], sectionname); if (!strcmp(sectionname, ".data")) sectionrawdata_ptr = get_le32(ptr + 20); @@ -903,12 +918,14 @@ int parse_coff(unsigned __int8 *buf, size_t sz) char name[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; strncpy(name, ptr, 8); //log_msg("COFF: Parsing symbol %s\n",name); + /* +1 to avoid printing leading underscore */ printf("%-40s EQU ", name + 1); } else { //log_msg("COFF: Parsing symbol %s\n", // buf + strtab_ptr + get_le32(ptr+4)); + /* +1 to avoid printing leading underscore */ printf("%-40s EQU ", buf + strtab_ptr + get_le32(ptr + 4) + 1); } -- cgit v1.2.3