Like r0-46282-gf41115930523b3, but this time for normal variables
rather than the constant pool.
With the simple C++ code on ia32:
```
std::initializer_list<long double> a = {0.3l};
```
GCC currently produces:
```
.section .rodata.cst16,"aM",@progbits,16
.align 16
.type _ZGR1a_, @object
.size _ZGR1a_, 12
_ZGR1a_:
.long -1717986918
.long -1717986919
.long 16381
.text
```
Notice how the mereable section is not being aligned at the end to
16 bytes.
This was exactly the same issue as reported in
https://sourceware.org/legacy-ml/binutils/2002-11/msg00615.html
except this time for DECLs which mergeable rather than the constant pool
(which was fixed by r0-46282-gf41115930523b3).
So we need to ensure the variables in mergable sections are filed
correctly for the rest of the section.
Note this showed up more with gcn after r16-2595-gf1c80147641783 since
more decls are done in mergable sections without the same size as the
alignment.
Bootstrapped and tested on x86_64-linux-gnu.
PR middle-end/121394
gcc/ChangeLog:
* varasm.cc (assemble_variable_contents): Ensure mergeable sections
get padded for each decl.
Signed-off-by: Andrew Pinski <[email protected]>
---
gcc/varasm.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 000ad9e26f6..7b04b82c1a5 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -2475,6 +2475,12 @@ assemble_variable_contents (tree decl, const char *name,
else
/* Leave space for it. */
assemble_zeros (tree_to_uhwi (DECL_SIZE_UNIT (decl)));
+ /* Make sure all decls in SECTION_MERGE sections have proper size. */
+ if (in_section
+ && (in_section->common.flags & SECTION_MERGE)
+ && tree_fits_uhwi_p (DECL_SIZE (decl))
+ && DECL_ALIGN (decl) > tree_to_uhwi (DECL_SIZE (decl)))
+ assemble_align (DECL_ALIGN (decl));
targetm.asm_out.decl_end ();
}
}
--
2.43.0