From a30475468f127e41dad08a7a4bfebdf133bfb00f Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 8 Feb 2014 23:33:26 +0200 Subject: [PATCH] asmproc: handle offset tables better --- tools/asmproc.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tools/asmproc.c b/tools/asmproc.c index fe6fa47..6f1e3d5 100644 --- a/tools/asmproc.c +++ b/tools/asmproc.c @@ -239,9 +239,11 @@ int main(int argc, char *argv[]) } // dd offset - if (IS(word, "dd") && IS(word2, "offset")) { + if (IS(word, "dd") + && (IS(word2, "offset") || strstr(p, "offset"))) + { fprintf(fout, "\t\tdd"); - strcpy(word, word3); + p = next_word(word, sizeof(word), line); goto offset_loop; } @@ -252,9 +254,12 @@ int main(int argc, char *argv[]) p = next_word(word4, sizeof(word4), p); // dd offset - if (IS(word2, "dd") && IS(word3, "offset")) { + if (IS(word2, "dd") + && (IS(word3, "offset") || strstr(p, "offset"))) + { fprintf(fout, "%s\tdd", word); - strcpy(word, word4); + p = next_word(word, sizeof(word), line); + p = next_word(word, sizeof(word), p); goto offset_loop; } @@ -304,6 +309,19 @@ pass: offset_loop: while (1) { + p2 = next_word(word, sizeof(word), p); + if (word[0] == 0 || word[0] == ';') { + break; + } + if (!IS(word, "offset")) { + // pass through + p2 = strstr(p, "offset"); + if (p2 == NULL) + break; + fwrite(p, 1, p2 - p, fout); + p2 = next_word(word, sizeof(word), p2); + } + p = next_word(word, sizeof(word), p2); p2 = strchr(word, ','); if (p2) *p2 = 0; @@ -314,16 +332,6 @@ offset_loop: fprintf(fout, " offset %s%s", (sym != NULL && sym->callsites) ? sym_use(sym) : word, p2 ? "," : ""); - - p2 = next_word(word, sizeof(word), p); - if (word[0] == 0 || word[0] == ';') { - break; - } - if (!IS(word, "offset")) { - printf("could not handle offset array\n"); - break; - } - p = next_word(word, sizeof(word), p2); } fprintf(fout, "%s", p); continue; -- 2.39.2