tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Support for indirect function in external modules


From: Vin Amiot
Subject: Re: [Tinycc-devel] Support for indirect function in external modules
Date: Mon, 9 Aug 2010 11:59:32 -0700

Great Job!
I will check it out shortly: does it mean tcc can be botstrapped on Linux now?
Best regards
Vin

On 8/9/10, Thomas Preud'homme <address@hidden> wrote:
> Hi all,
>
> last version of GNU libc uses symbol with indirect function type (also known
> as STT_GNU_IFUNC) in its recent versions on x86_64 architecture.
>
> This straightforward patch (pushed on mob with short sha1 bcc9137) allow
> tinycc to build against libraries using such type for symbol. Notes that
> this patch does not allow tcc to build executable or library with such
> symbol type. It only supports linking against such libraries.
>
> Important note: The documentation I read about STT_GNU_IFUNC symbols says
> that when a code *load* (which is different from jump and calls) such a
> symbol, the value used should be either its GOTPLT (.got.plt) entry or its
> GOT entry depending on the context. I quickly look at the code and saw that
> whenever a
> STT_FUNC (or also STT_IFUNC now) is used, a GOT *and* a PLTGOT entry is
> created but I don't know which of the two entries is used depending on the
> context. But for what I saw, whenever there is a load, it's loaded from the
> same place (I guess it's loaded from GOT, according to first comment in
> load() in
> x86_64-gen.c).
>
> I'm still lacking some tinycc knowledge about the link between source
> parsing and code generation so it would be quite long for me to add the
> necessary support. So could one of the tinycc guru add the code to handle
> this differentiation ? The rules about the value to load (GOTPLT entry or
> GOT entry) are
> explained in this document:
>
> http://generic-abi.googlegroups.com/web/ifunc.txt?gda=xtGavTsAAADkRlZw3fTn8WF8pRDgf6aLfN_Atkb_cwXe6cZOcg5qrUgoJ4G7--yvLPBq95D3B7sGRdr3QrylPkw2aRbXD_gF
>
> I quote:
>
> "Note:
>
> Instead of branching to an STT_GNU_IFUNC symbol directly, we always
> branch to its PLT entry, which simply loads its GOTPLT entry and branch
> to it.  Its GOTPLT entry has the real function address.  It has an
> optional GOT entry for the function pointer value of the symbol.  To
> load an STT_GNU_IFUNC symbol function pointer value,
>
> 1. Use its GOTPLT entry in a shared object if it is forced local or not
> dynamic.
> 2. Use its GOTPLT entry in a non-shared object if pointer equality isn't
> needed.
> 3. Use its GOTPLT entry in a position independent executable (PIE).
> 4. Use its GOTPLT entry if no normal GOT, other than GOTPLT, is used.
> 5. Otherwise use its GOT entry.  We only need to relocate its GOT entry
> in a shared object."
>
> Best regards,
>
> Thomas Preud'homme
>



reply via email to

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