I just see a report for reloc problems on apple m1.

The problem is in tccmacho.c. It always genenates x86_64 code:

    jmp = section_ptr_add(mo->stubs, 6);
    jmp[0] = 0xff;  /* jmpq *ofs(%rip) */
    jmp[1] = 0x25;
    put_elf_reloc(s1->symtab, mo->stubs,
               attr->plt_offset + 2,
               R_X86_64_GOTPCREL, sym_index);

This should be fixed for arm64.
I have no access to an apply m1 so can not fix this.

    Herman

Probably a good start would be:

diff --git a/tccmacho.c b/tccmacho.c
index f9048ea..d644d3e 100644
--- a/tccmacho.c
+++ b/tccmacho.c
@@ -354,12 +354,16 @@ static void check_relocs(TCCState *s1, struct macho *mo)
                     if (attr->plt_offset == -1) {
                         uint8_t *jmp;
                         attr->plt_offset = mo->stubs->data_offset;
+#ifdef TCC_TARGET_X86_64
                         jmp = section_ptr_add(mo->stubs, 6);
                         jmp[0] = 0xff;  /* jmpq *ofs(%rip) */
                         jmp[1] = 0x25;
                         put_elf_reloc(s1->symtab, mo->stubs,
                                       attr->plt_offset + 2,
                                       R_X86_64_GOTPCREL, sym_index);
+#else
+#error Platform not supported
+#endif
                     }
                     rel->r_info = ELFW(R_INFO)(mo->stubsym, type);
                     rel->r_addend += attr->plt_offset;


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to