From 32de5d0d7fbdf75e21e0abe3fb7c68e72deb8f37 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Wed, 28 Sep 2016 13:34:39 +0200 Subject: [PATCH] Fix msvc build. --- .appveyor.yml | 4 ++-- src/linker.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index abfd4e60..9ff77eb4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,9 +5,9 @@ os: Visual Studio 2015 environment: matrix: -# - { C: msvc-10.0-x86, CL_VERSION: 16.00, VS_VERSION: 2010 } # missing strtoull() + - { C: msvc-10.0-x86, CL_VERSION: 16.00, VS_VERSION: 2010 } ### - { C: msvc-10.0-x64, CL_VERSION: 16.00, VS_VERSION: 2010 } # AppVeyor: x64 compiler is not installed -# - { C: msvc-11.0-x86, CL_VERSION: 17.00, VS_VERSION: 2012 } # missing strtoull() + - { C: msvc-11.0-x86, CL_VERSION: 17.00, VS_VERSION: 2012 } ### - { C: msvc-11.0-x64, CL_VERSION: 17.00, VS_VERSION: 2012 } # AppVeyor: x64 compiler is not installed - { C: msvc-12.0-x86, CL_VERSION: 18.00, VS_VERSION: 2013 } - { C: msvc-12.0-x64, CL_VERSION: 18.00, VS_VERSION: 2013 } diff --git a/src/linker.cpp b/src/linker.cpp index 36517f2b..b37e8e7c 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -307,13 +307,18 @@ void ElfLinker::preprocessRelocations(char *start, char *end) char sign = *p; *p = 0; // terminate the symbol name p += 3; - assert(strlen(p) == 8 || strlen(p) == 16); +#if (ACC_CC_MSC && (_MSC_VER < 1800)) + unsigned a = 0, b = 0; + if (sscanf(p, "%08x%08x", &a, &b) == 2) + add = ((upx_uint64_t)a << 32) | b; + else + add = a; +#else char *endptr = NULL; - upx_uint64_t ull = strtoull(p, &endptr, 16); - add = (upx_uint64_t) ull; - assert(add == ull); + add = strtoull(p, &endptr, 16); assert(endptr && *endptr == '\0'); +#endif if (sign == '-') add = 0 - add; }