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
..
README Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +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 Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
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 * emultempl/ostring.sed: Rename from stringify.sed. 1999-08-06 22:46:03 +00:00
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 Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
cskyelf.em csky bfd.h tidy 2019-09-23 10:27:20 +09:30
elf-generic.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
elf-x86.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
elf.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
epiphanyelf_4x4.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
genelf.em Move elf32.em and elf-generic.em functions 2019-09-11 13:44:22 +09:30
generic.em bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
hppaelf.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
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 bfd_section_* macros 2019-09-19 09:40:13 +09:30
m68kelf.em m68k bfd.h tidy 2019-09-23 10:27:22 +09:30
metagelf.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
mipself.em bfd_section_* macros 2019-09-19 09:40:13 +09:30
mmix-elfnmmo.em bfd_section_* macros 2019-09-19 09:40:13 +09:30
mmixelf.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
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 Move elf32.em and elf-generic.em functions 2019-09-11 13:44:22 +09:30
needrelax.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
netbsd.em Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
nios2elf.em bfd_section_* macros 2019-09-19 09:40:13 +09:30
ostring.sed * emultempl/ostring.sed: Rename from stringify.sed. 1999-08-06 22:46:03 +00:00
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 bfd macro conversion to inline functions 2019-09-20 18:04:02 +09:30
pruelf.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
riscvelf.em Move elf32.em and elf-generic.em functions 2019-09-11 13:44:22 +09:30
rxelf.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
s390.em Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
scoreelf.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
solaris2-x86.em x86: Move x86-specific linker options to elf_linker_x86_params 2019-04-06 07:25:31 -07:00
solaris2.em Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
spu_icache.S bfd/ 2009-03-17 12:46:19 +00:00
spu_icache.o_c Regenerate spu overlay and icache manager files 2014-11-04 22:36:13 +10:30
spu_ovl.S Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
spu_ovl.o_c Regenerate spu_ovl.o_c 2016-10-15 12:53:57 +10:30
spuelf.em Avoid ubsan bug complaining about &p->field 2019-12-26 17:49:03 +10:30
tic6xdsbt.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
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 Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
vxworks.em Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
xtensaelf.em bfd macro conversion to inline functions, section 2019-09-20 18:04:03 +09:30
z80.em Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30

README

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.