4

I know 'init' is first process that is started after the kernel is loaded, but there is an ambiguity for me. If it is a process it must have a binary executable file. However, the following shared object is compiled code that looks like an executable file, but there is no main function.

sardari@mint / $ file /sbin/init
/sbin/init: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=7a4c688d009fc1f06ffc692f5f42ab09e68582b2, stripped

Apparently a shared object can be an executable file, but why?

  • 1
    If you are looking for a main symbol using nm, you won't see it in a stripped binary. Use readelf -a to determine the entry point (which usually points to the CRT anyway). Since init is dynamic, strictly speaking it is the dynamic linker (in the .interp section, e.g. /lib64/ld-linux-x86-64.so.2) that executes first. – mr.spuratic May 6 '15 at 9:19
2

When a file compiled with -pie (Position Independent Executable) such as :

gcc -pie -fPIC hello.c

Then you have :

#file ./a.out 
a.out: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x2afb7892000a1dc5b9010c591b75987188aa2d66, stripped

If you need more information , You can visit Position-independent code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.