[Bug target/94504] On powerpc, -ffunction-sections -fdata-sections is not as effective as expected for PIE and PIC

amodra at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Apr 13 03:49:37 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94504

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WONTFIX
            Summary|On powerpc,                 |On powerpc,
                   |-ffunction-sections         |-ffunction-sections
                   |-fdata-sections is not as   |-fdata-sections is not as
                   |effective as expected for   |effective as expected for
                   |non-PIE executables.        |PIE and PIC

--- Comment #6 from Alan Modra <amodra at gmail dot com> ---
For -fPIC or -fPIE on ppc32 gcc uses a per-object file compiler managed GOT
(.got2).  Fixed position code doesn't use a GOT.  -fpic/-fpie uses a linker
managed GOT but with limited size.  So, correcting the summary.

The problem reported here is due to the per-object file nature of .got2. (.got2
is similar to the per-object file ppc64 .toc, where compiling the testcase with
-mcmodel=large gives the same link failure.)  To handle -gc-sections properly,
ld needs to treat .got2 specially so that a relocation reference to .got2 does
not mark .got2 but rather the section referenced by the relevant .got2 entry,
and then remove unneeded .got2 entries.  No one has cared enough to write such
linker support for ppc32 or for large code model ppc64 .toc.  Alternatively gcc
code generated for -fPIC/-fPIE could be changed, but again no one has cared
enough to do that.

Since it is very unlikely that a bugzilla entry for gcc or binutils will prompt
anyone to write the necessary linker support or change gcc, I'm closing this as
won't fix.


More information about the Gcc-bugs mailing list