[committed] Fix placement of references to functions in COMDAT groups on hppa-linux

Message ID 3b730c1c-9ca6-f788-aa47-b832599e62af@bell.net
State New
Headers show
  • [committed] Fix placement of references to functions in COMDAT groups on hppa-linux
Related show

Commit Message

John David Anglin Jan. 1, 2020, 11:13 p.m.
When I changed pa_reloc_rw_mask() to allow references to function labels to be placed in .rodata*,
I broke the handling of references to function labels in COMDAT groups.  The linker only allows
references in .data.rel.ro.local to be ignored.

This change puts function label references back in .data.rel.ro.local when they refer to a function
in a COMDAT group.

Tested on hppa-unknown-linux-gnu.  The change fixes the build of the Debian voronota package.

Committed to trunk and gcc-9 branch.


2020-01-01  John David Anglin  <danglin@gcc.gnu.org>

	PR target/67834
	* config/pa/pa.c (pa_elf_select_rtx_section): New.  Put references to
	COMDAT group function labels in .data.rel.ro.local section.
	* config/pa/pa32-linux.h (TARGET_ASM_SELECT_RTX_SECTION): Define.


Index: config/pa/pa.c
--- config/pa/pa.c	(revision 279798)
+++ config/pa/pa.c	(working copy)
@@ -203,6 +203,7 @@ 
 static bool pa_modes_tieable_p (machine_mode, machine_mode);
 static bool pa_can_change_mode_class (machine_mode, machine_mode, reg_class_t);
 static HOST_WIDE_INT pa_starting_frame_offset (void);
+static section* pa_elf_select_rtx_section(machine_mode, rtx, unsigned HOST_WIDE_INT) ATTRIBUTE_UNUSED;

 /* The following extra sections are only used for SOM.  */
 static GTY(()) section *som_readonly_data_section;
@@ -9838,6 +9839,26 @@ 
     return data_section;

+/* Implement pa_elf_select_rtx_section.  If X is a function label operand
+   and the function is in a COMDAT group, place the plabel reference in the
+   .data.rel.ro.local section.  The linker ignores references to symbols in
+   discarded sections from this section.  */
+static section *
+pa_elf_select_rtx_section (machine_mode mode, rtx x,
+			   unsigned HOST_WIDE_INT align)
+  if (function_label_operand (x, VOIDmode))
+    {
+      tree decl = SYMBOL_REF_DECL (x);
+      if (DECL_P (decl) && DECL_COMDAT_GROUP (decl))
+	return get_named_section (NULL, ".data.rel.ro.local", 1);
+    }
+  return default_elf_select_rtx_section (mode, x, align);
 /* Implement pa_reloc_rw_mask.  */

 static int
Index: config/pa/pa32-linux.h
--- config/pa/pa32-linux.h	(revision 279798)
+++ config/pa/pa32-linux.h	(working copy)
@@ -76,3 +76,8 @@ 
    rodata when generating non-PIC code.  */
 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
+/* We need to override default selection to put references to functions
+   in COMDAT groups in .data.rel.ro.local.  */
+#define TARGET_ASM_SELECT_RTX_SECTION pa_elf_select_rtx_section