Skip to content

Commit

Permalink
appimagetool: calculate size via _runtime_binary_start and _runtime_b…
Browse files Browse the repository at this point in the history
…inary_end. (#288)

On my Ubuntu yakkety x86_64 sytem, the _runtime_binary_size
symbol is unreliable. For non-ASLR, it points somewhere after
0x555555554000 (where appimagetool is loaded). And with ASLR,
it's... random.

So, instead of relying on the address of _runtime_binary_size
being the size of the runtime blob, calculate the actual size
by using _runtime_binary_start and _runtime_binary_end.
  • Loading branch information
mkrautz authored and probonopd committed Nov 16, 2016
1 parent 4dc7953 commit 76d6cd5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions appimagetool.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include "getsection.h"

extern int _binary_runtime_start;
extern int _binary_runtime_size;
extern int _binary_runtime_end;


static gint repeats = 2;
Expand Down Expand Up @@ -481,7 +481,7 @@ main (int argc, char *argv[])
fprintf (stderr, "Generating squashfs...\n");
/* runtime is embedded into this executable
* http://stupefydeveloper.blogspot.de/2008/08/cc-embed-binary-data-into-elf.html */
int size = (int)&_binary_runtime_size;
int size = (int)((void *)&_binary_runtime_end - (void *)&_binary_runtime_start);
char *data = (char *)&_binary_runtime_start;
if (verbose)
printf("Size of the embedded runtime: %d bytes\n", size);
Expand Down

0 comments on commit 76d6cd5

Please sign in to comment.