[PATCH 04/13] libctf, ld: prohibit doing things with forwards prohibited in C
Nick Alcock
nick.alcock@oracle.com
Sun Dec 27 17:43:26 GMT 2020
On 18 Dec 2020, Nick Alcock via Binutils uttered the following:
> C allows you to do only a very few things with entities of incomplete
> type (as opposed to pointers to them): make pointers to them and give
> them cv-quals, roughly. In particular you can't sizeof them and you
> can't get their alignment.
>
> While we explicitly do not impose all the requirements the standard
> imposes on CTF users, and it *is* still desirable to be able to get size
> and alignment info for incomplete array types (because of their use as
> the last member of structures), it is meaningless to ask for the size or
> alignment of forwards. Worse, libctf didn't prohibit this and returned
> nonsense from internal implementation details when you asked (it
> returned the kind of the pointed-to type as both the size and alignment,
> because forwards reuse ctt_type as a type kind, and ctt_type and
> ctt_size overlap). So introduce a new error, ECTF_INCOMPLETE, which is
> returned when you try to get the size or alignment of forwards: we also
> return it when you try to construct CTF dicts that do invalid things
> with forwards, namely adding a forward member to a struct or union or
> making an array of elements of forward type.
... aaand this one is firing on real code. I'll figure out why tomorrow.
I suspect it's falsely firing in the one case C permits, incomplete
array types as the last member of a struct (though I tested this case
and it seemed to work).
More information about the Binutils
mailing list