summaryrefslogtreecommitdiff
path: root/bfd/targets.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>1999-07-19 14:55:16 +0000
committerNick Clifton <nickc@redhat.com>1999-07-19 14:55:16 +0000
commit98b02b436adfb62d5c07b862799a20dc140fb08c (patch)
tree763462cef3273f576dc53484abc3c9852416b989 /bfd/targets.c
parent9525f147b5a331ec4727b41c5339bea5a7320ab4 (diff)
downloadbinutils-redhat-98b02b436adfb62d5c07b862799a20dc140fb08c.tar.gz
Add new field to bfd_target structure.
Initialise this field for all known bfd targets. Add new search function to targets.c
Diffstat (limited to 'bfd/targets.c')
-rw-r--r--bfd/targets.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/bfd/targets.c b/bfd/targets.c
index 604c2689f3..f7ad7b0cb7 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -460,10 +460,21 @@ The general target vector.
. PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
.
+A pointer to an alternative bfd_target in case the current one is not
+satisfactory. This can happen when the target cpu supports both big
+and little endian code, and target chosen by the linker has the wrong
+endianness. The function open_output() in ld/ldlang.c uses this field
+to find an alternative output format that is suitable.
+
+. {* Opposite endian version of this target. *}
+. const struct bfd_target * alternative_target;
+.
+
Data for use by back-end routines, which isn't generic enough to belong
in this structure.
. PTR backend_data;
+.
.} bfd_target;
*/
@@ -1079,3 +1090,32 @@ bfd_target_list ()
return name_list;
}
+
+/*
+FUNCTION
+ bfd_seach_for_target
+
+SYNOPSIS
+ const bfd_target * bfd_search_for_target (int (* search_func)(const bfd_target *, void *), void *);
+
+DESCRIPTION
+ Return a pointer to the first transfer vector in the list of
+ transfer vectors maintained by BFD that produces a non-zero
+ result when passed to the function @var{search_func}. The
+ parameter @var{data} is passed, unexamined, to the search
+ function.
+*/
+
+const bfd_target *
+bfd_search_for_target (search_func, data)
+ int (* search_func) PARAMS ((const bfd_target * target, void * data));
+ void * data;
+{
+ const bfd_target * const * target;
+
+ for (target = bfd_target_vector; * target != NULL; target ++)
+ if (search_func (* target, data))
+ return * target;
+
+ return NULL;
+}