Skip to content

Commit

Permalink
Update tcc plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Apr 11, 2024
1 parent e5e6b35 commit f26a623
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tcc/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ lang_tcc.${EXT_SO}: tcc.o
-${CC} ${CFLAGS} -fPIC ${LDFLAGS_LIB} -o lang_tcc.${EXT_SO} tcc.c -ldl -ltcc
else
lang_tcc.${EXT_SO}: ;
# do nothing
@echo INFO: Missing libtcc. not building lang_tcc.$(EXT_SO)
endif
28 changes: 14 additions & 14 deletions tcc/tcc.c
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
/* tcc extension for libr (radare2) - copyright pancake 2011-2013 */
/* tcc extension for libr (radare2) - copyright pancake 2011-2024 */

#include "r_lib.h"
#include "r_lang.h"
#include <r_lib.h>
#include <r_lang.h>
#include <libtcc.h>

/* TODO: store the state globally or so.. */
static int r_lang_tcc_run(struct r_lang_t *lang, const char *code, int len) {
static bool r_lang_tcc_run(RLangSession *ls, const char *code, int len) {
TCCState *ts = tcc_new ();
/* TODO: set defined vars as global */
//list_for_each(lang->defs) {
// list_for_each(lang->defs) {
tcc_compile_string (ts, code);
tcc_run (ts, 0, 0);//argc, argv);
tcc_run (ts, 0, 0); //argc, argv);
tcc_delete (ts);
return R_TRUE;
}

static struct r_lang_plugin_t r_lang_plugin_tcc = {
.name = "c99",
static RLangPlugin r_lang_plugin_tcc = {
.meta = {
.name = "tcc",
.desc = "C99 rlang extension using libtcc",
},
.ext = "c",
.desc = "C99 language extension (using libtcc)",
.help = NULL,
.run = &r_lang_tcc_run,
.run_file = NULL,
.set_argv = NULL,
.run = &r_lang_tcc_run
};

#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_LANG,
.version = R2_VERSION,
.data = &r_lang_plugin_tcc,
};
#endif

0 comments on commit f26a623

Please sign in to comment.