从 Linux 确定 AIX 的库存档是 32 位、64 位还是两者兼而有之

发布于 2024-08-11 01:21:49 字数 337 浏览 8 评论 0原文

在 AIX 上,我将运行:

ar -X32 -t libdb2.a

并检查输出以确定存档中是否有 32 位对象。与 -X64 类似,用于检查 64 位对象。但是,如果我在另一个平台上,并且需要检查存档以查看其中的内容,该怎么办?通常,当我需要检查时,我会使用 Linux,但我也可以轻松地使用 Solaris 或 HP-UX。

我曾经检查过 shr.o 和 shr_64.o,因为这就是正在编译的内容,但这些内容开始出现在档案中的实际消息中,因此它们的可靠性已经下降到我认为的程度出现误报。

如果有人有一个指针,最好是我可以用 perl 做的事情,那就太好了。

On AIX, I would run:

ar -X32 -t libdb2.a

and check for output to determine if there is a 32-bit object in the archive. Similarly with -X64 for checking for a 64-bit object. However, what about if I'm on another platform, and need to check the archive to see what it has? Usually I'm on Linux when I need to check, but I could just as easily be on Solaris or HP-UX.

I used to check for shr.o and shr_64.o, since that's what's being compiled, but those are starting to show up in actual messages that are in the archives, and thus the reliability of these have dropped to the point where I'm getting false positives.

If anyone has a pointer, preferably something I can do in perl, that'd be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七分※倦醒 2024-08-18 01:21:49

我认为没有简单的方法。如果您创建两个 AIX 归档文件,一个是 32 位,一个是 64 位,如下所示:

$ cat a.c
int foo (void) { return 42; }
$ xlc -q32 a.c -c -o a32.o
$ xlc -q64 a.c -c -o a64.o
$ ar -X32 cr a32.a a32.o
$ ar -X64 cr a64.a a64.o

您最终得到的归档文件不是 linux ar 可读的格式:

$ file a32.a a64.a 
a32.a: archive (big format)
a64.a: archive (big format)
$ ar t a32.a
ar: a32.a: File format not recognized
$ ar t a64.a
ar: a64.a: File format not recognized

我尝试使用 strings 查看档案中是否有任何明显的东西,但什么也没找到。您剩下的唯一选择是构建一个针对 AIX 的 binutils 软件包(下载 binutils,使用选项 --target=powerpc-ibm-aix5.3 进行配置,运行 make 并瞧:您在该构建树中的某处有一个名为 powerpc-ibm-aix5.3-ar 的工具)。

I don't think there is an easy way. If you create two AIX archives, one 32-bit and one 64-bit, as follows:

$ cat a.c
int foo (void) { return 42; }
$ xlc -q32 a.c -c -o a32.o
$ xlc -q64 a.c -c -o a64.o
$ ar -X32 cr a32.a a32.o
$ ar -X64 cr a64.a a64.o

you end up with archives that are not in a readable format by the linux ar:

$ file a32.a a64.a 
a32.a: archive (big format)
a64.a: archive (big format)
$ ar t a32.a
ar: a32.a: File format not recognized
$ ar t a64.a
ar: a64.a: File format not recognized

I tried using strings to see if anything obvious was in the archives, but found nothing. Your ony remaining option is to build a binutils package targetting AIX (download binutils, configure with option --target=powerpc-ibm-aix5.3, run make and voilà: you've got a tool called powerpc-ibm-aix5.3-ar somewhere in that build tree).

乱世争霸 2024-08-18 01:21:49

我建议从 .a 存档中提取 .o 文件之一,然后对其运行 file 命令。示例:

$ file fortune/fortune.o
fortune/fortune.o: ELF 32-bit MSB relocatable, SPARC, version 1 (SYSV), not stripped

file 并非每个系统上的标准,但可以轻松编译。另外,还有一个 几个 perl 模块,它们的作用与 <代码>文件。

ar 提供了 p 命令来打印相关文件。例如:

$ ar p libcurl.a base64.o > /tmp/base64.o
$ file /tmp/base64.o  
base64.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped

I'd suggest extract one of the .o files from the .a archive, and then running the file command on it. Example:

$ file fortune/fortune.o
fortune/fortune.o: ELF 32-bit MSB relocatable, SPARC, version 1 (SYSV), not stripped

file isn't standard on every system, but can easily be compiled. Alternatively, there are a couple of perl modules which do the same thing as file.

ar offers the p command which prints the file in question. For example:

$ ar p libcurl.a base64.o > /tmp/base64.o
$ file /tmp/base64.o  
base64.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
与酒说心事 2024-08-18 01:21:49

所以......我迟到了一年,但我遇到了完全相同的问题。这是我解决问题的方法,我希望它可以帮助某人:

$ ar t mylib.a
myobj1.o
myobj2.o
myobj3.o

$ mkdir /tmp/mylib
$ cp mylib.a /tmp/mylib
$ cd /tmp/mylib
$ ls
mylib.a

$ ar x mylib.a
$ ls
mylib.a
myobj1.o
myobj2.o
myobj3.o

$ file *

可能的结果:

mylib.a: current ar archive
myobj1.o: ELF 64-bit (...)
myobj2.o: ELF 64-bit (...)
myobj3.o: ELF 64-bit (...)

mylib.a: current ar archive
myobj1.o: ELF 32-bit (...)
myobj2.o: ELF 32-bit (...)
myobj3.o: ELF 32-bit (...)

解释:
存档库文件只是“.o”文件的集合,当您使用 ar 的“t”参数时,您会列出存档的内容,当您使用 ar 的“x”参数时,您会提取它们。输入 man ar 了解更多说明。

So... I'm one year late, but I just had the exact same problem. Here is how I solved it, I hope it helps someone:

$ ar t mylib.a
myobj1.o
myobj2.o
myobj3.o

$ mkdir /tmp/mylib
$ cp mylib.a /tmp/mylib
$ cd /tmp/mylib
$ ls
mylib.a

$ ar x mylib.a
$ ls
mylib.a
myobj1.o
myobj2.o
myobj3.o

$ file *

Possible outcomes:

mylib.a: current ar archive
myobj1.o: ELF 64-bit (...)
myobj2.o: ELF 64-bit (...)
myobj3.o: ELF 64-bit (...)

OR

mylib.a: current ar archive
myobj1.o: ELF 32-bit (...)
myobj2.o: ELF 32-bit (...)
myobj3.o: ELF 32-bit (...)

Explanation:
An archive library file is just a collection of ".o" files, when you use the "t" argument of ar you list the contents of the archive and when you use the "x" argument of ar you extract them. Type man ar for further instructions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文