https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123846
Bug ID: 123846
Summary: mips(el): incorrect symbol .size emitted for struct
containing VLA
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: equinox-gccbugs at diac24 dot net
Target Milestone: ---
mipsel-*-gcc emits an incorrect symbol size for a struct with a VLA at the end
with initializers. Minimal testcase:
/******/
struct foo {
int a;
int b[];
} foovar = {
.a = 1,
.b = { 2, 3, 4, },
};
/******/
Assembling with mipsel-linux-gnu-gcc (Gentoo build of current HEAD ==
54c716b6fce2) results in:
/******/
.file 1 "tc.c"
.section .mdebug.abi32
.previous
.nan legacy
.module fp=32
.module nooddspreg
.module arch=mips1
.abicalls
.text
.globl foovar
.data
.align 2
.type foovar, @object
.size foovar, 4
foovar:
.word 1
.word 2
.word 3
.word 4
.ident "GCC: (Gentoo Hardened 16.0.9999 p, commit
54c716b6fce290b84871acc99da8dd8d28392069) 16.0.1 20260127 (experimental)
fe050fa9d1249a7a528a30a499d1abc23f47f2c8"
.section .note.GNU-stack,"",@progbits
/******/
meanwhile the other architectures I had at hand compile it correctly:
$ grep size *.S
aarch64-linux-gnu-tc.S: .size foovar, 16
arm-linux-gnueabihf-tc.S: .size foovar, 16
mipsel-linux-gnu-tc.S: .size foovar, 4
powerpc64-linux-gnu-tc.S: .size foovar, 16
powerpc-linux-gnu-tc.S: .size foovar, 16
x86_64-pc-linux-gnu-tc.S: .size foovar, 16
Note the data itself is actually output even on mipsel, so it works "most of
the time". But with a shared library, the incorrect size results in crashes
when the linker creates a copy relocation for such a symbol, truncating it in
the process.