tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] x86_64 static link fix


From: Michael Matz
Subject: Re: [Tinycc-devel] x86_64 static link fix
Date: Sun, 13 Jan 2019 06:08:31 +0100 (CET)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hi,

On Wed, 9 Jan 2019, Kurt Nalty wrote:

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.

It's still wrong. The relocation to use really should be PLT32, even though it doesn't often make a difference (*).

I've now found time to look into this, i.e. static linking with uClibc. I fixed some problems in mob and reverted your patch again. A simple hello world now works statically with uClibc. Would be nice if you can retry (and maybe with bigger examples :) ).


Ciao,
Michael.
* it's a historic mistake of the initial x86-64 psABI implementations that PC32 relocs are sometimes used in place of PLT32 relocs (or from a different point of view, that both relocations exist, and not only PC32).



reply via email to

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