binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

Unrelated symbol value when compiling with -c -g

Open sinitax opened this issue 8 months ago • 1 comments

Version and Platform (required):

  • Binary Ninja Version: 5.0.7290-stable & 5.1.7484-dev
  • Edition: Commercial
  • OS: Arch Linux
  • OS Version: 2025-05-01
  • CPU Architecture: x64

Bug Description: For at least one symbol, the value it references is replaced by a completely different string.

Steps To Reproduce: Reproducible by compiling with -c -g on gcc or clang, tested with gcc 15.1.1 and clang 19.1.7. Source-code for first screenshot: int main(void) {} Source-code for second screenshot: void abc(void) {}; int main(void) {}

Expected Behavior: The symbol does not reference an unrelated string.

Screenshots/Video Recording:

Image

Image

Binary:

First screenshot: main.zip

Second screenshot: main.zip

Additional Information: In the sample screenshots the symbol value was replaced with the contents of the .comment section, but this is not always the case. In another instance the string value was unsigned int, a binaryninja internal string.

Typically the symbol affected is that of the first defined function. When this function's name is <4 bytes long, the value in the Symbols view is correct, but in the Linear view it is the unrelated value.

Without knowing how things are implemented under the hood it looks like some sort of misindex into a string table, potentially with the index value being erroneously set to 0.

sinitax avatar May 21 '25 17:05 sinitax

For some reason we're resolving DW_AT_name to DebugStrRef(DebugStrOffset(0)) for the only DW_TAG_subprogram entry in that sample, when it should be DebugStrRef(DebugStrOffset(56))

negasora avatar May 22 '25 17:05 negasora

This was fixed with https://github.com/Vector35/binaryninja-api/issues/7480 in 5.2.8406-dev with https://github.com/Vector35/binaryninja-api/commit/b6740d03abd22441e2e79e1d6a13c474e3fcba90

negasora avatar Oct 18 '25 21:10 negasora