summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/bootstage.c15
-rw-r--r--include/bootstage.h15
2 files changed, 30 insertions, 0 deletions
diff --git a/common/bootstage.c b/common/bootstage.c
index a1e0939..15afa24 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -56,6 +56,21 @@ struct bootstage_hdr {
uint32_t magic; /* Unused */
};
+int bootstage_relocate(void)
+{
+ int i;
+
+ /*
+ * Duplicate all strings. They may point to an old location in the
+ * program .text section that can eventually get trashed.
+ */
+ for (i = 0; i < BOOTSTAGE_ID_COUNT; i++)
+ if (record[i].name)
+ record[i].name = strdup(record[i].name);
+
+ return 0;
+}
+
ulong bootstage_add_record(enum bootstage_id id, const char *name,
int flags, ulong mark)
{
diff --git a/include/bootstage.h b/include/bootstage.h
index bdda768..c8235e8 100644
--- a/include/bootstage.h
+++ b/include/bootstage.h
@@ -237,6 +237,16 @@ void show_boot_progress(int val);
/* This is the full bootstage implementation */
/**
+ * Relocate existing bootstage records
+ *
+ * Call this after relocation has happened and after malloc has been initted.
+ * We need to copy any pointers in bootstage records that were added pre-
+ * relocation, since memory can be overritten later.
+ * @return Always returns 0, to indicate success
+ */
+int bootstage_relocate(void);
+
+/**
* Add a new bootstage record
*
* @param id Bootstage ID to use (ignored if flags & BOOTSTAGEF_ALLOC)
@@ -326,6 +336,11 @@ static inline ulong bootstage_add_record(enum bootstage_id id,
* and won't even do that unless CONFIG_SHOW_BOOT_PROGRESS is defined
*/
+static inline int bootstage_relocate(void)
+{
+ return 0;
+}
+
static inline ulong bootstage_mark(enum bootstage_id id)
{
show_boot_progress(id);