Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get architecture of a shared object file(.so file) using gnu c++ program?

Tags:

c++

linux

I have to create a c++ program to find out the whether the *.so(shared object) file is 32 bit or 64 bit (ex, libjvm.so). I did the same for dll files in windows, but got stuck on non-windows shared object file.

There are many commands available in Linux to find this out. But i don't see a simple programmatic ways to get this. The command objdump source code is having so many stuffs, not sure i can replicate it in my code.

I don't want to call the commands using system("") function inside my code, to get the architecture details.

Any idea how to get the architecture of .so file using gnu c++ program.

I am using Linux RHEl 6.2 and Compiler GNU gcc 4.8.3.

Thanks

like image 556
thanga Avatar asked Oct 24 '25 16:10

thanga


1 Answers

In openSUSE 42.3 objdump -f <your.so> and you will get something like:

<your.so>:    file format elf32-i386
architecture: i386, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x00003a80
like image 163
Rodrigo Avatar answered Oct 26 '25 05:10

Rodrigo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!