Thursday, December 11, 2008

How to determine if a file is 32 or 64 bit on AIX

I was working on an AIX box recently and had to figure out if a binary was 32 or 64 bit. Took me a bit since I am not that familiar with AIX but I eventually figured out two methods:

The first is using the 'file' command. For a 32-bit binary this command produced the following output:

# file executable (RISC System/6000) or object module

However on a 64-bit binary it actually stated 64 bits:

# file 64-bit XCOFF executable or object module not stripped

The other way was to use the 'nm' command. Not entirely sure what nm stands for. Perhaps name mangling or just 'name'.

In any case this command has the '-X' switch which allows you to specify the type of file. So if you wanted to examine only 32 bit object files you would use '-X 32'. For 64-bit you would use '-X 64'. And for both you would use '-X32-64'.

Running nm with the 32-bit flag:

# nm -X32
0654-210 is not valid in the current object file mode.
Use the -X option to specify the desired object mode.

Basically gives me an error. However

# nm -X64

will produce copious amounts of output. This means that is a 64-bit file because the libraries it is linking to are 64-bit.

No comments: