asm: Use .asciz and .ascii instead of .string
We use the .string pseudo-op both in some of our test assembly files and in our -Oasm output. We expect this to emit a \0 terminated string into the .o file. However for certain targets (e.g. HP PA-RISC) it doesn't include the \0. Use .asciz instead, which explicitly does what we want. There's also one place we can use .ascii (which explicitly emits a string *without* \0 termination) instead of multiple .byte directives. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
5eb5927d81
commit
ff3a30c115
6 changed files with 75 additions and 77 deletions
23
dtc.h
23
dtc.h
|
@ -116,6 +116,12 @@ enum markertype {
|
|||
TYPE_UINT64,
|
||||
TYPE_STRING,
|
||||
};
|
||||
|
||||
static inline bool is_type_marker(enum markertype type)
|
||||
{
|
||||
return type >= TYPE_UINT8;
|
||||
}
|
||||
|
||||
extern const char *markername(enum markertype markertype);
|
||||
|
||||
struct marker {
|
||||
|
@ -140,7 +146,22 @@ struct data {
|
|||
for_each_marker(m) \
|
||||
if ((m)->type == (t))
|
||||
|
||||
size_t type_marker_length(struct marker *m);
|
||||
static inline struct marker *next_type_marker(struct marker *m)
|
||||
{
|
||||
for_each_marker(m)
|
||||
if (is_type_marker(m->type))
|
||||
break;
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline size_t type_marker_length(struct marker *m)
|
||||
{
|
||||
struct marker *next = next_type_marker(m->next);
|
||||
|
||||
if (next)
|
||||
return next->offset - m->offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void data_free(struct data d);
|
||||
|
||||
|
|
|
@ -134,9 +134,9 @@ static void asm_emit_string(void *e, const char *str, int len)
|
|||
FILE *f = e;
|
||||
|
||||
if (len != 0)
|
||||
fprintf(f, "\t.string\t\"%.*s\"\n", len, str);
|
||||
fprintf(f, "\t.asciz\t\"%.*s\"\n", len, str);
|
||||
else
|
||||
fprintf(f, "\t.string\t\"%s\"\n", str);
|
||||
fprintf(f, "\t.asciz\t\"%s\"\n", str);
|
||||
}
|
||||
|
||||
static void asm_emit_align(void *e, int a)
|
||||
|
@ -438,7 +438,7 @@ static void dump_stringtable_asm(FILE *f, struct data strbuf)
|
|||
|
||||
while (p < (strbuf.val + strbuf.len)) {
|
||||
len = strlen(p);
|
||||
fprintf(f, "\t.string \"%s\"\n", p);
|
||||
fprintf(f, "\t.asciz \"%s\"\n", p);
|
||||
p += len+1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ _dt_reserve_map:
|
|||
dt_struct_start:
|
||||
_dt_struct_start:
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string ""
|
||||
.asciz ""
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0xa
|
||||
|
@ -58,7 +58,7 @@ _dt_struct_start:
|
|||
.long 0x2
|
||||
.balign 4
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string "memory@0"
|
||||
.asciz "memory@0"
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0x7
|
||||
|
@ -77,7 +77,7 @@ _dt_struct_start:
|
|||
.balign 4
|
||||
.long OF_DT_END_NODE
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string "cpus"
|
||||
.asciz "cpus"
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0x4
|
||||
|
@ -151,22 +151,22 @@ _dt_struct_end:
|
|||
.globl dt_strings_start
|
||||
dt_strings_start:
|
||||
_dt_strings_start:
|
||||
.string "model"
|
||||
.string "compatible"
|
||||
.string "#address-cells"
|
||||
.string "#size-cells"
|
||||
.string "device_type"
|
||||
.string "reg"
|
||||
.string "d10"
|
||||
.string "d23"
|
||||
.string "b101"
|
||||
.string "o17"
|
||||
.string "hd00d"
|
||||
.string "stuff"
|
||||
.string "bad-d-1"
|
||||
.string "bad-d-2"
|
||||
.string "bad-o-1"
|
||||
.string "bad-o-2"
|
||||
.asciz "model"
|
||||
.asciz "compatible"
|
||||
.asciz "#address-cells"
|
||||
.asciz "#size-cells"
|
||||
.asciz "device_type"
|
||||
.asciz "reg"
|
||||
.asciz "d10"
|
||||
.asciz "d23"
|
||||
.asciz "b101"
|
||||
.asciz "o17"
|
||||
.asciz "hd00d"
|
||||
.asciz "stuff"
|
||||
.asciz "bad-d-1"
|
||||
.asciz "bad-d-2"
|
||||
.asciz "bad-o-1"
|
||||
.asciz "bad-o-2"
|
||||
.globl dt_strings_end
|
||||
dt_strings_end:
|
||||
_dt_strings_end:
|
||||
|
|
|
@ -44,7 +44,7 @@ _dt_reserve_map:
|
|||
dt_struct_start:
|
||||
_dt_struct_start:
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string ""
|
||||
.asciz ""
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0xc
|
||||
|
@ -76,7 +76,7 @@ _dt_struct_start:
|
|||
.long 0x2
|
||||
.balign 4
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string "cpus"
|
||||
.asciz "cpus"
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0x4
|
||||
|
@ -94,7 +94,7 @@ _dt_struct_start:
|
|||
.long 0x0
|
||||
.balign 4
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string "PowerPC,970@0"
|
||||
.asciz "PowerPC,970@0"
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0xc
|
||||
|
@ -139,7 +139,7 @@ _dt_struct_start:
|
|||
.balign 4
|
||||
.long OF_DT_END_NODE
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string "PowerPC,970@1"
|
||||
.asciz "PowerPC,970@1"
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0xc
|
||||
|
@ -181,7 +181,7 @@ _dt_struct_start:
|
|||
.long OF_DT_END_NODE
|
||||
.long OF_DT_END_NODE
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string "randomnode"
|
||||
.asciz "randomnode"
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0x13
|
||||
|
@ -216,7 +216,7 @@ _dt_struct_start:
|
|||
.balign 4
|
||||
.long OF_DT_END_NODE
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string "memory@0"
|
||||
.asciz "memory@0"
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0x7
|
||||
|
@ -242,7 +242,7 @@ memreg:
|
|||
.balign 4
|
||||
.long OF_DT_END_NODE
|
||||
.long OF_DT_BEGIN_NODE
|
||||
.string "chosen"
|
||||
.asciz "chosen"
|
||||
.balign 4
|
||||
.long OF_DT_PROP
|
||||
.long 0xf
|
||||
|
@ -267,25 +267,25 @@ _dt_struct_end:
|
|||
.globl dt_strings_start
|
||||
dt_strings_start:
|
||||
_dt_strings_start:
|
||||
.string "model"
|
||||
.string "compatible"
|
||||
.string "#address-cells"
|
||||
.string "#size-cells"
|
||||
.string "linux,phandle"
|
||||
.string "name"
|
||||
.string "device_type"
|
||||
.string "reg"
|
||||
.string "clock-frequency"
|
||||
.string "timebase-frequency"
|
||||
.string "linux,boot-cpu"
|
||||
.string "i-cache-size"
|
||||
.string "d-cache-size"
|
||||
.string "string"
|
||||
.string "blob"
|
||||
.string "ref"
|
||||
.string "mixed"
|
||||
.string "bootargs"
|
||||
.string "linux,platform"
|
||||
.asciz "model"
|
||||
.asciz "compatible"
|
||||
.asciz "#address-cells"
|
||||
.asciz "#size-cells"
|
||||
.asciz "linux,phandle"
|
||||
.asciz "name"
|
||||
.asciz "device_type"
|
||||
.asciz "reg"
|
||||
.asciz "clock-frequency"
|
||||
.asciz "timebase-frequency"
|
||||
.asciz "linux,boot-cpu"
|
||||
.asciz "i-cache-size"
|
||||
.asciz "d-cache-size"
|
||||
.asciz "string"
|
||||
.asciz "blob"
|
||||
.asciz "ref"
|
||||
.asciz "mixed"
|
||||
.asciz "bootargs"
|
||||
.asciz "linux,platform"
|
||||
.globl dt_strings_end
|
||||
dt_strings_end:
|
||||
_dt_strings_end:
|
||||
|
|
|
@ -54,13 +54,13 @@ tree##_rsvmap_end: ;
|
|||
#define PROP_STR(tree, name, str) \
|
||||
PROPHDR(tree, name, 55f - 54f) \
|
||||
54: \
|
||||
.string str ; \
|
||||
.asciz str ; \
|
||||
55: \
|
||||
.balign 4 ;
|
||||
|
||||
#define BEGIN_NODE(name) \
|
||||
FDTLONG(FDT_BEGIN_NODE) ; \
|
||||
.string name ; \
|
||||
.asciz name ; \
|
||||
.balign 4 ;
|
||||
|
||||
#define END_NODE \
|
||||
|
@ -68,7 +68,7 @@ tree##_rsvmap_end: ;
|
|||
|
||||
#define STRING(tree, name, str) \
|
||||
tree##_##name: ; \
|
||||
.string str ;
|
||||
.asciz str ;
|
||||
|
||||
.data
|
||||
|
||||
|
@ -253,9 +253,7 @@ truncated_string_struct_end:
|
|||
truncated_string_strings:
|
||||
STRING(truncated_string, good_string, "good")
|
||||
truncated_string_bad_string:
|
||||
.byte 'b'
|
||||
.byte 'a'
|
||||
.byte 'd'
|
||||
.ascii "bad"
|
||||
/* NOTE: terminating \0 deliberately missing */
|
||||
truncated_string_strings_end:
|
||||
truncated_string_end:
|
||||
|
|
23
treesource.c
23
treesource.c
|
@ -124,27 +124,6 @@ static void write_propval_int(FILE *f, const char *p, size_t len, size_t width)
|
|||
}
|
||||
}
|
||||
|
||||
static bool has_data_type_information(struct marker *m)
|
||||
{
|
||||
return m->type >= TYPE_UINT8;
|
||||
}
|
||||
|
||||
static struct marker *next_type_marker(struct marker *m)
|
||||
{
|
||||
while (m && !has_data_type_information(m))
|
||||
m = m->next;
|
||||
return m;
|
||||
}
|
||||
|
||||
size_t type_marker_length(struct marker *m)
|
||||
{
|
||||
struct marker *next = next_type_marker(m->next);
|
||||
|
||||
if (next)
|
||||
return next->offset - m->offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *delim_start[] = {
|
||||
[TYPE_UINT8] = "[",
|
||||
[TYPE_UINT16] = "/bits/ 16 <",
|
||||
|
@ -230,7 +209,7 @@ static void write_propval(FILE *f, struct property *prop)
|
|||
size_t data_len = type_marker_length(m) ? : len - m->offset;
|
||||
const char *p = &prop->val.val[m->offset];
|
||||
|
||||
if (has_data_type_information(m)) {
|
||||
if (is_type_marker(m->type)) {
|
||||
emit_type = m->type;
|
||||
fprintf(f, " %s", delim_start[emit_type]);
|
||||
} else if (m->type == LABEL)
|
||||
|
|
Loading…
Reference in a new issue