diff options
author | Alan Modra <amodra@gmail.com> | 2022-12-15 23:07:10 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-12-17 18:44:42 +1030 |
commit | 499766a6d77994259b3cdff602d8f38d014d08ce (patch) | |
tree | 5b10ac14d8383a3250baaa6fe3b02e913be16cc4 /bfd/libbfd.h | |
parent | 6e09ae77a199fe3a8ed814355eec7bb105a42ed4 (diff) | |
download | gdb-499766a6d77994259b3cdff602d8f38d014d08ce.zip gdb-499766a6d77994259b3cdff602d8f38d014d08ce.tar.gz gdb-499766a6d77994259b3cdff602d8f38d014d08ce.tar.bz2 |
Re: The problem with warning in elf_object_p
Commit 5aa0f10c424e added a per_xvec_warn array to provide support for
warnings from elf_object_p (and a later patch for warnings from
pe_bfd_object_p) to be cached and then only printed if the target
matches. It was quite limited in the style of message supported, only
one message could be printed, and didn't really meet the stated aim of
only warning when a target matches: There are many other errors and
warnings that can be emitted by functions called from elf_object_p.
So this patch extends the error handler functions to support printing
to a string buffer, extends per_xvec_warn to support multiple errors/
warnings, and hooks this all into bfd_check_format_matches. If
bfd_check_format_matches succeeds then any errors/warnings are printed
for the matching target. If bfd_check_format_matches fails either due
to no match or to multiple matches and only one target vector produced
errors, then those errors are printed.
* bfd.c (MAX_ARGS): Define, use throughout.
(print_func): New typedef.
(_bfd_doprnt): Add new print param. Replace calls to fprintf
with print.
(PRINT_TYPE): Similarly.
(error_handler_fprintf): Renamed from error_handler_internal.
Use _bfd_get_error_program_name. Add fprintf arg. Move code
setting up args..
(_bfd_doprnt_scan): ..to here. Add ap param.
(struct buf_stream): New.
(err_sprintf): New function.
(error_handler_bfd): New static variable.
(error_handler_sprintf): New function.
(_bfd_set_error_handler_caching): New function.
(_bfd_get_error_program_name): New function.
* elfcode.h (elf_swap_shdr_in): Use _bfd_error_handler in
warning messages.
(elf_object_p): Likewise.
* format.c (print_warnmsg): New function.
(clear_warnmsg): Rewrite.
(null_error_handler): New function.
(bfd_check_format_matches): Ignore warnings from recursive calls
checking first element of an archive. Use caching error handler
otherwise. Print warnings on successful match, or when only one
target has emitted warnings/errors.
* peicode.h (pe_bfd_object_p): Use _bfd_error_handler in
warning messages.
* targets.c (per_xvec_warn): Change type of array elements.
(struct per_xvec_message): New.
(_bfd_per_xvec_warn): Rewrite.
* Makefile.am (LIBBFD_H_FILES): Add bfd.c.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
Diffstat (limited to 'bfd/libbfd.h')
-rw-r--r-- | bfd/libbfd.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 2dec810..cba6d42 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1,6 +1,6 @@ /* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically - generated from "libbfd-in.h", "libbfd.c", "bfdio.c", "bfdwin.c", - "cache.c", "reloc.c", "section.c", "targets.c", "archures.c" + generated from "libbfd-in.h", "libbfd.c", "bfd.c", "bfdio.c", + "bfdwin.c", "cache.c", "reloc.c", "section.c", "targets.c", "archures.c" and "linker.c". Run "make headers" in your build bfd/ to regenerate. */ @@ -989,6 +989,11 @@ bool bfd_write_bigendian_4byte_int (bfd *, unsigned int); unsigned int bfd_log2 (bfd_vma x); +/* Extracted from bfd.c. */ +bfd_error_handler_type _bfd_set_error_handler_caching (bfd *); + +const char *_bfd_get_error_program_name (void); + /* Extracted from bfdio.c. */ struct bfd_iovec { @@ -3554,7 +3559,7 @@ bool _bfd_unrecognized_reloc bool _bfd_section_size_insane (bfd *abfd, asection *sec); /* Extracted from targets.c. */ -const char **_bfd_per_xvec_warn (const bfd_target *); +struct per_xvec_message **_bfd_per_xvec_warn (const bfd_target *, size_t); /* Extracted from archures.c. */ extern const bfd_arch_info_type bfd_default_arch_struct; |