]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
use proper DECL_INITIAL for VTV
authorMartin Liska <mliska@suse.cz>
Thu, 13 Oct 2022 13:39:08 +0000 (15:39 +0200)
committerMartin Liska <mliska@suse.cz>
Thu, 13 Oct 2022 15:47:15 +0000 (17:47 +0200)
gcc/cp/ChangeLog:

* vtable-class-hierarchy.cc (vtv_generate_init_routine): Emit
an artificial variable that would be put into .preinit_array
section.

gcc/ChangeLog:

* output.h (assemble_vtv_preinit_initializer): Remove.
* varasm.cc (assemble_vtv_preinit_initializer): Remove.

gcc/cp/vtable-class-hierarchy.cc
gcc/output.h
gcc/varasm.cc

index 79cb5f8de02a69356a6c9f01bc5c11397451925b..cc1df1ebdb23f00f6caacf55b03fb36ebd830c33 100644 (file)
@@ -1192,8 +1192,18 @@ vtv_generate_init_routine (void)
       cgraph_node::add_new_function (vtv_fndecl, false);
 
       if (flag_vtable_verify == VTV_PREINIT_PRIORITY && !TARGET_PECOFF)
-        assemble_vtv_preinit_initializer (vtv_fndecl);
-
+       {
+         tree vtv_var
+           = build_decl (BUILTINS_LOCATION, VAR_DECL,
+                         get_identifier ("__vtv_preinit"),
+                         build_pointer_type (TREE_TYPE (vtv_fndecl)));
+         TREE_STATIC (vtv_var) = 1;
+         DECL_ARTIFICIAL (vtv_var) = 1;
+         DECL_INITIAL (vtv_var) = build_fold_addr_expr (vtv_fndecl);
+         set_decl_section_name (vtv_var, ".preinit_array");
+
+         varpool_node::add (vtv_var);
+       }
     }
   pop_lang_context ();
 }
index 6dea630913a7fe8cd1baf3592981ebe264f214af..6936bdeeb6ca8e2bfc071edb8686fa27bd7a9876 100644 (file)
@@ -199,10 +199,6 @@ extern void assemble_end_function (tree, const char *);
    initial value (that will be done by the caller).  */
 extern void assemble_variable (tree, int, int, int);
 
-/* Put the vtable verification constructor initialization function
-   into the preinit array.  */
-extern void assemble_vtv_preinit_initializer (tree);
-
 /* Assemble everything that is needed for a variable declaration that has
    no definition in the current translation unit.  */
 extern void assemble_undefined_decl (tree);
index 423f3f91af8a4c111019df1a72c245f803b0e4d9..a11184584a21b44174e66c97a126c64f9e130294 100644 (file)
@@ -2419,23 +2419,6 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
     }
 }
 
-
-/* Given a function declaration (FN_DECL), this function assembles the
-   function into the .preinit_array section.  */
-
-void
-assemble_vtv_preinit_initializer (tree fn_decl)
-{
-  section *sect;
-  unsigned flags = SECTION_WRITE;
-  rtx symbol = XEXP (DECL_RTL (fn_decl), 0);
-
-  flags |= SECTION_NOTYPE;
-  sect = get_section (".preinit_array", flags, fn_decl);
-  switch_to_section (sect);
-  assemble_addr_to_section (symbol, sect);
-}
-
 /* Return 1 if type TYPE contains any pointers.  */
 
 static int