This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 10/11] ELFv2 ABI: structure passing / return
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 31 Jan 2014 14:09:46 +0400
- Subject: Re: [PATCH 10/11] ELFv2 ABI: structure passing / return
- Authentication-results: sourceware.org; auth=none
- References: <20140129050009 dot GQ4101 at adacore dot com> <201401291814 dot s0TIESsN004668 at d06av02 dot portsmouth dot uk dot ibm dot com>
> So I've chosen those types deliberately :-) In ppc64_aggregate_candidate
> we find *any* aggregate as long as all members are of the same type. It
> is theoretically possible that the number of such members exceed 2G, e.g.
> if the aggregate is a very large array. Thus the obvious return type is
> the type we use for array indices, i.e. LONGEST.
>
> However, in ppc64_elfv2_abi_homogeneous_aggregate we only ever set n_elts
> if the aggregate is one that is to be returned in registers, which means
> that the number of members can never exceed 8. Thus the obvious type of
> n_elts is int.
>
> Note that the cast is guaranteed to be safe, since the value is bounds-
> checked before:
>
> + if (field_count > 0)
> [...]
> + if (field_count * n_regs <= 8)
> [...]
> + *n_elts = (int) field_count;
>
> Given the above, it seems best to me to chose types as I did orignally ...
That is indeed a good explanation. I suggest we re-use your explanation,
or at least the second part of it, to explain why n_elts is an int
and why the cast of field_count down to int is safe. You'll avoid
someone like me, who is tuned to treat all casts as suspicious, from
unmaking your choice :-).
--
Joel