mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
3eb33b8875
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.
44 lines
1.5 KiB
C
44 lines
1.5 KiB
C
/* ldmisc.h -
|
|
Copyright (C) 1991-2024 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU Binutils.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
MA 02110-1301, USA. */
|
|
|
|
#ifndef LDMISC_H
|
|
#define LDMISC_H
|
|
|
|
extern void vfinfo (FILE *fp, const char *fmt, va_list arg, bool is_warning);
|
|
extern void einfo (const char *, ...);
|
|
extern void minfo (const char *, ...);
|
|
extern void info_msg (const char *, ...);
|
|
extern void lfinfo (FILE *, const char *, ...);
|
|
extern void info_assert (const char *, unsigned int);
|
|
extern void queue_unknown_cmdline_warning (const char *, ...);
|
|
extern void output_unknown_cmdline_warnings (void);
|
|
|
|
#define ASSERT(x) \
|
|
do { if (!(x)) info_assert(__FILE__,__LINE__); } while (0)
|
|
|
|
#define FAIL() \
|
|
do { info_assert(__FILE__,__LINE__); } while (0)
|
|
|
|
extern void print_spaces (int);
|
|
#define print_space() print_spaces (1)
|
|
extern void print_nl (void);
|
|
|
|
#endif
|