[Bug target/92499] nios2 backend needs to consider allocated object size, not C object size for gprel optimization

sandra at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 3 03:06:00 GMT 2019


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

--- Comment #11 from sandra at gcc dot gnu.org ---
I've committed a patch to fix this for nios2 only to mainline and the GCC 9
branch.

I did consider an alternate 1-line fix to target-independent code:

Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c        (revision 278907)
+++ gcc/varasm.c        (working copy)
@@ -1201,6 +1201,7 @@ get_variable_section (tree decl, bool pr

   if (ADDR_SPACE_GENERIC_P (as)
       && !DECL_THREAD_LOCAL_P (decl)
+      && !targetm.in_small_data_p (decl)
       && !(prefer_noswitch_p && targetm.have_switchable_bss_sections)
       && bss_initializer_p (decl))
     {

but I am not 100% sure this will DTRT on other affected targets.  On anything
that uses default_elf_select_section this will put zero-initialized data in
.sbss if targetm.in_small_data_p is true, but is that actually where it's
supposed to go?  E.g., are the linker scripts set up to cope with .sbss instead
of whatever lcomm_section maps to?  I think I have to defer to the other target
maintainers for what is right for their respective back ends.  :-S


More information about the Gcc-bugs mailing list