each FDE. */
static bool ld_needs_eh_markers = false;
+/* Emit a section-start symbol for mod init and term sections. */
+static bool ld_init_term_start_labels = false;
+
/* Section names. */
section * darwin_sections[NUM_DARWIN_SECTIONS];
else
switch_to_section (darwin_sections[constructor_section]);
+ /* Where needed, provide a linker-visible section-start symbol so that we
+ have stable output between debug and non-debug. */
+ if (ld_init_term_start_labels)
+ fputs (MACHOPIC_INDIRECT ? "_Mod.init:\n" : "_CTOR.sect:\n", asm_out_file);
+
if (vec_safe_length (ctors) > 1)
ctors->qsort (sort_cdtor_records);
FOR_EACH_VEC_SAFE_ELT (ctors, i, elt)
else
switch_to_section (darwin_sections[destructor_section]);
+ /* Where needed, provide a linker-visible section-start symbol so that we
+ have stable output between debug and non-debug. */
+ if (ld_init_term_start_labels)
+ fputs (MACHOPIC_INDIRECT ? "_Mod.term:\n" : "_DTOR.sect:\n", asm_out_file);
+
if (vec_safe_length (dtors) > 1)
dtors->qsort (sort_cdtor_records);
FOR_EACH_VEC_SAFE_ELT (dtors, i, elt)
/* Earlier versions are not specifically accounted, until required. */
}
- /* Older Darwin ld could not coalesce weak entities without them being
- placed in special sections. */
- if (darwin_target_linker
- && (strverscmp (darwin_target_linker, MIN_LD64_NO_COAL_SECTS) < 0))
- ld_uses_coal_sects = true;
+ /* Some codegen needs to account for the capabilities of the target
+ linker. */
+ if (darwin_target_linker)
+ {
+ /* Older Darwin ld could not coalesce weak entities without them being
+ placed in special sections. */
+ if (strverscmp (darwin_target_linker, MIN_LD64_NO_COAL_SECTS) < 0)
+ ld_uses_coal_sects = true;
+
+ /* Some newer assemblers emit section start temp symbols for mod init
+ and term sections if there is no suitable symbol present already.
+ The temp symbols are linker visible and therefore appear in the
+ symbol tables. Since the temp symbol number can vary when debug is
+ enabled, that causes compare-debug fails. The solution is to provide
+ a stable linker-visible symbol. */
+ if (strverscmp (darwin_target_linker,
+ MIN_LD64_INIT_TERM_START_LABELS) >= 0)
+ ld_init_term_start_labels = true;
+ }
/* In principle, this should be c-family only. However, we really need to
set sensible defaults for LTO as well, since the section selection stuff