uint8_t * AddBSDSymEntry(uint8_t * buf, SYM * sym, int globflag)
{
chptr = buf; // Point to buffer for depositing longs
- D_long(strindx); // Deposit the symbol string index
+ if (sym->sname)
+ {
+ D_long(strindx); // Deposit the symbol string index
+ }
+ else
+ {
+ D_long(0); // Deposit special NULL string index
+ }
uint16_t w1 = sym->sattr; // Obtain symbol attributes
uint32_t z = 0; // Initialize resulting symbol flags
- if (w1 & EQUATED)
+ if (sym->stype == DBGSYM)
{
- z = 0x02000000; // Set equated flag
+ // Debug symbols hard-code the a.out symbol type in the st_type field
+ // and can include additional type-specific data in the a.out symbol
+ // "other" and "description" fields, both packed into this same dword.
+ z = sym->st_type << 24;
+ z |= sym->st_other << 16;
+ z |= sym->st_desc;
}
+ else
+ {
+ // Translate rmac symbol attributes to an a.out symbol type.
+ if (w1 & EQUATED)
+ {
+ z = 0x02000000; // Set equated flag
+ }
- // If a symbol is both EQUd and flagged as TBD then we let the latter take
- // precedence. Otherwise the linker will not even bother trying to relocate
- // the address during link time.
+ // If a symbol is both EQUd and flagged as TBD then we let the latter
+ // take precedence. Otherwise the linker will not even bother trying to
+ // relocate the address during link time.
- switch (w1 & TDB)
- {
- case TEXT: z = 0x04000000; break; // Set TEXT segment flag
- case DATA: z = 0x06000000; break; // Set DATA segment flag
- case BSS : z = 0x08000000; break; // Set BSS segment flag
- }
+ switch (w1 & TDB)
+ {
+ case TEXT: z = 0x04000000; break; // Set TEXT segment flag
+ case DATA: z = 0x06000000; break; // Set DATA segment flag
+ case BSS : z = 0x08000000; break; // Set BSS segment flag
+ }
- if (globflag)
- z |= 0x01000000; // Set global flag if requested
+ if (globflag)
+ z |= 0x01000000; // Set global flag if requested
+ }
D_long(z); // Deposit symbol attribute
z = sym->svalue; // Obtain symbol value
z += sect[DATA].sloc; // If BSS add DATA segment size
D_long(z); // Deposit symbol value
- strcpy(strtable + strindx, sym->sname);
- strindx += strlen(sym->sname) + 1; // Incr string index incl null terminate
+ if (sym->sname)
+ {
+ strcpy(strtable + strindx, sym->sname);
+ strindx += strlen(sym->sname) + 1; // Incr string index incl null terminate
+ }
buf += 12; // Increment buffer to next record
symsize += 12; // Increment symbol table size
// Just write the object file
m6502obj(fd);
}
+ else if (obj_format == C64PRG)
+ {
+ // Just write the object file
+ m6502c64(fd);
+ }
else if (obj_format == P56 || obj_format == LOD)
{
// Allocate 6MB object file image memory
}
else if (obj_format == RAW)
{
- if (!org68k_active)
+ if (!org68k_active && used_architectures & (!(M6502 | M56001P | M56001X | M56001Y | M56001L)))
return error("cannot output absolute binary without a starting address (.org or command line)");
+ if (used_architectures & M6502)
+ {
+ // Okay, this is not the best. But it'll have to do until we revamp things a bit with sections.
+ // Basically we assume that if raw output is requested and 6502 mode was switched on, nobody
+ // switched to other architectures. The combination doesn't make much sense anyway for now.
+ m6502raw(fd);
+ return 0;
+ }
+
// Alloc memory for text + data construction.
tds = sect[TEXT].sloc + sect[DATA].sloc;
buf = malloc(tds);