Sync usage with man page.
[netbsd-mini2440.git] / libexec / ld.aout_so / arch / m68k / md.h
blob384d05609a34b51f712b356eaabff0e529f070aa
1 /* $NetBSD: md.h,v 1.10 2001/07/25 12:21:33 aymeric Exp $ */
3 /*
4 * - m68k dependent definitions
5 */
7 /*
8 * Prototype for the m68k _cachectl trap stub in mdprologue.S
9 */
10 void _cachectl __P((void *, size_t));
12 #if defined(CROSS_LINKER) && defined(XHOST) && \
13 (XHOST==i386 || XHOST==mipsel || XHOST==sh3el)
14 #define NEED_SWAP
15 #endif
17 #define MAX_ALIGNMENT (sizeof (long))
19 #ifdef CROSS_LINKER
20 /* XXX We should check for m68k ports that have pages of less than 8K (sun2) */
21 #ifndef MID_M68K
22 #define MID_M68K 135
23 #endif
25 #undef MID_MACHINE
26 #define MID_MACHINE MID_M68K
28 #undef AOUT_LDPGSZ
29 #define AOUT_LDPGSZ 8192
30 #endif /* CROSS_LINKER */
32 #define PAGSIZ AOUT_LDPGSZ
34 #define N_SET_FLAG(ex,f) N_SETMAGIC(ex,N_GETMAGIC(ex), MID_MACHINE, \
35 N_GETFLAG(ex)|(f))
37 #define N_IS_DYNAMIC(ex) ((N_GETFLAG(ex) & EX_DYNAMIC))
39 #define N_BADMID(ex) \
40 (N_GETMID(ex) != 0 && N_GETMID(ex) != MID_MACHINE && \
41 !md_midcompat(&(ex)))
44 * Should be handled by a.out.h ?
46 #define N_ADJUST(ex) (((ex).a_entry < PAGSIZ) ? -PAGSIZ : 0)
47 #define TEXT_START(ex) (N_TXTADDR(ex) + N_ADJUST(ex))
48 #define DATA_START(ex) (N_DATADDR(ex) + N_ADJUST(ex))
50 #define RELOC_STATICS_THROUGH_GOT_P(r) (1)
51 #define JMPSLOT_NEEDS_RELOC (0)
52 #define JMPSLOT_NONEXTERN_IS_INTERMODULE (0)
54 #define md_got_reloc(r) (0)
56 #define md_get_rt_segment_addend(r,a) md_get_addend(r,a)
58 /* Width of a Global Offset Table entry */
59 #define GOT_ENTRY_SIZE 4
60 typedef long got_t;
62 typedef struct jmpslot {
63 u_short opcode;
64 u_short addr[2];
65 u_short reloc_index;
66 #define JMPSLOT_RELOC_MASK 0xffff
67 } jmpslot_t;
69 #define NOP 0x4e71
70 #define BSRL 0x61ff /* BSR opcode with long offset */
71 #define BRAL 0x60ff /* BRA opcode with long offset */
72 #define BPT 0x4e42 /* breakpoint trap: trap #2 */
75 * Byte swap defs for cross linking
78 #if !defined(NEED_SWAP)
80 #define md_swapin_exec_hdr(h)
81 #define md_swapout_exec_hdr(h)
82 #define md_swapin_symbols(s,n)
83 #define md_swapout_symbols(s,n)
84 #define md_swapin_zsymbols(s,n)
85 #define md_swapout_zsymbols(s,n)
86 #define md_swapin_reloc(r,n)
87 #define md_swapout_reloc(r,n)
88 #define md_swapin__dynamic(l)
89 #define md_swapout__dynamic(l)
90 #define md_swapin_section_dispatch_table(l)
91 #define md_swapout_section_dispatch_table(l)
92 #define md_swapin_so_debug(d)
93 #define md_swapout_so_debug(d)
94 #define md_swapin_rrs_hash(f,n)
95 #define md_swapout_rrs_hash(f,n)
96 #define md_swapin_sod(l,n)
97 #define md_swapout_sod(l,n)
98 #define md_swapout_jmpslot(j,n)
99 #define md_swapout_got(g,n)
100 #define md_swapin_ranlib_hdr(h,n)
101 #define md_swapout_ranlib_hdr(h,n)
103 #endif /* NEED_SWAP */
105 #ifdef CROSS_LINKER
107 #define get_byte(p) ( ((unsigned char *)(p))[0] )
109 #define get_short(p) ( ( ((unsigned char *)(p))[0] << 8) | \
110 ( ((unsigned char *)(p))[1] ) \
113 #define get_long(p) ( ( ((unsigned char *)(p))[0] << 24) | \
114 ( ((unsigned char *)(p))[1] << 16) | \
115 ( ((unsigned char *)(p))[2] << 8 ) | \
116 ( ((unsigned char *)(p))[3] ) \
119 #define put_byte(p, v) { ((unsigned char *)(p))[0] = ((unsigned long)(v)); }
121 #define put_short(p, v) { ((unsigned char *)(p))[0] = \
122 ((((unsigned long)(v)) >> 8) & 0xff); \
123 ((unsigned char *)(p))[1] = \
124 ((((unsigned long)(v)) ) & 0xff); }
126 #define put_long(p, v) { ((unsigned char *)(p))[0] = \
127 ((((unsigned long)(v)) >> 24) & 0xff); \
128 ((unsigned char *)(p))[1] = \
129 ((((unsigned long)(v)) >> 16) & 0xff); \
130 ((unsigned char *)(p))[2] = \
131 ((((unsigned long)(v)) >> 8) & 0xff); \
132 ((unsigned char *)(p))[3] = \
133 ((((unsigned long)(v)) ) & 0xff); }
135 #ifdef NEED_SWAP
137 /* Define IO byte swapping routines */
139 void md_swapin_exec_hdr __P((struct exec *));
140 void md_swapout_exec_hdr __P((struct exec *));
141 void md_swapin_reloc __P((struct relocation_info *, int));
142 void md_swapout_reloc __P((struct relocation_info *, int));
143 void md_swapout_jmpslot __P((jmpslot_t *, int));
145 #define md_swapin_symbols(s,n) swap_symbols(s,n)
146 #define md_swapout_symbols(s,n) swap_symbols(s,n)
147 #define md_swapin_zsymbols(s,n) swap_zsymbols(s,n)
148 #define md_swapout_zsymbols(s,n) swap_zsymbols(s,n)
149 #define md_swapin__dynamic(l) swap__dynamic(l)
150 #define md_swapout__dynamic(l) swap__dynamic(l)
151 #define md_swapin_section_dispatch_table(l) swap_section_dispatch_table(l)
152 #define md_swapout_section_dispatch_table(l) swap_section_dispatch_table(l)
153 #define md_swapin_so_debug(d) swap_so_debug(d)
154 #define md_swapout_so_debug(d) swap_so_debug(d)
155 #define md_swapin_rrs_hash(f,n) swap_rrs_hash(f,n)
156 #define md_swapout_rrs_hash(f,n) swap_rrs_hash(f,n)
157 #define md_swapin_sod(l,n) swapin_sod(l,n)
158 #define md_swapout_sod(l,n) swapout_sod(l,n)
159 #define md_swapout_got(g,n) swap_longs((long*)(g),n)
160 #define md_swapin_ranlib_hdr(h,n) swap_ranlib_hdr(h,n)
161 #define md_swapout_ranlib_hdr(h,n) swap_ranlib_hdr(h,n)
163 #define md_swap_short(x) ( (((x) >> 8) & 0xff) | (((x) & 0xff) << 8) )
165 #define md_swap_long(x) ( (((x) >> 24) & 0xff ) | (((x) >> 8 ) & 0xff00 ) | \
166 (((x) << 8 ) & 0xff0000) | (((x) << 24) & 0xff000000))
168 #else /* We need not swap, but must pay attention to alignment: */
170 #define md_swap_short(x) (x)
171 #define md_swap_long(x) (x)
173 #endif /* NEED_SWAP */
175 #else /* Not a cross linker: use native */
177 #define md_swap_short(x) (x)
178 #define md_swap_long(x) (x)
180 #define get_byte(where) (*(char *)(where))
181 #define get_short(where) (*(short *)(where))
182 #define get_long(where) (*(long *)(where))
184 #define put_byte(where,what) (*(char *)(where) = (what))
185 #define put_short(where,what) (*(short *)(where) = (what))
186 #define put_long(where,what) (*(long *)(where) = (what))
188 #endif /* CROSS_LINKER */