//
-// RMAC - Reboot's Macro Assembler for all Atari computers
+// RMAC - Renamed Macro Assembler for all Atari computers
// OBJECT.C - Writing Object Files
-// Copyright (C) 199x Landon Dyer, 2011-2020 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
//
// Add an entry to the BSD symbol table
//
+// From stab.def (https://sites.uclouvain.be/SystInfo/usr/include/bits/stab.def.html):
+/*
+_________________________________________________
+| 00 - 1F are not dbx stab symbols |
+| In most cases, the low bit is the EXTernal bit|
+
+| 00 UNDEF | 02 ABS | 04 TEXT | 06 DATA |
+| 01 |EXT | 03 |EXT | 05 |EXT | 07 |EXT |
+
+| 08 BSS | 0A INDR | 0C FN_SEQ | 0E WEAKA |
+| 09 |EXT | 0B | 0D WEAKU | 0F WEAKT |
+
+| 10 WEAKD | 12 COMM | 14 SETA | 16 SETT |
+| 11 WEAKB | 13 | 15 | 17 |
+
+| 18 SETD | 1A SETB | 1C SETV | 1E WARNING|
+| 19 | 1B | 1D | 1F FN |
+*/
uint8_t * AddBSDSymEntry(uint8_t * buf, SYM * sym, int globflag)
{
chptr = buf; // Point to buffer for depositing longs
if (w1 & DEFINED)
{
if (globflag) // Export the symbol
- st_info |= 16; //STB_GLOBAL (1<<4)
+ st_info |= 16; // STB_GLOBAL (1<<4)
}
else if (w1 & (GLOBAL | REFERENCED))
st_info |= 16;
D_byte(st_info);
D_byte(0); // st_other
- uint16_t st_shndx = 0xFFF1; // Assume absolute (equated) number
+ uint16_t st_shndx = SHN_ABS; // Assume absolute (equated) number
if (w1 & TEXT)
st_shndx = elfHdrNum[ES_TEXT];
st_shndx = elfHdrNum[ES_DATA];
else if (w1 & BSS)
st_shndx = elfHdrNum[ES_BSS];
- else if (globflag)
- st_shndx = 0; // Global, not absolute
+ else if (globflag && !(w1 & DEFINED) && (w1 & REFERENCED))
+ {
+ st_shndx = SHN_UNDEF;
+ } // If the symbol is global then probably we
+ // don't need to do anything (probably)
+ // since we set STB_GLOBAL in st_info above.
+ // Unless we need to set it to SHN_COMMON?
D_word(st_shndx);