aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1993-01-08 21:46:36 +0000
committerIan Lance Taylor <ian@airs.com>1993-01-08 21:46:36 +0000
commit515c4292110048518ddacfaaece66c7829f0ca58 (patch)
tree94cec910a81fdc76206307b04902bf272a3c757e /bfd/bfd.c
parent06c3865a42c693175faa0693e2c66e9acccb04a8 (diff)
downloadgdb-515c4292110048518ddacfaaece66c7829f0ca58.zip
gdb-515c4292110048518ddacfaaece66c7829f0ca58.tar.gz
gdb-515c4292110048518ddacfaaece66c7829f0ca58.tar.bz2
Basically a checkpoint.
Fri Jan 8 15:47:53 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) * bfd.c (struct _bfd): Added ecoff_tdata to tdata union. * targets.c (enum target_flavour): Added bfd_target_ecoff_flavour. * coff-msym.c: Use DEFUN for function definitons. * coff-mips.c: Added code to read and print symbols, and to find line numbers.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r--bfd/bfd.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 0820c3f..8910ca8 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -146,6 +146,7 @@ CODE_FRAGMENT
. struct _oasys_data *oasys_obj_data;
. struct _oasys_ar_data *oasys_ar_data;
. struct coff_tdata *coff_obj_data;
+. struct ecoff_tdata *ecoff_obj_data;
. struct ieee_data_struct *ieee_data;
. struct ieee_ar_data_struct *ieee_ar_data;
. struct srec_data_struct *srec_data;
@@ -519,6 +520,53 @@ bfd_get_mtime (abfd)
/*
FUNCTION
+ The bfd_get_size function
+
+SYNOPSIS
+ long bfd_get_size(bfd *);
+
+DESCRIPTION
+ Return file size (as read from file system) for the file
+ associated with a bfd.
+
+ Note that the initial motivation for, and use of, this routine is not
+ so we can get the exact size of the object the bfd applies to, since
+ that might not be generally possible (archive members for example?).
+ Although it would be ideal if someone could eventually modify
+ it so that such results were guaranteed.
+
+ Instead, we want to ask questions like "is this NNN byte sized
+ object I'm about to try read from file offset YYY reasonable?"
+ As as example of where we might want to do this, some object formats
+ use string tables for which the first sizeof(long) bytes of the table
+ contain the size of the table itself, including the size bytes.
+ If an application tries to read what it thinks is one of these
+ string tables, without some way to validate the size, and for
+ some reason the size is wrong (byte swapping error, wrong location
+ for the string table, etc), the only clue is likely to be a read
+ error when it tries to read the table, or a "virtual memory
+ exhausted" error when it tries to allocated 15 bazillon bytes
+ of space for the 15 bazillon byte table it is about to read.
+ This function at least allows us to answer the quesion, "is the
+ size reasonable?".
+*/
+
+long
+bfd_get_size (abfd)
+ bfd *abfd;
+{
+ FILE *fp;
+ struct stat buf;
+
+ fp = bfd_cache_lookup (abfd);
+ if (0 != fstat (fileno (fp), &buf))
+ return 0;
+
+ return buf.st_size;
+}
+
+/*
+FUNCTION
stuff
DESCRIPTION