This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch]: Patch for wince
2009/1/3 Kai Tietz <ktietz70@googlemail.com>:
> Hi Richard,
>
> 2009/1/3 Richard Earnshaw <richard.earnshaw@buzzard.freeserve.co.uk>:
>> On Sat, 2009-01-03 at 08:59 +0100, Kai Tietz wrote:
>>> * windres.c (set_endianess): Get architecture name
>>> for triplets like "pe-arm-wince-little".
>>
>> pe-arm-wince-little isn't a triplet. It's a quadruplet (three hyphens).
>>
>> In general these are a bad idea, so where has this come from?
>>
>> Also, I think ARM targets should start with ARM, not some other
>> component, so that generic matchers for arm*-*-* will correctly detect
>> these targets.
>>
>> R.
>>
>>
>
> Be aware, that this isn't a configure triplet (or better quadruplet).
> This comes from internal bfd target specifiers.
> The origin of this is from gccce (mingwce).
> But by verifying this, I see that at least for name "x86-64" a special
> treating is necessary here.
>
> Cheers,
> Kai
>
> --
> | (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>
Hi,
I altered this patch in way to handle still internal target names,
like pe-x86-64, ...
So I search for the architecture name in internal target names from
right to left.
2009-01-03 Kai Tietz <kai.tietz@onevision.com>
* windres.c (set_endianess): Get architecture name
for internal target names like "pe-arm-wince-little".
(find_arch_match): New helper.
Is this patch ok for apply?
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
Index: src/binutils/windres.c
===================================================================
--- src.orig/binutils/windres.c
+++ src/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 *ta
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);