summaryrefslogtreecommitdiff
path: root/bfd/Makefile.am
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-12-15 23:07:10 +1030
committerAlan Modra <amodra@gmail.com>2022-12-17 18:44:42 +1030
commit499766a6d77994259b3cdff602d8f38d014d08ce (patch)
tree5b10ac14d8383a3250baaa6fe3b02e913be16cc4 /bfd/Makefile.am
parent6e09ae77a199fe3a8ed814355eec7bb105a42ed4 (diff)
downloadbinutils-gdb-499766a6d77994259b3cdff602d8f38d014d08ce.tar.gz
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/Makefile.am')
-rw-r--r--bfd/Makefile.am2
1 files changed, 1 insertions, 1 deletions
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index da55a0bb99e..6d8722e0cca 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -932,7 +932,7 @@ BFD_H_FILES = bfd-in.h init.c opncls.c libbfd.c \
syms.c bfd.c archive.c corefile.c targets.c format.c \
linker.c simple.c compress.c
BFD64_H_FILES = archive64.c
-LIBBFD_H_FILES = libbfd-in.h libbfd.c bfdio.c bfdwin.c \
+LIBBFD_H_FILES = libbfd-in.h libbfd.c bfd.c bfdio.c bfdwin.c \
cache.c reloc.c section.c targets.c archures.c linker.c
LIBCOFF_H_FILES = libcoff-in.h coffcode.h