22 const char *compilers[] = {
"llvm-gcc",
"clang",
"gcc" };
29 for (
i = 0;
i < 3;
i++) {
31 if (strcmp(
output, compilers[
i])) {
38 eprintf(
"Couldn't find a compiler ! Please, set CC.\n");
43 return (!strcmp(
arch,
"arm") || !strcmp(
arch,
"arm64") || !strcmp(
arch,
"aarch64") || !strcmp(
arch,
"thumb") || !strcmp(
arch,
"arm32") || !strcmp(
arch,
"mips") || !strcmp(
arch,
"mips32") || !strcmp(
arch,
"mips64"));
62 static inline bool isXNU(
const char *os) {
63 return (!strcmp(os,
"darwin") || !strcmp(os,
"macos") || !strcmp(os,
"tvos") || !strcmp(os,
"watchos") || !strcmp(os,
"ios"));
84 eprintf(
"Cannot find SFLIBPATH env var.\n"
85 "Please define it, or fix rizin installation.\n");
101 if (!strcmp(
arch,
"x86")) {
104 cEnv->
LDFLAGS =
strdup(
"-arch i386 -shared -c -fPIC -fPIE -pie");
107 cEnv->
LDFLAGS =
strdup(
"-arch x86_64 -shared -c -fPIC -fPIE -pie");
118 "// .type main, @function\n%s main\n",
120 if (!strcmp(
arch,
"x86")) {
129 cEnv->
CFLAGS =
strdup(
"-fPIC -fPIE -pie -fpic -nostartfiles");
130 cEnv->
LDFLAGS =
strdup(
"-fPIC -fPIE -pie -fpic -nostartfiles");
136 if (!strcmp(os,
"windows")) {
137 cEnv->
TEXT =
".text";
139 }
else if (
isXNU(os)) {
141 cEnv->
TEXT =
"0..__text";
143 cEnv->
TEXT =
".text";
147 if (!strcmp(cEnv->
TRIPLET,
"darwin-arm-64")) {
149 cEnv->
CC =
strdup(
"xcrun --sdk iphoneos gcc -arch arm64 -miphoneos-version-min=0.0");
151 cEnv->
TEXT =
"0.__TEXT.__text";
152 }
else if (!strcmp(cEnv->
TRIPLET,
"darwin-arm-32")) {
154 cEnv->
CC =
strdup(
"xcrun --sdk iphoneos gcc -arch armv7 -miphoneos-version-min=0.0");
156 cEnv->
TEXT =
"0.__TEXT.__text";
159 buffer =
rz_str_newf(
"%s -fno-stack-protector -nostdinc -include '%s'/'%s'/sflib.h",
170 " -fno-zero-initialized-in-bss",
180 " -finline-functions -fno-zero-initialized-in-bss",
197 eprintf(
"Error with cEnv allocation!\n");
216 eprintf(
"Could not open '%s'.\n", fileExt);
224 const char *words[] = {
".cstring",
"size",
"___main",
"section",
"__alloca",
"zero",
"cfi" };
226 for (
i = 0;
i < 7;
i++) {
249 char *fileExt =
NULL;
311 eprintf(
"FALLBACK: Using objcopy instead of rz_bin");
322 const char *extArray[] = {
"bin",
"tmp",
"s",
"o" };
323 for (
i = 0;
i < 4;
i++) {
int bits(struct state *s, int need)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
static void rz_egg_Cfile_free_cEnv(struct cEnv_t *cEnv)
static bool isXNU(const char *os)
static bool rz_egg_Cfile_check_cEnv(struct cEnv_t *cEnv)
RZ_API char * rz_egg_Cfile_parser(const char *file, const char *arch, const char *os, int bits)
static bool rz_egg_Cfile_parseCompiled(const char *file)
static bool rz_egg_Cfile_armOrMips(const char *arch)
static char * rz_egg_Cfile_getCompiler(void)
static struct cEnv_t * rz_egg_Cfile_set_cEnv(const char *arch, const char *os, int bits)
RZ_API void Ht_() free(HtName_(Ht) *ht)
void * calloc(size_t number, size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API bool rz_file_exists(const char *str)
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
RZ_API bool rz_file_dump(const char *file, const ut8 *buf, int len, bool append)
RZ_API bool rz_file_rm(const char *file)
RZ_API char * rz_file_path(const char *bin)
RZ_API ut64 rz_file_size(const char *str)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API void rz_str_stripLine(char *str, const char *key)
RZ_API char * rz_str_replace(char *str, const char *key, const char *val, int g)
RZ_API void rz_str_sanitize(char *c)
RZ_API char * rz_sys_getenv(const char *key)
Get the value of an environment variable named key or NULL if none exists.
RZ_API char * rz_sys_cmd_strf(const char *cmd,...) RZ_PRINTF_CHECK(1
RZ_API int rz_sys_system(const char *command)