tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] x86_64 static link fix


From: Kurt Nalty
Subject: [Tinycc-devel] x86_64 static link fix
Date: Wed, 9 Jan 2019 16:33:41 +0000

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]