Skip to content

Commit

Permalink
fix clang build
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Aug 5, 2023
1 parent 12b2de5 commit d79ba3a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/assembler/X86Assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct X86Operand {
X86Register m_reg;
uint32_t m_value = 0;
X86Operand(X86Register reg) : m_reg(reg), m_type(Type::Register) {}
X86Operand(X86Pointer ptr) : m_reg(ptr.m_register), m_value(ptr.m_offset), m_type(Type::ModRM) {}
X86Operand(X86Pointer ptr) : m_reg(ptr.reg), m_value(ptr.offset), m_type(Type::ModRM) {}
};

static void encodeModRM(X86Assembler* ass, X86Operand op, uint8_t digit) {
Expand Down
5 changes: 3 additions & 2 deletions src/assembler/X86Assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ namespace tulip::hook {
};

struct X86Pointer {
X86Register m_register;
int32_t m_offset = 0;
X86Register reg;
int32_t offset = 0;
X86Pointer(X86Register reg, int32_t offset = 0) : reg(reg), offset(offset) {}
};

class X86Assembler : public BaseAssembler {
Expand Down
24 changes: 12 additions & 12 deletions test/assembler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ std::vector<uint8_t> operator""_bytes(const char* data, size_t size) {
return std::vector(reinterpret_cast<const uint8_t*>(data), reinterpret_cast<const uint8_t*>(data + size));
}

template <class T, class U>
void assertEqImpl(T&& a, U&& b, const char* expr, const char* file, int line) {
if (a != b) {
std::cout << "Assertion `" << expr << "` failed at " << file << ':' << line << std::endl;
std::cout << "lhs is: " << a << std::endl;
std::cout << "rhs is: " << b << std::endl;
std::abort();
}
}

#define assertEq(a, b) assertEqImpl(a, b, #a " == " #b, __FILE__, __LINE__)

std::ostream& operator<<(std::ostream& stream, const std::vector<uint8_t>& value) {
stream << '{';
bool first = true;
Expand All @@ -33,6 +21,18 @@ std::ostream& operator<<(std::ostream& stream, const std::vector<uint8_t>& value
return stream << '}';
}

template <class T, class U>
void assertEqImpl(T&& a, U&& b, const char* expr, const char* file, int line) {
if (a != b) {
std::cout << "Assertion `" << expr << "` failed at " << file << ':' << line << std::endl;
std::cout << "lhs is: " << a << std::endl;
std::cout << "rhs is: " << b << std::endl;
std::abort();
}
}

#define assertEq(a, b) assertEqImpl(a, b, #a " == " #b, __FILE__, __LINE__)

int main() {
using enum X86Register;

Expand Down

0 comments on commit d79ba3a

Please sign in to comment.