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: Jeff Law <law at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>, 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>, Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- Date: Wed, 10 Oct 2018 11:58:51 -0600
- 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> <7612b837-b314-638a-58c4-7e5243f6bf28@redhat.com> <VI1PR0701MB28623F9C616130E9E01DF992E4E70@VI1PR0701MB2862.eurprd07.prod.outlook.com>
On 10/9/18 6:45 AM, Bernd Edlinger wrote:
> On 10/03/18 18:31, Jeff Law wrote:
>>> - && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
>>> - && TREE_STRING_LENGTH (decl) >= len)
>>> + && (len = int_size_in_bytes (TREE_TYPE (decl))) >= 0
>>> + && TREE_STRING_LENGTH (decl) == len)
>> Not sure why you want to test for >= 0 here. > 0 seems sufficient,
>> though I guess there's no harm in the = 0 case.
>>
>
> Aehm, cough...
>
> Sorry Jeff, I need to change that back. It turns out that
> completely empty strings don't work right, because of this
> check in output_constant:
>
> output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
> bool reverse, bool merge_strings)
> {
> enum tree_code code;
> unsigned HOST_WIDE_INT thissize;
> rtx cst;
>
> if (size == 0 || flag_syntax_only)
> return size;
>
> So while my intention was to add a null-termination for all strings, including empty ones,
> this does not work for empty strings, which was diagnosed by the solaris assembler/linker.
>
> However since those empty strings do not use any space, there is no improvement
> by merging them in the first place.
>
>
> Rainer bootstrapped the attached patch successfully.
> Is it OK for trunk?
OK. Funny I almost called out the zero size stuff as being pointless to
bother handling in the first place. Oh well.
Jeff