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: Tue, 10 Aug 2010 13:57:13 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6

Hi y'all!

I used Thomas Preud'homme's patch on the tcc-0.9.25 I had retrieved from sourceforge
(on Ubuntu Lucid 10.04 x86_64: Linux Gypsy-IV 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010 x86_64 GNU/Linux)
  • I the tcc bootstraps again
  • the bootstrapped tcc is able to compile the complete Eiffel 6.6.8 system and a sample program (freeze/finalize)... the sample program executes properly
I applied 'patch' on elf.h & tccelf.c,
however the 3rd file (tccrun.cc) was nowhere to be found... yet everything works (I suspect T had a slightly more recent tcc version)

Kudos to Thomas!!!
Vin

On 08/09/2010 11:24 AM, Thomas Preud'homme 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
  
_______________________________________________ Tinycc-devel mailing list address@hidden http://lists.nongnu.org/mailman/listinfo/tinycc-devel


--


Best regards

Vin Amiot

address@hidden
425-220-0378
646-236-3073 (backup)

 



Projects Vin Amiot worked on (3 of them in a key role):

   * Charles de Gaulle Aircraft Carrier (French Navy)
   * Ariane V (European Space Agency)
   * Aegis ATC (US Navy)
   * International Space Station (NASA/Boeing)
   * Boeing 787 (Braking System)

 

Charles de Gaulle AC Ariane V Aegis Cruiser ISS b787



Attachment: vin_amiot.vcf
Description: Vcard


reply via email to

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