2017-11-23 00:57:43 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2020-06-27 23:15:06 +08:00
|
|
|
#if (defined _WIN32 || defined __APPLE__) && (!defined __TINYC__ || defined __leading_underscore)
|
2020-05-23 09:46:32 +08:00
|
|
|
# define _ "_"
|
2017-11-23 00:57:43 +08:00
|
|
|
#else
|
2017-11-27 08:09:50 +08:00
|
|
|
# define _
|
2017-11-23 00:57:43 +08:00
|
|
|
#endif
|
|
|
|
|
2020-05-23 09:46:32 +08:00
|
|
|
#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)
|
2017-11-27 08:09:50 +08:00
|
|
|
{
|
2017-12-13 00:57:20 +08:00
|
|
|
printf(" x1");
|
2017-11-27 08:09:50 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-12-17 00:52:59 +08:00
|
|
|
#if __i386__
|
2017-11-27 08:09:50 +08:00
|
|
|
asm(".text;"_"x1: call "_"x1_c; ret");
|
2020-12-17 00:52:59 +08:00
|
|
|
#else
|
|
|
|
/* Keep stack aligned */
|
|
|
|
asm(".text;"_"x1: sub $8,%rsp; call "_"x1_c; add $8,%rsp; ret");
|
|
|
|
#endif
|
2017-11-23 00:57:43 +08:00
|
|
|
|
2017-11-27 11:03:03 +08:00
|
|
|
void callx4(void);
|
2017-12-04 10:51:14 +08:00
|
|
|
void callx5_again(void);
|
2017-12-13 00:57:20 +08:00
|
|
|
|
|
|
|
void x6()
|
|
|
|
{
|
|
|
|
printf(" x6-1");
|
|
|
|
}
|
|
|
|
|
2017-11-23 00:57:43 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2017-12-13 00:57:20 +08:00
|
|
|
printf("*");
|
2017-11-27 08:09:50 +08:00
|
|
|
asm("call "_"x1");
|
|
|
|
asm("call "_"x2");
|
|
|
|
asm("call "_"x3");
|
2017-11-27 11:03:03 +08:00
|
|
|
callx4();
|
2017-12-04 10:51:14 +08:00
|
|
|
asm("call "_"x5");
|
|
|
|
callx5_again();
|
2017-12-13 00:57:20 +08:00
|
|
|
x6();
|
|
|
|
printf(" *\n");
|
2017-11-23 00:57:43 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
2020-05-23 09:46:32 +08:00
|
|
|
int __USED x2(void)
|
2017-11-23 00:57:43 +08:00
|
|
|
{
|
2017-12-13 00:57:20 +08:00
|
|
|
printf(" x2");
|
2017-11-23 00:57:43 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int x3(void);
|
2017-11-27 11:03:03 +08:00
|
|
|
|
|
|
|
void x4(void)
|
|
|
|
{
|
2017-12-13 00:57:20 +08:00
|
|
|
printf(" x4");
|
2017-11-27 11:03:03 +08:00
|
|
|
}
|
2017-12-04 10:51:14 +08:00
|
|
|
|
|
|
|
void x5(void);
|
|
|
|
void x5(void)
|
|
|
|
{
|
2017-12-13 00:57:20 +08:00
|
|
|
printf(" x5");
|
2017-12-04 10:51:14 +08:00
|
|
|
}
|