Files
Alan Modra 5c4ce239a3 Tidy bfdio to consistenly use containing archive
Archive element IO is performed on the file of the containing archive,
which leads to the BFD "where" field of archives and their elements
being out of sync with the real file position.  (We're talking
traditional archives here, not thin archives.)  The old bfd_seek code
recognized this by not attempting to optimize away seeks for
archives.  However, there was other code that could return bogus
results.  For example, cache.c limits the number of open files by
closing a file and remembering its state once the limit is reached.
If bfd_tell is called on an archive element when the containing
archive is closed, it will return an invalid file pointer.

It's possible to have a valid "where" field for archives by always
using and updating the containing archive BFD.  That's what this patch
does.  Note that cache.c used to find the containing archive BFD
anyway for the iostream, so we're not really doing extra work, just
transferring it up to the correct abstraction level.

The patch also gets rid of some hacks.  bfd_tell was called when
bfd_seek failed, in an attempt to correct "where".  That's got to be
papering over another problem, so that code has been removed.
bfd_read also had an "optimiziation" to return early when the number
of bytes was zero, and bfd_seek optimized calls that didn't move the
file pointer.  This was covering for a coff_slurp_line_table bug where
IO was attempted on a pe-dll BFD without an iovec.

	* bfd.c (struct bfd): Update comment on "where" usage.
	* bfdio.c (bfd_bwrite, bfd_stat): Use and update "iovec",
	"iostream", and "where" from containing archive file.  Return
	error on NULL iovec.
	(bfd_bread): Similarly, and return error attempted out of
	bounds archive element access.
	(bfd_tell, bfd_flush): Use and update "iovec", "iostream", and
	"where" from containing archive file.
	(bfd_seek): Likewise.  Return error on NULL iovec.  Don't
	attempt to optimize away seeks.  Don't paper over errors by
	calling bfd_tell.
	(bfd_get_mtime): Call bfd_stat rather than iovec->bstat.
	(bfd_get_size): Likewise.
	(bfd_mmap): Operate on and use iovec of containing archive
	file.  Return error on NULL iovec.
	* cache.c (bfd_cache_lookup_worker): Abort if working on
	archive element bfd.
	(cache_bread_1): Delete bfd parameter, add FILE* parameter.
	Don't ignore zero byte reads.
	(cache_bread): Look up FILE* in cache here.  Error on NULL
	lookup.
	(cache_bwrite): Rename "where" to "from".
	(cache_bmmap): Don't handle archive elements.
	* coffcode.h (coff_slurp_line_table): Exit early on zero
	lineno count.
	* bfd-in2.h: Regenerate.
2018-06-05 22:39:12 +09:30
..
2018-05-18 13:07:21 +09:30
2018-05-25 16:05:30 +09:30
2018-02-16 19:09:23 +10:30
2017-01-02 13:55:05 +10:30
2018-01-03 17:49:42 +10:30
2018-02-16 19:09:23 +10:30
2018-04-16 20:29:05 +09:30
2018-02-16 19:09:23 +10:30
2018-02-16 19:09:23 +10:30
2018-02-26 09:32:35 +10:30
2018-02-16 19:09:23 +10:30
2018-02-16 19:09:23 +10:30
2018-05-07 12:33:26 +09:30
2018-02-19 23:55:54 +10:30
2018-05-18 13:07:41 +09:30
2018-06-01 09:34:16 -07:00
2018-04-16 15:23:38 +09:30
2018-04-16 15:29:39 +09:30
2018-04-16 15:11:22 +09:30
2018-05-28 08:15:21 -07:00
2018-03-01 09:12:50 +10:30
2018-05-28 08:15:21 -07:00
2018-04-09 17:40:54 +09:30
2018-04-16 15:29:39 +09:30
2018-04-16 15:29:39 +09:30
2018-05-28 08:15:21 -07:00
2018-02-19 23:55:54 +10:30
2018-04-09 17:40:54 +09:30
2018-05-28 08:15:21 -07:00
2018-02-26 09:29:15 +10:30
2018-04-05 08:24:15 +09:30
2018-02-19 23:55:55 +10:30
2018-05-28 08:15:21 -07:00
2018-03-28 12:17:15 +02:00
2018-02-16 19:09:23 +10:30
2018-02-16 19:09:23 +10:30
2018-02-16 19:09:23 +10:30
2018-04-16 15:23:38 +09:30
2018-05-25 16:05:30 +09:30
2018-02-19 23:55:54 +10:30
2018-04-16 15:23:38 +09:30
2018-02-26 09:34:15 +10:30
2018-04-16 15:31:36 +09:30
2018-02-16 19:09:23 +10:30
2018-02-16 19:09:23 +10:30
2018-04-16 15:17:57 +09:30
2018-02-16 19:09:23 +10:30
2018-02-26 09:33:15 +10:30
2018-02-26 09:33:15 +10:30
2018-02-16 19:09:23 +10:30
2018-02-16 19:09:23 +10:30
2018-06-05 00:00:36 +00:00
2018-06-01 09:34:16 -07:00
2018-02-16 19:09:23 +10:30
2018-02-16 19:09:23 +10:30
2018-02-19 23:55:54 +10: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 with BFD to bug-binutils@gnu.org.

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-2018 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.