From 5b15f31ae8263268f140f0ffaf214df88b36ecbc Mon Sep 17 00:00:00 2001 From: John David Anglin Date: Wed, 1 Jan 2020 22:57:54 +0000 Subject: [PATCH] re PR target/67834 (Local references inside comdat groups) 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. From-SVN: r279823 --- gcc/ChangeLog | 5 +++++ gcc/config/pa/pa.c | 21 +++++++++++++++++++++ gcc/config/pa/pa32-linux.h | 5 +++++ 3 files changed, 31 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 305b7785bb5..382c3004d1c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2020-01-01 John David Anglin + 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. + PR target/93111 * config/pa/pa.md (scc): Use ordered_comparison_operator instead of comparison_operator in B and S integer comparisons. Likewise, use diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 07051d4ac1f..fb7e2ee110f 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -203,6 +203,7 @@ static bool pa_hard_regno_mode_ok (unsigned int, machine_mode); 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 @@ pa_select_section (tree exp, int reloc, 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 diff --git a/gcc/config/pa/pa32-linux.h b/gcc/config/pa/pa32-linux.h index ea6fd6c2579..f271bbf51a2 100644 --- a/gcc/config/pa/pa32-linux.h +++ b/gcc/config/pa/pa32-linux.h @@ -76,3 +76,8 @@ call_ ## FUNC (void) \ rodata when generating non-PIC code. */ #undef JUMP_TABLES_IN_TEXT_SECTION #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. */ +#undef TARGET_ASM_SELECT_RTX_SECTION +#define TARGET_ASM_SELECT_RTX_SECTION pa_elf_select_rtx_section -- 2.30.2