patch_area_number++;
ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number);
- switch_to_section (get_section ("__patchable_function_entries",
- flags, current_function_decl));
+ section *sect = get_section ("__patchable_function_entries",
+ flags, current_function_decl);
+ if (HAVE_COMDAT_GROUP && DECL_COMDAT_GROUP (current_function_decl))
+ switch_to_comdat_section (sect, current_function_decl);
+ else
+ switch_to_section (sect);
assemble_align (POINTER_SIZE);
fputs (asm_op, file);
assemble_name_raw (file, buf);
--- /dev/null
+/* { dg-module-do link } */
+/* { dg-options "-std=c++11 -fpatchable-function-entry=1 -O2" } */
+/* { dg-additional-options "-std=c++11 -fpatchable-function-entry=1 -O2" } */
+
+/* This test is in the "modules" package because it supports multiple files
+ linkage. */
+
+#include "pr105169.h"
+
+WinsockInterfaceClass* PacketTransport;
+
+IPXAddressClass::IPXAddressClass(void)
+{
+}
+
+int function()
+{
+ return PacketTransport->Get_Protocol();
+}
+
+int main()
+{
+ IPXAddressClass ipxaddr;
+ return 0;
+}
fprintf (asm_out_file, "%s\"%s\"\n", ident_asm_op, ident_str);
}
-
-/* This function ensures that vtable_map variables are not only
- in the comdat section, but that each variable has its own unique
- comdat name. Without this the variables end up in the same section
- with a single comdat name.
-
+/* Switch to a COMDAT section with COMDAT name of decl.
+
FIXME: resolve_unique_section needs to deal better with
decls with both DECL_SECTION_NAME and DECL_ONE_ONLY. Once
that is fixed, this if-else statement can be replaced with
a single call to "switch_to_section (sect)". */
-static void
-handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED)
+void
+switch_to_comdat_section (section *sect, tree decl)
{
#if defined (OBJECT_FORMAT_ELF)
targetm.asm_out.named_section (sect->named.name,
sect->named.common.flags
| SECTION_LINKONCE,
- DECL_NAME (decl));
+ decl);
in_section = sect;
#else
/* Neither OBJECT_FORMAT_PE, nor OBJECT_FORMAT_COFF is set here.
{
char *name;
- if (TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE)
+ if (TREE_CODE (decl) == IDENTIFIER_NODE)
name = ACONCAT ((sect->named.name, "$",
- IDENTIFIER_POINTER (DECL_NAME (decl)), NULL));
+ IDENTIFIER_POINTER (decl), NULL));
else
name = ACONCAT ((sect->named.name, "$",
- IDENTIFIER_POINTER (DECL_COMDAT_GROUP (DECL_NAME (decl))),
+ IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl)),
NULL));
targetm.asm_out.named_section (name,
sect->named.common.flags
| SECTION_LINKONCE,
- DECL_NAME (decl));
+ decl);
in_section = sect;
}
else
#endif
}
+/* This function ensures that vtable_map variables are not only
+ in the comdat section, but that each variable has its own unique
+ comdat name. Without this the variables end up in the same section
+ with a single comdat name. */
+
+static void
+handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED)
+{
+ switch_to_comdat_section(sect, DECL_NAME (decl));
+}
+
#include "gt-varasm.h"