binutils-gdb/ld/emultempl
Alan Modra 8ce18f9cdf Avoid ubsan bug complaining about &p->field
I reckon it's quite OK to write &p->field in C when p might be NULL,
and lots of old C programmers probably agree with me.  However, ubsan
disagrees and so do some people I respect.  I suspect C++ influence is
to blame for the ubsan behaviour.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92634.  So far no one has
educated me as to why I'm wrong to claim that there isn't anything in
the C standard to say that p->field is always (*p).field.  Note 79
doesn't quite do that because it doesn't cover null pointers.  If
there was such an equivalence then you could claim &p->field has a
null pointer reference when p is NULL, even though no C compiler would
ever dereference p.

Anyway, to silence ubsan I'm going to apply the following though I
prefer to avoid casts when possible.  And I'm using (void *)
deliberately because this is C, not C++!

	* ldlang.c (lang_output_section_find_by_flags): Don't use &p->field
	when p might be NULL.
	* ldelf.c (output_rel_find, ldelf_place_orphan): Likewise.
	(insert_os_after, lang_insert_orphan, lookup_name): Likewise.
	(strip_excluded_output_sections, lang_clear_os_map): Likewise.
	(lang_check, lang_for_each_input_file): Likewise.
	(lang_reset_memory_regions, find_replacements_insert_point): Likewise.
	(find_rescan_insertion, lang_propagate_lma_regions): Likewise.
	(lang_record_phdrs): Likewise.
	* emultempl/alphaelf.em (alpha_after_open): Likewise.
	* emultempl/mmo.em (mmo_place_orphan): Likewise.
	* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
	* emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
	* emultempl/ppc32elf.em (ppc_after_check_relocs): Likewise.
	* emultempl/spuelf.em (spu_before_allocation): Likewise.
	(embedded_spu_file): Likewise.
2019-12-26 17:49:03 +10:30
..
aarch64elf.em aarch64 bfd.h tidy 2019-09-23 10:27:21 +09:30
aix.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
alphaelf.em Avoid ubsan bug complaining about &p->field 2019-12-26 17:49:03 +10:30
arclinux.em
armcoff.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
armelf.em arm bfd.h tidy 2019-09-23 10:27:21 +09:30
astring.sed
avrelf.em Silence a build-time warning about constant comparisons when building with clang, 2019-09-25 14:34:23 +01:00
beos.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
bfin.em bfin bfd.h tidy 2019-09-23 10:27:21 +09:30
cr16elf.em cr16 bfd.h tidy 2019-09-23 10:27:21 +09:30
crxelf.em
cskyelf.em
elf-generic.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
elf-x86.em
elf.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
epiphanyelf_4x4.em
genelf.em
generic.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
hppaelf.em
ia64elf.em ia64 bfd.h tidy 2019-09-23 10:27:21 +09:30
irix.em elf bfd.h tidy 2019-09-23 10:27:22 +09:30
linux.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
m68hc1xelf.em
m68kelf.em m68k bfd.h tidy 2019-09-23 10:27:22 +09:30
metagelf.em
mipself.em
mmix-elfnmmo.em
mmixelf.em
mmo.em Avoid ubsan bug complaining about &p->field 2019-12-26 17:49:03 +10:30
msp430.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
nds32elf.em
needrelax.em
netbsd.em
nios2elf.em
ostring.sed
pe.em Avoid ubsan bug complaining about &p->field 2019-12-26 17:49:03 +10:30
pep.em Avoid ubsan bug complaining about &p->field 2019-12-26 17:49:03 +10:30
ppc32elf.em Avoid ubsan bug complaining about &p->field 2019-12-26 17:49:03 +10:30
ppc64elf.em
pruelf.em
README
riscvelf.em
rxelf.em
s390.em
scoreelf.em
solaris2-x86.em
solaris2.em
spu_icache.o_c
spu_icache.S
spu_ovl.o_c
spu_ovl.S
spuelf.em Avoid ubsan bug complaining about &p->field 2019-12-26 17:49:03 +10:30
tic6xdsbt.em
ticoff.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
v850elf.em v850 bfd.h tidy 2019-09-23 10:27:20 +09:30
vanilla.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
vms.em
vxworks.em
xtensaelf.em
z80.em

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The files in this directory are sourced by genscripts.sh, after
setting some variables to substitute in, to produce
C source files that contain jump tables for each emulation.

Copyright (C) 2012-2019 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.