diff -r 8e2f7a031410 -r 2e333a3ca49a objwriter.cxx --- a/objwriter.cxx Mon Aug 13 19:12:21 2012 +0300 +++ b/objwriter.cxx Mon Aug 13 23:10:39 2012 +0300 @@ -101,15 +101,17 @@ // Write string table void ObjWriter::WriteStringTable () { - // If we added strings here, we need to write a list of them. unsigned int stringcount = CountStringTable (); - if (stringcount) { - Write (DH_STRINGLIST); - Write (stringcount); - - for (unsigned int a = 0; a < stringcount; a++) - WriteString (g_StringTable[a]); - } + if (!stringcount) + return; + + // Write header + Write (DH_STRINGLIST); + Write (stringcount); + + // Write all strings + for (unsigned int a = 0; a < stringcount; a++) + WriteString (g_StringTable[a]); } // Write main buffer to file @@ -124,11 +126,11 @@ if (!ref) continue; - for (unsigned int v = 0; v < sizeof (word); v++) { - union_t uni; - uni.val = static_cast (MainBuffer->marks[ref->num]->pos); + // Substitute the placeholder with the mark position + union_t uni; + uni.val = static_cast (MainBuffer->marks[ref->num]->pos); + for (unsigned int v = 0; v < sizeof (word); v++) memset (MainBuffer->buffer + ref->pos + v, uni.b[v], 1); - } /* printf ("reference %u at %d resolved to %u at %d\n", @@ -139,7 +141,7 @@ // Then, dump the main buffer to the file for (unsigned int x = 0; x < MainBuffer->writesize; x++) - WriteDataToFile (*(MainBuffer->buffer+x)); + WriteDataToFile (*(MainBuffer->buffer+x)); printf ("-- %u byte%s written to %s\n", numWrittenBytes, PLURAL (numWrittenBytes), filepath.chars()); fclose (fp);