binutils-gdb/ld/testsuite
Nick Alcock ffeece6ac2 libctf, ld: prohibit getting the size or alignment of forwards
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.

We cannot impose all the requirements the standard imposes on CTF users,
because the deduplicator can transform any structure type into a forward
for the purposes of breaking cycles: so CTF type graphs can easily
contain things like arrays of forward type (if you want to figure out
their size or alignment, you need to chase down the types this forward
might be a forward to in child TU dicts: we will soon add API functions
to make doing this much easier).

Nonetheless, it is still meaningless to ask for the size or alignment of
forwards: but 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 do things that require libctf itself to get the size or alignment of
a forward, notably using a forward as an array index type (which C
should never do in any case) or adding forwards to structures without
specifying their offset explicitly.

The dumper will not emit size or alignment info for forwards any more.

(This should not be an API break since ctf_type_size and ctf_type_align
could both return errors before now: any code that isn't expecting error
returns is already potentially broken.)

include/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-api.h (ECTF_INCOMPLETE): New.
	(ECTF_NERR): Adjust.

ld/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Adjust for dumper
	changes.
	* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
	* testsuite/ld-ctf/forward.c: New test...
	* testsuite/ld-ctf/forward.d: ... and results.

libctf/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-types.c (ctf_type_resolve): Improve comment.
	(ctf_type_size): Yield ECTF_INCOMPLETE when applied to forwards.
	Emit errors into the right dict.
	(ctf_type_align): Likewise.
	* ctf-create.c (ctf_add_member_offset): Yield ECTF_INCOMPLETE
	when adding a member without explicit offset when this member, or
	the previous member, is incomplete.
	* ctf-dump.c (ctf_dump_format_type): Do not try to print the size of
	forwards.
	(ctf_dump_member): Do not try to print their alignment.
2021-01-05 14:53:39 +00:00
..
config Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-aarch64 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-alpha Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-arc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-arm PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
ld-auto-import Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-avr Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-bootstrap Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-bpf Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-cdtest Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-checks Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-cris Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-crx Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-csky CSKY: Change default linker script for elf toolchain. 2020-10-26 17:13:21 +08:00
ld-ctf libctf, ld: prohibit getting the size or alignment of forwards 2021-01-05 14:53:39 +00:00
ld-cygwin Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-d10v Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-discard Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-dynamic Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-elf Re: elf: Allow mixed ordered/unordered inputs for non-relocatable link 2021-01-05 15:47:06 +10:30
ld-elfcomm Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-elfvers Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-elfvsb Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-elfweak Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-fastcall Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-frv Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-gc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-h8300 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-i386 PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
ld-ia64 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-ifunc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-libs Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-linkonce Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-m68hc11 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-m68k Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-mep Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-metag Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-mips-elf PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
ld-misc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-mmix Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-mn10300 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-msp430-elf Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-nds32 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-nios2
ld-or1k Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-pdp11 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-pe Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-pie Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-plugin PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
ld-powerpc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-pru
ld-riscv-elf Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-s12z Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-s390 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-scripts ld sysroot-prefix test fails 2021-01-05 23:09:05 +10:30
ld-selective Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-sh Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-shared Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-size Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-sparc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-spu Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-srec Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-tic6x PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
ld-tilegx Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-tilepro Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-undefined Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-unique Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-v850 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-vax-elf Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-visium Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-vxworks Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-x86-64 PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
ld-xc16x Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-xstormy16 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-xtensa PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
ld-z8k Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ld-z80 Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
lib Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-9303