Mark variables as used so they are not removed by LTO

Fixes #2324
This commit is contained in:
Paulo Matos 2018-10-22 15:50:11 +02:00 committed by Matthew Flatt
parent 08c1ba619c
commit 071406d10d
2 changed files with 20 additions and 0 deletions

View File

@ -3,6 +3,13 @@
#pragma GCC diagnostic ignored "-Wwrite-strings"
#if defined(__GNUC__)
# define PRESERVE_IN_EXECUTABLE __attribute__((used))
#else
# define PRESERVE_IN_EXECUTABLE /* empty */
#endif
PRESERVE_IN_EXECUTABLE
char * volatile scheme_cmdline_exe_hack = (char *)
("[Replace me for EXE hack "
" ]");
@ -14,6 +21,7 @@ char * volatile scheme_cmdline_exe_hack = (char *)
#else
# define GC_PRECISION_TYPE "c"
#endif
PRESERVE_IN_EXECUTABLE
char * volatile scheme_binary_type_hack = "bINARy tYPe:" INITIAL_BIN_TYPE GC_PRECISION_TYPE;
/* The format of bINARy tYPe is e?[zr]i[3cs].
e indicates a starter executable
@ -29,6 +37,7 @@ char * volatile scheme_binary_type_hack = "bINARy tYPe:" INITIAL_BIN_TYPE GC_PRE
# endif
#endif
PRESERVE_IN_EXECUTABLE
char * volatile scheme_coldir = "coLLECTs dIRECTORy:" /* <- this tag stays, so we can find it again */
INITIAL_COLLECTS_DIRECTORY
"\0\0" /* <- 1st nul terminates path, 2nd terminates path list */
@ -59,6 +68,7 @@ static int _coldir_offset = 19; /* Skip permanent tag */
# endif
#endif
PRESERVE_IN_EXECUTABLE
char * volatile scheme_configdir = "coNFIg dIRECTORy:" /* <- this tag stays, so we can find it again */
INITIAL_CONFIG_DIRECTORY
"\0"

View File

@ -12,6 +12,12 @@
#include <errno.h>
#include <stdio.h>
#if defined(__GNUC__)
# define PRESERVE_IN_EXECUTABLE __attribute__((used))
#else
# define PRESERVE_IN_EXECUTABLE /* empty */
#endif
/* The config string after : is replaced with ! followed by a sequence
of little-endian 4-byte ints:
start - offset into the binary
@ -33,14 +39,17 @@
adjusted. Using a seciton offset allows linking tools (such as
`strip') to move the data in the executable.
*/
PRESERVE_IN_EXECUTABLE
char *config = "cOnFiG:[***************************";
PRESERVE_IN_EXECUTABLE
char *binary_type_hack = "bINARy tYPe:ezic";
/* This path list is used instead of the one in the Racket/GRacket
binary. That way, the same Racket/GRacket binary can be shared
among embedding exectuables that have different collection
paths. */
PRESERVE_IN_EXECUTABLE
char *_coldir = "coLLECTs dIRECTORy:" /* <- this tag stays, so we can find it again */
"../collects"
"\0\0" /* <- 1st nul terminates path, 2nd terminates path list */
@ -63,6 +72,7 @@ char *_coldir = "coLLECTs dIRECTORy:" /* <- this tag stays, so we can find it ag
"****************************************************************";
static int _coldir_offset = 19; /* Skip permanent tag */
PRESERVE_IN_EXECUTABLE
char * volatile _configdir = "coNFIg dIRECTORy:" /* <- this tag stays, so we can find it again */
"../etc"
"\0"