1
0
mirror of https://github.com/bitdefender/bddisasm.git synced 2024-11-22 23:48:07 +00:00

Merge pull request #9 from cbsirb/master

Fix the disasmtool_lix build
This commit is contained in:
Andrei Kisari 2020-07-28 15:48:37 +03:00 committed by GitHub
commit 5e14a6f25c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 121 additions and 31 deletions

View File

@ -79,8 +79,8 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,-O1") set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,-O1")
if (CMAKE_COMPILER_IS_GNUCC) if (CMAKE_COMPILER_IS_GNUCXX)
if (NOT (CMAKE_C_COMPILER_VERSION LESS 6.0)) if (NOT (CMAKE_CXX_COMPILER_VERSION LESS 6.0))
add_compile_options( add_compile_options(
-Wshift-overflow=2 -Wshift-overflow=2
-Wnull-dereference -Wnull-dereference
@ -90,7 +90,7 @@ if (CMAKE_COMPILER_IS_GNUCC)
) )
endif() endif()
if (NOT (CMAKE_C_COMPILER_VERSION LESS 7.0)) if (NOT (CMAKE_CXX_COMPILER_VERSION LESS 7.0))
add_compile_options( add_compile_options(
-Wdangling-else -Wdangling-else
-Wshadow=global -Wshadow=global
@ -98,7 +98,7 @@ if (CMAKE_COMPILER_IS_GNUCC)
) )
endif() endif()
if (NOT (CMAKE_C_COMPILER_VERSION LESS 8.0)) if (NOT (CMAKE_CXX_COMPILER_VERSION LESS 8.0))
add_compile_options( add_compile_options(
-Wmultistatement-macros -Wmultistatement-macros
-Warray-bounds=2 -Warray-bounds=2
@ -116,33 +116,139 @@ if (CMAKE_COMPILER_IS_GNUCC)
-Wcast-qual -Wcast-qual
-Wcast-align -Wcast-align
-Wparentheses -Wparentheses
-Wjump-misses-init
-Wfloat-conversion -Wfloat-conversion
-Wmissing-prototypes
-Wredundant-decls -Wredundant-decls
-Wdisabled-optimization -Wdisabled-optimization
-Woverlength-strings -Woverlength-strings
-Wswitch-enum
-fstack-clash-protection -fstack-clash-protection
-static -static
) )
endif() endif()
else()
if (NOT (CMAKE_CXX_COMPILER_VERSION LESS 9.0))
add_compile_options(
-Wcatch-value=2
-Wduplicated-branches
-Wextra-semi
-Wif-not-aligned
-Wplacement-new=2
-Wsuggest-override
-Wunused-but-set-parameter
-Wswitch-enum
-Wuseless-cast
)
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options( add_compile_options(
-Wno-missing-braces -Wno-missing-braces
) )
if (NOT (CMAKE_C_COMPILER_VERSION LESS 6.0)) if (NOT (CMAKE_CXX_COMPILER_VERSION LESS 6.0))
add_compile_options( add_compile_options(
-Wshift-overflow -Wshift-overflow
-Wnull-dereference -Wnull-dereference
-Wvla -Wvla
-Wdangling-else -Wdangling-else
-Wshadow
-Wpragmas -Wpragmas
-Wtautological-compare -Wtautological-compare
-Wzero-as-null-pointer-constant -Wzero-as-null-pointer-constant
) )
endif() endif()
if (NOT (CMAKE_CXX_COMPILER_VERSION LESS 10.0))
add_compile_options(
-Warray-bounds-pointer-arithmetic
-Wassign-enum
-Watomic-implicit-seq-cst
-Watomic-properties
-Wauto-import
-Wbad-function-cast
-Wbind-to-temporary-copy
-Wbitfield-enum-conversion
-Wbitwise-op-parentheses
-Wcomma
-Wconditional-uninitialized
-Wconsumed
-Wcstring-format-directive
-Wctad-maybe-unsupported
-Wcustom-atomic-properties
-Wdelete-non-abstract-non-virtual-dtor
-Wdeprecated-copy
-Wdeprecated-copy-dtor
-Wdeprecated-dynamic-exception-spec
-Wdeprecated-implementations
-Wdouble-promotion
-Wduplicate-enum
-Wduplicate-method-arg
-Wduplicate-method-match
-Wembedded-directive
-Wempty-init-stmt
-Wexit-time-destructors
-Wexplicit-ownership-type
-Wextra-semi
-Wfloat-conversion
-Wfor-loop-analysis
-Wformat-non-iso
-Wformat-type-confusion
-Wheader-hygiene
-Widiomatic-parentheses
-Winfinite-recursion
-Wlogical-op-parentheses
-Wmethod-signatures
-Wmissing-noreturn
-Wmissing-variable-declarations
-Wmove
-Wnon-gcc
-Wnon-virtual-dtor
-Wnull-pointer-arithmetic
-Wnullable-to-nonnull-conversion
-Wover-aligned
-Woverlength-strings
-Woverloaded-virtual
-Woverriding-method-mismatch
-Wpragma-pack
-Wpragma-pack-suspicious-include
-Wquoted-include-in-framework-header
-Wrange-loop-analysis
-Wredundant-move
-Wredundant-parens
-Wreserved-id-macro
-Wreturn-std-move
-Wself-assign
-Wself-move
-Wsemicolon-before-method-body
-Wshadow-all
-Wshift-sign-overflow
-Wsometimes-uninitialized
-Wstatic-in-inline
-Wstrict-prototypes
-Wstrict-selector-match
-Wstring-conversion
-Wsuper-class-method-mismatch
-Wswitch-enum
-Wtautological-bitwise-compare
-Wtautological-constant-in-range-compare
-Wtautological-overlap-compare
-Wtautological-type-limit-compare
-Wtautological-unsigned-enum-zero-compare
-Wtautological-unsigned-zero-compare
-Wunneeded-internal-declaration
-Wunneeded-member-function
-Wunreachable-code-aggressive
-Wunused-label
-Wunused-lambda-capture
-Wunused-local-typedef
-Wunused-variable
-Wvla-extension
-Wzero-length-array
-Wno-sign-conversion
-Wno-shorten-64-to-32
)
endif()
else()
message(FATAL_ERROR "Unsupported compiler!")
endif() endif()
include_directories( include_directories(

View File

@ -43,26 +43,10 @@ typedef size_t SIZE_T;
#define MAX_PATH 255 #define MAX_PATH 255
#endif #endif
#ifndef __in
#define __in
#endif
#ifndef __out
#define __out
#endif
#ifndef __inout
#define __inout
#endif
// Main disasm header file. // Main disasm header file.
// #include "bdshemu.h" // #include "bdshemu.h"
#include "bddisasm.h" #include "bddisasm.h"
#undef __in
#undef __out
#undef __inout
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
} }

View File

@ -13,7 +13,7 @@
static const long NSEC_PER_SEC = (1000ULL * 1000ULL * 1000ULL); static const long NSEC_PER_SEC = (1000ULL * 1000ULL * 1000ULL);
const char *gSpaces[16] = static const char *gSpaces[16] =
{ {
"", "",
" ", " ",
@ -40,7 +40,7 @@ struct options {
size_t size; size_t size;
size_t count; size_t count;
int bits; uint8_t bits;
uint8_t vendor; uint8_t vendor;
bool no_color; bool no_color;
@ -113,7 +113,7 @@ static bool _hexstring_to_bytes(options &opts)
if (pair == "0x" || pair == "0X" || pair == "\\x") if (pair == "0x" || pair == "0X" || pair == "\\x")
continue; continue;
auto b = std::strtoul(pair.c_str(), &end_ptr, 16); auto b = static_cast<uint8_t>(std::strtoul(pair.c_str(), &end_ptr, 16));
size_t conv_size = static_cast<size_t>(end_ptr - pair.c_str()); size_t conv_size = static_cast<size_t>(end_ptr - pair.c_str());
@ -486,7 +486,7 @@ size_t disassemble(options &opts)
size_t icount = 0, miss_count = 0, ibytes = 0; size_t icount = 0, miss_count = 0, ibytes = 0;
size_t rel_rip = opts.offset; size_t rel_rip = opts.offset;
size_t total_disasm = 0; size_t total_disasm = 0;
auto bytes = reinterpret_cast<uint8_t *>(opts.bytes.get()); auto bytes = opts.bytes.get();
auto disasm_size = std::min(opts.actual_size - opts.offset, opts.size); auto disasm_size = std::min(opts.actual_size - opts.offset, opts.size);
while ((total_disasm < disasm_size) && (icount < opts.count)) { while ((total_disasm < disasm_size) && (icount < opts.count)) {
@ -657,7 +657,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
opts.bits = parser.get<int>("bits"); opts.bits = parser.get<uint8_t>("bits");
opts.interactive = parser.get<bool>("interactive"); opts.interactive = parser.get<bool>("interactive");
opts.comm = parser.get<bool>("comm"); opts.comm = parser.get<bool>("comm");
opts.offset = _get_hex_opt(parser, "offset"); opts.offset = _get_hex_opt(parser, "offset");