Based on patches from Philippe De Muyter <phdm@info.ucl.ac.be>.
* coff-svm68k.c: New file. Just defines some macros and includes coff-m68k.c. * coff-m68k.c: Add functions to handle common addends, moved in from cf-m68klynx.c. Control them using COFF_COMMON_ADDEND macro. Control whether relocs are visible using STATIC_RELOCS. * cf-m68klynx.c: Simplify greatly: just define macros to control coff-m68k.c. * coff-aux.c: Likewise. Just leave add_one_symbol routine. * targets. (m68ksysvcoff_vec): Declare. (bfd_target_vector): Add m68ksysvcoff_vec. * config.bfd (m68*-motorola-sysv*): New target. * configure.in (m68ksysvcoff_vec): New vector. * configure: Rebuild. * Makefile.in: Rebuild dependencies. (BFD32_BACKENDS): Add coff-svm68k.o. (BFD32_BACKENDS_CFILES): Add coff-svm68k.c.
This commit is contained in:
parent
593f97fe13
commit
ac388f2a39
@ -117,6 +117,7 @@ coff-ppc.c
|
||||
coff-rs6000.c
|
||||
coff-sh.c
|
||||
coff-sparc.c
|
||||
coff-svm68k.c
|
||||
coff-u68k.c
|
||||
coff-we32k.c
|
||||
coff-w65.c
|
||||
|
@ -1,5 +1,23 @@
|
||||
Thu Mar 20 12:39:02 1997 Ian Lance Taylor <ian@cygnus.com>
|
||||
|
||||
Based on patches from Philippe De Muyter <phdm@info.ucl.ac.be>.
|
||||
* coff-svm68k.c: New file. Just defines some macros and includes
|
||||
coff-m68k.c.
|
||||
* coff-m68k.c: Add functions to handle common addends, moved in
|
||||
from cf-m68klynx.c. Control them using COFF_COMMON_ADDEND macro.
|
||||
Control whether relocs are visible using STATIC_RELOCS.
|
||||
* cf-m68klynx.c: Simplify greatly: just define macros to control
|
||||
coff-m68k.c.
|
||||
* coff-aux.c: Likewise. Just leave add_one_symbol routine.
|
||||
* targets. (m68ksysvcoff_vec): Declare.
|
||||
(bfd_target_vector): Add m68ksysvcoff_vec.
|
||||
* config.bfd (m68*-motorola-sysv*): New target.
|
||||
* configure.in (m68ksysvcoff_vec): New vector.
|
||||
* configure: Rebuild.
|
||||
* Makefile.in: Rebuild dependencies.
|
||||
(BFD32_BACKENDS): Add coff-svm68k.o.
|
||||
(BFD32_BACKENDS_CFILES): Add coff-svm68k.c.
|
||||
|
||||
* binary.c (binary_set_section_contents): Don't get misled if the
|
||||
first section is not loadable. From Matthew L. Martin
|
||||
<mlm@xedia.com>.
|
||||
|
@ -205,6 +205,7 @@ BFD32_BACKENDS = \
|
||||
coff-rs6000.o \
|
||||
coff-sh.o \
|
||||
coff-sparc.o \
|
||||
coff-svm68k.o \
|
||||
$(start-sanitize-tic80) \
|
||||
coff-tic80.o \
|
||||
$(end-sanitize-tic80) \
|
||||
@ -315,6 +316,7 @@ BFD32_BACKENDS_CFILES = \
|
||||
coff-rs6000.c \
|
||||
coff-sh.c \
|
||||
coff-sparc.c \
|
||||
coff-svm68k.c \
|
||||
coff-u68k.c \
|
||||
coff-we32k.c \
|
||||
coff-w65.c \
|
||||
@ -1015,6 +1017,9 @@ coff-sh.o: coff-sh.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/sh.h \
|
||||
$(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h
|
||||
coff-sparc.o: coff-sparc.c $(INCDIR)/coff/sparc.h $(INCDIR)/coff/internal.h \
|
||||
libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h
|
||||
coff-svm68k.o: coff-svm68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \
|
||||
$(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
|
||||
coffcode.h coffswap.h
|
||||
coff-u68k.o: coff-u68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \
|
||||
$(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \
|
||||
coffcode.h coffswap.h
|
||||
@ -1033,7 +1038,8 @@ ecoff.o: ecoff.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/ar.h \
|
||||
libcoff.h libecoff.h
|
||||
ecofflink.o: ecofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/objalloc.h \
|
||||
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h \
|
||||
$(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h
|
||||
$(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
|
||||
libcoff.h libecoff.h
|
||||
elf32-gen.o: elf32-gen.c elf-bfd.h $(INCDIR)/elf/common.h \
|
||||
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
|
||||
elf32-target.h
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* BFD back-end for Motorola M68K COFF LynxOS files.
|
||||
Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
|
||||
Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
@ -20,207 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68klynx_coff_vec
|
||||
#define TARGET_NAME "coff-m68k-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#define _bfd_m68kcoff_howto_table _bfd_m68klynx_howto_table
|
||||
#define _bfd_m68kcoff_rtype2howto _bfd_m68klynx_rtype2howto
|
||||
#define _bfd_m68kcoff_howto2rtype _bfd_m68klynx_howto2rtype
|
||||
#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68klynx_reloc_type_lookup
|
||||
|
||||
#define LYNX_SPECIAL_FN _bfd_m68klynx_special_fn
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
struct internal_reloc;
|
||||
struct coff_link_hash_entry;
|
||||
struct internal_syment;
|
||||
#endif
|
||||
|
||||
static bfd_reloc_status_type _bfd_m68klynx_special_fn
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_m68k_lynx_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
/* For some reason when using m68k COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
|
||||
for I386 COFF). */
|
||||
|
||||
/* If we are producing relocateable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
_bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocateable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||
the object file contains the value of the common symbol. By the
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == R_PCRBYTE \
|
||||
|| reloc.r_type == R_PCRWORD \
|
||||
|| reloc.r_type == R_PCRLONG)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_m68k_lynx_rtype_to_howto
|
||||
#define STATIC_RELOCS
|
||||
#define COFF_COMMON_ADDEND
|
||||
|
||||
#include "coff-m68k.c"
|
||||
|
||||
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||
adjust common symbols.
|
||||
|
||||
We can't define this function until after we have included
|
||||
coff-m68k.c, because it uses RTYPE2HOWTO. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static reloc_howto_type *
|
||||
coff_m68k_lynx_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
BFD_ASSERT (h != NULL);
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocateable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
26
bfd/coff-svm68k.c
Normal file
26
bfd/coff-svm68k.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* BFD back-end for Motorola sysv68
|
||||
Copyright 1997 Free Software Foundation, Inc.
|
||||
Written by Philippe De Muyter <phdm@info.ucl.ac.be>.
|
||||
|
||||
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68ksysvcoff_vec
|
||||
#define TARGET_NAME "coff-m68k-sysv"
|
||||
#define STATIC_RELOCS
|
||||
#define COFF_COMMON_ADDEND
|
||||
|
||||
#include "coff-m68k.c"
|
@ -108,11 +108,9 @@ case "${targ}" in
|
||||
targ_underscore=yes
|
||||
;;
|
||||
|
||||
# start-sanitize-d10v
|
||||
d10v-*-*)
|
||||
targ_defvec=bfd_elf32_d10v_vec
|
||||
;;
|
||||
# end-sanitize-d10v
|
||||
|
||||
# start-sanitize-d30v
|
||||
d30v-*-*)
|
||||
@ -262,6 +260,9 @@ case "${targ}" in
|
||||
targ_defvec=m68kcoffun_vec
|
||||
targ_underscore=yes
|
||||
;;
|
||||
m68*-motorola-sysv*)
|
||||
targ_defvec=m68ksysvcoff_vec
|
||||
;;
|
||||
m68*-hp-bsd*)
|
||||
targ_defvec=hp300bsd_vec
|
||||
targ_underscore=yes
|
||||
@ -387,6 +388,10 @@ case "${targ}" in
|
||||
targ_defvec=ecoff_big_vec
|
||||
targ_selvecs=ecoff_little_vec
|
||||
;;
|
||||
mips*-*-lnews*)
|
||||
targ_defvec=ecoff_biglittle_vec
|
||||
targ_selvecs="ecoff_little_vec ecoff_big_vec"
|
||||
;;
|
||||
mips*-*-mach3*)
|
||||
targ_defvec=aout_mips_little_vec
|
||||
targ_cflags=-DSTAT_FOR_EXEC
|
||||
@ -437,7 +442,7 @@ case "${targ}" in
|
||||
targ_underscore=yes
|
||||
;;
|
||||
|
||||
powerpc-*-aix*)
|
||||
powerpc-*-aix* | powerpc-*-beos*)
|
||||
targ_defvec=rs6000coff_vec
|
||||
;;
|
||||
powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
|
||||
|
604
bfd/configure
vendored
604
bfd/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -293,6 +293,7 @@ changequote([,])dnl
|
||||
rs6000-*-*) COREFILE=rs6000-core.o ;;
|
||||
powerpc-*-aix4*) COREFILE=rs6000-core.o ;;
|
||||
powerpc-*-aix*) COREFILE=rs6000-core.o ;;
|
||||
powerpc-*-beos*) ;;
|
||||
sparc-*-netbsd*)
|
||||
COREFILE=netbsd-core.o
|
||||
;;
|
||||
@ -443,9 +444,7 @@ do
|
||||
bfd_elf32_bigmips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;;
|
||||
bfd_elf64_bigmips_vec) tb="$tb elf64-mips.o elf64.o elf32-mips.o elf32.o $elf ecofflink.o"
|
||||
target64=true ;;
|
||||
# start-sanitize-d10v
|
||||
bfd_elf32_d10v_vec) tb="$tb elf32-d10v.o elf32.o $elf" ;;
|
||||
# end-sanitize-d10v
|
||||
# start-sanitize-d30v
|
||||
bfd_elf32_d30v_vec) tb="$tb elf32-d30v.o elf32.o $elf" ;;
|
||||
# end-sanitize-d30v
|
||||
@ -482,6 +481,7 @@ do
|
||||
target64=true ;;
|
||||
ecoff_big_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
|
||||
ecoff_little_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
|
||||
ecoff_biglittle_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;;
|
||||
ecoffalpha_little_vec) tb="$tb coff-alpha.o ecoff.o ecofflink.o"
|
||||
target64=true ;;
|
||||
evax_alpha_vec) tb="$tb evax-alpha.o evax-emh.o evax-egsd.o evax-etir.o evax-misc.o"
|
||||
@ -517,6 +517,7 @@ do
|
||||
m68knetbsd_vec) tb="$tb m68knetbsd.o aout32.o" ;;
|
||||
m68k4knetbsd_vec) tb="$tb m68k4knetbsd.o aout32.o" ;;
|
||||
m68kaux_coff_vec) tb="$tb coff-aux.o coff-m68k.o cofflink.o" ;;
|
||||
m68ksysvcoff_vec) tb="$tb coff-svm68k.o cofflink.o" ;;
|
||||
m88kbcs_vec) tb="$tb coff-m88k.o" ;;
|
||||
newsos3_vec) tb="$tb newsos3.o aout32.o" ;;
|
||||
nlm32_i386_vec) tb="$tb nlm32-i386.o nlm32.o nlm.o" ;;
|
||||
|
146
bfd/targets.c
146
bfd/targets.c
@ -560,6 +560,7 @@ extern const bfd_target m68klinux_vec;
|
||||
extern const bfd_target m68klynx_aout_vec;
|
||||
extern const bfd_target m68klynx_coff_vec;
|
||||
extern const bfd_target m68knetbsd_vec;
|
||||
extern const bfd_target m68ksysvcoff_vec;
|
||||
extern const bfd_target m68k4knetbsd_vec;
|
||||
extern const bfd_target m88kbcs_vec;
|
||||
extern const bfd_target m88kmach3_vec;
|
||||
@ -760,6 +761,7 @@ const bfd_target * const bfd_target_vector[] = {
|
||||
&m68klynx_aout_vec,
|
||||
&m68klynx_coff_vec,
|
||||
&m68knetbsd_vec,
|
||||
&m68ksysvcoff_vec,
|
||||
&m88kbcs_vec,
|
||||
&m88kmach3_vec,
|
||||
&newsos3_vec,
|
||||
@ -849,7 +851,7 @@ const bfd_target * const bfd_target_vector[] = {
|
||||
/* bfd_default_vector[0] contains either the address of the default vector,
|
||||
if there is one, or zero if there isn't. */
|
||||
|
||||
const bfd_target * const bfd_default_vector[] = {
|
||||
const bfd_target *bfd_default_vector[] = {
|
||||
#ifdef DEFAULT_VECTOR
|
||||
&DEFAULT_VECTOR,
|
||||
#endif
|
||||
@ -860,7 +862,7 @@ const bfd_target * const bfd_default_vector[] = {
|
||||
names of the matching targets in an array. This variable is the maximum
|
||||
number of entries that the array could possibly need. */
|
||||
const size_t _bfd_target_vector_entries = sizeof(bfd_target_vector)/sizeof(*bfd_target_vector);
|
||||
|
||||
|
||||
/* This array maps configuration triplets onto BFD vectors. */
|
||||
|
||||
struct targmatch
|
||||
@ -882,6 +884,101 @@ static const struct targmatch bfd_target_match[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const bfd_target *find_target PARAMS ((const char *));
|
||||
|
||||
/* Find a target vector, given a name or configuration triplet. */
|
||||
|
||||
static const bfd_target *
|
||||
find_target (name)
|
||||
const char *name;
|
||||
{
|
||||
const bfd_target * const *target;
|
||||
const struct targmatch *match;
|
||||
|
||||
for (target = &bfd_target_vector[0]; *target != NULL; target++)
|
||||
if (strcmp (name, (*target)->name) == 0)
|
||||
return *target;
|
||||
|
||||
/* If we couldn't match on the exact name, try matching on the
|
||||
configuration triplet. FIXME: We should run the triplet through
|
||||
config.sub first, but that is hard. */
|
||||
for (match = &bfd_target_match[0]; match->triplet != NULL; match++)
|
||||
{
|
||||
if (fnmatch (match->triplet, name, 0) == 0)
|
||||
{
|
||||
while (match->vector == NULL)
|
||||
++match;
|
||||
if (match->vector != UNSUPPORTED_TARGET)
|
||||
return match->vector;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bfd_set_error (bfd_error_invalid_target);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_set_default_target
|
||||
|
||||
SYNOPSIS
|
||||
boolean bfd_set_default_target (const char *name);
|
||||
|
||||
DESCRIPTION
|
||||
Set the default target vector to use when recognizing a BFD.
|
||||
This takes the name of the target, which may be a BFD target
|
||||
name or a configuration triplet.
|
||||
*/
|
||||
|
||||
boolean
|
||||
bfd_set_default_target (name)
|
||||
const char *name;
|
||||
{
|
||||
const bfd_target *old_default;
|
||||
const bfd_target *target;
|
||||
|
||||
old_default = bfd_default_vector[0];
|
||||
if (old_default != NULL)
|
||||
{
|
||||
register const struct targmatch *match;
|
||||
|
||||
/* Try to save some strcmp and fnmatch calls by seeing if we
|
||||
already have the default. */
|
||||
|
||||
if (strcmp (name, old_default->name) == 0)
|
||||
return true;
|
||||
|
||||
for (match = &bfd_target_match[0]; match->triplet != NULL; match++)
|
||||
{
|
||||
if (match->vector == old_default)
|
||||
{
|
||||
const struct targmatch *back;
|
||||
|
||||
back = match;
|
||||
do
|
||||
{
|
||||
if (fnmatch (back->triplet, name, 0) == 0)
|
||||
return true;
|
||||
|
||||
if (back == &bfd_target_match[0])
|
||||
break;
|
||||
|
||||
--back;
|
||||
}
|
||||
while (back->vector == NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
target = find_target (name);
|
||||
if (target == NULL)
|
||||
return false;
|
||||
|
||||
bfd_default_vector[0] = target;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_find_target
|
||||
@ -906,9 +1003,8 @@ bfd_find_target (target_name, abfd)
|
||||
const char *target_name;
|
||||
bfd *abfd;
|
||||
{
|
||||
const bfd_target * const *target;
|
||||
const char *targname;
|
||||
const struct targmatch *match;
|
||||
const bfd_target *target;
|
||||
|
||||
if (target_name != NULL)
|
||||
targname = target_name;
|
||||
@ -919,45 +1015,23 @@ bfd_find_target (target_name, abfd)
|
||||
if (targname == NULL || strcmp (targname, "default") == 0)
|
||||
{
|
||||
abfd->target_defaulted = true;
|
||||
abfd->xvec = bfd_target_vector[0];
|
||||
return bfd_target_vector[0];
|
||||
if (bfd_default_vector[0] != NULL)
|
||||
abfd->xvec = bfd_default_vector[0];
|
||||
else
|
||||
abfd->xvec = bfd_target_vector[0];
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
abfd->target_defaulted = false;
|
||||
|
||||
for (target = &bfd_target_vector[0]; *target != NULL; target++)
|
||||
{
|
||||
if (strcmp (targname, (*target)->name) == 0)
|
||||
{
|
||||
abfd->xvec = *target;
|
||||
return *target;
|
||||
}
|
||||
}
|
||||
target = find_target (targname);
|
||||
if (target == NULL)
|
||||
return NULL;
|
||||
|
||||
/* If we couldn't match on the exact name, try matching on the
|
||||
configuration triplet. FIXME: We should run the triplet through
|
||||
config.sub first, but that is hard. */
|
||||
for (match = &bfd_target_match[0]; match->triplet != NULL; match++)
|
||||
{
|
||||
if (fnmatch (match->triplet, targname, 0) == 0)
|
||||
{
|
||||
while (match->vector == NULL)
|
||||
++match;
|
||||
if (match->vector != UNSUPPORTED_TARGET)
|
||||
{
|
||||
abfd->xvec = match->vector;
|
||||
return match->vector;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bfd_set_error (bfd_error_invalid_target);
|
||||
|
||||
return NULL;
|
||||
abfd->xvec = target;
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_target_list
|
||||
|
Loading…
Reference in New Issue
Block a user