Alien-TinyCCx
view release on metacpan or search on metacpan
src/tccasm.c view on Meta::CPAN
asm_expr_logic(s1, pe);
for(;;) {
op = tok;
if (op != '+' && op != '-')
break;
next();
asm_expr_logic(s1, &e2);
if (op == '+') {
if (pe->sym != NULL && e2.sym != NULL)
goto cannot_relocate;
pe->v += e2.v;
if (pe->sym == NULL && e2.sym != NULL)
pe->sym = e2.sym;
} else {
pe->v -= e2.v;
/* NOTE: we are less powerful than gas in that case
because we store only one symbol in the expression */
if (!pe->sym && !e2.sym) {
/* OK */
} else if (pe->sym && !e2.sym) {
/* OK */
} else if (pe->sym && e2.sym) {
if (pe->sym == e2.sym) {
/* OK */
} else if (pe->sym->r == e2.sym->r && pe->sym->r != 0) {
/* we also accept defined symbols in the same section */
pe->v += pe->sym->jnext - e2.sym->jnext;
} else {
goto cannot_relocate;
}
pe->sym = NULL; /* same symbols can be subtracted to NULL */
} else {
cannot_relocate:
tcc_error("invalid operation with label");
}
}
}
}
ST_FUNC void asm_expr(TCCState *s1, ExprValue *pe)
{
asm_expr_sum(s1, pe);
}
src/tccpe.c view on Meta::CPAN
sym = (ElfW(Sym) *)symtab_section->data + sym_index;
if (sym->st_shndx == SHN_UNDEF) {
const char *name = symtab_section->link->data + sym->st_name;
unsigned type = ELFW(ST_TYPE)(sym->st_info);
int imp_sym = pe_find_import(pe->s1, sym);
struct import_symbol *is;
if (0 == imp_sym)
goto not_found;
if (type == STT_NOTYPE) {
/* symbols from assembler have no type, find out which */
if (pe_isafunc(sym_index))
type = STT_FUNC;
else
type = STT_OBJECT;
}
is = pe_add_import(pe, imp_sym);
src/tccpe.c view on Meta::CPAN
}
if (type == STT_OBJECT) { /* data, ptr to that should be */
if (0 == is->iat_index) {
/* original symbol will be patched later in pe_build_imports */
is->iat_index = sym_index;
continue;
}
}
not_found:
tcc_error_noabort("undefined symbol '%s'", name);
ret = -1;
} else if (pe->s1->rdynamic
&& ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
/* if -rdynamic option, then export all non local symbols */
sym->st_other |= ST_PE_EXPORT;
}
}
return ret;
src/tests/tcctest.c view on Meta::CPAN
}
void math_cmp_test(void)
{
double nan = 0.0/0.0;
double one = 1.0;
double two = 2.0;
int comp = 0;
#define bug(a,b,op,iop,part) printf("Test broken: %s %s %s %s %d\n", #a, #b, #op, #iop, part)
/* This asserts that "a op b" is _not_ true, but "a iop b" is true.
And it does this in various ways so that all code generation paths
are checked (generating inverted tests, or non-inverted tests, or
producing a 0/1 value without jumps (that's done in the fcompare
function). */
#define FCMP(a,b,op,iop,code) \
if (fcompare (a,b,code)) \
bug (a,b,op,iop,1); \
if (a op b) \
bug (a,b,op,iop,2); \
if (a iop b) \
( run in 0.636 second using v1.01-cache-2.11-cpan-cc502c75498 )