for (; *s != 0; s++) {
if (*s == '"') {
- strcpy(t, "\\x22");
+ strcpy(t, "\\\"");
t += strlen(t);
continue;
}
}
*t++ = *s;
}
- *t = *s;
+ *t++ = *s;
+ if (t - buf > sizeof(buf))
+ aerr("string is too long\n");
return strcpy(s, buf);
}
val = parse_number(words[w]);
if (val & ~0xff)
aerr("bad string trailing byte?\n");
- fprintf(fout, "\\x%02lx", val);
+ // unfortunately \xHH is unusable - gas interprets
+ // things like \x27b as 0x7b, so have to use octal here
+ fprintf(fout, "\\%03lo", val);
}
}
fprintf(fout, "\"");