summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorMilton Miller <miltonm@bga.com>2007-07-07 01:18:52 -0500
committerJon Loeliger <jdl@freescale.com>2007-07-07 10:14:12 -0500
commit43a68c63e46c88b94068c18255db2d6c7d9e3740 (patch)
tree74b9f6aae37598c4bfd50469c7c38939f73453d6 /data.c
parent6a99b1313208d05ba6d9c5d3858230d9ee785f8c (diff)
downloaddtc-43a68c63e46c88b94068c18255db2d6c7d9e3740.tar.gz
dtc: store labels in ascending order
When adding a label, walk to the end of the list since the label reflects the end of the data. Since merging data buffers already preserved the order, this will cause the labels to be emitted in order when writing assembly output. It should also aid emiting labels when writing dts output should that be added in the future (data formatting would need to break at each label). Signed-off-by: Milton Miller <miltonm@bga.com>
Diffstat (limited to 'data.c')
-rw-r--r--data.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/data.c b/data.c
index 3e96d11..f42ad58 100644
--- a/data.c
+++ b/data.c
@@ -301,16 +301,22 @@ struct data data_add_fixup(struct data d, char *ref)
struct data data_add_label(struct data d, char *label)
{
- struct fixup *f;
+ struct fixup *f, **p;
struct data nd;
f = xmalloc(sizeof(*f));
f->offset = d.len;
f->ref = label;
- f->next = d.labels;
nd = d;
- nd.labels = f;
+ p = &nd.labels;
+
+ /* adding to end keeps them sorted */
+ while (*p)
+ p = &((*p)->next);
+
+ f->next = *p;
+ *p = f;
return nd;
}