From 27b7a96d9b0b4a30345ce82171439f3c5fe6cd59 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 8 Nov 2021 14:57:18 +0100 Subject: [PATCH] winedump: Fix computation of signed integers in codeview symbol's annotations. Signed-off-by: Eric Pouech Signed-off-by: Alexandre Julliard --- tools/winedump/msc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/winedump/msc.c b/tools/winedump/msc.c index 79dd022a088..40daf4d50d5 100644 --- a/tools/winedump/msc.c +++ b/tools/winedump/msc.c @@ -1221,6 +1221,11 @@ static unsigned binannot_uncompress(const unsigned char** pptr) return res; } +static inline int binannot_getsigned(unsigned i) +{ + return (i & 1) ? -(int)(i >> 1) : (i >> 1); +} + static void dump_binannot(const unsigned char* ba, const char* last, const char* pfx) { while (ba < (const unsigned char*)last) @@ -1248,7 +1253,7 @@ static void dump_binannot(const unsigned char* ba, const char* last, const char* printf("%sChangeFile %u\n", pfx, binannot_uncompress(&ba)); break; case BA_OP_ChangeLineOffset: - printf("%sChangeLineOffset %d\n", pfx, binannot_uncompress(&ba)); + printf("%sChangeLineOffset %d\n", pfx, binannot_getsigned(binannot_uncompress(&ba))); break; case BA_OP_ChangeLineEndDelta: printf("%sChangeLineEndDelta %u\n", pfx, binannot_uncompress(&ba)); @@ -1265,7 +1270,7 @@ static void dump_binannot(const unsigned char* ba, const char* last, const char* case BA_OP_ChangeCodeOffsetAndLineOffset: { unsigned p1 = binannot_uncompress(&ba); - printf("%sChangeCodeOffsetAndLineOffset %u %u (0x%x)\n", pfx, p1 & 0xf, p1 >> 4, p1); + printf("%sChangeCodeOffsetAndLineOffset %u %u (0x%x)\n", pfx, p1 & 0xf, binannot_getsigned(p1 >> 4), p1); } break; case BA_OP_ChangeCodeLengthAndCodeOffset: