Warn used and not used symbols in section with the same name
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 3 Dec 2020 23:39:59 +0000 (15:39 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 16 Dec 2020 13:40:57 +0000 (05:40 -0800)
commit2a976020603589e897fcfa3276590ef50b489d34
tree909ff9b5f5bd0e29304015e097ad0b6d79144c8c
parent6175383249143309fdc780a02bea484f4450def7
Warn used and not used symbols in section with the same name

When SECTION_RETAIN is used, issue a warning when a symbol without used
attribute and a symbol with used attribute are placed in the section with
the same name, like

int __attribute__((used,section(".data.foo"))) foo2 = 2;
int __attribute__((section(".data.foo"))) foo1 = 1;

since assembler will put them in different sections with the same section
name.

gcc/

PR target/98146
* varasm.c (switch_to_section): Warn when a symbol without used
attribute and a symbol with used attribute are placed in the
section with the same name.

gcc/testsuite/

PR target/98146
* c-c++-common/attr-used-5.c: Updated.
* c-c++-common/attr-used-6.c: Likewise.
* c-c++-common/attr-used-7.c: Likewise.
* c-c++-common/attr-used-8.c: Likewise.
gcc/testsuite/c-c++-common/attr-used-5.c
gcc/testsuite/c-c++-common/attr-used-6.c
gcc/testsuite/c-c++-common/attr-used-7.c
gcc/testsuite/c-c++-common/attr-used-8.c
gcc/varasm.c