Hi Grischka,

> Everything is possible.  This is software after all.

Yep :-)

> Say your original function is:
>      int add(int a, int b) { return a + b; }

> Your replacement (same prototype) is:
>      int sub(int a, int b) { return a - b; }

> Have a tool to make it happen:
>      void replace_function(TCCState *s, const char *name, void *new)
>      {
>          char *old = tcc_get_symbol(s, name);
>          set_pages_executable(old, 5); //from tccrun.c
>      #ifdef ___i386__
>          *old = 0xe9;
>          *(unsigned*)(old + 1) = (char *)new - old - 5;
>      #endif
>      }

Excellent! that is way simpler than I expected.  I will take it for a spin now.

Thanks a lot for your help

Henry

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to