Skip to content

Commit 45b3769

Browse files
committedAug 2, 2021
fix a crash bug where BSS size calculation was attemped on the value of a data item (bytes) intstead of the size of that data item (int)
The size of the bss section was increased with the value of the defined symbol rather than the size of that value (number of bytes). This change fixes that.
1 parent 8d7981d commit 45b3769

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
 

‎esp32_ulp/assemble.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ def append_section(self, value, expected_section=None):
150150
if expected_section is not None and s is not expected_section:
151151
raise TypeError('only allowed in %s section' % expected_section)
152152
if s is BSS:
153-
# just increase BSS size by value
154-
self.offsets[s] += value
153+
# just increase BSS size by length of value
154+
self.offsets[s] += len(value)
155155
else:
156156
self.sections[s].append(value)
157157
self.offsets[s] += len(value)

‎tests/assemble.py

+19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
.data
1515
"""
1616

17+
src_bss = """\
18+
.bss
19+
20+
label:
21+
.long 0
22+
"""
23+
1724

1825
def test_parse_line():
1926
a = Assembler()
@@ -53,6 +60,17 @@ def test_assemble():
5360
assert a.offsets[BSS] == 0
5461

5562

63+
def test_assemble_bss():
64+
a = Assembler()
65+
try:
66+
a.assemble(src_bss)
67+
except TypeError:
68+
raised = True
69+
else:
70+
raised = False
71+
assert not raised
72+
73+
5674
def test_symbols():
5775
st = SymbolTable({}, {})
5876
for entry in [
@@ -109,4 +127,5 @@ def test_symbols():
109127
test_parse_line()
110128
test_parse()
111129
test_assemble()
130+
test_assemble_bss()
112131
test_symbols()

0 commit comments

Comments
 (0)