This is the mail archive of the
mailing list for the GCC project.
[PATCH] Handle not explicitly zero terminated strings in merge sections
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: Olivier Hainque <hainque at adacore dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Richard Biener <rguenther at suse dot de>, Eric Botcazou <ebotcazou at adacore dot com>, Arnaud Charlet <charlet at adacore dot com>, Jakub Jelinek <jakub at redhat dot com>
- Date: Sat, 4 Aug 2018 15:43:04 +0000
- Subject: [PATCH] Handle not explicitly zero terminated strings in merge sections
- References: <AM5PR0701MB2657F9BAF49A613759D90D13E42E0@AM5PR0701MB2657.eurprd07.prod.outlook.com> <7D840828-B2C9-4C20-BFE9-57249E324ED3@adacore.com> <AM5PR0701MB265712E733498503B2AE5F6AE4220@AM5PR0701MB2657.eurprd07.prod.outlook.com>
This patch is inspired by Olivier's feedback to my previous patch on the
zero-termination of Ada STRING_CST.
The idea is that strings that do not have embedded nul characters _and_
do not happen to be zero-terminated in the DECL_UNIT_SIZE, are currently
not in the merge string sections. To be in the merge string section
they need a terminating nul character, that gets written directly
in varasm while assembling the string constant. This patch uses
the new string properties that my previous patch series implements,
and is based on the other patches here:
[PATCH] Check the STRING_CSTs in varasm.c
[PATCH] Handle overlength strings in the C FE
[PATCH] Handle overlength strings in C++ FE
[PATCH] Make GO string literals properly NUL terminated
[PATCH] [Ada] Make middle-end string literals NUL terminated
The existing test case gcc.dg/merge-all-constants-1.c
contains two overlength strings that get now stripped down
by the C FE, and look in the middle end exactly like normal
Ada, Fortran or Go strings. And get now allocated
in the merge.str section, unless they have an embedded
nul character, which I changed to make the test pass again.
Olivier, could you add test cases from the Ada side to this?
Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk (after all pre-condition patches