views:

23

answers:

1

Is it generally sane to append some random data to an executable binary file? What measures should be taken to ensure safe operation of the resulting executable, like padding before appended data or whatever?

A typical C example would be:

gcc -o main.o -c main.c
gcc -o main main.o -lfoo
cat bar.txt >> main

The target system is broadly Unix but a breakdown by system (Mac OS X, Linux, AIX...) is welcome if need be. A Windows point of view is welcome too for the sake of completeness.

A: 

This should be possible without issues, because in the ELF format the size of the program object should be specified and therefore only the data that should get loaded and executed gets loaded and executed.

joni