← index #8782PR #12123
Related · high · value 0.464
QUERY · ISSUE

mpy_ld.py: "AttributeError: 'Symbol' object has no attribute 'section'" when relocating data section

openby phlashopened 2022-06-19updated 2022-06-19
bug

While linking a larg(ish) project, with the latest micropython and ESP-IDF compiler, I had a failure in mpy_ld.py due to a relocation in a .data.rel.ro section that went via an unresolved (UND) symbol. The symbol was correctly resolved later on, however the logic in do_relocation_data does not take account of this fact, and fails when trying to de-reference the non-existant section attribute. Applying similar logic to that in do_relocation_text (see diff below) appears to fix this issue:

@@ -638,6 +639,9 @@ def do_relocation_data(env, text_addr, r):
         or env.arch.name == "EM_XTENSA"
         and r_info_type == R_XTENSA_32
     ):
+        # Bug fix: use resolved symbol if available (as per text relocs)
+        if hasattr(s, "resolved"):
+            s = s.resolved
         # Relocation in data.rel.ro to internal/external symbol
         if env.arch.word_size == 4:
CANDIDATE · PULL REQUEST

mpy_ld.py: Support complex RO sections

mergedby jonnoropened 2023-07-30updated 2023-09-01
tools

Sometimes the sections are named .rodata.str1.1 etc, instead of just .rodata. Fix thanks to @phlash in #8783

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied