Problem with NOTE commit

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with NOTE commit

tinycc-devel mailing list
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            0000000000000000
0002e0 000028 00   G  0   0  4
   [65] .rela.gnu.build.attributes.hot RELA 0000000000000000 001b38
000030 18  IG 90  64  8
   [72] .gnu.build.attributes.hot NOTE            0000000000000000
000380 000028 00   G  0   0  4
   [73] .rela.gnu.build.attributes.hot RELA 0000000000000000 001bf8
000030 18  IG 90  72  8
   [80] .gnu.build.attributes.hot NOTE            0000000000000000
000420 000028 00   G  0   0  4
   [81] .rela.gnu.build.attributes.hot RELA 0000000000000000 001cb8
000030 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
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with NOTE commit

Michael Matz-4
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            0000000000000000 0002e0
> 000028 00   G  0   0  4
>   [65] .rela.gnu.build.attributes.hot RELA 0000000000000000 001b38 000030 18 
> IG 90  64  8
>   [72] .gnu.build.attributes.hot NOTE            0000000000000000 000380
> 000028 00   G  0   0  4
>   [73] .rela.gnu.build.attributes.hot RELA 0000000000000000 001bf8 000030 18 
> IG 90  72  8
>   [80] .gnu.build.attributes.hot NOTE            0000000000000000 000420
> 000028 00   G  0   0  4
>   [81] .rela.gnu.build.attributes.hot RELA 0000000000000000 001cb8 000030 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
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel