aboutsummaryrefslogtreecommitdiff
path: root/bfd/syms.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1995-07-13 14:46:06 +0000
committerIan Lance Taylor <ian@airs.com>1995-07-13 14:46:06 +0000
commitc3246d9b00ee6626c79eced991d3b669aa4846ab (patch)
treec848743cf5324d8649724550d7b3d6449f5bedaf /bfd/syms.c
parentac7530a8958a2d871bf5967b58f7e3283883d567 (diff)
downloadgdb-c3246d9b00ee6626c79eced991d3b669aa4846ab.zip
gdb-c3246d9b00ee6626c79eced991d3b669aa4846ab.tar.gz
gdb-c3246d9b00ee6626c79eced991d3b669aa4846ab.tar.bz2
* targets.c (bfd_target): Add fields _read_minisymbols and
_minisymbol_to_symbol. (BFD_JUMP_TABLE_SYMBOLS): Add _read_minisymbols and _minisymbol_to_symbol. (bfd_read_minisymbols): Define. (bfd_minisymbol_to_symbol): Define. * syms.c (_bfd_generic_read_minisymbols): Define. (_bfd_generic_minisymbol_to_symbol): Define. * libbfd-in.h (_bfd_nosymbols_read_minisymbols): Define. (_bfd_nosymbols_minisymbol_to_symbol): Define. (_bfd_generic_read_minisymbols): Declare. (_bfd_generic_minisymbol_to_symbol): Declare. * bfd-in2.h: Rebuild. * libbfd.h: Rebuild. * aoutx.h (MINISYM_THRESHOLD): Define. (NAME(aout,read_minisymbols)): New function. (NAME(aout,minisymbol_to_symbol)): New function. * libaout.h (NAME(aout,read_minisymbols)): Declare. (NAME(aout,minisymbol_to_symbol)): Declare. * aout-target.h (MY_read_minisymbols): Define. (MY_minisymbol_to_symbol): Define. * All targets: Define read_minisymbols and minisymbol_to_symbol. PR 5332.
Diffstat (limited to 'bfd/syms.c')
-rw-r--r--bfd/syms.c89
1 files changed, 86 insertions, 3 deletions
diff --git a/bfd/syms.c b/bfd/syms.c
index 2234c80..402d766 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*
SECTION
@@ -91,7 +91,7 @@ SUBSECTION
INODE
-Writing Symbols, typedef asymbol, Reading Symbols, Symbols
+Writing Symbols, Mini symbols, Reading Symbols, Symbols
SUBSECTION
Writing symbols
@@ -137,6 +137,28 @@ SUBSECTION
which is not one of <<.text>>, <<.data>> or <<.bss>> cannot
be described.
+INODE
+Mini symbols, typedef asymbol, Writing Symbols, Symbols
+SUBSECTION
+ Mini symbols
+
+ Mini symbols provide read-only access to the symbol table.
+ They use less memory space, but require more time to access.
+ They can be useful for tools like nm or objdump, which may
+ have to handle symbol tables of extremely large executables.
+
+ The <<bfd_read_minisymbols>> function will read the symbols
+ into memory in an internal form. It will return a <<void *>>
+ pointer to a block of memory, a symbol count, and the size of
+ each symbol. The pointer is allocated using <<malloc>>, and
+ should be freed by the caller when it is no longer needed.
+
+ The function <<bfd_minisymbol_to_symbol>> will take a pointer
+ to a minisymbol, and a pointer to a structure returned by
+ <<bfd_make_empty_symbol>>, and return a <<asymbol>> structure.
+ The return value may or may not be the same as the value from
+ <<bfd_make_empty_symbol>> which was passed in.
+
*/
@@ -144,7 +166,7 @@ SUBSECTION
/*
DOCDD
INODE
-typedef asymbol, symbol handling functions, Writing Symbols, Symbols
+typedef asymbol, symbol handling functions, Mini symbols, Symbols
*/
/*
@@ -589,3 +611,64 @@ DESCRIPTION
. (ibfd, isymbol, obfd, osymbol))
*/
+
+/* The generic version of the function which returns mini symbols.
+ This is used when the backend does not provide a more efficient
+ version. It just uses BFD asymbol structures as mini symbols. */
+
+long
+_bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
+ bfd *abfd;
+ boolean dynamic;
+ PTR *minisymsp;
+ unsigned int *sizep;
+{
+ long storage;
+ asymbol **syms = NULL;
+ long symcount;
+
+ if (dynamic)
+ storage = bfd_get_dynamic_symtab_upper_bound (abfd);
+ else
+ storage = bfd_get_symtab_upper_bound (abfd);
+ if (storage < 0)
+ goto error_return;
+
+ syms = (asymbol **) malloc (storage);
+ if (syms == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ goto error_return;
+ }
+
+ if (dynamic)
+ symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
+ else
+ symcount = bfd_canonicalize_symtab (abfd, syms);
+ if (symcount < 0)
+ goto error_return;
+
+ *minisymsp = (PTR) syms;
+ *sizep = sizeof (asymbol *);
+ return symcount;
+
+ error_return:
+ if (syms != NULL)
+ free (syms);
+ return -1;
+}
+
+/* The generic version of the function which converts a minisymbol to
+ an asymbol. We don't worry about the sym argument we are passed;
+ we just return the asymbol the minisymbol points to. */
+
+/*ARGSUSED*/
+asymbol *
+_bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
+ bfd *abfd;
+ boolean dynamic;
+ const PTR minisym;
+ asymbol *sym;
+{
+ return *(asymbol **) minisym;
+}