Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Nov 2009 19:57:45 +0100
From:      Luigi Rizzo <rizzo@iet.unipi.it>
To:        arch@freebsd.org
Subject:   [[atch] Re: anyone interested in helping fixing the 'tcc' compiler ?
Message-ID:  <20091128185745.GA7612@onelab2.iet.unipi.it>
In-Reply-To: <20091122111732.GA45909@onelab2.iet.unipi.it>
References:  <20091122111732.GA45909@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help

--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

followup to myself due to scarce success...
I have done some partial step in fixing the ELF produced by tcc
to work with freebsd. A patch is attached which works for simple
programs but not for more complex ones.

I found the following problems:
- tcc does not produce a PHDR program header, which caused the
  linker to fail. This should be fixed by this patch.

- the relocation sections produced by tcc apparently include a
  mix of JMP and non JMP relocations in the same place.
  Our loader complains when it finds this mix.
  I have changed the section definitions but it seems to work
  only for simple things (Hello World -style).

- the relocation info is not in the place rtld is looking for.
  What i found is that UNDEF symbols had the offset to be
  patched in the dynsym section, instead of the .got section where
  (apparently) our loader is looking for. The function
  patch_dynsym_undef() in the patch attached seems to handle this,
  but I am not sure how general is this.

With this patch the simplest example programs (ex1, ex2, ex3, ex5)
do work, but ex4 (which uses -lX11) fails to load
ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/i386/reloc.c:292
(I hope i can track this later).

cheers
luigi

  

On Sun, Nov 22, 2009 at 12:17:32PM +0100, Luigi Rizzo wrote:
> Hi,
> I have recently started playing with the Tiny C Compuler (lang/tcc)
> which is amazingly useful for prototyping, but has problem generating
> non-static binaries in FreeBSD -- basically it produces a bogus
> elf file which our loader does not like.
> Static binaries work fine, as well as 'tcc -run ' (compile
> and run on the fly -- you should really try it if you haven't yet).
> 
> There is an open PR on this
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=138481
> 
> and the problem is known upstream but no fix
> 
> http://lists.gnu.org/archive/html/tinycc-devel/2005-07/msg00070.html
> 
> However, from the description it does not seem a horribly
> hard problem. Perhaps someone with a bit of knowledge on
> how our ld-elf.so works should not have a hard time pinpointing
> the problem so that other people can fix it ?
> 
> Any takers ?
> 
> cheers
> luigi

--Nq2Wo0NMKNjxTN9z--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091128185745.GA7612>