binutils-gdb/ld/emultempl
H.J. Lu 3eb33b8875 ld: Improve --fatal-warnings for unknown command-line options
There are 2 problems with --fatal-warnings for unknown command-line
options:

1. --fatal-warnings doesn't trigger an error for an unknown command-line
option when --fatal-warnings is the last command-line option.
2. When --fatal-warnings triggers an error for an unknown command-line
option, the message says that the unknown command-line option is ignored.

This patch queues unknown command-line option warnings and outputs queued
command-line option warnings after all command-line options have been
processed so that --fatal-warnings can work for unknown command-line
options regardless of the order of --fatal-warnings.

When --fatal-warnings is used, the linker message is changed from

ld: warning: -z bad-option ignored

to

ld: error: unsupported option: -z bad-option

The above also applies to "-z dynamic-undefined-weak" when the known
"-z dynamic-undefined-weak" option is ignored.

	PR ld/31289
	* ldelf.c (ldelf_after_parse): Use queue_unknown_cmdline_warning
	to warn the ignored -z dynamic-undefined-weak option.
	* ldmain.c (main): Call output_unknown_cmdline_warnings after
	calling ldemul_after_parse.
	* ldmisc.c (CMDLINE_WARNING_SIZE): New.
	(cmdline_warning_list): Likewise.
	(cmdline_warning_head): Likewise.
	(cmdline_warning_tail): Likewise.
	(queue_unknown_cmdline_warning): Likewise.
	(output_unknown_cmdline_warnings): Likewise.
	* ldmisc.h (queue_unknown_cmdline_warning): Likewise.
	(output_unknown_cmdline_warnings): Likewise.
	* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Use
	queue_unknown_cmdline_warning to warn unknown -z option.
	* testsuite/ld-elf/fatal-warnings-1a.d: New file.
	* testsuite/ld-elf/fatal-warnings-1b.d: Likewise.
	* testsuite/ld-elf/fatal-warnings-2a.d: Likewise.
	* testsuite/ld-elf/fatal-warnings-2b.d: Likewise.
	* testsuite/ld-elf/fatal-warnings-3a.d: Likewise.
	* testsuite/ld-elf/fatal-warnings-3b.d: Likewise.
	* testsuite/ld-elf/fatal-warnings-4a.d: Likewise.
	* testsuite/ld-elf/fatal-warnings-4b.d: Likewise.
2024-01-25 05:42:04 -08:00
..
aarch64elf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
aix.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
alphaelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
arclinux.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
armelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
avrelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
beos.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
bfin.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
cr16elf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
crxelf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
cskyelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
elf-generic.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
elf-x86.em ld: Add --enable-mark-plt configure option 2024-01-09 06:45:38 -08:00
elf.em ld: Improve --fatal-warnings for unknown command-line options 2024-01-25 05:42:04 -08:00
emulation.em ld: Add a before_plugin_all_symbols_read hook 2022-03-09 18:23:43 -08:00
epiphanyelf_4x4.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
genelf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
generic.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
hppaelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
ia64elf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
irix.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
kvxelf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
loongarchelf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
m68hc1xelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
m68kelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
metagelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
mipself.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
mmix-elfnmmo.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
mmixelf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
mmo.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
msp430.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
nds32elf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
needrelax.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
netbsd.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
nios2elf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
nto.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
pdp11.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
pe.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
pep.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
ppc32elf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
ppc64elf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
pruelf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
README Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
riscvelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
rxelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
rxlinux.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
s390.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
scoreelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
solaris2-x86.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
solaris2.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
spu_icache.o_c Regenerate spu overlay and icache manager files 2014-11-04 22:36:13 +10:30
spu_icache.S bfd/ 2009-03-17 12:46:19 +00:00
spu_ovl.o_c Regenerate spu_ovl.o_c 2016-10-15 12:53:57 +10:30
spu_ovl.S Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
spuelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
stringify.sed ld STRINGIFY 2023-08-26 10:57:00 +09:30
tic6xdsbt.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
ticoff.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
v850elf.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
vanilla.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
vms.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
vxworks.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
xtensaelf.em ld: Put all emulation options in ldlex.h 2024-01-19 05:35:16 -08:00
z80.em Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30

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-2024 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.