如何获得".a"文件的体系结构? [英] How can I get the architecture of a '.a' file?

查看:70
本文介绍了如何获得".a"文件的体系结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.a文件,我想从中获取体系结构信息.运行file myFile.a会导致file.a: current ar archive.如何获得有关文件包含的体系结构的更多信息?

I have a .a file from which I want to get architecture information. Running file myFile.a results in file.a: current ar archive. How can I get more information on what architecture the file contains?

推荐答案

您还可以跳过ar命令并使用

You can also skip the ar command and use readelf, via something like:

readelf -h <archive>.a | grep 'Class\|File\|Machine'

[00:32:15] /usr/lib $ readelf -h libxslt.a | grep 'Class\|File\|Machine'
File: libxslt.a(attrvt.o)
  Class:                             ELF32
  Machine:                           Intel 80386
File: libxslt.a(xslt.o)
  Class:                             ELF32
  Machine:                           Intel 80386
... #Trimmed this, it goes on a bit
File: libxslt.a(transform.o)
  Class:                             ELF32
  Machine:                           Intel 80386
File: libxslt.a(security.o)
  Class:                             ELF32
  Machine:                           Intel 80386
[00:32:24] /usr/lib $


如果相关,这里是您可以从readelf -h获取的其他信息.我只是用grep修剪了上面的内容,显然:


In case it's relevant, here's the other information that you can get from readelf -h. I just trimmed the above with grep, obviously:

File: libxslt.a(security.o)
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          2548 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         16
  Section header string table index: 13

该输出用于libxslt.a中的一个对象文件,但每个文件都提供相同的信息.

That output is for one of the object files in libxslt.a, but it gives the same information for each file.

这篇关于如何获得".a"文件的体系结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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