Files
binutils-gdb/bfd
Tom Tromey bacc61fd3e Thread-safety improvements for bfd_check_format_matches
A gdb bug found that bfd_check_format_matches has some data races when
called from multiple threads.

In particular, it changes the BFD error handler, which is a global.
It also has a local static variable ("in_check_format") that is used
for recursion detection.  And, finally, it may emit warnings to the
per-xvec warning array, which is a global.

This patch removes all the races here.

The first part of patch is to change _bfd_error_handler to directly
handle the needs of bfd_check_format_matches.  This way, the error
handler does not need to be changed.

This change lets us use the new per-thread global
(error_handler_messages, replacing error_handler_bfd) to also remove
the need for in_check_format -- a single variable suffices.

Finally, the global per-xvec array is replaced with a new type that
holds the error messages.  The outermost such type is stack-allocated
in bfd_check_format_matches.

I tested this using the binutils test suite.  I also built gdb with
thread sanitizer and ran the test case that was noted as failing.
Finally, Alan sent me the test file that caused the addition of the
xvec warning code in the first place, and I confirmed that "nm-new"
has the same behavior on this file both before and after this patch.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31264
Co-Authored-By: Alan Modra <amodra@gmail.com>
2024-04-16 14:01:43 -06:00
..
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-03-18 12:53:42 +01:00
2024-04-16 11:59:41 +01:00
2024-04-11 17:05:16 +09:30
2024-01-15 14:42:15 +00:00
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2023-11-15 12:53:04 +00:00
2024-04-04 21:02:40 +10:30
2024-04-04 21:02:40 +10:30
2024-04-04 21:02:40 +10:30
2024-03-13 13:47:34 +08:00
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-02-29 15:02:49 +08:00
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-11 17:05:16 +09:30
2024-04-16 00:00:13 +00:00
2024-04-11 17:05:16 +09:30
2024-02-09 12:17:20 +10:30
2024-04-11 17:05:16 +09: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.
BFD is an object file library.  It permits applications to use the
same routines to process object files regardless of their format.

BFD is used by the GNU debugger, assembler, linker, and the binary
utilities.

The documentation on using BFD is scanty and may be occasionally
incorrect.  Pointers to documentation problems, or an entirely
rewritten manual, would be appreciated.

There is some BFD internals documentation in doc/bfdint.texi which may
help programmers who want to modify BFD.

BFD is normally built as part of another package.  See the build
instructions for that package, probably in a README file in the
appropriate directory.

BFD supports the following configure options:

  --target=TARGET
	The default target for which to build the library.  TARGET is
	a configuration target triplet, such as sparc-sun-solaris.
  --enable-targets=TARGET,TARGET,TARGET...
	Additional targets the library should support.  To include
	support for all known targets, use --enable-targets=all.
  --enable-64-bit-bfd
	Include support for 64 bit targets.  This is automatically
	turned on if you explicitly request a 64 bit target, but not
	for --enable-targets=all.  This requires a compiler with a 64
	bit integer type, such as gcc.
  --enable-shared
	Build BFD as a shared library.
  --with-mmap
	Use mmap when accessing files.  This is faster on some hosts,
	but slower on others.  It may not work on all hosts.

Report bugs in BFD to https://sourceware.org/bugzilla/

Patches are encouraged.  When sending patches, always send the output
of diff -u or diff -c from the original file to the new file.  Do not
send default diff output.  Do not make the diff from the new file to
the original file.  Remember that any patch must not break other
systems.  Remember that BFD must support cross compilation from any
host to any target, so patches which use ``#ifdef HOST'' are not
acceptable.  Please also read the ``Reporting Bugs'' section of the
gcc manual.

Bug reports without patches will be remembered, but they may never get
fixed until somebody volunteers to fix them.

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.