Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the architecture of a '.a' file?

Tags:

linux

elf

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?

like image 495
Mike Avatar asked Sep 18 '10 04:09

Mike


People also ask

How do I find the architecture of a file in Linux?

Just run file on the kernel image. It will show what architecture the binary was compiled as. file vmlinuz-2.6.

What is the command to find architecture in Linux?

The command is uname -m . Open a terminal try using uname -m command. This should show you the OS architecture. If it gives any output like ix86 , where x is 3,4,5 or 6, Your OS is 32bit.


1 Answers

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 $ 

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 

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

like image 170
eldarerathis Avatar answered Sep 21 '22 10:09

eldarerathis