tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Fix bad linkage on alias symbols


From: Thomas Preud'homme
Subject: [Tinycc-devel] Fix bad linkage on alias symbols
Date: Sat, 1 May 2010 17:14:26 +0200
User-agent: KMail/1.12.4 (Linux/2.6.32-3-686; KDE/4.3.4; i686; ; )

Hi all,

I've been reported a while ago a problem with the use of environ variable (see 
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=452876). I worked on that 
this week and found the problem is that tinycc don't link alias symbols 
together. I made a patch which I commited to mob. It has sha1 a28b18f.

Here is an example to understand the problem:

glibc define 3 symbols with the same address, two of them are WEAK symbols 
which they call aliases since they have the same address that the GLOBAL 
symbol.

environ and _environ are aliases of __environ.

Until now, when tcc was compiling a program using the environ variable, it 
used to only add environ in the .dynsym. The R_ARCH_COPY (R_386_COPY on 
x86_32) relocation was correctly performed at dynamic link time but as 
__environ is initialized to NULL in the glibc, the program had a NULL value in 
its environ copy. When the libc change the value of environ to point to the 
environment, it uses the __environ symbol. As __environ isn't in the .dynsym 
section of the program no relocation was done in the library and thus the 
library was changing its own copy of __environ.

Now, I made tcc add all alias symbols in the .dynsym section so that whatever 
symbol the glibc uses to update environ, it will be done on the program 
environ copy.

Hope I'm clear since my english isn't very good.


By the way, I assumed there isn't lots of object symbols in a typical library 
so that I can iterate on all symbols in dynsymtab_section to find aliases. If 
object symbols aren't that rare, another implementation should be done.

Best regards,

Thomas Preud'homme

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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