在macOS上打印可执行文件的rpath [英] Print rpath of an executable on macOS

查看:118
本文介绍了在macOS上打印可执行文件的rpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用install_name_tool更改可执行文件的 rpath ,但是我无法弄清楚 rpath 现在是什么. install_name_tool要求在命令行中同时提供新旧的 rpath .我可以使用什么命令在macOS下打印可执行文件的 rpath ?

I want to change the rpath of an executable using install_name_tool, but I can't figure out what the rpath is right now. install_name_tool requires both the old and the new rpath's to be given on the commandline. What command can I use to print the rpath of an executable under macOS?

推荐答案

首先,请了解可执行文件不包含单个rpath条目,而是包含一个或多个条目的数组.

First of all, understand that an executable doesn't contain a single rpath entry, but an array of one or more entries.

第二,您可以使用otool列出图像的rpath条目.使用otool -l,您将获得如下所示的输出,其末尾是rpath条目:

Second, you can use otool to list an image's rpath entries. Using otool -l, you'll get output like the following, at the very end of which are the rpath entries:

Load command 34
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 1038.32.0
compatibility version 45.0.0

Load command 35
          cmd LC_RPATH
      cmdsize 40
         path @loader_path/../Frameworks (offset 12)

查找LC_RPATH命令并记下path条目下的路径.

Look for the LC_RPATH commands and note the path under the path entry.

这篇关于在macOS上打印可执行文件的rpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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