X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fconfig%2Ftc-riscv.c;h=b6c8c4eb23e7bb9ca6b7e4eae6bc0594d8296312;hb=39ff0b812324f4b050bb0b367b269db6d4d0cb8b;hp=cc77dbf6c00a3c9fe769da654b657e0d276d6736;hpb=cbd7581f343d85b4216db2eefdf601f6d988062d;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index cc77dbf6c0..b6c8c4eb23 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -126,8 +126,6 @@ riscv_set_default_priv_spec (const char *s) enum riscv_priv_spec_class class; unsigned major, minor, revision; obj_attribute *attr; - size_t buf_size; - char *buf; /* Find the corresponding priv spec class. */ if (riscv_get_priv_spec_class (s, &class)) @@ -149,40 +147,24 @@ riscv_set_default_priv_spec (const char *s) minor = (unsigned) attr[Tag_RISCV_priv_spec_minor].i; revision = (unsigned) attr[Tag_RISCV_priv_spec_revision].i; - /* The priv attributes setting 0.0.0 is meaningless. We should have set - the default_priv_spec by md_parse_option and riscv_after_parse_args, - so just skip the following setting. */ - if (major == 0 && minor == 0 && revision == 0) - return 1; - - buf_size = riscv_estimate_digit (major) - + 1 /* '.' */ - + riscv_estimate_digit (minor) - + 1; /* string terminator */ - if (revision != 0) + if (riscv_get_priv_spec_class_from_numbers (major, + minor, + revision, + &class)) { - buf_size += 1 /* '.' */ - + riscv_estimate_digit (revision); - buf = xmalloc (buf_size); - snprintf (buf, buf_size, "%d.%d.%d", major, minor, revision); - } - else - { - buf = xmalloc (buf_size); - snprintf (buf, buf_size, "%d.%d", major, minor); - } + /* The priv attributes setting 0.0.0 is meaningless. We should have set + the default_priv_spec by md_parse_option and riscv_after_parse_args, + so just skip the following setting. */ + if (class == PRIV_SPEC_CLASS_NONE) + return 1; - if (riscv_get_priv_spec_class (buf, &class)) - { default_priv_spec = class; - free (buf); return 1; } /* Still can not find the priv spec class. */ as_bad (_("Unknown default privilege spec `%d.%d.%d' set by " "privilege attributes"), major, minor, revision); - free (buf); return 0; }