From 2ec0cfbe995e4c6487a3259490ae221bcb6884e8 Mon Sep 17 00:00:00 2001
From: Johann <johannkoenig@google.com>
Date: Mon, 14 Mar 2011 11:10:24 -0400
Subject: [PATCH] obj_int_extract: win64 does not prefix symbols

obj_int_extract was unconditionally skipping the first character in the
symbol. make sure it's actually an '_' first

Change-Id: Icfe527eb8a0028faeabaa1dcedf8cd8f51c92754
---
 build/make/obj_int_extract.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/build/make/obj_int_extract.c b/build/make/obj_int_extract.c
index 01b3129d75..c46d9d58ba 100644
--- a/build/make/obj_int_extract.c
+++ b/build/make/obj_int_extract.c
@@ -918,15 +918,23 @@ 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);
+                /* The 64bit Windows compiler doesn't prefix with an _.
+                 * Check what's there, and bump if necessary
+                 */
+                if (name[0] == '_')
+                    printf("%-40s EQU ", name + 1);
+                else
+                    printf("%-40s EQU ", name);
             }
             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);
+                if ((buf + strtab_ptr + get_le32(ptr + 4))[0] == '_')
+                    printf("%-40s EQU ",
+                           buf + strtab_ptr + get_le32(ptr + 4) + 1);
+                else
+                    printf("%-40s EQU ", buf + strtab_ptr + get_le32(ptr + 4));
             }
 
             if (!(strcmp(sectionlist[section-1], ".bss")))
-- 
GitLab