--- ./src/mkheader-orig.c 2019-10-29 16:44:55.221984624 +0100 +++ ./src/mkheader.c 2019-10-29 17:08:30.982060233 +0100 @@ -146,17 +146,39 @@ * KERNEL-SYSTEM is specific enough. We now do a second pass by * replacing VENDOR with "unknown". */ char *buf = xmalloc (strlen (triplet) + 7 + 1); + int append_hf = 0; + /* ARM platforms usually have a variant (arch level, endian, extensions) + * right after "arm". "hf" may also appear there, which we must then move + * after the system at the end. + */ for (p=buf,s=triplet,i=0; *s; s++) { *p++ = *s; - if (*s == '-' && ++i == 1) - { - memcpy (p, "unknown-",8); - p += 8; - for (s++; *s != '-'; s++) - ; - } + if (*s != '-' || ++i != 1) + continue; + + if (p >= buf + 3 && !strncmp(p - 3, "hf", 2)) + append_hf = 1; + if (!strncmp(buf, "armv5", 5) || + !strncmp(buf, "armv6", 5) || + !strncmp(buf, "armv7", 5)) + p = buf+5; + else if (!strncmp(buf, "arm", 3)) + p = buf+3; + else + p--; + + memcpy (p, "-unknown-",9); + p += 9; + for (s++; *s != '-'; s++) + ; + } + + if (append_hf) + { + memcpy (p, "hf", 2); + p += 2; } *p = 0; result = canon_host_triplet (buf, 1, NULL);