]> git.ipfire.org Git - thirdparty/gcc.git/commit
varasm: Handle private COMDAT function symbol reference in readonly data section...
authorJakub Jelinek <jakub@redhat.com>
Mon, 26 Feb 2024 16:55:07 +0000 (17:55 +0100)
committerJakub Jelinek <jakub@redhat.com>
Mon, 26 Feb 2024 16:55:07 +0000 (17:55 +0100)
commit1931c40364bb9fb0a7c4b650917e3ac0e88bf6f4
tree07bd9c137f76ae5287cbbb01e3a8e4c7c3d12595
parent77576915cfd26e603aba5295dfdac54a5545f5f2
varasm: Handle private COMDAT function symbol reference in readonly data section [PR113617]

If default_elf_select_rtx_section is called to put a reference to some
local symbol defined in a comdat section into memory, which happens more often
since the r14-4944 RA change, linking might fail.
default_elf_select_rtx_section puts such constants into .data.rel.ro.local
etc. sections and if linker chooses comdat sections from some other TU
and discards the one to which a relocation in .data.rel.ro.local remains,
linker diagnoses error.  References to private comdat symbols can only appear
from functions or data objects in the same comdat group, so the following
patch arranges using .data.rel.ro.local.pool.<comdat_name> and similar sections.

2024-02-26  Jakub Jelinek  <jakub@redhat.com>
    H.J. Lu  <hjl.tools@gmail.com>

PR rtl-optimization/113617
* varasm.cc (default_elf_select_rtx_section): For
references to private symbols in comdat sections
use .data.relro.local.pool.<comdat>, .data.relro.pool.<comdat>
or .rodata.<comdat> comdat sections.

* g++.dg/other/pr113617.C: New test.
* g++.dg/other/pr113617.h: New test.
* g++.dg/other/pr113617-aux.cc: New test.
gcc/testsuite/g++.dg/other/pr113617-aux.cc [new file with mode: 0644]
gcc/testsuite/g++.dg/other/pr113617.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/pr113617.h [new file with mode: 0644]
gcc/varasm.cc