1*56bb7041Schristos /* Mach-O object file format for gas, the assembler.
2*56bb7041Schristos    Copyright (C) 2009-2020 Free Software Foundation, Inc.
3*56bb7041Schristos 
4*56bb7041Schristos    This file is part of GAS, the GNU Assembler.
5*56bb7041Schristos 
6*56bb7041Schristos    GAS is free software; you can redistribute it and/or modify
7*56bb7041Schristos    it under the terms of the GNU General Public License as
8*56bb7041Schristos    published by the Free Software Foundation; either version 3,
9*56bb7041Schristos    or (at your option) any later version.
10*56bb7041Schristos 
11*56bb7041Schristos    GAS is distributed in the hope that it will be useful, but
12*56bb7041Schristos    WITHOUT ANY WARRANTY; without even the implied warranty of
13*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
14*56bb7041Schristos    the GNU General Public License for more details.
15*56bb7041Schristos 
16*56bb7041Schristos    You should have received a copy of the GNU General Public License
17*56bb7041Schristos    along with GAS; see the file COPYING.  If not, write to the Free
18*56bb7041Schristos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19*56bb7041Schristos    02110-1301, USA.  */
20*56bb7041Schristos 
21*56bb7041Schristos #ifndef _OBJ_MACH_O_H
22*56bb7041Schristos #define _OBJ_MACH_O_H
23*56bb7041Schristos 
24*56bb7041Schristos /* Tag to validate Mach-O object file format processing */
25*56bb7041Schristos #define OBJ_MACH_O 1
26*56bb7041Schristos 
27*56bb7041Schristos #include "bfd/mach-o.h"
28*56bb7041Schristos 
29*56bb7041Schristos #include "targ-cpu.h"
30*56bb7041Schristos 
31*56bb7041Schristos #define OUTPUT_FLAVOR bfd_target_mach_o_flavour
32*56bb7041Schristos 
33*56bb7041Schristos /* We want to control how the sections are pre-defined on startup.  */
34*56bb7041Schristos #define obj_begin() mach_o_begin ()
35*56bb7041Schristos extern void mach_o_begin (void);
36*56bb7041Schristos 
37*56bb7041Schristos /* All our align expressions are power of two.  */
38*56bb7041Schristos #define USE_ALIGN_PTWO 1
39*56bb7041Schristos 
40*56bb7041Schristos /* Common symbols can carry alignment information.  */
41*56bb7041Schristos #ifndef S_SET_ALIGN
42*56bb7041Schristos #define S_SET_ALIGN(S,V) do {\
43*56bb7041Schristos   bfd_mach_o_asymbol *___s = (bfd_mach_o_asymbol *) symbol_get_bfdsym (S);\
44*56bb7041Schristos   ___s->n_desc = (___s->n_desc & 0xf0ff) | (((V) & 0x0f) << 8);\
45*56bb7041Schristos } while (0)
46*56bb7041Schristos #endif
47*56bb7041Schristos 
48*56bb7041Schristos extern const pseudo_typeS mach_o_pseudo_table[];
49*56bb7041Schristos 
50*56bb7041Schristos #ifndef obj_pop_insert
51*56bb7041Schristos #define obj_pop_insert() pop_insert (mach_o_pseudo_table)
52*56bb7041Schristos #endif
53*56bb7041Schristos 
54*56bb7041Schristos #define obj_sec_sym_ok_for_reloc(SEC)	1
55*56bb7041Schristos 
56*56bb7041Schristos #define obj_read_begin_hook()	{;}
57*56bb7041Schristos #define obj_symbol_new_hook(s)	{;}
58*56bb7041Schristos 
59*56bb7041Schristos #define EMIT_SECTION_SYMBOLS		0
60*56bb7041Schristos 
61*56bb7041Schristos struct obj_mach_o_symbol_data
62*56bb7041Schristos {
63*56bb7041Schristos   /* If the symbol represents a subsection, this is the size of the subsection.
64*56bb7041Schristos      This is used to check whether a local symbol belongs to a subsection.  */
65*56bb7041Schristos   valueT subsection_size;
66*56bb7041Schristos };
67*56bb7041Schristos #define OBJ_SYMFIELD_TYPE struct obj_mach_o_symbol_data
68*56bb7041Schristos 
69*56bb7041Schristos #define obj_frob_colon obj_mach_o_frob_colon
70*56bb7041Schristos extern void obj_mach_o_frob_colon (const char *);
71*56bb7041Schristos 
72*56bb7041Schristos /* Called when a label is defined.  Mach-O uses this to create subsections.  */
73*56bb7041Schristos #define obj_frob_label obj_mach_o_frob_label
74*56bb7041Schristos extern void obj_mach_o_frob_label (symbolS *);
75*56bb7041Schristos 
76*56bb7041Schristos #define obj_frob_symbol(s, punt) punt = obj_mach_o_frob_symbol(s)
77*56bb7041Schristos extern int obj_mach_o_frob_symbol (struct symbol *);
78*56bb7041Schristos 
79*56bb7041Schristos #define OBJ_PROCESS_STAB(SEG,W,S,T,O,D)	obj_mach_o_process_stab(W,S,T,O,D)
80*56bb7041Schristos extern void obj_mach_o_process_stab (int, const char *,int, int, int);
81*56bb7041Schristos 
82*56bb7041Schristos struct obj_mach_o_frag_data
83*56bb7041Schristos {
84*56bb7041Schristos   /* Symbol that corresponds to the subsection.  */
85*56bb7041Schristos   symbolS *subsection;
86*56bb7041Schristos };
87*56bb7041Schristos 
88*56bb7041Schristos #define OBJ_FRAG_TYPE struct obj_mach_o_frag_data
89*56bb7041Schristos 
90*56bb7041Schristos #define md_pre_output_hook obj_mach_o_pre_output_hook()
91*56bb7041Schristos extern void obj_mach_o_pre_output_hook(void);
92*56bb7041Schristos 
93*56bb7041Schristos #define md_pre_relax_hook obj_mach_o_pre_relax_hook()
94*56bb7041Schristos extern void obj_mach_o_pre_relax_hook (void);
95*56bb7041Schristos 
96*56bb7041Schristos #define md_post_relax_hook obj_mach_o_post_relax_hook()
97*56bb7041Schristos extern void obj_mach_o_post_relax_hook (void);
98*56bb7041Schristos 
99*56bb7041Schristos #define obj_frob_file_after_relocs obj_mach_o_frob_file_after_relocs
100*56bb7041Schristos extern void obj_mach_o_frob_file_after_relocs (void);
101*56bb7041Schristos 
102*56bb7041Schristos #define SET_SECTION_RELOCS(sec, relocs, n) \
103*56bb7041Schristos   obj_mach_o_reorder_section_relocs (sec, relocs, n)
104*56bb7041Schristos extern void obj_mach_o_reorder_section_relocs (asection *, arelent **,
105*56bb7041Schristos 					       unsigned int);
106*56bb7041Schristos 
107*56bb7041Schristos /* Emit relocs for local subtracts, to cater for subsections-via-symbols.  */
108*56bb7041Schristos #define md_allow_local_subtract(LEFT, RIGHT, SECTION) \
109*56bb7041Schristos  obj_mach_o_allow_local_subtract (LEFT, RIGHT, SECTION)
110*56bb7041Schristos extern int obj_mach_o_allow_local_subtract (expressionS *, expressionS *,
111*56bb7041Schristos 					    segT);
112*56bb7041Schristos 
113*56bb7041Schristos struct fix;
114*56bb7041Schristos extern int obj_mach_o_in_different_subsection (symbolS *a, symbolS *b);
115*56bb7041Schristos extern int obj_mach_o_force_reloc (struct fix *fix);
116*56bb7041Schristos extern int obj_mach_o_force_reloc_sub_same (struct fix *fix, segT seg);
117*56bb7041Schristos extern int obj_mach_o_force_reloc_sub_local (struct fix *fix, segT seg);
118*56bb7041Schristos 
119*56bb7041Schristos #endif /* _OBJ_MACH_O_H */
120