diff options
author | Alex Coplan <alex.coplan@arm.com> | 2022-12-01 17:36:02 +0000 |
---|---|---|
committer | Alex Coplan <alex.coplan@arm.com> | 2022-12-01 17:36:02 +0000 |
commit | de144fdab17dbbb64ccb540056ab78b4ffb3fbbc (patch) | |
tree | 4c2aa990111d8064fe8f4d3dbfc8d27d1f92a769 /gcc/tree-ssa-loop-unswitch.cc | |
parent | a5354dafb30cb13a3fbdf731ccea61ca51f406b1 (diff) | |
download | gcc-de144fdab17dbbb64ccb540056ab78b4ffb3fbbc.zip gcc-de144fdab17dbbb64ccb540056ab78b4ffb3fbbc.tar.gz gcc-de144fdab17dbbb64ccb540056ab78b4ffb3fbbc.tar.bz2 |
varasm: Fix type confusion bug
This patch fixes a type confusion bug in varasm.cc:assemble_variable.
The problem is that the current code calls:
sect = get_variable_section (decl, false);
and then accesses sect->named.name without checking whether the section
is in fact a named section. In the surrounding else clause, we only know
that SECTION_STYLE (sect) != SECTION_NOSWITCH, so it is possible that
the section is an unnamed section.
In practice, this means that we end up doing a wild string compare
between a function pointer and the string literal ".vtable_map_vars".
This is because sect->named.name aliases sect->unnamed.callback in the
section union.
This can be seen in GDB with a simple testcase such as "int x;".
This patch fixes the issue by checking the SECTION_STYLE of the section
is in fact SECTION_NAMED before trying to do the string comparison.
We drop the existing check of whether sect->named.name is non-NULL
because this should presumably always be the case for a named section.
gcc/ChangeLog:
* varasm.cc (assemble_variable): Fix type confusion bug when
checking for ".vtable_map_vars" section.
Diffstat (limited to 'gcc/tree-ssa-loop-unswitch.cc')
0 files changed, 0 insertions, 0 deletions