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>main
parent
6a99b13132
commit
43a68c63e4
12
data.c
12
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue