Skip to content

Instantly share code, notes, and snippets.

@swkim101
Created December 3, 2020 22:53
Show Gist options
  • Save swkim101/ba2031a5266be1ab881173153131fc47 to your computer and use it in GitHub Desktop.
Save swkim101/ba2031a5266be1ab881173153131fc47 to your computer and use it in GitHub Desktop.
Patcherex Tricore README

Patcherex Tricore Support

Requirements

  • gcc tool chain for Tricore

https://hightec-rt.com/en/downloads.html

  • Windows Subsystem Linux

https://docs.microsoft.com/en-us/windows/wsl/install-win10

Please make sure that tricore-gcc.exe and tricore-objcopy.exe is available on WSL.

Example

import patcherex
import os
from patcherex.backends.detourbackend import DetourBackend
from patcherex.patches import *

filename = "tricore.elf"
backend = DetourBackend(filename)

trampolin_code = '''
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
    mov.a       %a15, %d15
'''
p1 = InsertCodePatch(0x8000041C, trampolin_code, "trampolin_code")

backend.apply_patches([ p1 ])
backend.save("tricore.patched.elf")
@swkim101
Copy link
Author

swkim101 commented Dec 3, 2020

Result:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment