From ec7d36326de63fa284f6c181db5b3d1c02f071bf Mon Sep 17 00:00:00 2001 From: bellard Date: Tue, 5 Oct 2004 22:33:55 +0000 Subject: C67 COFF executable format support (TK) --- tccelf.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tccelf.c') diff --git a/tccelf.c b/tccelf.c index e599867..07deca8 100644 --- a/tccelf.c +++ b/tccelf.c @@ -552,6 +552,24 @@ static void relocate_section(TCCState *s1, Section *s) case R_C60_32: *(int *)ptr += val; break; + case R_C60LO16: + { + uint32_t orig; + + /* put the low 16 bits of the absolute address */ + // add to what is already there + + orig = ((*(int *)(ptr )) >> 7) & 0xffff; + orig |= (((*(int *)(ptr+4)) >> 7) & 0xffff) << 16; + + //patch both at once - assumes always in pairs Low - High + + *(int *) ptr = (*(int *) ptr & (~(0xffff << 7)) ) | (((val+orig) & 0xffff) << 7); + *(int *)(ptr+4) = (*(int *)(ptr+4) & (~(0xffff << 7)) ) | ((((val+orig)>>16) & 0xffff) << 7); + } + break; + case R_C60HI16: + break; default: fprintf(stderr,"FIXME: handle reloc type %x at %lx [%.8x] to %lx\n", type,addr,(unsigned int )ptr,val); @@ -1536,6 +1554,9 @@ int tcc_output_file(TCCState *s1, const char *filename) ehdr.e_entry = text_section->sh_addr; /* XXX: is it correct ? */ } +#ifdef TCC_TARGET_COFF + ret = tcc_output_coff(s1, filename); +#else sort_syms(s1, symtab_section); /* align to 4 */ @@ -1629,6 +1650,7 @@ int tcc_output_file(TCCState *s1, const char *filename) fclose(f); ret = 0; +#endif the_end: tcc_free(s1->symtab_to_dynsym); tcc_free(section_order); -- cgit v1.3.1