1

我想在 Windows 下使用 libdwarf 库在 C 中创建一个程序,该库能够提取有关作为输入给出的变量的信息。程序应该以字节为单位输出变量的大小和类型(无符号、有符号、浮点)。

到目前为止,我能够在 Windows 下编译该库,但我很难弄清楚所有的库函数。我需要的是一个函数,它接受一个字符串(变量的名称)并输出一个 DIE 偏移量。之后,我可以使用其他函数在给定的 DIE 偏移处提取类型属性。

有这样的功能吗?

4

1 回答 1

0

Windows uses the PE format, not ELF, for executables so it seems odd that you are doing this under windows.

Using libdwarf it should be possible to figure out the size and type of a variable, but there is no function in the library that operates at that high level. I believe what you need to do is roughly 1. iterate over compilation units with dwarf_next_cu_header 2. Get the first DIE in the CU with dwarf_siblingof 3. Walk the DIE tree to find the DIE you need 4. Get information about that DIE

于 2014-04-11T00:22:13.623 回答