用于检查.rlib二进制文件的Rust库 [英] Rust library for inspecting .rlib binaries

查看:70
本文介绍了用于检查.rlib二进制文件的Rust库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种加载和检查rustc生成的.rlib二进制文件的方法.我在标准库中四处寻觅,没有多大运气.我的假设是.rlib包含类型化"它的静态类型检查程序所必需的所有类型信息.rustc :: metadata是我的狩猎结束的地方.我无法弄清楚编译器此刻可用的结构是否打算用作用户的入口点,或者它们仅仅是中间抽象,取决于先前初始化的数据链.

I'm looking for a way to load and inspect .rlib binaries generated by rustc. I've hunted around the standard library without much luck. My assumption is that an .rlib contains all the type information necessary to statically type check programs that "extern crate" it. rustc::metadata is where my hunt ended. I can't quite figure out if the structures available at this point in the compiler are intended as entry points for users, or if they are solely intermediate abstractions depending on a chain of previously initialized data.

或者,如果有一种方法可以将.rlib以可解析的形式转储到stdout,那也很棒.我尝试了/usr/bin/nm,但似乎不包括函数类型签名.也许我想念一些东西.

Alternatively, If there's a way to dump an .rlib to stdout in a parsable form then that's also fantastic. I tried /usr/bin/nm, but it seemed to be excluding function type signatures. Maybe I'm missing something.

无论如何,我正在开发emacs的编辑器实用程序,希望在某个时候可以提供上下文相关的信息,例如可用的方法,模块项及其类型等.我非常感谢任何人提供的任何提示.

Anyways, I'm working on an editor utility for emacs that I hope at some point will provide contextually relevant information such as available methods, module items and their types, etc. I'd really appreciate any hints anyone has.

推荐答案

.rlib文件是ar存档文件.您可以使用 readelf 读取其内容.

The .rlib file is an ar archive file. You can use readelf to read its content.

尝试 readelf -s< your_lib> .rlib .类型名称可能由编译器混合/修饰,因此它可能与.rs文件中的名称不完全相同.

Try readelf -s <your_lib>.rlib. The type name may be mingled/decorated by the compiler so it may not be exactly the same as in .rs file.

这篇关于用于检查.rlib二进制文件的Rust库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆