feat: add custom b-type instruction (jump)
This commit is contained in:
@@ -40,10 +40,11 @@ def mangle(value):
|
|||||||
return (result, c_manglers)
|
return (result, c_manglers)
|
||||||
|
|
||||||
def get_check_code(flag_part, user_part, c_mangler):
|
def get_check_code(flag_part, user_part, c_mangler):
|
||||||
return f"""if(({flag_part}) != ({c_mangler(user_part)})){{
|
variations = [
|
||||||
return false;
|
f"custom_jmp_neq({flag_part} ^ 0x7C, {c_mangler(user_part)}, label_false);",
|
||||||
}}
|
f"custom_jmp_neq({flag_part}, {c_mangler(user_part)} ^ 0x7C, label_false);"
|
||||||
"""
|
]
|
||||||
|
return random.choice(variations)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
@@ -105,6 +106,9 @@ bool check(char* userflag, uint8_t len) {{
|
|||||||
{check}
|
{check}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
label_false:
|
||||||
|
return false;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
""")
|
""")
|
||||||
|
|||||||
@@ -13,3 +13,12 @@
|
|||||||
_result; \
|
_result; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#define custom_jmp_neq(a, b, label_true) \
|
||||||
|
asm goto( \
|
||||||
|
".insn b 0x2B, 0x00, %0, %1, %l2" \
|
||||||
|
: \
|
||||||
|
: "r" ((int32_t)(a)), \
|
||||||
|
"r" ((int32_t)(b)) \
|
||||||
|
: \
|
||||||
|
: label_true \
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user