[PATCH] ld: Improve --fatal-warnings for unknown command-line options
Jan Beulich
jbeulich@suse.com
Thu Jan 25 08:24:21 GMT 2024
On 25.01.2024 08:58, Fangrui Song wrote:
> On Wed, Jan 24, 2024 at 2:51 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> There are 2 problems with --fatal-warnings for ignored 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/pr31289-1a.d: New file.
>> * testsuite/ld-elf/pr31289-1b.d: Likewise.
>> * testsuite/ld-elf/pr31289-2a.d: Likewise.
>> * testsuite/ld-elf/pr31289-2b.d: Likewise.
>> * testsuite/ld-elf/pr31289-3a.d: Likewise.
>> * testsuite/ld-elf/pr31289-3b.d: Likewise.
>> * testsuite/ld-elf/pr31289-4a.d: Likewise.
>> * testsuite/ld-elf/pr31289-4b.d: Likewise.
>> ---
>> ld/emultempl/elf.em | 2 +-
>> ld/ldelf.c | 2 +-
>> ld/ldmain.c | 2 +
>> ld/ldmisc.c | 75 ++++++++++++++++++++++++++++++++
>> ld/ldmisc.h | 2 +
>> ld/testsuite/ld-elf/pr31289-1a.d | 5 +++
>> ld/testsuite/ld-elf/pr31289-1b.d | 5 +++
>> ld/testsuite/ld-elf/pr31289-2a.d | 5 +++
>> ld/testsuite/ld-elf/pr31289-2b.d | 5 +++
>> ld/testsuite/ld-elf/pr31289-3a.d | 5 +++
>> ld/testsuite/ld-elf/pr31289-3b.d | 5 +++
>> ld/testsuite/ld-elf/pr31289-4a.d | 5 +++
>> ld/testsuite/ld-elf/pr31289-4b.d | 5 +++
>> 13 files changed, 121 insertions(+), 2 deletions(-)
>> create mode 100644 ld/testsuite/ld-elf/pr31289-1a.d
>> create mode 100644 ld/testsuite/ld-elf/pr31289-1b.d
>> create mode 100644 ld/testsuite/ld-elf/pr31289-2a.d
>> create mode 100644 ld/testsuite/ld-elf/pr31289-2b.d
>> create mode 100644 ld/testsuite/ld-elf/pr31289-3a.d
>> create mode 100644 ld/testsuite/ld-elf/pr31289-3b.d
>> create mode 100644 ld/testsuite/ld-elf/pr31289-4a.d
>> create mode 100644 ld/testsuite/ld-elf/pr31289-4b.d
>
> Thanks for the patch. For newer tests, I wonder whether a descriptive
> short name (in this case, fatal-warnings-*[ab].s) would be more
> suitable than PR<number>.
> A descriptive name helps future readers group related tests together.
> A PR number is useful as well, but it can be noted down as a comment.
+1
Jan
More information about the Binutils
mailing list