Switch to a new section if the SECTION_RETAIN bit doesn't match
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 3 Dec 2020 19:01:06 +0000 (11:01 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 16 Dec 2020 13:40:57 +0000 (05:40 -0800)
commit6175383249143309fdc780a02bea484f4450def7
tree8a91ba4ed7888a01e7748bf51d5058126d41e210
parentab9bd93271061f436c10e35e261ecb73e2108ccc
Switch to a new section if the SECTION_RETAIN bit doesn't match

When definitions marked with used attribute and unmarked definitions are
placed in the section with the same name, switch to a new section if the
SECTION_RETAIN bit doesn't match.

gcc/

PR target/98146
* output.h (switch_to_section): Add a tree argument, default to
nullptr.
* varasm.c (get_section): If the SECTION_RETAIN bit doesn't match,
return and switch to a new section later.
(assemble_start_function): Pass decl to switch_to_section.
(assemble_variable): Likewise.
(switch_to_section): If the SECTION_RETAIN bit doesn't match,
switch to a new section.

gcc/testsuite/

PR target/98146
* c-c++-common/attr-used-5.c: New test.
* c-c++-common/attr-used-6.c: Likewise.
* c-c++-common/attr-used-7.c: Likewise.
* c-c++-common/attr-used-8.c: Likewise.
* c-c++-common/attr-used-9.c: Likewise.
gcc/output.h
gcc/testsuite/c-c++-common/attr-used-5.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/attr-used-6.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/attr-used-7.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/attr-used-8.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/attr-used-9.c [new file with mode: 0644]
gcc/varasm.c