diff options
author | Milton Miller <miltonm@bga.com> | 2007-07-07 01:18:52 -0500 |
---|---|---|
committer | Jon Loeliger <jdl@freescale.com> | 2007-07-07 10:14:12 -0500 |
commit | 43a68c63e46c88b94068c18255db2d6c7d9e3740 (patch) | |
tree | 74b9f6aae37598c4bfd50469c7c38939f73453d6 | |
parent | 6a99b1313208d05ba6d9c5d3858230d9ee785f8c (diff) | |
download | dtc-43a68c63e46c88b94068c18255db2d6c7d9e3740.zip dtc-43a68c63e46c88b94068c18255db2d6c7d9e3740.tar.gz dtc-43a68c63e46c88b94068c18255db2d6c7d9e3740.tar.bz2 |
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>
-rw-r--r-- | data.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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; } |