This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Commit: Use of alloca considered dangerous
- From: Andrew Cagney <cagney at gnu dot org>
- To: Alan Modra <amodra at gmail dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, Paul Koning <Paul_Koning at dell dot com>, Nick Clifton <nickc at redhat dot com>, Binutils <binutils at sourceware dot org>
- Date: Wed, 23 Mar 2016 09:53:42 -0400
- Subject: Re: Commit: Use of alloca considered dangerous
- Authentication-results: sourceware.org; auth=none
- References: <87mvprx079 dot fsf at redhat dot com> <B1F8A0EC-9D4D-459E-899A-5638E2CCE924 at dell dot com> <CAMe9rOrTuKJmk5F0Hvban2_dq2gqSxdYp+GLR6Cnb3hV6zymHA at mail dot gmail dot com> <20160322035708 dot GR22605 at bubble dot grove dot modra dot org>
On 21 March 2016 at 23:57, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Mar 21, 2016 at 11:01:36AM -0700, H.J. Lu wrote:
>> It caused:
>>
>> https://sourceware.org/bugzilla/show_bug.cgi?id=19851
>
> Let's avoid the warning then.
>
> diff --git a/bfd/ChangeLog b/bfd/ChangeLog
> index 43c9c28..ffafbf6 100644
> --- a/bfd/ChangeLog
> +++ b/bfd/ChangeLog
> @@ -1,3 +1,8 @@
> +2016-03-22 Alan Modra <amodra@gmail.com>
> +
> + PR 19851
> + * plugin.c (try_load_plugin): Avoid -Wstack-usage warning.
> +
> 2016-03-21 Andrew Burgess <andrew.burgess@embecosm.com>
>
> * archures.c (bfd_mach_arc_nps400): Define.
> diff --git a/bfd/plugin.c b/bfd/plugin.c
> index 82a87d6..f57833c 100644
> --- a/bfd/plugin.c
> +++ b/bfd/plugin.c
> @@ -206,8 +206,7 @@ static int
> try_load_plugin (const char *pname, bfd *abfd, int *has_plugin_p)
> {
> void *plugin_handle;
> - int tv_size = 4;
> - struct ld_plugin_tv tv[tv_size];
Yea, a variable-length array. While, thanks to nuanced C, this isn't:
#define TV_SIZE
struct ld_plugin_tv tv[TV_SIZE];
For instance, http://mail-index.netbsd.org/tech-kern/2016/01/12/msg019991.html
> + struct ld_plugin_tv tv[4];
If the objective really is to out do each others paranoia then,
perhaps, references to tv_size should be replaced by sizeof(tv)?
Oh, wait, never mind, tv_size isn't even used ... :-)
> int i;
> ld_plugin_onload onload;
> enum ld_plugin_status status;
>
> --
> Alan Modra
> Australia Development Lab, IBM