- // If this is a debug symbol and the include debug symbol flag (-g) is not set then do nothing
- if ((type & 0xF0000000) && !gflag) {
- // Do nothing
- } else {
- ostresult = ost_lookup(name); // Get symbol index in OST
- // If the symbol is in the output symbol table and the bflag is set (don't remove multiply
- // defined locals) and this is not an external/global symbol *** OR *** the symbol is not
- // in the output symbol table then add it.
- if (((ostresult != -1) && bflag && !(type & 0x01000000)) ||
- ((ostresult != -1) && gflag && (type & 0xF0000000)) || (ostresult == -1)) {
- if ((type & 0xF0000000) == 0x40000000)
- putlong(ost_ptr, 0x00000000); // Zero string table offset for dbg line
- else
- putlong(ost_ptr, (oststr_ptr - oststr)); // String table offset of symbol string
- putlong(ost_ptr + 4, type );
- putlong(ost_ptr + 8, value);
- ost_ptr += 12;
- // If the symbol type is anything but a debug line information symbol then write
- // the symbol string to the string table
- if ((type & 0xF0000000) != 0x40000000) {
- strcpy(oststr_ptr, name); // Put symbol name in string table
- *(oststr_ptr + slen) = '\0'; // Add null terminating character
- oststr_ptr += (slen + 1);
- putlong(oststr_ptr, 0x00000000); // Null terminating long
- putlong(oststr, (oststr_ptr - oststr)); // Update size of string table
- }
- return(ost_index++); // Return OST index
- }
- }
+ ost_ptr = ost; // Set OST start pointer
+ ost_end = ost + OST_BLOCK; // Set OST end pointer
+
+ if ((oststr = malloc(OST_BLOCK)) == NULL)
+ {
+ printf("OST memory allocation error (string).\n");
+ return -1;
+ }
+
+ putlong(oststr, 0x00000004); // Just null long for now
+ oststr_ptr = oststr + 4; // Skip size of str table long (incl null long)
+ putlong(oststr_ptr, 0x00000000); // Null terminating long
+ oststr_end = oststr + OST_BLOCK;
+ }
+ else
+ {
+ // If next symbol record exceeds current allocation then expand symbol table.
+ ost_offset_p = (ost_ptr - ost);
+ ost_offset_e = (ost_end - ost);
+
+ // 3 x int (12)
+ if ((ost_ptr + 12) > ost_end)
+ {
+ if ((ost = realloc(ost, (unsigned)(ost_end + OST_BLOCK))) == NULL)
+ {
+ printf("OST memory reallocation error.\n");
+ return -1;
+ }
+
+ ost_ptr = ost + ost_offset_p;
+ ost_end = (ost + ost_offset_e) + OST_BLOCK;
+ }
+
+ ost_offset_p = (oststr_ptr - oststr);
+ ost_offset_e = (oststr_end - oststr);
+
+ if ((oststr_ptr + (slen + 1 + 4)) > oststr_end)
+ {
+ if ((oststr = realloc(oststr, (unsigned)(oststr_end + OST_BLOCK))) == NULL)
+ {
+ printf("OSTSTR memory reallocation error.\n");
+ return -1;
+ }
+
+ oststr_ptr = oststr + ost_offset_p;
+ oststr_end = (oststr + ost_offset_e) + OST_BLOCK;
+ }
+ }
+
+#if 0
+if ((strcmp(name, "U235SE_playback_rate") == 0)
+ || (strcmp(name, "U235SE_playback_period") == 0))
+{
+ printf("%s found: ost[0]=$%08X, ost[1]=$%08X, ost[2]=$%08X\n", name, getlong(ost_ptr), type, value);
+}
+#endif
+ // If this is a debug symbol and the include debug symbol flag (-g) is not
+ // set then do nothing
+ if ((type & 0xF0000000) && !gflag)
+ {
+ // Do nothing
+#if 0
+if ((strcmp(name, "U235SE_playback_rate") == 0)
+ || (strcmp(name, "U235SE_playback_period") == 0))
+ printf("%s was IGNORED!\n", name);
+#endif
+ }
+ else
+ {
+ ostresult = ost_lookup(name); // Get symbol index in OST
+
+ // If the symbol is in the output symbol table and the bflag is set
+ // (don't remove multiply defined locals) and this is not an
+ // external/global symbol *** OR *** the symbol is not in the output
+ // symbol table then add it.
+ if (((ostresult != -1) && bflag && !(type & 0x01000000))
+ || ((ostresult != -1) && gflag && (type & 0xF0000000)) || (ostresult == -1))
+ {
+#if 1
+if ((strcmp(name, "U235SE_playback_rate") == 0)
+ || (strcmp(name, "U235SE_playback_period") == 0))
+ printf("%s was added to the ost.\n", name);
+#endif
+ if ((type & 0xF0000000) == 0x40000000)
+ putlong(ost_ptr, 0x00000000); // Zero string table offset for dbg line
+ else
+ putlong(ost_ptr, (oststr_ptr - oststr)); // String table offset of symbol string
+
+ putlong(ost_ptr + 4, type );
+ putlong(ost_ptr + 8, value);
+ ost_ptr += 12;
+
+ // If the symbol type is anything but a debug line information
+ // symbol then write the symbol string to the string table
+ if ((type & 0xF0000000) != 0x40000000)
+ {
+ strcpy(oststr_ptr, name); // Put symbol name in string table
+ *(oststr_ptr + slen) = '\0'; // Add null terminating character
+ oststr_ptr += (slen + 1);
+ putlong(oststr_ptr, 0x00000000); // Null terminating long
+ putlong(oststr, (oststr_ptr - oststr)); // Update size of string table
+ }