After firing up gdb, and tracing through a few combinations of static and 
dynamically linked object files, I have determined that the segfaults were due 
to usage of procedure linking tables
(.plt) with the statically linked process. The plt addresses are not corrected  
when static loaded, but are corrected during dynamic linking. File 
x86_64-gen.c, lines
630-634 were

#ifdef TCC_TARGET_PE
            greloca(cur_text_section, vtop->sym, ind + 1, R_X86_64_PC32, 
(int)(vtop->c.i-4));
#else
            greloca(cur_text_section, vtop->sym, ind + 1, R_X86_64_PLT32, 
(int)(vtop->c.i-4));
#endif

and are replaced by 
            greloca(cur_text_section, vtop->sym, ind + 1, R_X86_64_PC32, 
(int)(vtop->c.i-4));


This restores correct static linking in uClibc-0-9.30 and musl environments. 
Dynamic linking is
unaffected, and continues to use procedure link table jumps and calls.

I am going to test this against the current archive, and if happy, will push.


_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to