s->symbol.udata.i = SYM_MACHO_FIELDS_NOT_VALIDATED;
}
-/* This is a place to check for any errors that we can't detect until we know
- what remains undefined at the end of assembly. */
-
-static void
-obj_mach_o_check_before_writing (bfd *abfd ATTRIBUTE_UNUSED,
- asection *sec,
- void *unused ATTRIBUTE_UNUSED)
-{
- fixS *fixP;
- struct frchain *frchp;
- segment_info_type *seginfo = seg_info (sec);
-
- if (seginfo == NULL)
- return;
-
- /* We are not allowed subtractions where either of the operands is
- undefined. So look through the frags for any fixes to check. */
- for (frchp = seginfo->frchainP; frchp != NULL; frchp = frchp->frch_next)
- for (fixP = frchp->fix_root; fixP != NULL; fixP = fixP->fx_next)
- {
- if (fixP->fx_addsy != NULL
- && fixP->fx_subsy != NULL
- && (! S_IS_DEFINED (fixP->fx_addsy)
- || ! S_IS_DEFINED (fixP->fx_subsy)))
- {
- segT add_symbol_segment = S_GET_SEGMENT (fixP->fx_addsy);
- segT sub_symbol_segment = S_GET_SEGMENT (fixP->fx_subsy);
-
- if (! S_IS_DEFINED (fixP->fx_addsy)
- && S_IS_DEFINED (fixP->fx_subsy))
- {
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("`%s' can't be undefined in `%s' - `%s' {%s section}"),
- S_GET_NAME (fixP->fx_addsy), S_GET_NAME (fixP->fx_addsy),
- S_GET_NAME (fixP->fx_subsy), segment_name (sub_symbol_segment));
- }
- else if (! S_IS_DEFINED (fixP->fx_subsy)
- && S_IS_DEFINED (fixP->fx_addsy))
- {
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("`%s' can't be undefined in `%s' {%s section} - `%s'"),
- S_GET_NAME (fixP->fx_subsy), S_GET_NAME (fixP->fx_addsy),
- segment_name (add_symbol_segment), S_GET_NAME (fixP->fx_subsy));
- }
- else
- {
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("`%s' and `%s' can't be undefined in `%s' - `%s'"),
- S_GET_NAME (fixP->fx_addsy), S_GET_NAME (fixP->fx_subsy),
- S_GET_NAME (fixP->fx_addsy), S_GET_NAME (fixP->fx_subsy));
- }
- }
- }
-}
-
-/* Do any checks that we can't complete without knowing what's undefined. */
-void
-obj_mach_o_pre_output_hook (void)
-{
- bfd_map_over_sections (stdoutput, obj_mach_o_check_before_writing, NULL);
-}
-
/* Here we count up frags in each subsection (where a sub-section is defined
as starting with a non-local symbol).
Note that, if there are no non-local symbols in a section, all the frags will
return obj_mach_o_is_frame_section (seg);
}
-int
+static bool
obj_mach_o_in_different_subsection (symbolS *a, symbolS *b)
{
fragS *fa;
|| !S_IS_DEFINED (b))
{
/* Not in the same segment, or undefined symbol. */
- return 1;
+ return true;
}
fa = symbol_get_frag (a);
if (fa == NULL || fb == NULL)
{
/* One of the symbols is not in a subsection. */
- return 1;
+ return true;
}
return fa->obj_frag_data.subsection != fb->obj_frag_data.subsection;
}
-int
+bool
obj_mach_o_force_reloc_sub_same (fixS *fix, segT seg)
{
if (! SEG_NORMAL (seg))
- return 1;
+ return true;
return obj_mach_o_in_different_subsection (fix->fx_addsy, fix->fx_subsy);
}
-int
+bool
obj_mach_o_force_reloc_sub_local (fixS *fix, segT seg ATTRIBUTE_UNUSED)
{
- return obj_mach_o_in_different_subsection (fix->fx_addsy, fix->fx_subsy);
+ symbolS *fragsym = fix->fx_frag->obj_frag_data.subsection;
+ if (fragsym == NULL)
+ return false;
+ return obj_mach_o_in_different_subsection (fix->fx_subsy, fragsym);
}
-int
+bool
obj_mach_o_force_reloc (fixS *fix)
{
if (generic_force_reloc (fix))
- return 1;
+ return true;
/* 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 ? */
/* There might be no subsections at all. */
if (subsec == NULL)
- return 0;
+ return false;
if (S_GET_SEGMENT (targ) == absolute_section)
- return 0;
+ return false;
return obj_mach_o_in_different_subsection (targ, subsec);
}
- return 0;
+ return false;
}
#define OBJ_FRAG_TYPE struct obj_mach_o_frag_data
-#define md_pre_output_hook obj_mach_o_pre_output_hook()
-extern void obj_mach_o_pre_output_hook(void);
-
#define md_pre_relax_hook obj_mach_o_pre_relax_hook()
extern void obj_mach_o_pre_relax_hook (void);
segT);
struct fix;
-extern int obj_mach_o_in_different_subsection (symbolS *a, symbolS *b);
-extern int obj_mach_o_force_reloc (struct fix *fix);
-extern int obj_mach_o_force_reloc_sub_same (struct fix *fix, segT seg);
-extern int obj_mach_o_force_reloc_sub_local (struct fix *fix, segT seg);
+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);
#endif /* _OBJ_MACH_O_H */