Determine whether Unix system and library files are 32 bit or 64 bit in detail

  • 2020-05-13 04:23:38
  • OfStack

Determine whether the Unix system and library files are 32-bit or 64-bit in detail

1. Check whether the system is 32-bit or 64-bit

bootinfo-y view hardware digits
bootinfo-K view kernel bits

2. Check whether the library file is 32-bit or 64-bit

1. Use the file command

Linux:


# file libnss1_files-2.2.4.so 
libnss1_files-2.2.4.so: ELF 32-bit LSB shared object, Intel 80386, version 1, not stripped 
# file libtrsbean.so 
libtrsbean.so: ELF 64-bit LSB shared object, version 1, not stripped

AIX: 32-bit not specified


#file /usr/ccs/lib/mcrt0.o 
/usr/ccs/lib/mcrt0.o:  executable (RISC System/6000) or object module not stripped
#file /usr/ccs/lib/mcrt0_64.o 
/usr/ccs/lib/mcrt0_64.o:    64-bit XCOFF executable or object module not stripped

Solaris:


# file libmp.so 
libmp.so:    ELF 32- position  MSB  The dynamic library  SPARC  version  1 Dynamic link, not removed 

2. Using the binary view command od to view the relevant library files can also solve this problem, but it is difficult and not safe. The results for different systems are given below for reference (due to testing under only one version of the operating system, the following results may not be applicable to all versions of the system)

Linux



32 A first 4 Segment is 0101 ; 64 A first 4 Segment is 0102  
 -h  According to the said 16 Into the system 2 Byte integer view, integer high and low bit also adjusted (such as 7f45 become 457f );  -N 10  Said to see 10 bytes 
#od -h -N 10 32.so 
   0000000 457f 464c 0101 0001 0000
#od -h -N 10 64.so 
   0000000 457f 464c 0102 0001 0000

Solaris

It is similar to Linux, except that the -h parameter of Linux becomes -x. In addition, the display result is not quite the same. Solaris is displayed in byte order, and Linux is viewed in hexadecimal 2-byte integer, which will adjust the high and low bit.


#od -x -N 10 32.so      
   0000000 7f45 4c46 0101 0100 0000
#od -x -N 10 64.so      
   0000000 7f45 4c46 0102 0100 0000

AIX

32 bits is 01df; 64 is f7 01


#od -N 10 -h crt0_r.o 
   0000000 01df 0003 3d65 462a 0000
#od -N 10 -h mcrt0_64.o 
   0000000 01f7 0003 3fe2 7fd5 0000

HP Unix

No actual action, just open two files xxx32.sl and xxx64.sl via UltraEdit and compare the first few bytes (the HP library file ends in.sl instead of.so). Find a 64-bit file similar to Linux/Solaris.


02 10 01 0e 05 12 40
7f 45 4c 46 02 02 01

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: