mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
dtc: implement labels on property data
Extend the parser grammer to allow labels before or after any property data (string, cell list, or byte list), and any byte or cell within the property data. Store the labels using the same linked list structure as node references, but using a parallel list. When writing assembly output emit global labels as offsets from the start of the definition of the data. Note that the alignment for a cell list is done as part of the opening < delimiter, not the = or , before it. To label a cell after a string or byte list put the label inside the cell list. For example, prop = zero: [ aa bb ], two: < four: 1234 > eight: ; will produce labels with offsets 0, 2, 4, and 8 bytes from the beginning of the data for property prop. Signed-off-by: Milton Miller <miltonm@bga.com>
This commit is contained in:
parent
ac6a5e26b4
commit
6a99b13132
4 changed files with 60 additions and 12 deletions
13
flattree.c
13
flattree.c
|
@ -121,6 +121,12 @@ static void emit_label(FILE *f, char *prefix, char *label)
|
|||
fprintf(f, "_%s_%s:\n", prefix, label);
|
||||
}
|
||||
|
||||
static void emit_offset_label(FILE *f, char *label, int offset)
|
||||
{
|
||||
fprintf(f, "\t.globl\t%s\n", label);
|
||||
fprintf(f, "%s\t= . + %d\n", label, offset);
|
||||
}
|
||||
|
||||
static void asm_emit_cell(void *e, cell_t val)
|
||||
{
|
||||
FILE *f = e;
|
||||
|
@ -157,6 +163,13 @@ static void asm_emit_data(void *e, struct data d)
|
|||
{
|
||||
FILE *f = e;
|
||||
int off = 0;
|
||||
struct fixup *l;
|
||||
|
||||
l = d.labels;
|
||||
while (l) {
|
||||
emit_offset_label(f, l->ref, l->offset);
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
while ((d.len - off) >= sizeof(u32)) {
|
||||
fprintf(f, "\t.long\t0x%x\n",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue