aboutsummaryrefslogtreecommitdiff
path: root/common/bootstage.c
diff options
context:
space:
mode:
authorDoug Anderson2013-04-17 16:13:41 +0000
committerSimon Glass2013-05-13 13:33:21 -0700
commit150678a5820bed338c1c8de570c451bc77c15900 (patch)
treea988ef54d38a9e55c064a75456156b5bfd8d5cc5 /common/bootstage.c
parente802ee0f990b634138d55844ee36e4125a0fa0fc (diff)
bootstage: Copy bootstage strings post-relocation
Any pointers to name strings that were passed to bootstage_mark_name() pre-relocation should be copied post-relocation so that they don't get trashed as the original location of U-Boot is re-used for other purposes. This change introduces a new API call that should be called from board_init_r() after malloc has been initted on any board that uses bootstage. Signed-off-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/bootstage.c')
-rw-r--r--common/bootstage.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/bootstage.c b/common/bootstage.c
index a1e09394cc5..15afa24c44b 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)
{