summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/stddef.h7
-rw-r--r--src/lib/lzma.c7
-rw-r--r--src/vendorcode/google/chromeos/cros_vpd.c18
-rw-r--r--src/vendorcode/google/chromeos/fmap.c5
4 files changed, 13 insertions, 24 deletions
diff --git a/src/include/stddef.h b/src/include/stddef.h
index 3a030e14a1..60e34595ee 100644
--- a/src/include/stddef.h
+++ b/src/include/stddef.h
@@ -49,4 +49,11 @@ typedef unsigned int wint_t;
#define ROMSTAGE_CONST
#endif
+/* Work around non-writable data segment in execute-in-place romstage on x86. */
+#if defined(__PRE_RAM__) && CONFIG_ARCH_X86
+#define MAYBE_STATIC
+#else
+#define MAYBE_STATIC static
+#endif
+
#endif /* STDDEF_H */
diff --git a/src/lib/lzma.c b/src/lib/lzma.c
index ea5f15f2d1..8efa1e6e1a 100644
--- a/src/lib/lzma.c
+++ b/src/lib/lzma.c
@@ -24,12 +24,7 @@ unsigned long ulzma(unsigned char * src, unsigned char * dst)
int res;
CLzmaDecoderState state;
SizeT mallocneeds;
-#if !defined(__PRE_RAM__)
- /* in ramstage, this can go in BSS */
- static
-#endif
- /* in pre-ram, it must go on the stack */
- unsigned char scratchpad[15980];
+ MAYBE_STATIC unsigned char scratchpad[15980];
unsigned char *cp;
memcpy(properties, src, LZMA_PROPERTIES_SIZE);
diff --git a/src/vendorcode/google/chromeos/cros_vpd.c b/src/vendorcode/google/chromeos/cros_vpd.c
index 26b01ee7a3..df2b5bf667 100644
--- a/src/vendorcode/google/chromeos/cros_vpd.c
+++ b/src/vendorcode/google/chromeos/cros_vpd.c
@@ -15,16 +15,6 @@
#include "lib_vpd.h"
#include "vpd_tables.h"
-/*
- * Static variables are available in ramstage (all platforms), and romstage for
- * some platforms (ex, ARM, which uses SRAM).
- */
-#if defined(__PRE_RAM__) && CONFIG_ARCH_X86
-#define STATIC_VAR
-#else
-#define STATIC_VAR static
-#endif
-
/* Currently we only support Google VPD 2.0, which has a fixed offset. */
enum {
GOOGLE_VPD_2_0_OFFSET = 0x600,
@@ -39,10 +29,10 @@ struct vpd_gets_arg {
static int cros_vpd_load(uint8_t **vpd_address, int32_t *vpd_size)
{
- STATIC_VAR int cached = 0;
- STATIC_VAR uint8_t *cached_address = NULL;
- STATIC_VAR int32_t cached_size = 0;
- STATIC_VAR int result = -1;
+ MAYBE_STATIC int cached = 0;
+ MAYBE_STATIC uint8_t *cached_address = NULL;
+ MAYBE_STATIC int32_t cached_size = 0;
+ MAYBE_STATIC int result = -1;
struct google_vpd_info info;
int32_t base;
diff --git a/src/vendorcode/google/chromeos/fmap.c b/src/vendorcode/google/chromeos/fmap.c
index d758f57a20..a8425c0d10 100644
--- a/src/vendorcode/google/chromeos/fmap.c
+++ b/src/vendorcode/google/chromeos/fmap.c
@@ -92,10 +92,7 @@ const struct fmap_area *find_fmap_area(const struct fmap *fmap,
int find_fmap_entry(const char name[], void **pointer)
{
-#ifndef __PRE_RAM__
- static
-#endif
- const struct fmap *fmap = NULL;
+ MAYBE_STATIC const struct fmap *fmap = NULL;
const struct fmap_area *area;
void *base = NULL;