Skip to content

Commit 2417778

Browse files
committed
let SymbolTable.export() optionally export non-global symbols too
This is then the same behaviour as before the .global directive was supported. It might be useful for debugging purposes or potentially some backward compatibility issues (e.g. scripts that depend on the symbol printout after assembling)
1 parent 3a2d312 commit 2417778

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

esp32_ulp/assemble.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def dump(self):
5353
for symbol, entry in self._symbols.items():
5454
print(symbol, entry)
5555

56-
def export(self):
56+
def export(self, incl_non_globals=False):
5757
addrs_syms = [(self.resolve_absolute(entry), symbol)
5858
for symbol, entry in self._symbols.items()
59-
if symbol in self._globls]
59+
if incl_non_globals or symbol in self._globls]
6060
return sorted(addrs_syms)
6161

6262
def to_abs_addr(self, section, offset):

tests/assemble.py

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ def test_assemble_global():
118118
assert 'internal' not in [x[1] for x in exported_symbols]
119119
assert exported_symbols == [(0, 'counter'), (2, 'entry')]
120120

121+
exported_symbols = a.symbols.export(True) # include non-global symbols
122+
assert 'internal' in [x[1] for x in exported_symbols]
123+
assert exported_symbols == [(0, 'counter'), (1, 'internal'), (2, 'entry')]
124+
121125

122126
def test_symbols():
123127
st = SymbolTable({}, {}, {})

0 commit comments

Comments
 (0)