[binutils-gdb] macho debug changes
Alan Modra via Binutils-cvs <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f577746edb4ca2678f69feb5e5848a646d5cd856 commit f577746edb4ca2678f69feb5e5848a646d5cd856 Author: Alan Modra <[email protected]> Date: Mon Jun 1 18:28:19 2026 +0930 macho debug changes 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. Diff: --- gas/config/obj-macho.c | 28 +++++++++++++++++++++------- gas/config/obj-macho.h | 6 +++--- gas/config/tc-i386.h | 6 +++--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c index bf6f2758bc7..d0d4763724e 100644 --- a/gas/config/obj-macho.c +++ b/gas/config/obj-macho.c @@ -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) diff --git a/gas/config/obj-macho.h b/gas/config/obj-macho.h index eac0afdf407..0a499f29503 100644 --- a/gas/config/obj-macho.h +++ b/gas/config/obj-macho.h @@ -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 */ diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 20e5334d14e..5eaed702ea9 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -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 */