mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-01 04:20:09 +08: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
65 lines
904 B
C
65 lines
904 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
|
|
|
|
static int __USED x1_c (void)
|
|
{
|
|
printf(" x1");
|
|
return 1;
|
|
}
|
|
|
|
asm(".text;"_"x1: call "_"x1_c; ret");
|
|
|
|
void callx4(void);
|
|
void callx5_again(void);
|
|
|
|
void x6()
|
|
{
|
|
printf(" x6-1");
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
printf("*");
|
|
asm("call "_"x1");
|
|
asm("call "_"x2");
|
|
asm("call "_"x3");
|
|
callx4();
|
|
asm("call "_"x5");
|
|
callx5_again();
|
|
x6();
|
|
printf(" *\n");
|
|
return 0;
|
|
}
|
|
|
|
static
|
|
int __USED x2(void)
|
|
{
|
|
printf(" x2");
|
|
return 2;
|
|
}
|
|
|
|
extern int x3(void);
|
|
|
|
void x4(void)
|
|
{
|
|
printf(" x4");
|
|
}
|
|
|
|
void x5(void);
|
|
void x5(void)
|
|
{
|
|
printf(" x5");
|
|
}
|