This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F28386D:EABI 文件-使用 pyelftools 通过类型签名查找 CU。

Guru**** 2457760 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1395850/tms320f28386d-eabi-file---use-pyelftools-to-lookup-cu-via-type-signature

器件型号:TMS320F28386D

工具与软件:

你好,我试图使用 pyelftools (我愿意使用任何工具,可能在 python 中工作)来查找类型签名 cus。

例如:

我在 CU 中有这个可变裸片:

[2><6000>:缩写编号:88 (DW_TAG_variable)
<6001> DW_AT_LOCATION:1字节块:51 (DW_OP_REG1 (R1))
<6002> DW_AT_name:(间接字符串、偏移量:0x18ba): 电压
<6003> DW_AT_TYPE:签名:0x2d17b183dd167833

这种类型签名0x942beca6370cb633 与 CU 匹配:

编译单元@偏移0x10d1:
长度:0x2E (32位)
版本:4
缩写偏移量:0
指针大小:4
签名:0x2d17b183dd167833
类型偏移:0x20
<0><10e8>:缩写编号:93 (DW_TAG_TYPE_UNIT)
<10E9> DW_AT_stmt_list:0x44dcb
<10ed> DW_AT_producer:(间接字符串、偏移量:0x4d):TI TMS320C2000 Linker PC v22.6.1版权所有(c) 1996-2018 Texas Instruments Incorporated
<1><10F1>:缩写号码:49 (DW_TAG_BASE_TYPE)
<10f2> DW_AT_name:unsigned char
<1100> DW_AT_BYTE_SIZE:1.
<1101> DW_AT_encoding:8 (unsigned char)

我从 readelf debug-dump=info 中获得了该信息。  它告诉我、voltage 为 unsigned char 类型、大小为1个字节。

似乎 CU 在 pyelftools 中没有 Signature 属性?  我如何在 python 中将这些关系关联起来?

根据一些研究、 其他转储会使用偏移量。  类似于:<6003> DW_AT_type:<0x20>(这是 unsigned char cu.的偏移量) 而不是类型签名。

我的最终目标是列出所有变量、以及 它们的类型、字节大小(这些变量都列在 CU 中且签名为0x2d17b183dd167833)和内存地址(我认为我必须先看一下该段、然后再看偏移量)。  为了实现任何这一点、我必须以递归方式浏览 DW_AT_TYPE 签名树。


这里不支持它吗?   https://github.com/eliben/pyelftools/blob/0f72cb7990c7039258b7988602b0aec83c5864f7/elftools/dwarf/die.py#L120-L123 我还可以使用其他任何方法吗?

请提供任何援助。  谢谢!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    很遗憾、我不知道有任何 TI 员工熟悉 pyelftools、因此我们无法为您提供帮助。   

    Unknown 说:
    我从 readelf debug-dump=info 中获得了此信息。  它告诉我 voltage 为 unsigned char 类型、大小为1个字节。[/QUOT]

    需要注意的一个细节。  在 C28x 上、大小为 字符 是16位、因此的大小 电压 是16位。  pyelftools 可能会假定这种情况 字符 始终为8位。   

    谢谢。此致、

    -George.