mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-26 03:50:07 +08:00
Serveral updates
arm-gen.c: - remove fr parameter from load_value tccelf.c: - update comment and remove check for sh_size tests/boundtest.c: - fix testcase 16/17
This commit is contained in:
parent
28646b559d
commit
c74c6ed61a
10
arm-gen.c
10
arm-gen.c
@ -538,11 +538,11 @@ static int negcc(int cc)
|
|||||||
|
|
||||||
/* Load value into register r.
|
/* Load value into register r.
|
||||||
Use relative/got addressing to avoid setting DT_TEXTREL */
|
Use relative/got addressing to avoid setting DT_TEXTREL */
|
||||||
static void load_value(SValue *sv, int fr, int r)
|
static void load_value(SValue *sv, int r)
|
||||||
{
|
{
|
||||||
o(0xE59F0000|(intr(r)<<12));
|
o(0xE59F0000|(intr(r)<<12));
|
||||||
o(0xEA000000);
|
o(0xEA000000);
|
||||||
if(fr & VT_SYM) {
|
if(sv->r & VT_SYM) {
|
||||||
if (sv->sym->type.t & VT_STATIC) {
|
if (sv->sym->type.t & VT_STATIC) {
|
||||||
greloc(cur_text_section, sv->sym, ind, R_ARM_REL32);
|
greloc(cur_text_section, sv->sym, ind, R_ARM_REL32);
|
||||||
o(sv->c.i - 12);
|
o(sv->c.i - 12);
|
||||||
@ -656,14 +656,14 @@ void load(int r, SValue *sv)
|
|||||||
if (v == VT_CONST) {
|
if (v == VT_CONST) {
|
||||||
op=stuff_const(0xE3A00000|(intr(r)<<12),sv->c.i);
|
op=stuff_const(0xE3A00000|(intr(r)<<12),sv->c.i);
|
||||||
if (fr & VT_SYM || !op)
|
if (fr & VT_SYM || !op)
|
||||||
load_value(sv, fr, r);
|
load_value(sv, r);
|
||||||
else
|
else
|
||||||
o(op);
|
o(op);
|
||||||
return;
|
return;
|
||||||
} else if (v == VT_LOCAL) {
|
} else if (v == VT_LOCAL) {
|
||||||
op=stuff_const(0xE28B0000|(intr(r)<<12),sv->c.i);
|
op=stuff_const(0xE28B0000|(intr(r)<<12),sv->c.i);
|
||||||
if (fr & VT_SYM || !op) {
|
if (fr & VT_SYM || !op) {
|
||||||
load_value(sv, fr, r);
|
load_value(sv, r);
|
||||||
o(0xE08B0000|(intr(r)<<12)|intr(r));
|
o(0xE08B0000|(intr(r)<<12)|intr(r));
|
||||||
} else
|
} else
|
||||||
o(op);
|
o(op);
|
||||||
@ -797,7 +797,7 @@ static void gcall_or_jmp(int is_jmp)
|
|||||||
o(x|(is_jmp?0xE0000000:0xE1000000));
|
o(x|(is_jmp?0xE0000000:0xE1000000));
|
||||||
} else {
|
} else {
|
||||||
r = TREG_LR;
|
r = TREG_LR;
|
||||||
load_value(vtop, vtop->r, r);
|
load_value(vtop, r);
|
||||||
if(is_jmp)
|
if(is_jmp)
|
||||||
o(0xE1A0F000 | intr(r)); // mov pc, r
|
o(0xE1A0F000 | intr(r)); // mov pc, r
|
||||||
else
|
else
|
||||||
|
4
tccelf.c
4
tccelf.c
@ -2243,7 +2243,7 @@ static int final_sections_reloc(TCCState *s1)
|
|||||||
These gaps are a result of final_sections_reloc. Here some relocs are removed.
|
These gaps are a result of final_sections_reloc. Here some relocs are removed.
|
||||||
The gaps are then filled with 0 in tcc_output_elf. The 0 is intepreted as
|
The gaps are then filled with 0 in tcc_output_elf. The 0 is intepreted as
|
||||||
R_...NONE reloc. This does work on most targets but on OpenBSD/arm64 this
|
R_...NONE reloc. This does work on most targets but on OpenBSD/arm64 this
|
||||||
is illegal. */
|
is illegal. OpenBSD/arm64 does not support R_...NONE reloc. */
|
||||||
static void update_reloc_sections(TCCState *s1, struct dyn_inf *dyninf)
|
static void update_reloc_sections(TCCState *s1, struct dyn_inf *dyninf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -2256,7 +2256,7 @@ static void update_reloc_sections(TCCState *s1, struct dyn_inf *dyninf)
|
|||||||
|
|
||||||
for(i = 1; i < s1->nb_sections; i++) {
|
for(i = 1; i < s1->nb_sections; i++) {
|
||||||
s = s1->sections[i];
|
s = s1->sections[i];
|
||||||
if (s->sh_type == SHT_RELX && s->sh_size && s != relocplt) {
|
if (s->sh_type == SHT_RELX && s != relocplt) {
|
||||||
if (dyninf->rel_size == 0) {
|
if (dyninf->rel_size == 0) {
|
||||||
dyninf->rel_addr = s->sh_addr;
|
dyninf->rel_addr = s->sh_addr;
|
||||||
file_offset = s->sh_offset;
|
file_offset = s->sh_offset;
|
||||||
|
@ -172,6 +172,7 @@ int test13(void)
|
|||||||
#if defined __i386__ || defined __x86_64__
|
#if defined __i386__ || defined __x86_64__
|
||||||
#define allocf(x)
|
#define allocf(x)
|
||||||
#else
|
#else
|
||||||
|
#undef alloca
|
||||||
#define alloca(x) malloc(x)
|
#define alloca(x) malloc(x)
|
||||||
#define allocf(x) free(x)
|
#define allocf(x) free(x)
|
||||||
#endif
|
#endif
|
||||||
@ -207,10 +208,10 @@ int test16()
|
|||||||
|
|
||||||
p = alloca(16);
|
p = alloca(16);
|
||||||
strcpy(p,"12345678901234");
|
strcpy(p,"12345678901234");
|
||||||
allocf(p);
|
|
||||||
|
|
||||||
/* Test alloca embedded in a larger expression */
|
/* Test alloca embedded in a larger expression */
|
||||||
printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)+1),demo) );
|
printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)+1),demo) );
|
||||||
|
allocf(p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -223,10 +224,10 @@ int test17()
|
|||||||
|
|
||||||
p = alloca(16);
|
p = alloca(16);
|
||||||
strcpy(p,"12345678901234");
|
strcpy(p,"12345678901234");
|
||||||
allocf(p);
|
|
||||||
|
|
||||||
/* Test alloca embedded in a larger expression */
|
/* Test alloca embedded in a larger expression */
|
||||||
printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)),demo) );
|
printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)),demo) );
|
||||||
|
allocf(p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user