Type libraries for non-x86 are weirdly wrong and incomplete

Open
#4,347 0 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, python

Research direction

Start by comparing the generated libraries at typelib/armv7/libc.so.6.bntl, typelib/aarch64/libc.so.6.bntl, and typelib/x86/libc.so.6.bntl, using the TypeLibrary Python calls shown in the report. Trace the undocumented builtin type-library generation process and verify that non-x86 libraries include strcpy with the same correct two-argument signature as x86.

Written by the indexing model from the issue text.

Description

Component: Type Libraries Effort: Medium Impact: Medium

Version and Platform (required):

  • Binary Ninja Version: 3.5.4296-dev
  • OS: Arch Linux
  • CPU Architecture: x64

Bug Description:
strcpy gets an absolutely bonkers type on armv7, and doesn't exist on aarch64. The process by which the builtin type libraries are generated is undocumented, which makes it difficult to discern why this is the case, and what the actual extent of the problem is.

Steps To Reproduce:

In [1]: from binaryninja import *

In [2]: tylib = TypeLibrary.load_from_file('/home/maya/binaryninja/typelib/armv7/libcv
   ...: 7.so.6.bntl')

In [3]: tylib.get_named_object('strcpy')
Out[3]: <type: immutable:FunctionTypeClass 'char*(char* dest, char const* src, char const* src, char* dest)'>

In [4]: tylib = TypeLibrary.load_from_file('/home/maya/binaryninja/typelib/aarch64/lib
   ...: c.so.6.bntl')

In [5]: tylib.get_named_object('strcpy')

In [6]: tylib.get_named_object('strcpy') is None
Out[6]: True

Expected Behavior:
The type is correct, as on x86:

In [7]: tylib = TypeLibrary.load_from_file('/home/maya/binaryninja/typelib/x86/libc.so
   ...: .6.bntl')

In [8]: tylib.get_named_object('strcpy')
Out[8]: <type: immutable:FunctionTypeClass 'char*(char*, char const*)'>
Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Vector35/binaryninja-api

All issues in Vector35/binaryninja-api

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.