aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-bfd.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-12-10 21:44:34 +1030
committerAlan Modra <amodra@gmail.com>2014-12-10 23:13:49 +1030
commitf4943d8253e8c9c539fd72d23e94a65f84c92d1a (patch)
treefe266edba1bb0bc50b592209d8630aad00a2fe65 /bfd/coff-bfd.c
parente00e81980c70659d0efe686b31a55db5faaa91f9 (diff)
downloadgdb-f4943d8253e8c9c539fd72d23e94a65f84c92d1a.zip
gdb-f4943d8253e8c9c539fd72d23e94a65f84c92d1a.tar.gz
gdb-f4943d8253e8c9c539fd72d23e94a65f84c92d1a.tar.bz2
Don't always build coffgen.o
Removes a bunch of unused functions from libbfd when building ELF or AOUT. Split off the bits we need externally when not building a COFF target into coff-bfd.c and coff-bfd.h. bfd/ * Makefile.am (BFD32_LIBS, BFD32_LIBS_CFILES): Remove dwarf2 and coffgen. Add coff-bfd. Sort. (BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Add coffgen and dwarf2. * bfd-in.h (bfd_coff_get_syment, bfd_coff_get_auxent): Delete. (struct coff_comdat_info, bfd_coff_get_comdat_section): Delete. * coffgen.c (coff_symbol_from): Move to coff-bfd.h as macro, without unused param. Update uses. (bfd_coff_get_comdat_section): Move to coff-bfd.h as macro. (bfd_coff_get_syment, bfd_coff_get_auxent): Move to coff-bfd.c. * libcoff-in.h: #include "coff-bfd.h". (struct coff_section_tdata, coff_section_data): Move to coff-bfd.h. (coff_symbol_from): Delete. * coff-bfd.c: New file. * coff-bfd.h: New file. * coff-i386.c: Update coff_symbol_from occurrences. * coff-i960.c: Likewise. * coff-m68k.c: Likewise. * coff-sh.c: Likewise. * coff-x86_64.c: Likewise. * coffcode.h: Likewise. * pe-mips.c: Likewise. * configure.ac (elf): Add dwarf2.lo. (coffgen, coff, ecoff, xcoff): Define. Use when mapping bfd target vectors to .o files. Add dwarf2 for mach-o targets. Fix the sh target FIXME. * po/SRC-POTFILES.in: Regenerate. * Makefile.in: Regenerate. * configure: Regenerate. * bfd-in2.h: Regenerate. * libcoff.h: Regenerate. binutils/ * objdump.c: #include "coff-bfd.h". ld/ * ldmisc.c: #include "coff-bfd.h"
Diffstat (limited to 'bfd/coff-bfd.c')
-rw-r--r--bfd/coff-bfd.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/bfd/coff-bfd.c b/bfd/coff-bfd.c
new file mode 100644
index 0000000..81ecdf8
--- /dev/null
+++ b/bfd/coff-bfd.c
@@ -0,0 +1,99 @@
+/* BFD COFF interfaces used outside of BFD.
+ Copyright (C) 1990-2014 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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., 51 Franklin Street - Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "coff/internal.h"
+#include "libcoff.h"
+
+/* Return the COFF syment for a symbol. */
+
+bfd_boolean
+bfd_coff_get_syment (bfd *abfd,
+ asymbol *symbol,
+ struct internal_syment *psyment)
+{
+ coff_symbol_type *csym;
+
+ csym = coff_symbol_from (symbol);
+ if (csym == NULL || csym->native == NULL
+ || ! csym->native->is_sym)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return FALSE;
+ }
+
+ *psyment = csym->native->u.syment;
+
+ if (csym->native->fix_value)
+ psyment->n_value = psyment->n_value -
+ (bfd_hostptr_t) obj_raw_syments (abfd);
+
+ /* FIXME: We should handle fix_line here. */
+
+ return TRUE;
+}
+
+/* Return the COFF auxent for a symbol. */
+
+bfd_boolean
+bfd_coff_get_auxent (bfd *abfd,
+ asymbol *symbol,
+ int indx,
+ union internal_auxent *pauxent)
+{
+ coff_symbol_type *csym;
+ combined_entry_type *ent;
+
+ csym = coff_symbol_from (symbol);
+
+ if (csym == NULL
+ || csym->native == NULL
+ || ! csym->native->is_sym
+ || indx >= csym->native->u.syment.n_numaux)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return FALSE;
+ }
+
+ ent = csym->native + indx + 1;
+
+ BFD_ASSERT (! ent->is_sym);
+ *pauxent = ent->u.auxent;
+
+ if (ent->fix_tag)
+ pauxent->x_sym.x_tagndx.l =
+ ((combined_entry_type *) pauxent->x_sym.x_tagndx.p
+ - obj_raw_syments (abfd));
+
+ if (ent->fix_end)
+ pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l =
+ ((combined_entry_type *) pauxent->x_sym.x_fcnary.x_fcn.x_endndx.p
+ - obj_raw_syments (abfd));
+
+ if (ent->fix_scnlen)
+ pauxent->x_csect.x_scnlen.l =
+ ((combined_entry_type *) pauxent->x_csect.x_scnlen.p
+ - obj_raw_syments (abfd));
+
+ return TRUE;
+}