tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] TCC Static Link - Section Header Offsets


From: Kurt Nalty
Subject: [Tinycc-devel] TCC Static Link - Section Header Offsets
Date: Mon, 7 Jan 2019 08:28:17 +0000

I am investigating 'tcc27 -static' segfaults on x86_64. I had earlier reported 
(in error) that changing the 
ELF_START_ADDR and ELF_PAGE_SIZE fixed compile errors using uClibc-0.9.30. 
Michael Matz pointed out (correctly)
that this change should have no effect, and that deeper investigation was 
needed. Rechecking my work, I found 
that tcc27 was still broken, with regard to static linking, and my false 
positive claim was due to forgetting
the -static switch  in my (excited) testing. 

I am currently looking at tcc27 side by side static linking of hello27.o, 
produced by tcc27, and hello26.o, produced by tcc26.
I find that the entry point address is off by sixteen bytex in tcc27

Entry point address:               0x80480c0       (works, tcc26 object file)   
                                              
Entry point address:               0x80480b0       (crashed, tcc27 object file)

Examining tccelf.c, we see the calculation of the entry point address involving 
s->sh_addralign

------------------------------------
~/tcc-0.9.27 # ./tcc -static hello26.o -o hello26
Kurt Nalty -debug - addr =  8048000 (expect 08048000)
Kurt Nalty -debug - file_offset =       B0
Kurt Nalty -debug - (s_align - 1) =      FFF

kn - looks like alignment may be the issue
s->sh_addralign =       20
(s->sh_addralign - 1) =       1f
~(s->sh_addralign - 1) = ffffffe0
(addr + s->sh_addralign - 1) =  80480cf
kn debug - looks like address update - addr =  80480c0 (works as expected)

--------------------------------------

~/tcc-0.9.27 # ./tcc -static hello27.o -o hello27
Kurt Nalty -debug - addr =  8048000 (expect 08048000)
Kurt Nalty -debug - file_offset =       B0
Kurt Nalty -debug - (s_align - 1) =      FFF

kn - looks like alignment may be the issue
s->sh_addralign =       10  <------------- I am tracking where this value came 
from
(s->sh_addralign - 1) =        f
~(s->sh_addralign - 1) = fffffff0
(addr + s->sh_addralign - 1) =  80480bf
kn debug - looks like address update - addr =  80480b0 (crash on launch)

-------------------------------------

In the object files, we see different alignments between tcc26 (32) and tcc27 
(8)


My current task is auditing and comparing the section head alignment from 
object file creation
to final static link. I hope to report positive results soon.


 



reply via email to

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