14

Compilation using gcc -s and Unix strip remove all symbol table and relocation information from an executable (making it smaller in size).

Could this ever affect the functioning of the executable? Do some operating systems which perform Address Space Layout Randomization (ASLR) need this information? If not, why keep them around in the first place?

A slightly-detailed overview of the above would be helpful.

moo
  • 1,597
  • 1
  • 14
  • 29
Anirudh Ramanathan
  • 46,179
  • 22
  • 132
  • 191
  • 1
    I am not sure any modern `strip` would remove relocation information. Do you think otherwise? – NPE Jan 05 '13 at 20:58
  • @NPE `gcc -s ` and `gcc ` + `strip` yielded the exact same-sized executable, so I assumed they were doing the same. But you are right, it doesn't remove relocation information. – Anirudh Ramanathan Jan 05 '13 at 21:33
  • 1
    See [this question](http://stackoverflow.com/questions/2463150/fpie-position-independent-executable-option-gcc-ld). fPIE (and fPIC) code doesn't need to hardcode its location, so it doesn't need any relocation information. –  Jan 05 '13 at 22:50

1 Answers1

10

It seems pretty clear that removing relocation information would interfere with ASLR.

However, I've taken a look at man strip on a couple of my systems, and none of them suggest that strip does (or indeed can?) remove relocation information. It is mainly about removing debugging symbols.

NPE
  • 486,780
  • 108
  • 951
  • 1,012
  • 1
    You are right there. `gcc -s` on the other hand, will not add relocation information to the binary. The relocation-table must matter right? Considering that the ELF uses it at the time of loading. – Anirudh Ramanathan Jan 05 '13 at 21:36