tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Static Link SegFault Investigation for tcc-0.9.27 (tcc27)


From: Kurt Nalty
Subject: [Tinycc-devel] Static Link SegFault Investigation for tcc-0.9.27 (tcc27)
Date: Fri, 4 Jan 2019 00:02:07 +0000

Greetings,

I have spent some time investigating static link problems with tcc-0.9.27 
(hereafter called tcc27),
and wanted to report my findings.

My test system is x86_64-uClibc-linux-gnu, uClibc 0.9.30.1, with shared and 
static libraries.
I have three release versions of tcc, statically linked, using the same 
configuration, uClibc libraries
and headers, and the same /usr/lib/tcc/libtcc1.a. Dynamic linking works fine in 
all three
environments. Static linking works fine for tcc25 and tcc26, but segfaults on 
load for tcc27.

My initial fear was that static linking was terribly messed up, but having 
tcc27 statically link
object files created by earlier versions worked fine, indicating that the 
problem may be a simpler
change in object file formats. 

Comparing object files produced by gcc-4.6.4, tcc25, tcc26, and tcc27 shows the 
new object files
are 40 bytes smaller than previous versions. "Readelf -a" did not show anything 
alarming, 
and interestingly enough, gcc, tcc25 and tcc26 correctly statically link 
everyone's object file,
and tcc27 correctly links every object file, excepting its own.
   

~ # gcc -c hello.c -o hello.gcc.o
~ # tcc25 -c hello.c -o hello.t25.o
~ # tcc26 -c hello.c -o hello.t26.o
~ # tcc27 -c hello.c -o hello.t27.o
~ # ls -al *.o
-rw-r--r--    1 root     root          1472 Jan  3 22:32 hello.gcc.o
-rw-r--r--    1 root     root           924 Jan  3 22:32 hello.t25.o
-rw-r--r--    1 root     root           924 Jan  3 22:32 hello.t26.o
-rw-r--r--    1 root     root           884 Jan  3 22:33 hello.t27.o

~ # gcc -static hello.gcc.o
~ # ./a.out
Hello World!
~ # gcc -static hello.t25.o
~ # ./a.out
Hello World!
~ # gcc -static hello.t26.o
~ # ./a.out
Hello World!
~ # gcc -static hello.t27.o
~ # ./a.out
Hello World!

Conclusion: sizes differ, but gcc can statically link all four files

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

~ # tcc25 -vv                                     ~ # tcc26 -vv                 
                    ~ # tcc27 -vv
tcc version 0.9.25                                tcc version 0.9.26 (x86-64 
Linux)                 tcc version 0.9.27 (x86_64 Linux)

~ # tcc25 -static hello.gcc.o                     ~ # tcc26 -static hello.gcc.o 
                    ~ # tcc27 -static hello.gcc.o
~ # ./a.out                                       ~ # ./a.out                   
                    ~ # ./a.out
Hello World!                                      Hello World!                  
                    Hello World!
~ # tcc25 -static hello.t25.o                     ~ # tcc26 -static hello.t25.o 
                    ~ # tcc27 -static hello.t25.o
~ # ./a.out                                       ~ # ./a.out                   
                    ~ # ./a.out
Hello World!                                      Hello World!                  
                    Hello World!
~ # tcc25 -static hello.t26.o                     ~ # tcc26 -static hello.t26.o 
                    ~ # tcc27 -static hello.t26.o
~ # ./a.out                                       ~ # ./a.out                   
                    ~ # ./a.out
Hello World!                                      Hello World!                  
                    Hello World!
~ # tcc25 -static hello.t27.o                     ~ # tcc26 -static hello.t27.o 
                    ~ # tcc27 -static hello.t27.o
~ # ./a.out                                       ~ # ./a.out                   
                    ~ # ./a.out
Hello World!                                      Hello World!                  
                    Segmentation fault


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

Conclusion:

Static linking is only broken when tcc27 links one of tcc27 produced object 
files.
Easy fix is to identify the missing 40 bytes (cluster of 24 and cluster of 16) 
and put them back in.
Better and correct fix is to identify what is confusing tcc27 with these object 
files, as they are 
valid for dynamic linking and other static linkers.



reply via email to

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