On Fri, Dec 4, 2020 at 4:17 AM Jozef Lawrynowicz <joze...@mittosystems.com> wrote: > > On Thu, Dec 03, 2020 at 04:06:50PM -0800, H.J. Lu via Gcc-patches wrote: > > When SECTION_RETAIN is used, definitions marked with used attribute and > > unmarked definitions are placed in the same section. Instead of issue > > an error: > > > > [hjl@gnu-cfl-2 gcc]$ /usr/gcc-11.0.0-x32/bin/gcc -S c.c > > -fdiagnostics-plain-output > > c.c:2:49: error: ‘foo1’ causes a section type conflict with ‘foo2’ > > c.c:1:54: note: ‘foo2’ was declared here > > [hjl@gnu-cfl-2 gcc]$ > > > > the first patch switches to a new section if the SECTION_RETAIN bit > > doesn't match. The second optional patch issues a warning: > > > > [hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S c.c -fdiagnostics-plain-output > > c.c:2:49: warning: ‘foo1’ without ‘used’ attribute is placed in a section > > with ‘foo2’ with ‘used’ attribute [-Wattributes] > > [hjl@gnu-cfl-2 gcc]$ > > I think the warning is useful, since we are modifying the structure of > the object file where the user may not expect it. It ensures they review > which declarations have "used" applied so they don't unexpectedly lose > parts of their program they wanted to keep by putting them in a > section that was marked "used" elsewhere.
I agree. > > > > H.J. Lu (2): > > Switch to a new section if the SECTION_RETAIN bit doesn't match > > Warn used and not used symbols in the same section > > We should probably use a new PR to associate with these patches, rather > than PR/98121. > > Your changes here address the issue exposed by glibc code, whilst 98121 > was for the broader issue of whether "used" should apply SHF_GNU_RETAIN. > > Let me know if you agree, and I'll create a new GCC PR for the specific Please do. > issue that was exposed by glibc. We should then mark 98121 as > resolved/rejected, since we are not changing whether "used" applies > SHF_GNU_RETAIN. > Thanks. -- H.J.