This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCHv2] Handle not explicitly zero terminated strings in merge sections
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: Olivier Hainque <hainque at adacore dot com>, "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>, Jeff Law <law at redhat dot com>
- Date: Fri, 14 Sep 2018 21:01:53 +0200
- Subject: Re: [PATCHv2] 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> <AM5PR0701MB2657264E715830F482111033E4220@AM5PR0701MB2657.eurprd07.prod.outlook.com> <AM5PR0701MB2657D5808765EA7B6D463886E4220@AM5PR0701MB2657.eurprd07.prod.outlook.com> <AM5PR0701MB2657D45A93A9A5C51850CC46E4220@AM5PR0701MB2657.eurprd07.prod.outlook.com> <AM5PR0701MB26574579A01C0EA68AEE8C1BE4270@AM5PR0701MB2657.eurprd07.prod.outlook.com> <AM5PR0701MB2657DE146167A258FE79441DE43D0@AM5PR0701MB2657.eurprd07.prod.outlook.com> <VI1PR0701MB286296920A9FB159972A9487E4190@VI1PR0701MB2862.eurprd07.prod.outlook.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Sep 14, 2018 at 06:39:38PM +0000, Bernd Edlinger wrote:
> Hi,
>
> this is an upate of the string-merge section, it is based on the V2-STRING_CST
> semantic patch series, which was finally installed yesterday.
> It merges single-byte string constants with or without terminating NUL.
> The patch has the same Ada and C test cases that were already in the V1 patch.
>
> Thus there are no pre-requisite patches necessary at this time.
>
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
I believe SHF_MERGE | SHF_STRINGS sections should only ever contain
zero-terminated strings.
See e.g. SCO ELF documentation:
"The size of each element is specified in the section header's sh_entsize field. If the SHF_STRINGS flag is also set, the data elements consist of null-terminated character strings."
http://www.sco.com/developers/gabi/2003-12-17/ch4.sheader.html
https://docs.oracle.com/cd/E23824_01/html/819-0690/ggdlu.html
So, please never put non-zero terminated strings into MS sections.
Jakub