]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
macho debug changes
authorAlan Modra <amodra@gmail.com>
Mon, 1 Jun 2026 08:58:19 +0000 (18:28 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 1 Jun 2026 08:58:19 +0000 (18:28 +0930)
This patch is aimed at fixing "FAIL: eqv involving dot" and any
similar problems in real code when generating DWARF.

* config/obj-macho.c (obj_mach_o_frob_label),
(obj_mach_o_frob_symbol): Ignore more debug symbols.
(obj_mach_o_set_subsections): Ignore SEC_DEBUGGING sections.
(obj_mach_o_force_reloc_sub_same),
(obj_mach_o_force_reloc_sub_local),
(obj_mach_o_force_reloc): Add seg param.  Return false when
processing debug sections.
* config/obj-macho.h: Update prototypes.
* config/tc-i386.h <OBJ_MACHO>: Smuggle section being
processed by TC_FORCE_RELOCATION* to obj_macho_o functions.

gas/config/obj-macho.c
gas/config/obj-macho.h
gas/config/tc-i386.h

index bf6f2758bc7f95a7fa2812f2a0d79f6ad9c7b60e..d0d4763724e6ae6469b47b112fc456a736c7022d 100644 (file)
@@ -1383,7 +1383,8 @@ void obj_mach_o_frob_label (struct symbol *sp)
 
   s = (bfd_mach_o_asymbol *) symbol_get_bfdsym (sp);
   /* Leave debug symbols alone.  */
-  if ((s->n_type & BFD_MACH_O_N_STAB) != 0)
+  if ((s->n_type & BFD_MACH_O_N_STAB) != 0
+      || (s->symbol.section->flags & SEC_DEBUGGING) != 0)
     return;
 
   /* This is the base symbol type, that we mask in.  */
@@ -1433,7 +1434,8 @@ obj_mach_o_frob_symbol (struct symbol *sp)
 
   s = (bfd_mach_o_asymbol *) symbol_get_bfdsym (sp);
   /* Leave debug symbols alone.  */
-  if ((s->n_type & BFD_MACH_O_N_STAB) != 0)
+  if ((s->n_type & BFD_MACH_O_N_STAB) != 0
+      || (s->symbol.section->flags & SEC_DEBUGGING) != 0)
     return 0;
 
   base_type = obj_mach_o_type_for_symbol (s);
@@ -1570,6 +1572,10 @@ obj_mach_o_set_subsections (bfd *abfd ATTRIBUTE_UNUSED,
   fragS *frag;
   frchainS *chain;
 
+  /* Don't waste time on debug sections.  */
+  if ((sec->flags & SEC_DEBUGGING) != 0)
+    return;
+
   /* Protect against sections not created by gas.  */
   if (seginfo == NULL)
     return;
@@ -1893,17 +1899,22 @@ obj_mach_o_in_different_subsection (symbolS *a, segT aseg, valueT offset,
 }
 
 bool
-obj_mach_o_force_reloc_sub_same (fixS *fix, segT seg)
+obj_mach_o_force_reloc_sub_same (segT seg, fixS *fix, segT addsymseg)
 {
-  if (! SEG_NORMAL (seg))
+  if (!SEG_NORMAL (addsymseg))
     return true;
-  return obj_mach_o_in_different_subsection (fix->fx_addsy, seg,
+  if ((seg->flags & SEC_DEBUGGING) != 0)
+    return false;
+  return obj_mach_o_in_different_subsection (fix->fx_addsy, addsymseg,
                                             fix->fx_offset, fix->fx_subsy);
 }
 
 bool
-obj_mach_o_force_reloc_sub_local (fixS *fix, segT seg ATTRIBUTE_UNUSED)
+obj_mach_o_force_reloc_sub_local (segT seg, fixS *fix,
+                                 segT addsymseg ATTRIBUTE_UNUSED)
 {
+  if ((seg->flags & SEC_DEBUGGING) != 0)
+    return false;
   symbolS *fragsym = fix->fx_frag->obj_frag_data.subsection;
   if (fragsym == NULL)
     return false;
@@ -1911,11 +1922,14 @@ obj_mach_o_force_reloc_sub_local (fixS *fix, segT seg ATTRIBUTE_UNUSED)
 }
 
 bool
-obj_mach_o_force_reloc (fixS *fix)
+obj_mach_o_force_reloc (segT seg, fixS *fix)
 {
   if (generic_force_reloc (fix))
     return true;
 
+  if ((seg->flags & SEC_DEBUGGING) != 0)
+    return false;
+
   /* Force a reloc if the target is not in the same subsection.
      FIXME: handle (a - b) where a and b belongs to the same subsection ?  */
   if (fix->fx_addsy != NULL)
index eac0afdf407be41bb34255309a1565f377a1b7e4..0a499f29503ffd7be03d766bb0e3f642a14ea6fd 100644 (file)
@@ -108,8 +108,8 @@ extern int obj_mach_o_allow_local_subtract (expressionS *, expressionS *,
                                            segT);
 
 struct fix;
-extern bool obj_mach_o_force_reloc (struct fix *);
-extern bool obj_mach_o_force_reloc_sub_same (struct fix *, segT);
-extern bool obj_mach_o_force_reloc_sub_local (struct fix *, segT);
+extern bool obj_mach_o_force_reloc (segT, struct fix *);
+extern bool obj_mach_o_force_reloc_sub_same (segT, struct fix *, segT);
+extern bool obj_mach_o_force_reloc_sub_local (segT, struct fix *, segT);
 
 #endif /* _OBJ_MACH_O_H */
index 20e5334d14e604eef7bba2d165a206fcf4847f7c..5eaed702ea939035b6811b1581aa1fca4fb3b367 100644 (file)
@@ -498,13 +498,13 @@ void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
 
 #ifdef OBJ_MACH_O
 
-#define TC_FORCE_RELOCATION(FIX) (obj_mach_o_force_reloc (FIX))
+#define TC_FORCE_RELOCATION(FIX) (obj_mach_o_force_reloc (this_segment, FIX))
 
 #define TC_FORCE_RELOCATION_SUB_SAME(FIX,SEG) \
-         (obj_mach_o_force_reloc_sub_same (FIX, SEG))
+         (obj_mach_o_force_reloc_sub_same (this_segment, FIX, SEG))
 
 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX,SEG) \
-       (obj_mach_o_force_reloc_sub_local (FIX, SEG))
+       (obj_mach_o_force_reloc_sub_local (this_segment, FIX, SEG))
 
 #endif /* OBJ_MACH_O */