Skip to content

Ghidra is a software reverse engineering (SRE) framework

Additional adjustments

caheckman5ec6cfcd8151
diff --git a/Ghidra/Features/Decompiler/buildNatives.gradle b/Ghidra/Features/Decompiler/buildNatives.gradle
index 94b7699b8f..a05736f686 100644
--- a/Ghidra/Features/Decompiler/buildNatives.gradle
+++ b/Ghidra/Features/Decompiler/buildNatives.gradle
@@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-import java.nio.ByteOrder
-
+
// Native build files are already applied in development mode (indicated by presence of the
// Generic project). Only need to apply them if we are in a distribution.
if (findProject(':Generic') == null) {
@@ -24,13 +22,6 @@ if (findProject(':Generic') == null) {
apply from: "../../../GPL/nativeBuildProperties.gradle"
}
-def getHostEndianDefine() {
- if (ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN)) {
- return "HOST_ENDIAN=1"
- }
- return "HOST_ENDIAN=0"
-}
-
/**
* Define the "native build model" for building the decompiler executables.
*/
@@ -196,7 +187,6 @@ model {
binaries {
all{ b ->
- b.cppCompiler.define getHostEndianDefine()
if (b.toolChain in Gcc) {
b.cppCompiler.args "-std=c++11"
b.cppCompiler.args "-Wall"
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/types.h b/Ghidra/Features/Decompiler/src/decompile/cpp/types.h
index bf2d369d8d..93843432da 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/types.h
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/types.h
@@ -16,20 +16,15 @@
*/
/* typedefs for getting specific word sizes */
-/* Defines for the "preferred" intm size, where this is not determined by the */
-/* algorithm being coded. I.e. the code works without change using */
-/* maximum wordsize when compiled on 64 OR 32 machines */
-
-/* uintp is intended to be an unsigned integer that is the same size as a pointer */
-
#ifndef __MYTYPES__
#define __MYTYPES__
#include <cstdint>
-#include <type_traits>
-typedef size_t uintm;
-typedef std::make_signed<uintm>::type intm;
+// Use of uintm and intm is deprecated. They must currently be set to be 32-bit.
+typedef uint32_t uintm;
+typedef int32_t intm;
+
typedef uint64_t uint8;
typedef int64_t int8;
typedef uint32_t uint4;
@@ -38,8 +33,16 @@ typedef uint16_t uint2;
typedef int16_t int2;
typedef uint8_t uint1;
typedef int8_t int1;
+
+/* uintp is intended to be an unsigned integer that is the same size as a pointer */
typedef uintptr_t uintp;
+class Endian {
+public:
+ static constexpr const union { int4 whole; int1 part[4]; } host = { 1 };
+};
+#define HOST_ENDIAN Endian::host.part[3]
+
#if defined(_WINDOWS)
#pragma warning (disable:4312)
#pragma warning (disable:4311)
@@ -57,34 +60,15 @@ typedef uintptr_t uintp;
//#define _HAS_ITERATOR_DEBUGGING 0
#endif
-/* In order to have a little more flexibility in integer precision vs efficiency,
- we subdivide the integer types into three classes:
-
- Small integers: Integers that never come close to overflowing their (machine word)
- precision. We will always use int4 or uint4 (or smaller) for
- these so that the precision is explicitly given.
-
- Machine word integers: These integers exactly match the largest precision that
- will fit in a general purpose register. They should be
- used exclusively by in implementations of larger
- precision objects. Use intm or uintm
-
+/*
Big integers: These are intended to be arbitrary precison integers. However
- for efficiency, these will always be implemented as fixed precision.
+ for efficiency, these are currently implemented as fixed precision.
So for coding purposes, these should be interpreted as fixed
precision integers that store as big a number as you would ever need.
*/
-/* Specify that unsigned big ints are coded with 8 bytes */
-#define UINTB8
-
typedef int8 intb; /* This is a signed big integer */
-//#include "integer.hh"
-#ifdef UINTB8
typedef uint8 uintb; /* This is an unsigned big integer */
-#else
-typedef uint4 uintb;
-#endif
/*