From 2758cbb40c9a5b629d8122081afd2eec132eb82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Mon, 12 Sep 2022 19:53:44 +0200 Subject: [PATCH 1/6] Prevent underflow in calc_mask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Klaus Kämpf --- Ghidra/Features/Decompiler/src/decompile/cpp/address.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh index ace26f1750..a8ee9798d1 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh @@ -479,7 +479,7 @@ inline bool Range::contains(const Address &addr) const { /// \param size is the desired size in bytes /// \return a value appropriate for masking off the first \e size bytes -inline uintb calc_mask(int4 size) { return uintbmasks[(size<8)? size : 8]; } +inline uintb calc_mask(uint4 size) { return uintbmasks[(size<8)? size : 8]; } /// Perform a CPUI_INT_RIGHT on the given val /// \param val is the value to shift @@ -518,7 +518,7 @@ inline uintb minimalmask(uintb val) } extern bool signbit_negative(uintb val,int4 size); ///< Return true if the sign-bit is set -extern uintb calc_mask(int4 size); ///< Calculate a mask for a given byte size +extern uintb calc_mask(uint4 size); ///< Calculate a mask for a given byte size extern uintb uintb_negate(uintb in,int4 size); ///< Negate the \e sized value extern uintb sign_extend(uintb in,int4 sizein,int4 sizeout); ///< Sign-extend a value between two byte sizes From 23c1b63f55f704f0f9968658cf8ebd13404737f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Mon, 12 Sep 2022 19:57:33 +0200 Subject: [PATCH 2/6] Improve sleigh compiler error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Klaus Kämpf --- .../src/decompile/cpp/slgh_compile.cc | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc index c26cd468fd..bc0585e754 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc @@ -1945,8 +1945,10 @@ void SleighCompile::buildPatterns(void) errors += 1; } for(int4 i=0;iisError()) + if (tables[i]->isError()) { + reportError(getLocation(tables[i]), "Problem in table '"+tables[i]->getName() + "':" + msg.str()); errors += 1; + } if (tables[i]->getPattern() == (TokenPattern *)0) { reportWarning(getLocation(tables[i]), "Unreferenced table '"+tables[i]->getName() + "'"); } @@ -2192,7 +2194,11 @@ const Location *SleighCompile::getLocation(Constructor *ctor) const const Location *SleighCompile::getLocation(SleighSymbol *sym) const { - return &symbolLocationMap.at(sym); + try { + return &symbolLocationMap.at(sym); + } catch (const std::exception &e) { + return NULL; + } } /// The current filename and line number are placed into a Location object @@ -2241,7 +2247,7 @@ void SleighCompile::reportError(const Location* loc, const string &msg) void SleighCompile::reportError(const string &msg) { - cerr << "ERROR " << msg << endl; + cerr << filename.back() << ":" << lineno.back() << " - ERROR " << msg << endl; errors += 1; if (errors > 1000000) { cerr << "Too many errors: Aborting" << endl; @@ -2670,7 +2676,10 @@ void SleighCompile::attachValues(vector *symlist,vector *n if (sym == (ValueSymbol *)0) continue; PatternValue *patval = sym->getPatternValue(); if (patval->maxValue() + 1 != numlist->size()) { - reportError(getCurrentLocation(), "Attach value '" + sym->getName() + "' is wrong size for list"); + ostringstream msg; + msg << "Attach value '" + sym->getName(); + msg << "' (range 0.." << patval->maxValue() << ") is wrong size for list (of " << numlist->size() << " entries"; + reportError(getCurrentLocation(), msg.str()); } symtab.replaceSymbol(sym, new ValueMapSymbol(sym->getName(),patval,*numlist)); } @@ -2695,7 +2704,10 @@ void SleighCompile::attachNames(vector *symlist,vector * if (sym == (ValueSymbol *)0) continue; PatternValue *patval = sym->getPatternValue(); if (patval->maxValue() + 1 != names->size()) { - reportError(getCurrentLocation(), "Attach name '" + sym->getName() + "' is wrong size for list"); + ostringstream msg; + msg << "Attach name '" + sym->getName(); + msg << "' (range 0.." << patval->maxValue() << ") is wrong size for list (of " << names->size() << " entries)"; + reportError(getCurrentLocation(), msg.str()); } symtab.replaceSymbol(sym,new NameSymbol(sym->getName(),patval,*names)); } @@ -2720,7 +2732,10 @@ void SleighCompile::attachVarnodes(vector *symlist,vectorgetPatternValue(); if (patval->maxValue() + 1 != varlist->size()) { - reportError(getCurrentLocation(), "Attach varnode '" + sym->getName() + "' is wrong size for list"); + ostringstream msg; + msg << "Attach varnode '" + sym->getName(); + msg << "' (range 0.." << patval->maxValue() << ") is wrong size for list (of " << varlist->size() << " entries)"; + reportError(getCurrentLocation(), msg.str()); } int4 sz = 0; for(int4 j=0;jsize();++j) { From 6a75d6c2abaead1bd34c31fd080fb72e8eaf0df8 Mon Sep 17 00:00:00 2001 From: James <49045138+ghidracadabra@users.noreply.github.com> Date: Fri, 2 Dec 2022 17:20:53 +0000 Subject: [PATCH 3/6] GP-2913 reflect calc_mask cpp change in java --- .../java/ghidra/pcodeCPort/utils/Utils.java | 224 +++++++++--------- 1 file changed, 118 insertions(+), 106 deletions(-) diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/utils/Utils.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/utils/Utils.java index 2617a9159c..2fd0bd2933 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/utils/Utils.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/utils/Utils.java @@ -16,31 +16,29 @@ */ package ghidra.pcodeCPort.utils; -import ghidra.pcodeCPort.context.*; +import ghidra.pcodeCPort.context.SleighError; import ghidra.sleigh.grammar.Location; public class Utils { - public static final String endl = System.getProperty( "line.separator" ); - - private static long[] uintbmasks = { - 0, 0xff, 0xffff, 0xffffff, 0xffffffffL, 0xffffffffffL, 0xffffffffffffL, - 0xffffffffffffffL, 0xffffffffffffffffL - }; + public static final String endl = System.getProperty("line.separator"); - public static long calc_mask( int size ) { - return uintbmasks[(size < 8) ? size : 8]; + private static long[] uintbmasks = { 0, 0xff, 0xffff, 0xffffff, 0xffffffffL, 0xffffffffffL, + 0xffffffffffffL, 0xffffffffffffffL, 0xffffffffffffffffL }; + + public static long calc_mask(int size) { + return uintbmasks[(Integer.compareUnsigned(size, 8) < 0) ? size : 8]; } - public static long pcode_right( long val, int sa ) { - if ( sa >= 64 ) { + public static long pcode_right(long val, int sa) { + if (sa >= 64) { return 0; } return val >>> sa; } - public static long pcode_left( long val, int sa ) { - if ( sa >= 64 ) { + public static long pcode_left(long val, int sa) { + if (sa >= 64) { return 0; } return val << sa; @@ -61,30 +59,30 @@ public class Utils { // return s; // } - public static boolean signbit_negative( long val, int size ) { // Return true if signbit is set - // (negative) + public static boolean signbit_negative(long val, int size) { // Return true if signbit is set + // (negative) long mask = 0x80; mask <<= 8 * (size - 1); return ((val & mask) != 0); } - public static long uintb_negate( long in, int size ) { // Invert bits - return ((~in) & calc_mask( size )); + public static long uintb_negate(long in, int size) { // Invert bits + return ((~in) & calc_mask(size)); } - public static long sign_extend( long in, int sizein, int sizeout ) + public static long sign_extend(long in, int sizein, int sizeout) { int signbit; long mask; signbit = sizein * 8 - 1; - in &= calc_mask( sizein ); - if ( sizein >= sizeout ) { + in &= calc_mask(sizein); + if (sizein >= sizeout) { return in; } - if ( (in >>> signbit) != 0 ) { - mask = calc_mask( sizeout ); + if ((in >>> signbit) != 0) { + mask = calc_mask(sizeout); long tmp = mask << signbit; // Split shift into two pieces tmp = (tmp << 1) & mask; // In case, everything is shifted out in |= tmp; @@ -93,22 +91,23 @@ public class Utils { } // this used to void and changed the parameter val - can't do it in java - public static long zzz_sign_extend( long val, int bit ) + public static long zzz_sign_extend(long val, int bit) { // Sign extend -val- above -bit- long mask = 0; mask = (~mask) << bit; - if ( ((val >>> bit) & 1) != 0 ) { + if (((val >>> bit) & 1) != 0) { val |= mask; - } else { + } + else { val &= (~mask); } return val; } // this used to void and changed the parameter val - can't do it in java - public static long zzz_zero_extend( long val, int bit ) { // Clear all bits in -val- above - // -bit- + public static long zzz_zero_extend(long val, int bit) { // Clear all bits in -val- above + // -bit- long mask = 0; mask = (~mask) << bit; mask <<= 1; @@ -117,9 +116,9 @@ public class Utils { } // this used to void and changed the parameter val - can't do it in java - public static long byte_swap( long val, int size ) { // Swap the least sig -size- bytes in val + public static long byte_swap(long val, int size) { // Swap the least sig -size- bytes in val long res = 0; - while ( size > 0 ) { + while (size > 0) { res <<= 8; res |= (val & 0xff); val >>>= 8; @@ -128,9 +127,9 @@ public class Utils { return res; } - long byte_swap( int val ) { // Swap the bytes for the whole machine int + long byte_swap(int val) { // Swap the bytes for the whole machine int long res = 0; - for ( int i = 0; i < 4; ++i ) { + for (int i = 0; i < 4; ++i) { res <<= 8; res |= (val & 0xff); val >>>= 8; @@ -138,21 +137,21 @@ public class Utils { return res; } - public static boolean isprint(int c) { - if (c >= 32 && c <= 126) - return true; - return false; - } + public static boolean isprint(int c) { + if (c >= 32 && c <= 126) + return true; + return false; + } - public static boolean isascii(int c) { - if (c >= 0 && c <= 127) - return true; - return false; - } + public static boolean isascii(int c) { + if (c >= 0 && c <= 127) + return true; + return false; + } - public static int leastsigbit_set( long val ) { // Return bit number (0=lsb) + public static int leastsigbit_set(long val) { // Return bit number (0=lsb) // of the least signifigant bit set or -1 if none set - if ( val == 0 ) { + if (val == 0) { return -1; } int res = 0; @@ -160,18 +159,19 @@ public class Utils { long mask = -1; do { mask >>>= sz; - if ( (mask & val) == 0 ) { + if ((mask & val) == 0) { res += sz; val >>>= sz; } sz >>= 1; - } while ( sz != 0 ); + } + while (sz != 0); return res; } - public static int mostsigbit_set( long val ) { // Return bit number (0=lsb) + public static int mostsigbit_set(long val) { // Return bit number (0=lsb) // of the most signifigant bit set or -1 if none set - if ( val == 0 ) { + if (val == 0) { return -1; } @@ -180,103 +180,108 @@ public class Utils { long mask = -1; do { mask <<= sz; - if ( (mask & val) == 0 ) { + if ((mask & val) == 0) { res -= sz; val <<= sz; } sz >>= 1; - } while ( sz != 0 ); + } + while (sz != 0); return res; } - public static long coveringmask( long val ) + public static long coveringmask(long val) { // Return smallest number of form 2^n-1, bigger or equal to val long res = val; int sz = 1; - while ( sz < 64 ) { + while (sz < 64) { res = res | (res >>> sz); sz <<= 1; } return res; } - public static String paddedHexString( long value, int padLength ) { - String decodedString = Long.toString( value, 16 ); - if ( decodedString.length() >= padLength ) { + public static String paddedHexString(long value, int padLength) { + String decodedString = Long.toString(value, 16); + if (decodedString.length() >= padLength) { return decodedString; } StringBuffer buffer = new StringBuffer(); int missingLength = padLength - decodedString.length(); - for ( int i = 0; i < missingLength; i++ ) { - buffer.append( "0" ); + for (int i = 0; i < missingLength; i++) { + buffer.append("0"); } - buffer.append( decodedString ); + buffer.append(decodedString); return buffer.toString(); } - public static int unsignedCompare( long v1, long v2 ) { - if ( v1 == v2 ) { + public static int unsignedCompare(long v1, long v2) { + if (v1 == v2) { return 0; } - if ( v1 >= 0 && v2 >= 0 ) { + if (v1 >= 0 && v2 >= 0) { return v1 < v2 ? -1 : 1; } - if ( v1 < 0 && v2 < 0 ) { + if (v1 < 0 && v2 < 0) { return v1 < v2 ? -1 : 1; } - if ( v1 < 0 ) { + if (v1 < 0) { return 1; } return -1; } - public static int unsignedCompare( int v1, int v2 ) { - if ( v1 == v2 ) { + + public static int unsignedCompare(int v1, int v2) { + if (v1 == v2) { return 0; } - if ( v1 >= 0 && v2 >= 0 ) { + if (v1 >= 0 && v2 >= 0) { return v1 < v2 ? -1 : 1; } - if ( v1 < 0 && v2 < 0 ) { + if (v1 < 0 && v2 < 0) { return v1 < v2 ? -1 : 1; } - if ( v1 < 0 ) { + if (v1 < 0) { return 1; } return -1; } - public static void calc_maskword( Location location, int sbit, int ebit, MutableInt num, MutableInt shift, MutableInt mask ) { - num.set(unsignedDivide(sbit, 8 * 4)); - if(num.get() != unsignedDivide(ebit, 8 * 4)) { - throw new SleighError( "Context field not contained within one machine int", location ); - } - sbit -= (int) (unsignedInt(num.get()) * 8 * 4); - ebit -= (int) (unsignedInt(num.get()) * 8 * 4); - - shift.set(8 * 4 - ebit - 1); - int m = (-1) >>> (sbit + shift.get()); - m <<= shift.get(); - mask.set(m); - } - public static int bytesToInt( byte[] bytes, boolean bigEndian ) { + + public static void calc_maskword(Location location, int sbit, int ebit, MutableInt num, + MutableInt shift, MutableInt mask) { + num.set(unsignedDivide(sbit, 8 * 4)); + if (num.get() != unsignedDivide(ebit, 8 * 4)) { + throw new SleighError("Context field not contained within one machine int", location); + } + sbit -= (int) (unsignedInt(num.get()) * 8 * 4); + ebit -= (int) (unsignedInt(num.get()) * 8 * 4); + + shift.set(8 * 4 - ebit - 1); + int m = (-1) >>> (sbit + shift.get()); + m <<= shift.get(); + mask.set(m); + } + + public static int bytesToInt(byte[] bytes, boolean bigEndian) { int result = 0; if (bigEndian) { - for(int i=0;i<4;i++) { + for (int i = 0; i < 4; i++) { result <<= 8; result |= (bytes[i] & 0xFF); } } else { - for(int i=3;i>=0;i--) { + for (int i = 3; i >= 0; i--) { result <<= 8; result |= (bytes[i] & 0xFF); } - + } return result; } - + public static long shiftLeft(long a, long b) { b &= 0xff; if (b >= 64) { @@ -284,6 +289,7 @@ public class Utils { } return a << b; } + public static long ashiftRight(long a, long b) { b &= 0xff; if (b >= 64) { @@ -291,6 +297,7 @@ public class Utils { } return a >> b; } + public static long lshiftRight(long a, long b) { b &= 0xff; if (b >= 64) { @@ -298,36 +305,41 @@ public class Utils { } return a >>> b; } + public static long unsignedInt(int a) { - long result = a; - if (result < 0) { - result += 4294967296L; - } - return result; + long result = a; + if (result < 0) { + result += 4294967296L; + } + return result; } - public static int unsignedDivide(int a, int b) { - long la = unsignedInt(a); - long lb = unsignedInt(b); - long result = la/lb; - return (int) result; - } - public static int unsignedModulo(int a, int b) { - long la = unsignedInt(a); - long lb = unsignedInt(b); - long result = la%lb; - return (int) result; - } + + public static int unsignedDivide(int a, int b) { + long la = unsignedInt(a); + long lb = unsignedInt(b); + long result = la / lb; + return (int) result; + } + + public static int unsignedModulo(int a, int b) { + long la = unsignedInt(a); + long lb = unsignedInt(b); + long result = la % lb; + return (int) result; + } + public static void main(String[] args) { - System.out.println(unsignedDivide(-8, 32)); - System.out.println(unsignedModulo(-8, 32)); + System.out.println(unsignedDivide(-8, 32)); + System.out.println(unsignedModulo(-8, 32)); } + public static String toUnsignedIntHex(int n) { - return Long.toHexString(unsignedInt(n)); + return Long.toHexString(unsignedInt(n)); } public static long bytesToLong(byte[] byteBuf) { long value = 0; - for(int i=0;i<8;i++) { + for (int i = 0; i < 8; i++) { value = value << 8 | byteBuf[i]; } return value; From 6e6cf6d9350b2e5003dfa921abeef38dcb4be14c Mon Sep 17 00:00:00 2001 From: James <49045138+ghidracadabra@users.noreply.github.com> Date: Fri, 2 Dec 2022 19:30:21 +0000 Subject: [PATCH 4/6] GP-2913 minor adjustments --- .../Decompiler/src/decompile/cpp/slgh_compile.cc | 11 +++++++---- .../ghidra/pcodeCPort/slgh_compile/SleighCompile.java | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc index bc0585e754..2de830ffe2 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc @@ -2135,8 +2135,11 @@ void SleighCompile::checkCaseSensitivity(void) SleighSymbol *oldsym = (*check.first).second; ostringstream s; s << "Name collision: " << sym->getName() << " --- "; + s << "Duplicate symbol " << oldsym->getName(); const Location *oldLocation = getLocation(oldsym); - s << "Duplicate symbol " << oldsym->getName() << " defined at " << oldLocation->format(); + if (oldLocation != (Location *) 0x0) { + s << " defined at " << oldLocation->format(); + } const Location *location = getLocation(sym); reportError(location,s.str()); } @@ -2190,13 +2193,13 @@ const Location *SleighCompile::getLocation(Constructor *ctor) const } /// \param sym is the given symbol -/// \return the filename and line number +/// \return the filename and line number or null if location not found const Location *SleighCompile::getLocation(SleighSymbol *sym) const { try { return &symbolLocationMap.at(sym); - } catch (const std::exception &e) { + } catch (const std::out_of_range &e) { return NULL; } } @@ -2678,7 +2681,7 @@ void SleighCompile::attachValues(vector *symlist,vector *n if (patval->maxValue() + 1 != numlist->size()) { ostringstream msg; msg << "Attach value '" + sym->getName(); - msg << "' (range 0.." << patval->maxValue() << ") is wrong size for list (of " << numlist->size() << " entries"; + msg << "' (range 0.." << patval->maxValue() << ") is wrong size for list (of " << numlist->size() << " entries)"; reportError(getCurrentLocation(), msg.str()); } symtab.replaceSymbol(sym, new ValueMapSymbol(sym->getName(),patval,*numlist)); diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/slgh_compile/SleighCompile.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/slgh_compile/SleighCompile.java index 292e01436b..1e9ea0a332 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/slgh_compile/SleighCompile.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/slgh_compile/SleighCompile.java @@ -488,6 +488,8 @@ public class SleighCompile extends SleighBase { } for (int i = 0; i < tables.size(); ++i) { if (tables.get(i).isError()) { + reportError(tables.get(i).getLocation(), + "Problem in table: '" + tables.get(i).getName()); errors += 1; } if (tables.get(i).getPattern() == null) { From e600b96980b2fd79ee1a50a3bf6925c921af6a01 Mon Sep 17 00:00:00 2001 From: James <49045138+ghidracadabra@users.noreply.github.com> Date: Fri, 2 Dec 2022 19:37:59 +0000 Subject: [PATCH 5/6] GP-2913 certifications and Utils.java --- .../src/main/java/ghidra/pcodeCPort/utils/Utils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/utils/Utils.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/utils/Utils.java index 2fd0bd2933..2d11d27b46 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/utils/Utils.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/utils/Utils.java @@ -1,6 +1,5 @@ /* ### * IP: GHIDRA - * REVIEWED: YES * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 93d38082325297dddf3bb6cf4a09b3cd86c88034 Mon Sep 17 00:00:00 2001 From: James <49045138+ghidracadabra@users.noreply.github.com> Date: Tue, 6 Dec 2022 21:34:28 +0000 Subject: [PATCH 6/6] GP-2913 addressing code review comments --- Ghidra/Features/Decompiler/src/decompile/cpp/address.hh | 4 ++-- Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh index a8ee9798d1..46f73910b6 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh @@ -479,7 +479,7 @@ inline bool Range::contains(const Address &addr) const { /// \param size is the desired size in bytes /// \return a value appropriate for masking off the first \e size bytes -inline uintb calc_mask(uint4 size) { return uintbmasks[(size<8)? size : 8]; } +inline uintb calc_mask(int4 size) { return uintbmasks[((uint4)size) < 8 ? size : 8]; } /// Perform a CPUI_INT_RIGHT on the given val /// \param val is the value to shift @@ -518,7 +518,7 @@ inline uintb minimalmask(uintb val) } extern bool signbit_negative(uintb val,int4 size); ///< Return true if the sign-bit is set -extern uintb calc_mask(uint4 size); ///< Calculate a mask for a given byte size +extern uintb calc_mask(int4 size); ///< Calculate a mask for a given byte size extern uintb uintb_negate(uintb in,int4 size); ///< Negate the \e sized value extern uintb sign_extend(uintb in,int4 sizein,int4 sizeout); ///< Sign-extend a value between two byte sizes diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc index 2de830ffe2..a0cd141ae1 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc @@ -2199,8 +2199,8 @@ const Location *SleighCompile::getLocation(SleighSymbol *sym) const { try { return &symbolLocationMap.at(sym); - } catch (const std::out_of_range &e) { - return NULL; + } catch (const out_of_range &e) { + return nullptr; } }