代码之家  ›  专栏  ›  技术社区  ›  Mike

如何获取“.a”文件的体系结构?

  •  24
  • Mike  · 技术社区  · 14 年前

    我有一个.a文件,我想从中获取架构信息。跑步 file myFile.a file.a: current ar archive . 如何获得文件包含的体系结构的更多信息?

    5 回复  |  直到 14 年前
        1
  •  44
  •   eldarerathis sreeji    14 年前

    你也可以跳过 ar readelf ,例如:

    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 ,显然:

    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 ,但它为每个文件提供相同的信息。

        2
  •  17
  •   pcbabu    12 年前

    使用

    它将决定它为谁而建的建筑。其他函数(如otool或file)不能给出准确的答案,有时需要详细的操作才能获得正确的信息。

        3
  •  8
  •   Matthew Flaschen    14 年前

    objdump 是另一种选择:

    objdump -a file.a|grep 'file format'
    
        4
  •  1
  •   msw    14 年前
        5
  •  0
  •   Naseef Chowdhury    10 年前

    我建议用objdump代替lipo。objdump提供了比lipo更详细的信息。