mirror of
https://github.com/frida/tinycc
synced 2024-11-24 08:39:37 +03:00
6a4f3cf127
tested on win32/64 to pass the tests when enabled - libtcc.c : let tcc define __leading_underscore if enabled tcc_add_symbol() : add _ automatically - tccelf.c : remove tcc_get_symbol_err(), find_c_sym() currently symbol length is limited to 256 in several places, so we can use a fixed local buffer for now as well. - win32/lib/crtinit.c : new file for init/fini - lib/*.S, tests7* : use __leading_underscore - bt-log.c: this file wont work relibaly if compiled with gcc
44 lines
749 B
C
44 lines
749 B
C
#include <stdio.h>
|
|
|
|
#if (defined _WIN32 || defined __APPLE__) && (!defined __TINYC__ || defined __leading_underscore)
|
|
# define _ "_"
|
|
#else
|
|
# define _
|
|
#endif
|
|
|
|
#ifdef __clang__
|
|
/* clang needs some help tp not throw functions away even at -O0 */
|
|
#define __USED __attribute__((__used__))
|
|
#else
|
|
#define __USED
|
|
#endif
|
|
|
|
int x3(void)
|
|
{
|
|
printf(" x3");
|
|
return 3;
|
|
}
|
|
|
|
/* That callx4 is defined globally (as if ".globl callx4")
|
|
is a TCC extension. GCC doesn't behave like this. */
|
|
void callx4(void);
|
|
__asm__(_"callx4: call "_"x4; ret;"
|
|
#ifndef __TINYC__
|
|
" .global "_"callx4"
|
|
#endif
|
|
);
|
|
|
|
extern void x5(void);
|
|
|
|
void callx5_again(void);
|
|
void callx5_again(void)
|
|
{
|
|
x5();
|
|
asm("call "_"x6");
|
|
}
|
|
|
|
static void __USED x6()
|
|
{
|
|
printf(" x6-2");
|
|
}
|