From: Pekka Jääskeläinen Date: Mon, 9 Oct 2017 13:06:01 +0000 (+0000) Subject: [BRIGFE] Support BRIG_KIND_NONE directives. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=14108eda7ee4aaaa4840be8728b3161f8c7bd364;p=gcc.git [BRIGFE] Support BRIG_KIND_NONE directives. These directives are legal everywhere. They can be used to patch away BRIG entries at the binary level. Also add extra error detection for zeroed regions: make sure the byteCount field is never zero. The call code still failed a few PRM test cases. Now all PRM branch cases pass again. From-SVN: r253545 --- diff --git a/gcc/brig/ChangeLog b/gcc/brig/ChangeLog index bdb70188240..fa7668486b2 100644 --- a/gcc/brig/ChangeLog +++ b/gcc/brig/ChangeLog @@ -1,3 +1,18 @@ +2017-10-09 Pekka Jääskeläinen + + * brigfrontend/brig-to-generic.cc: Support BRIG_KIND_NONE + directives. These directives are legal everywhere. They + can be used to patch away BRIG entries at the binary level. + Also add extra error detection for zeroed regions: make sure + the byteCount field is never zero. + * brig/brigfrontend/phsa.h: Added a new error prefix for + errors which are due to corrupted BRIG modules. + +2017-10-09 Henry Linjamäki + + * brigfrontend/brig-branch-inst-handler.cc: The call code + still failed a few test cases. Now all PRM cases pass again. + 2017-10-03 Henry Linjamäki * brigfrontend/brig-branch-inst-handler.cc: Fix (more) crash with diff --git a/gcc/brig/brigfrontend/brig-branch-inst-handler.cc b/gcc/brig/brigfrontend/brig-branch-inst-handler.cc index 30aec373732..039f1853d4a 100644 --- a/gcc/brig/brigfrontend/brig-branch-inst-handler.cc +++ b/gcc/brig/brigfrontend/brig-branch-inst-handler.cc @@ -70,7 +70,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base) const BrigOperandOffset32_t *operand_ptr = (const BrigOperandOffset32_t *) data->bytes; - vec *&args = i == 0 ? out_args : in_args; + bool out_args_p = i == 0; while (bytes > 0) { @@ -85,7 +85,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base) if (brig_var->type & BRIG_TYPE_ARRAY) { /* Array return values are passed as the first argument. */ - args = in_args; + out_args_p = false; /* Pass pointer to the element zero and use its element zero as the base address. */ tree etype = TREE_TYPE (TREE_TYPE (var)); @@ -97,8 +97,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base) } gcc_assert (var != NULL_TREE); - vec_safe_reserve (args, 1); - vec_safe_push (args, var); + vec_safe_push (out_args_p ? out_args : in_args, var); ++operand_ptr; bytes -= 4; } diff --git a/gcc/brig/brigfrontend/brig-to-generic.cc b/gcc/brig/brigfrontend/brig-to-generic.cc index 6459f9e1076..41246ba2bfc 100644 --- a/gcc/brig/brigfrontend/brig-to-generic.cc +++ b/gcc/brig/brigfrontend/brig-to-generic.cc @@ -248,7 +248,12 @@ brig_to_generic::analyze (const char *brig_blob) if (handlers[i].kind == entry->kind) handler = handlers[i].handler; } - b += (*handler) (entry); + + int bytes_processed = (*handler) (entry); + if (bytes_processed == 0) + fatal_error (UNKNOWN_LOCATION, PHSA_ERROR_PREFIX_CORRUPTED_MODULE + "Element with 0 bytes."); + b += bytes_processed; } if (m_cf != NULL) @@ -335,7 +340,10 @@ brig_to_generic::parse (const char *brig_blob) /* There are no supported pragmas at this moment. */ {BRIG_KIND_DIRECTIVE_PRAGMA, &skipped_handler}, {BRIG_KIND_DIRECTIVE_CONTROL, &control_handler}, - {BRIG_KIND_DIRECTIVE_EXTENSION, &skipped_handler}}; + {BRIG_KIND_DIRECTIVE_EXTENSION, &skipped_handler}, + /* BRIG_KIND_NONE entries are valid anywhere. They can be used + for patching BRIGs before finalization. */ + {BRIG_KIND_NONE, &skipped_handler}}; const BrigSectionHeader *csection_header = (const BrigSectionHeader *) m_code; diff --git a/gcc/brig/brigfrontend/phsa.h b/gcc/brig/brigfrontend/phsa.h index 2da21c8335c..88e87eb6a9d 100644 --- a/gcc/brig/brigfrontend/phsa.h +++ b/gcc/brig/brigfrontend/phsa.h @@ -61,9 +61,10 @@ typedef struct __attribute__((__packed__)) #define PHSA_DESC_SECTION_PREFIX "phsa.desc." #define PHSA_HOST_DEF_PTR_PREFIX "__phsa.host_def." -/* The frontend error messages are parsed by the host runtime, known +/* The frontend error messages are parsed by the host runtime. Known prefix strings are used to separate the different runtime error codes. */ -#define PHSA_ERROR_PREFIX_INCOMPATIBLE_MODULE "Incompatible module:" +#define PHSA_ERROR_PREFIX_INCOMPATIBLE_MODULE "Incompatible module: " +#define PHSA_ERROR_PREFIX_CORRUPTED_MODULE "Corrupted module: " #endif