This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix P81033 for FDEs in partitioned code.


A more detailed explanation is in

When function sub-sections are enabled, Darwin’s assembler needs the FDE local start
label for each sub-section to follow a linker-visible one so that the FDE will be correctly
associated with the code of the subsection.

The current code in final.c emits a linker-visible symbol, as needed by several targets.
However the local label used to define the FDE start precedes the linker-visible one
which, for Darwin causes it (the FDE start) to be associated with the previous linker-
visible symbol (or the section start if there isn’t one).  This applies regardless of the 
actual address of the label, for toolchain assemblers that have strict interpretation of
the Darwin sub-sections-via-symbols ABI.

The patch adds a new local label (analogous to the "LFBn” emitted for the regular
function starts) just after the linker-visible label emitted after switching text section.
The FDE second entry is made to point to this instead of the LcoldStartn one.  This
should be a no-op for targets using .cfi_ and for targets without sub-sections-via-symbols.

Bootstrapped on x86_64 and i686 linux and on a number of Darwin platforms (from 
i686-darwin9 to x86_64-darwin17).

OK for trunk?
open branches? (although it's a regression on 8, it’s a latent wrong-code on all branches)


2018-08-14  Iain Sandoe  <>


        PR target/81033
	* dwarf2out.c (FUNC_SECOND_SECT_LABEL): New.
	(dwarf2out_switch_text_section): Generate subsection label and
	assign it to the FDE second section start.
	* final.c (final_scan_insn_1): Emit second section label when
 gcc/dwarf2out.c | 11 +++++++++--
 gcc/final.c     |  3 +++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 9ed473088e..c7557eb51d 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -297,6 +297,10 @@ static unsigned int rnglist_idx;
 #define FUNC_END_LABEL		"LFE"
@@ -1212,21 +1216,24 @@ static void set_cur_line_info_table (section *);
 dwarf2out_switch_text_section (void)
   section *sect;
   dw_fde_ref fde = cfun->fde;
   gcc_assert (cfun && fde && fde->dw_fde_second_begin == NULL);
+			       current_function_funcdef_no);
+  fde->dw_fde_second_begin = xstrdup (label);
   if (!in_cold_section_p)
       fde->dw_fde_end = crtl->subsections.cold_section_end_label;
-      fde->dw_fde_second_begin = crtl->subsections.hot_section_label;
       fde->dw_fde_second_end = crtl->subsections.hot_section_end_label;
       fde->dw_fde_end = crtl->subsections.hot_section_end_label;
-      fde->dw_fde_second_begin = crtl->subsections.cold_section_label;
       fde->dw_fde_second_end = crtl->subsections.cold_section_end_label;
   have_multiple_function_sections = true;
diff --git a/gcc/final.c b/gcc/final.c
index 842e5e067d..6943c073d9 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -2232,6 +2232,9 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
 	      ASM_OUTPUT_LABEL (asm_out_file,
 				IDENTIFIER_POINTER (cold_function_name));
+	      if (dwarf2out_do_frame ()
+	          && cfun->fde->dw_fde_second_begin != NULL)
+		ASM_OUTPUT_LABEL (asm_out_file, cfun->fde->dw_fde_second_begin);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]