Repository navigation
[DWARF Import] Update object to 0.41 to read Xtensa debug relocations - #8728
Merged
Merged
Conversation
Loading an Xtensa relocatable object built with -g failed with "Failed to load DWARF info: Unsupported relocation type", so no debug info was imported. ESP-IDF builds with -ggdb by default, so this affected nearly every object built for the ESP32, ESP32-S2, ESP32-S3 and ESP8266. object 0.41 handles these relocations itself (gimli-rs/object#1010): it skips the R_XTENSA_DIFF*/PDIFF*/NDIFF* label-difference relocations, whose result GNU as has already stored, and gives R_XTENSA_32 an implicit addend, since binutils treats it as partial-inplace even though Xtensa uses RELA. Without that, a DW_FORM_strp emitted as R_XTENSA_32 .debug_str + 0 would read as offset 0.
ElykDeer
self-requested a review
November 19, 2026 19:32
ElykDeer
approved these changes
Nov 19, 2026
ElykDeer
left a comment
Member
There was a problem hiding this comment.
Just have wait for tests to pass, and this should be good. Thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Loading an Xtensa relocatable object built with
-gimports no debug info. The DWARF importer logs:ESP-IDF builds with
-ggdbby default, so this affects nearly every object built for the ESP32, ESP32-S2, ESP32-S3 and ESP8266. Linked ELFs are unaffected because they have no relocations.GNU as emits
R_XTENSA_PDIFF8/16/32(orDIFF*/NDIFF*) relocations for symbol differences in.debug_info,.debug_line,.debug_frame,.debug_aranges,.debug_loclistsand.debug_rnglists, whichobject0.36 maps toRelocationKind::Unknown, soRelocationMap::addrejects them.R_XTENSA_32is also partial-inplace in binutils even though Xtensa uses RELA, so aDW_FORM_strpemitted asR_XTENSA_32 .debug_str + 0would read as offset 0.object0.41.0 fixes both (gimli-rs/object#1010): the difference relocations returnRelocationKind::None, whichRelocationMapskips, andR_XTENSA_32has an implicit addend.Changes
object0.36 → 0.41 inplugins/dwarf/sharedandplugins/dwarf/dwarf_import. No source changes are needed.dwarf_exportstays on 0.32.The other change between 0.36 and 0.41 that touches this code:
RelocationMap::addnow rejects relocations with a subtractor (object#1012). 0.36 already rejected Mach-OSUBTRACTORpairs, asUnknownrelocations, so they still fail, just with a different message.Testing
Built
dwarf_importfrom this branch and loaded it headless into Binary Ninja 6.1.11155-dev (same core ABI asdev), in place of the bundled importer (corePlugins.dwarfImport: false, with the built.soin a throwaway user plugin directory). An Xtensa/ESP32 architecture plugin with an ELF relocation handler was loaded alongside it. The test files arecorpus.cbuilt with Espressif GCC 14.2 for the ESP32 (-O2 -ggdband-Og -ggdb,-c; 177R_XTENSA_32, 164R_XTENSA_PDIFF16and 53R_XTENSA_PDIFF32relocations) and the ESP32-C3, plus x86-64 objects and binaries.devfails with the error above. This branch imports 13 functions, 1 of the 2 data variables, and 4 types. Both data variables are at offset 0 of their sections (.dataand.bss), so they get the same address and one replaces the other. An x86-64 object loses one the same way ondev. The function signatures and types are identical to the import of the same object linked withld.dev(DWARF functions, data variables and types, and the view's function types and variables): the linked ESP32 ELF, the ESP32-C3 objects (-O2,-Og, which still fail on RISC-V relocations; [DWARF Import] Place relocatable object addresses where the view put their sections, and import RISC-V objects #8731 fixes that) and linked ELF, an x86-64 object, and linked x86-64 PIE and non-PIE binaries.add3at 0x10020), and the view's function types and local variables are identical to the import of the linked object.dwarfreader/dwarf_importas ondev.cargo fmt --checkreports two diffs indwarfdebuginfo.rs, which comes fromdevand isn't changed here.