From 017a93661be8ce142d2d4d68acca0a7edc300b11 Mon Sep 17 00:00:00 2001 From: Kai Tietz Date: Tue, 6 Jan 2009 15:36:05 +0000 Subject: 2009-01-06 Kai Tietz * windres.c (set_endianess): Get architecture name for internal target names like "pe-arm-wince-little". (find_arch_match): New helper. * ChangeLog: Reset it. * ChangeLog-2008: Moved old ChangeLog. --- binutils/windres.c | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'binutils/windres.c') diff --git a/binutils/windres.c b/binutils/windres.c index 98ce1652a0..ece32bad6b 100644 --- a/binutils/windres.c +++ b/binutils/windres.c @@ -1062,6 +1062,25 @@ main (int argc, char **argv) return 0; } +static int +find_arch_match(const char *tname,const char **arch) +{ + while (*arch != NULL) + { + const char *in_a = strstr (*arch, tname); + char end_ch = (in_a ? in_a[strlen(tname)] : 0); + + if (in_a && (in_a == *arch || in_a[-1] == ':') + && end_ch == 0) + { + def_target_arch = *arch; + return 1; + } + arch++; + } + return 0; +} + static void set_endianess (bfd *abfd, const char *target) { @@ -1079,23 +1098,28 @@ set_endianess (bfd *abfd, const char *target) if (arches && tname) { - const char ** arch = arches; + char *hyp = strchr (tname, '-'); - if (strchr (tname, '-') != NULL) - tname = strchr (tname, '-') + 1; - while (*arch != NULL) + if (hyp != NULL) { - const char *in_a = strstr (*arch, tname); - char end_ch = (in_a ? in_a[strlen(tname)] : 0); + tname = hyp + 1; - if (in_a && (in_a == *arch || in_a[-1] == ':') - && end_ch == 0) + /* Make sure we dectect architecture names + for triplets like "pe-arm-wince-little". */ + if (!find_arch_match (tname, arches)) { - def_target_arch = *arch; - break; + char *new_tname = (char *) alloca (strlen (hyp) + 1); + strcpy (new_tname, hyp); + while ((hyp = strrchr (new_tname, '-')) != NULL) + { + *hyp = 0; + if (find_arch_match (new_tname, arches)) + break; + } } - arch++; } + else + find_arch_match (tname, arches); } free (arches); -- cgit v1.2.1