0

On redhat most of the systemd started services are implemented as shared objects. Why is this the case?

For instance:

file /usr/sbin/sshd
file /usr/sbin/squid 
file /usr/sbin/crond 
file /usr/sbin/rsyslogd

The output for all these daemons is ELF 64-bit LSB shared object, x86-64. I can understand why systemd itself is implemented as a shared object. When Kernel loads it there are no other shared objects/executables in user space. So very likely systemd is full of direct system call instead of going through libc.

However what is the reason for the daemons listed above to be implemented as shared objects instead of executables?

  • 1
    Shared objects are executables... – Stephen Kitt Nov 25 '16 at 17:09
  • I understand that both shared objects and executables have machine code in them. However, there is a distinction between the two. The shared objects code is a library of several functions that are shared among multiple executables. – sshekhar1980 Nov 25 '16 at 17:21
  • That question is similar to asking why a building has an elevator and the other next to it doesn't. If you want to ask about the benefits of using a shared object, ask so on http://stackoverflow.com where programming related questions are relevant. – Julie Pelletier Nov 25 '16 at 17:26
  • See the answer to the question Executables vs Shared objects. In brief: all shared objects are executables, but not all executables are shared objects. – AlexP Nov 25 '16 at 18:44
  • Thanks @AlexP, that's a useful link! @sshekhar1980, try running your libc.so.6... Basically an ELF dynamically-linked executable is a shared object with a program header, and file doesn't look at that. This LWN article has more detail. Check out ldd systemd, you'll see it uses libc just like the other daemons you're asking about... – Stephen Kitt Nov 25 '16 at 18:59
  • Which version do you see this on? Recently, various distros from various vendors have started to compile all executables as position-independent so that their code can be subjected to ASLR. – Mark Plotnick Nov 25 '16 at 23:27
  • @MarkPlotnick I see this on RHEL 7.2 HVM (on aws). – sshekhar1980 Nov 26 '16 at 01:46
  • As far as I can tell, RHEL 7 apparently continued Fedora's policy of compiling several dozen security-conscious packages as position-independent code. I can't find a RHEL-specific statement about this yet. – Mark Plotnick Nov 29 '16 at 20:29

0 Answers0