Re: [Tinycc-devel] Problem with NOTE commit

2020-12-24 Thread Michael Matz

Hello,

On Thu, 24 Dec 2020, Herman ten Brugge via Tinycc-devel wrote:

The recent commit 'ELF: include SHT_NOTE sections everywhere' does not work 
for me on x86_64.


The problem is in /usr/lib64/crt1.o
If I do: readelf -a -W /usr/lib64/crt1.o | grep .gnu.build.attributes.hot
I get:
  [64] .gnu.build.attributes.hot NOTE     0002e0 
28 00   G  0   0  4
  [65] .rela.gnu.build.attributes.hot RELA  001b38 30 18  
IG 90  64  8
  [72] .gnu.build.attributes.hot NOTE     000380 
28 00   G  0   0  4
  [73] .rela.gnu.build.attributes.hot RELA  001bf8 30 18  
IG 90  72  8
  [80] .gnu.build.attributes.hot NOTE     000420 
28 00   G  0   0  4
  [81] .rela.gnu.build.attributes.hot RELA  001cb8 30 18  
IG 90  80  8

   [   64]   .gnu.build.attributes.hot
   [   65]   .rela.gnu.build.attributes.hot
   [   72]   .gnu.build.attributes.hot
   [   73]   .rela.gnu.build.attributes.hot
   [   80]   .gnu.build.attributes.hot
   [   81]   .rela.gnu.build.attributes.hot


Huh, so multiple same-named sections in an .o file.  Somewhat unusual, but 
the above are all in section groups, so a supported scenario (in the ELF 
sense, not by TCC).  Can you send my your crt1.o file, please?


The tcc_load_object_file tries to merge the sections and then adjust the 
reloads. This does not work in this case because there are 3 section 
with the same name.


A hack would be to accept NOTE sections but only if they aren't in groups. 
Ugly, but, well...   Of course, correctly implementing ELF group support 
would also be an option, but more work, or maybe other hacks are possible. 
I'll take a look if I can get such crt file.



Ciao,
Michael.___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] Problem with NOTE commit

2020-12-24 Thread Herman ten Brugge via Tinycc-devel
The recent commit 'ELF: include SHT_NOTE sections everywhere' does not 
work for me on x86_64.


The problem is in /usr/lib64/crt1.o
If I do: readelf -a -W /usr/lib64/crt1.o | grep .gnu.build.attributes.hot
I get:
  [64] .gnu.build.attributes.hot NOTE     
0002e0 28 00   G  0   0  4
  [65] .rela.gnu.build.attributes.hot RELA  001b38 
30 18  IG 90  64  8
  [72] .gnu.build.attributes.hot NOTE     
000380 28 00   G  0   0  4
  [73] .rela.gnu.build.attributes.hot RELA  001bf8 
30 18  IG 90  72  8
  [80] .gnu.build.attributes.hot NOTE     
000420 28 00   G  0   0  4
  [81] .rela.gnu.build.attributes.hot RELA  001cb8 
30 18  IG 90  80  8

   [   64]   .gnu.build.attributes.hot
   [   65]   .rela.gnu.build.attributes.hot
   [   72]   .gnu.build.attributes.hot
   [   73]   .rela.gnu.build.attributes.hot
   [   80]   .gnu.build.attributes.hot
   [   81]   .rela.gnu.build.attributes.hot

The tcc_load_object_file tries to merge the sections and then adjust the 
reloads.
This does not work in this case because there are 3 section with the 
same name.


The result is that memtest aborts with:
 memtest 
free(): invalid next size (normal)
make[2]: *** [Makefile:182: memtest] Aborted (core dumped)
make[1]: *** [Makefile:89: all] Error 2
make[1]: Leaving directory '/home/herman/tcc_git/tinycc.tst/tests'
make: *** [Makefile:404: test] Error 2

If I revert the change everything works as normal.

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel