From ee200713c739fde7ba74f1c2f750e659a098d2d1 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 9 Sep 2018 13:26:17 +0000 Subject: [PATCH] compiler: make sure type descriptor initializers go in .rodata When creating type descriptor variables, the compiler (specifically Type::make_type_descriptor_var) invokes the immutable_struct() and immutable_struct_set_init() back end methods, so as to insure that these items go into the ".rodata" section of the generate object file. The expression initializers for these variables can contain nested subexpressions, however, and these subexpressions were not always being placed into .rodata. This patch changes the backend-gen code for slice initializers to emit implicit variables into .rodata if those initializers are part of a type descriptor init. Reviewed-on: https://go-review.googlesource.com/132596 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264181 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/expressions.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 9495882b5da2..1ef2c8d39d3a 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -da249ffd264154cc992e76ff03f91f700d3bf53e +06e688ff6d829c8de3735e9f59b61b373afc596f The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 143f0a73df68..efc8eba99082 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -4453,7 +4453,8 @@ Unary_expression::do_get_backend(Translate_context* context) // initialize the value once, so we can use this directly // rather than copying it. In that case we can't make it // read-only, because the program is permitted to change it. - copy_to_heap = context->function() != NULL; + copy_to_heap = (context->function() != NULL + || context->is_const()); } std::string asm_name(go_selectively_encode_id(var_name)); Bvariable* implicit = -- 2.47.2