]>
Commit | Line | Data |
---|---|---|
882bdc69 ILT |
1 | /* tc-ppc.c -- Assemble for the PowerPC or POWER (RS/6000) |
2 | Copyright (C) 1994 Free Software Foundation, Inc. | |
3 | Written by Ian Lance Taylor, Cygnus Support. | |
4 | ||
5 | This file is part of GAS, the GNU Assembler. | |
6 | ||
7 | GAS is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GAS is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GAS; see the file COPYING. If not, write to | |
840886d8 | 19 | the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
882bdc69 ILT |
20 | |
21 | #include <stdio.h> | |
22 | #include <ctype.h> | |
23 | #include "as.h" | |
24 | #include "subsegs.h" | |
25 | ||
26 | #include "opcode/ppc.h" | |
27 | ||
ce9a2805 MM |
28 | #ifdef OBJ_ELF |
29 | #include "elf/ppc.h" | |
30 | #endif | |
31 | ||
882bdc69 ILT |
32 | /* This is the assembler for the PowerPC or POWER (RS/6000) chips. */ |
33 | ||
2c474754 | 34 | /* Tell the main code what the endianness is. */ |
882bdc69 ILT |
35 | extern int target_big_endian; |
36 | ||
2c474754 MM |
37 | /* Whether or not, we've set target_big_endian. */ |
38 | static int set_target_endian = 0; | |
39 | ||
882bdc69 ILT |
40 | static void ppc_set_cpu PARAMS ((void)); |
41 | static unsigned long ppc_insert_operand | |
42 | PARAMS ((unsigned long insn, const struct powerpc_operand *operand, | |
43 | offsetT val, char *file, unsigned int line)); | |
44 | static void ppc_macro PARAMS ((char *str, const struct powerpc_macro *macro)); | |
45 | static void ppc_byte PARAMS ((int)); | |
46 | static int ppc_is_toc_sym PARAMS ((symbolS *sym)); | |
47 | static void ppc_tc PARAMS ((int)); | |
48 | #ifdef OBJ_COFF | |
49 | static void ppc_comm PARAMS ((int)); | |
50 | static void ppc_bb PARAMS ((int)); | |
51 | static void ppc_bf PARAMS ((int)); | |
52 | static void ppc_biei PARAMS ((int)); | |
53 | static void ppc_bs PARAMS ((int)); | |
54 | static void ppc_eb PARAMS ((int)); | |
55 | static void ppc_ef PARAMS ((int)); | |
56 | static void ppc_es PARAMS ((int)); | |
57 | static void ppc_csect PARAMS ((int)); | |
58 | static void ppc_function PARAMS ((int)); | |
59 | static void ppc_extern PARAMS ((int)); | |
60 | static void ppc_lglobl PARAMS ((int)); | |
61 | static void ppc_stabx PARAMS ((int)); | |
62 | static void ppc_rename PARAMS ((int)); | |
63 | static void ppc_toc PARAMS ((int)); | |
64 | #endif | |
4a6b2f8b MM |
65 | #ifdef OBJ_ELF |
66 | static bfd_reloc_code_real_type ppc_elf_suffix PARAMS ((char **)); | |
67 | static void ppc_elf_cons PARAMS ((int)); | |
99146659 | 68 | static void ppc_elf_validate_fix PARAMS ((fixS *, segT)); |
4a6b2f8b | 69 | #endif |
882bdc69 ILT |
70 | \f |
71 | /* Generic assembler global variables which must be defined by all | |
72 | targets. */ | |
73 | ||
74 | /* Characters which always start a comment. */ | |
75 | const char comment_chars[] = "#"; | |
76 | ||
77 | /* Characters which start a comment at the beginning of a line. */ | |
78 | const char line_comment_chars[] = "#"; | |
79 | ||
80 | /* Characters which may be used to separate multiple commands on a | |
81 | single line. */ | |
82 | const char line_separator_chars[] = ";"; | |
83 | ||
84 | /* Characters which are used to indicate an exponent in a floating | |
85 | point number. */ | |
86 | const char EXP_CHARS[] = "eE"; | |
87 | ||
88 | /* Characters which mean that a number is a floating point constant, | |
89 | as in 0d1.0. */ | |
90 | const char FLT_CHARS[] = "dD"; | |
91 | \f | |
92 | /* The target specific pseudo-ops which we support. */ | |
93 | ||
94 | const pseudo_typeS md_pseudo_table[] = | |
95 | { | |
96 | /* Pseudo-ops which must be overridden. */ | |
97 | { "byte", ppc_byte, 0 }, | |
98 | ||
99 | #ifdef OBJ_COFF | |
100 | /* Pseudo-ops specific to the RS/6000 XCOFF format. Some of these | |
101 | legitimately belong in the obj-*.c file. However, XCOFF is based | |
102 | on COFF, and is only implemented for the RS/6000. We just use | |
103 | obj-coff.c, and add what we need here. */ | |
104 | { "comm", ppc_comm, 0 }, | |
105 | { "lcomm", ppc_comm, 1 }, | |
106 | { "bb", ppc_bb, 0 }, | |
107 | { "bf", ppc_bf, 0 }, | |
108 | { "bi", ppc_biei, 0 }, | |
109 | { "bs", ppc_bs, 0 }, | |
110 | { "csect", ppc_csect, 0 }, | |
111 | { "eb", ppc_eb, 0 }, | |
112 | { "ef", ppc_ef, 0 }, | |
113 | { "ei", ppc_biei, 1 }, | |
114 | { "es", ppc_es, 0 }, | |
115 | { "extern", ppc_extern, 0 }, | |
116 | { "function", ppc_function, 0 }, | |
117 | { "lglobl", ppc_lglobl, 0 }, | |
118 | { "rename", ppc_rename, 0 }, | |
119 | { "stabx", ppc_stabx, 0 }, | |
120 | { "toc", ppc_toc, 0 }, | |
121 | #endif | |
4a6b2f8b MM |
122 | #ifdef OBJ_ELF |
123 | { "long", ppc_elf_cons, 4 }, | |
124 | { "word", ppc_elf_cons, 2 }, | |
125 | { "short", ppc_elf_cons, 2 }, | |
4a6b2f8b | 126 | #endif |
882bdc69 ILT |
127 | |
128 | /* This pseudo-op is used even when not generating XCOFF output. */ | |
129 | { "tc", ppc_tc, 0 }, | |
130 | ||
131 | { NULL, NULL, 0 } | |
132 | }; | |
133 | \f | |
134 | /* Local variables. */ | |
135 | ||
1e147242 ILT |
136 | /* The type of processor we are assembling for. This is one or more |
137 | of the PPC_OPCODE flags defined in opcode/ppc.h. */ | |
882bdc69 ILT |
138 | static int ppc_cpu = 0; |
139 | ||
1e147242 ILT |
140 | /* The size of the processor we are assembling for. This is either |
141 | PPC_OPCODE_32 or PPC_OPCODE_64. */ | |
142 | static int ppc_size = PPC_OPCODE_32; | |
143 | ||
882bdc69 ILT |
144 | /* Opcode hash table. */ |
145 | static struct hash_control *ppc_hash; | |
146 | ||
147 | /* Macro hash table. */ | |
148 | static struct hash_control *ppc_macro_hash; | |
149 | ||
3f81f3cf MM |
150 | #ifdef OBJ_ELF |
151 | /* Whether to warn about non PC relative relocations that aren't | |
152 | in the .got2 section. */ | |
ce9a2805 | 153 | static boolean mrelocatable = false; |
2c474754 MM |
154 | |
155 | /* Flags to set in the elf header */ | |
156 | static flagword ppc_flags = 0; | |
3f81f3cf MM |
157 | #endif |
158 | ||
882bdc69 ILT |
159 | #ifdef OBJ_COFF |
160 | ||
161 | /* The RS/6000 assembler uses the .csect pseudo-op to generate code | |
162 | using a bunch of different sections. These assembler sections, | |
163 | however, are all encompassed within the .text or .data sections of | |
164 | the final output file. We handle this by using different | |
165 | subsegments within these main segments. */ | |
166 | ||
167 | /* Next subsegment to allocate within the .text segment. */ | |
168 | static subsegT ppc_text_subsegment = 2; | |
169 | ||
170 | /* Linked list of csects in the text section. */ | |
171 | static symbolS *ppc_text_csects; | |
172 | ||
173 | /* Next subsegment to allocate within the .data segment. */ | |
174 | static subsegT ppc_data_subsegment = 2; | |
175 | ||
176 | /* Linked list of csects in the data section. */ | |
177 | static symbolS *ppc_data_csects; | |
178 | ||
179 | /* The current csect. */ | |
180 | static symbolS *ppc_current_csect; | |
181 | ||
182 | /* The RS/6000 assembler uses a TOC which holds addresses of functions | |
183 | and variables. Symbols are put in the TOC with the .tc pseudo-op. | |
184 | A special relocation is used when accessing TOC entries. We handle | |
185 | the TOC as a subsegment within the .data segment. We set it up if | |
186 | we see a .toc pseudo-op, and save the csect symbol here. */ | |
187 | static symbolS *ppc_toc_csect; | |
188 | ||
189 | /* The first frag in the TOC subsegment. */ | |
190 | static fragS *ppc_toc_frag; | |
191 | ||
192 | /* The first frag in the first subsegment after the TOC in the .data | |
193 | segment. NULL if there are no subsegments after the TOC. */ | |
194 | static fragS *ppc_after_toc_frag; | |
195 | ||
1eeb357e ILT |
196 | /* The current static block. */ |
197 | static symbolS *ppc_current_block; | |
198 | ||
882bdc69 ILT |
199 | /* The COFF debugging section; set by md_begin. This is not the |
200 | .debug section, but is instead the secret BFD section which will | |
201 | cause BFD to set the section number of a symbol to N_DEBUG. */ | |
202 | static asection *ppc_coff_debug_section; | |
203 | ||
204 | /* The size of the .debug section. */ | |
205 | static bfd_size_type ppc_debug_name_section_size; | |
206 | ||
207 | #endif /* OBJ_COFF */ | |
da8fa3ba MM |
208 | |
209 | #ifdef OBJ_ELF | |
210 | symbolS *GOT_symbol; /* Pre-defined "_GLOBAL_OFFSET_TABLE" */ | |
211 | #endif /* OBJ_ELF */ | |
212 | ||
4a6b2f8b MM |
213 | #ifndef WORKING_DOT_WORD |
214 | const int md_short_jump_size = 4; | |
215 | const int md_long_jump_size = 4; | |
216 | #endif | |
882bdc69 | 217 | \f |
1eeb357e ILT |
218 | #ifdef OBJ_ELF |
219 | CONST char *md_shortopts = "um:VQ:"; | |
220 | #else | |
221 | CONST char *md_shortopts = "um:"; | |
222 | #endif | |
223 | struct option md_longopts[] = { | |
224 | {NULL, no_argument, NULL, 0} | |
225 | }; | |
226 | size_t md_longopts_size = sizeof(md_longopts); | |
882bdc69 ILT |
227 | |
228 | int | |
1eeb357e ILT |
229 | md_parse_option (c, arg) |
230 | int c; | |
231 | char *arg; | |
882bdc69 | 232 | { |
1eeb357e | 233 | switch (c) |
882bdc69 | 234 | { |
1eeb357e ILT |
235 | case 'u': |
236 | /* -u means that any undefined symbols should be treated as | |
237 | external, which is the default for gas anyhow. */ | |
238 | break; | |
882bdc69 | 239 | |
1eeb357e ILT |
240 | case 'm': |
241 | /* -mpwrx and -mpwr2 mean to assemble for the IBM POWER/2 | |
242 | (RIOS2). */ | |
243 | if (strcmp (arg, "pwrx") == 0 || strcmp (arg, "pwr2") == 0) | |
244 | ppc_cpu = PPC_OPCODE_POWER | PPC_OPCODE_POWER2; | |
245 | /* -mpwr means to assemble for the IBM POWER (RIOS1). */ | |
246 | else if (strcmp (arg, "pwr") == 0) | |
247 | ppc_cpu = PPC_OPCODE_POWER; | |
248 | /* -m601 means to assemble for the Motorola PowerPC 601. FIXME: We | |
249 | ignore the option for now, but we should really use it to permit | |
250 | instructions defined on the 601 that are not part of the standard | |
251 | PowerPC architecture (mostly holdovers from the POWER). */ | |
252 | else if (strcmp (arg, "601") == 0) | |
253 | ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_601; | |
254 | /* -mppc, -mppc32, -m603, and -m604 mean to assemble for the | |
255 | Motorola PowerPC 603/604. */ | |
256 | else if (strcmp (arg, "ppc") == 0 | |
257 | || strcmp (arg, "ppc32") == 0 | |
9b0da28b | 258 | || strcmp (arg, "403") == 0 |
1eeb357e ILT |
259 | || strcmp (arg, "603") == 0 |
260 | || strcmp (arg, "604") == 0) | |
261 | ppc_cpu = PPC_OPCODE_PPC; | |
262 | /* -mppc64 and -m620 mean to assemble for the 64-bit PowerPC | |
263 | 620. */ | |
264 | else if (strcmp (arg, "ppc64") == 0 || strcmp (arg, "620") == 0) | |
265 | { | |
266 | ppc_cpu = PPC_OPCODE_PPC; | |
267 | ppc_size = PPC_OPCODE_64; | |
268 | } | |
269 | /* -many means to assemble for any architecture (PWR/PWRX/PPC). */ | |
270 | else if (strcmp (arg, "any") == 0) | |
271 | ppc_cpu = PPC_OPCODE_POWER | PPC_OPCODE_POWER2 | PPC_OPCODE_PPC; | |
99146659 | 272 | |
3f81f3cf | 273 | #ifdef OBJ_ELF |
2c474754 | 274 | /* -mrelocatable/-mrelocatable-lib -- warn about initializations that require relocation */ |
3f81f3cf | 275 | else if (strcmp (arg, "relocatable") == 0) |
2c474754 MM |
276 | { |
277 | mrelocatable = true; | |
278 | ppc_flags |= EF_PPC_RELOCATABLE; | |
279 | } | |
280 | ||
281 | else if (strcmp (arg, "relocatable-lib") == 0) | |
282 | { | |
283 | mrelocatable = true; | |
4493af66 | 284 | ppc_flags |= EF_PPC_RELOCATABLE_LIB; |
2c474754 MM |
285 | } |
286 | ||
287 | /* -memb, set embedded bit */ | |
288 | else if (strcmp (arg, "emb") == 0) | |
289 | ppc_flags |= EF_PPC_EMB; | |
99146659 MM |
290 | |
291 | /* -mlittle/-mbig set the endianess */ | |
292 | else if (strcmp (arg, "little") == 0 || strcmp (arg, "little-endian") == 0) | |
2c474754 MM |
293 | { |
294 | target_big_endian = 0; | |
295 | set_target_endian = 1; | |
296 | } | |
99146659 MM |
297 | |
298 | else if (strcmp (arg, "big") == 0 || strcmp (arg, "big-endian") == 0) | |
2c474754 MM |
299 | { |
300 | target_big_endian = 1; | |
301 | set_target_endian = 1; | |
302 | } | |
3f81f3cf | 303 | #endif |
1eeb357e ILT |
304 | else |
305 | { | |
99146659 | 306 | as_bad ("invalid switch -m%s", arg); |
1eeb357e ILT |
307 | return 0; |
308 | } | |
309 | break; | |
882bdc69 | 310 | |
1eeb357e ILT |
311 | #ifdef OBJ_ELF |
312 | /* -V: SVR4 argument to print version ID. */ | |
313 | case 'V': | |
314 | print_version_id (); | |
315 | break; | |
882bdc69 | 316 | |
1eeb357e ILT |
317 | /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section |
318 | should be emitted or not. FIXME: Not implemented. */ | |
319 | case 'Q': | |
320 | break; | |
321 | #endif | |
882bdc69 | 322 | |
1eeb357e ILT |
323 | default: |
324 | return 0; | |
882bdc69 ILT |
325 | } |
326 | ||
1eeb357e ILT |
327 | return 1; |
328 | } | |
882bdc69 | 329 | |
1eeb357e ILT |
330 | void |
331 | md_show_usage (stream) | |
332 | FILE *stream; | |
333 | { | |
334 | fprintf(stream, "\ | |
335 | PowerPC options:\n\ | |
336 | -u ignored\n\ | |
99146659 | 337 | -mpwrx, -mpwr2 generate code for IBM POWER/2 (RIOS2)\n\ |
1eeb357e ILT |
338 | -mpwr generate code for IBM POWER (RIOS1)\n\ |
339 | -m601 generate code for Motorola PowerPC 601\n\ | |
9b0da28b | 340 | -mppc, -mppc32, -m403, -m603, -m604\n\ |
4a6b2f8b | 341 | generate code for Motorola PowerPC 603/604\n\ |
99146659 | 342 | -mppc64, -m620 generate code for Motorola PowerPC 620\n\ |
1eeb357e | 343 | -many generate code for any architecture (PWR/PWRX/PPC)\n"); |
882bdc69 | 344 | #ifdef OBJ_ELF |
1eeb357e | 345 | fprintf(stream, "\ |
99146659 | 346 | -mrelocatable support for GCC's -mrelocatble option\n\ |
2c474754 MM |
347 | -mrelocatable-lib support for GCC's -mrelocatble-lib option\n\ |
348 | -memb set PPC_EMB bit in ELF flags\n\ | |
99146659 | 349 | -mlittle, -mlittle-endian\n\ |
840886d8 MM |
350 | generate code for a little endian machine\n\ |
351 | -mbig, -mbig-endian generate code for a big endian machine\n\ | |
1eeb357e ILT |
352 | -V print assembler version number\n\ |
353 | -Qy, -Qn ignored\n"); | |
882bdc69 | 354 | #endif |
882bdc69 | 355 | } |
1eeb357e | 356 | \f |
882bdc69 ILT |
357 | /* Set ppc_cpu if it is not already set. */ |
358 | ||
359 | static void | |
360 | ppc_set_cpu () | |
361 | { | |
362 | const char *default_cpu = TARGET_CPU; | |
363 | ||
364 | if (ppc_cpu == 0) | |
365 | { | |
366 | if (strcmp (default_cpu, "rs6000") == 0) | |
367 | ppc_cpu = PPC_OPCODE_POWER; | |
99146659 MM |
368 | else if (strcmp (default_cpu, "powerpc") == 0 |
369 | || strcmp (default_cpu, "powerpcle") == 0) | |
882bdc69 ILT |
370 | ppc_cpu = PPC_OPCODE_PPC; |
371 | else | |
99146659 | 372 | as_fatal ("Unknown default cpu = %s", default_cpu); |
882bdc69 ILT |
373 | } |
374 | } | |
375 | ||
376 | /* Figure out the BFD architecture to use. */ | |
377 | ||
378 | enum bfd_architecture | |
379 | ppc_arch () | |
380 | { | |
381 | ppc_set_cpu (); | |
382 | ||
1e147242 | 383 | if ((ppc_cpu & PPC_OPCODE_PPC) != 0) |
882bdc69 | 384 | return bfd_arch_powerpc; |
1e147242 ILT |
385 | else if ((ppc_cpu & PPC_OPCODE_POWER) != 0) |
386 | return bfd_arch_rs6000; | |
882bdc69 | 387 | else |
99146659 | 388 | as_fatal ("Neither Power nor PowerPC opcodes were selected."); |
882bdc69 ILT |
389 | } |
390 | ||
391 | /* This function is called when the assembler starts up. It is called | |
392 | after the options have been parsed and the output file has been | |
393 | opened. */ | |
394 | ||
395 | void | |
396 | md_begin () | |
397 | { | |
398 | register const struct powerpc_opcode *op; | |
399 | const struct powerpc_opcode *op_end; | |
400 | const struct powerpc_macro *macro; | |
401 | const struct powerpc_macro *macro_end; | |
402 | ||
403 | ppc_set_cpu (); | |
404 | ||
ce9a2805 | 405 | #ifdef OBJ_ELF |
2c474754 MM |
406 | /* Set the ELF flags if desired. */ |
407 | if (ppc_flags) | |
408 | bfd_set_private_flags (stdoutput, ppc_flags); | |
ce9a2805 MM |
409 | #endif |
410 | ||
882bdc69 ILT |
411 | /* Insert the opcodes into a hash table. */ |
412 | ppc_hash = hash_new (); | |
413 | ||
414 | op_end = powerpc_opcodes + powerpc_num_opcodes; | |
415 | for (op = powerpc_opcodes; op < op_end; op++) | |
416 | { | |
417 | know ((op->opcode & op->mask) == op->opcode); | |
418 | ||
1e147242 ILT |
419 | if ((op->flags & ppc_cpu) != 0 |
420 | && ((op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64)) == 0 | |
421 | || (op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64)) == ppc_size)) | |
882bdc69 ILT |
422 | { |
423 | const char *retval; | |
424 | ||
425 | retval = hash_insert (ppc_hash, op->name, (PTR) op); | |
426 | if (retval != (const char *) NULL) | |
1eeb357e | 427 | { |
76e30835 ILT |
428 | /* We permit a duplication of the mfdec instruction on |
429 | the 601, because it seems to have one value on the | |
430 | 601 and a different value on other PowerPC | |
431 | processors. It's easier to permit a duplication than | |
432 | to define a new instruction type flag. When using | |
433 | -many, the comparison instructions are a harmless | |
434 | special case. */ | |
435 | if (strcmp (retval, "exists") != 0 | |
436 | || (((ppc_cpu & PPC_OPCODE_601) == 0 | |
437 | || strcmp (op->name, "mfdec") != 0) | |
438 | && (ppc_cpu != (PPC_OPCODE_POWER | |
439 | | PPC_OPCODE_POWER2 | |
440 | | PPC_OPCODE_PPC) | |
441 | || (strcmp (op->name, "cmpli") != 0 | |
442 | && strcmp (op->name, "cmpi") != 0 | |
443 | && strcmp (op->name, "cmp") != 0 | |
444 | && strcmp (op->name, "cmpl") != 0)))) | |
1eeb357e ILT |
445 | abort (); |
446 | } | |
882bdc69 ILT |
447 | } |
448 | } | |
449 | ||
450 | /* Insert the macros into a hash table. */ | |
451 | ppc_macro_hash = hash_new (); | |
452 | ||
453 | macro_end = powerpc_macros + powerpc_num_macros; | |
454 | for (macro = powerpc_macros; macro < macro_end; macro++) | |
455 | { | |
456 | if ((macro->flags & ppc_cpu) != 0) | |
457 | { | |
458 | const char *retval; | |
459 | ||
460 | retval = hash_insert (ppc_macro_hash, macro->name, (PTR) macro); | |
461 | if (retval != (const char *) NULL) | |
462 | abort (); | |
463 | } | |
464 | } | |
465 | ||
2c474754 MM |
466 | /* Tell the main code what the endianness is if it is not overidden by the user. */ |
467 | if (!set_target_endian) | |
468 | { | |
469 | set_target_endian = 1; | |
470 | target_big_endian = PPC_BIG_ENDIAN; | |
471 | } | |
882bdc69 ILT |
472 | |
473 | #ifdef OBJ_COFF | |
474 | ppc_coff_debug_section = coff_section_from_bfd_index (stdoutput, N_DEBUG); | |
475 | ||
476 | /* Create dummy symbols to serve as initial csects. This forces the | |
477 | text csects to precede the data csects. These symbols will not | |
478 | be output. */ | |
479 | ppc_text_csects = symbol_make ("dummy\001"); | |
480 | ppc_text_csects->sy_tc.within = ppc_text_csects; | |
481 | ppc_data_csects = symbol_make ("dummy\001"); | |
482 | ppc_data_csects->sy_tc.within = ppc_data_csects; | |
483 | #endif | |
484 | } | |
485 | ||
486 | /* Insert an operand value into an instruction. */ | |
487 | ||
488 | static unsigned long | |
489 | ppc_insert_operand (insn, operand, val, file, line) | |
490 | unsigned long insn; | |
491 | const struct powerpc_operand *operand; | |
492 | offsetT val; | |
493 | char *file; | |
494 | unsigned int line; | |
495 | { | |
496 | if (operand->bits != 32) | |
497 | { | |
498 | long min, max; | |
499 | offsetT test; | |
500 | ||
1eeb357e | 501 | if ((operand->flags & PPC_OPERAND_SIGNED) != 0) |
882bdc69 | 502 | { |
1eeb357e ILT |
503 | if ((operand->flags & PPC_OPERAND_SIGNOPT) != 0 |
504 | && ppc_size == PPC_OPCODE_32) | |
505 | max = (1 << operand->bits) - 1; | |
506 | else | |
507 | max = (1 << (operand->bits - 1)) - 1; | |
882bdc69 ILT |
508 | min = - (1 << (operand->bits - 1)); |
509 | } | |
510 | else | |
511 | { | |
512 | max = (1 << operand->bits) - 1; | |
513 | min = 0; | |
514 | } | |
515 | ||
516 | if ((operand->flags & PPC_OPERAND_NEGATIVE) != 0) | |
517 | test = - val; | |
518 | else | |
519 | test = val; | |
520 | ||
521 | if (test < (offsetT) min || test > (offsetT) max) | |
522 | { | |
523 | const char *err = | |
524 | "operand out of range (%s not between %ld and %ld)"; | |
525 | char buf[100]; | |
526 | ||
527 | sprint_value (buf, test); | |
528 | if (file == (char *) NULL) | |
529 | as_warn (err, buf, min, max); | |
530 | else | |
531 | as_warn_where (file, line, err, buf, min, max); | |
532 | } | |
533 | } | |
534 | ||
535 | if (operand->insert) | |
536 | { | |
537 | const char *errmsg; | |
538 | ||
539 | errmsg = NULL; | |
540 | insn = (*operand->insert) (insn, (long) val, &errmsg); | |
541 | if (errmsg != (const char *) NULL) | |
542 | as_warn (errmsg); | |
543 | } | |
544 | else | |
545 | insn |= (((long) val & ((1 << operand->bits) - 1)) | |
546 | << operand->shift); | |
547 | ||
548 | return insn; | |
549 | } | |
550 | ||
4a6b2f8b MM |
551 | #ifdef OBJ_ELF |
552 | /* Parse @got, etc. and return the desired relocation. */ | |
553 | static bfd_reloc_code_real_type | |
554 | ppc_elf_suffix (str_p) | |
555 | char **str_p; | |
556 | { | |
557 | char *str = *str_p; | |
558 | ||
559 | if (*str != '@') | |
560 | return BFD_RELOC_UNUSED; | |
561 | ||
562 | if (strncmp (str, "@GOT", 4) == 0 || strncmp (str, "@got", 4) == 0) | |
563 | { | |
564 | *str_p += 4; | |
565 | return BFD_RELOC_PPC_TOC16; | |
566 | } | |
567 | else if (strncmp (str, "@L", 2) == 0 || strncmp (str, "@l", 2) == 0) | |
568 | { | |
569 | *str_p += 2; | |
570 | return BFD_RELOC_LO16; | |
571 | } | |
572 | else if (strncmp (str, "@HA", 3) == 0 || strncmp (str, "@ha", 3) == 0) | |
573 | { | |
574 | *str_p += 3; | |
575 | return BFD_RELOC_HI16_S; | |
576 | } | |
577 | else if (strncmp (str, "@H", 2) == 0 || strncmp (str, "@h", 2) == 0) | |
578 | { | |
579 | *str_p += 2; | |
580 | return BFD_RELOC_HI16; | |
581 | } | |
840886d8 MM |
582 | else if (strncmp (str, "@sdarel", 7) == 0 || strncmp (str, "@sdarel", 7) == 0) |
583 | { | |
584 | *str_p += 7; | |
585 | return BFD_RELOC_GPREL16; | |
586 | } | |
587 | else if (strncmp (str, "@FIXUP", 6) == 0 || strncmp (str, "@fixup", 6) == 0) | |
588 | { | |
589 | *str_p += 6; | |
590 | return BFD_RELOC_CTOR; /* synonym for BFD_RELOC_32 that doesn't get */ | |
591 | } /* warnings with -mrelocatable */ | |
4a6b2f8b MM |
592 | |
593 | return BFD_RELOC_UNUSED; | |
594 | } | |
595 | ||
3f81f3cf | 596 | /* Like normal .long/.short/.word, except support @got, etc. */ |
4a6b2f8b MM |
597 | /* clobbers input_line_pointer, checks */ |
598 | /* end-of-line. */ | |
599 | static void | |
600 | ppc_elf_cons (nbytes) | |
601 | register int nbytes; /* 1=.byte, 2=.word, 4=.long */ | |
602 | { | |
603 | expressionS exp; | |
604 | bfd_reloc_code_real_type reloc; | |
605 | ||
606 | if (is_it_end_of_statement ()) | |
607 | { | |
608 | demand_empty_rest_of_line (); | |
609 | return; | |
610 | } | |
611 | ||
612 | do | |
613 | { | |
614 | expression (&exp); | |
615 | if (nbytes == 4 | |
616 | && exp.X_op == O_symbol | |
617 | && *input_line_pointer == '@' | |
618 | && (reloc = ppc_elf_suffix (&input_line_pointer)) != BFD_RELOC_UNUSED) | |
619 | { | |
620 | register char *p = frag_more ((int) nbytes); | |
621 | reloc_howto_type *reloc_howto = bfd_reloc_type_lookup (stdoutput, reloc); | |
622 | int offset = (!reloc_howto) ? 0 : (nbytes - bfd_get_reloc_size (reloc_howto)); | |
623 | ||
624 | if (offset < 0) | |
625 | offset = 0; | |
626 | ||
627 | fix_new_exp (frag_now, p - frag_now->fr_literal + offset, (int) nbytes - offset, &exp, 0, reloc); | |
628 | } | |
629 | else | |
630 | emit_expr (&exp, (unsigned int) nbytes); | |
631 | } | |
632 | while (*input_line_pointer++ == ','); | |
633 | ||
634 | input_line_pointer--; /* Put terminator back into stream. */ | |
635 | demand_empty_rest_of_line (); | |
636 | } | |
637 | ||
840886d8 MM |
638 | /* Validate any relocations emitted for -mrelocatable, possibly adding |
639 | fixups for word relocations in writable segments, so we can adjust | |
640 | them at runtime. */ | |
3f81f3cf | 641 | static void |
99146659 MM |
642 | ppc_elf_validate_fix (fixp, seg) |
643 | fixS *fixp; | |
644 | segT seg; | |
3f81f3cf MM |
645 | { |
646 | if (mrelocatable | |
647 | && !fixp->fx_done | |
648 | && !fixp->fx_pcrel | |
649 | && fixp->fx_r_type <= BFD_RELOC_UNUSED | |
74e1b52e | 650 | && strcmp (segment_name (seg), ".got2") != 0 |
9b0da28b KR |
651 | && strcmp (segment_name (seg), ".dtors") != 0 |
652 | && strcmp (segment_name (seg), ".ctors") != 0 | |
840886d8 | 653 | && strcmp (segment_name (seg), ".fixup") != 0 |
74e1b52e | 654 | && strcmp (segment_name (seg), ".stab") != 0) |
3f81f3cf | 655 | { |
840886d8 MM |
656 | if ((seg->flags & (SEC_READONLY | SEC_CODE)) != 0 |
657 | || fixp->fx_r_type != BFD_RELOC_CTOR) | |
658 | { | |
659 | as_warn_where (fixp->fx_file, fixp->fx_line, | |
660 | "Relocation cannot be done when using -mrelocatable"); | |
661 | } | |
3f81f3cf MM |
662 | } |
663 | } | |
664 | ||
4a6b2f8b MM |
665 | #endif /* OBJ_ELF */ |
666 | ||
882bdc69 ILT |
667 | /* We need to keep a list of fixups. We can't simply generate them as |
668 | we go, because that would require us to first create the frag, and | |
669 | that would screw up references to ``.''. */ | |
670 | ||
671 | struct ppc_fixup | |
672 | { | |
673 | expressionS exp; | |
674 | int opindex; | |
4a6b2f8b | 675 | bfd_reloc_code_real_type reloc; |
882bdc69 ILT |
676 | }; |
677 | ||
678 | #define MAX_INSN_FIXUPS (5) | |
679 | ||
680 | /* This routine is called for each instruction to be assembled. */ | |
681 | ||
682 | void | |
683 | md_assemble (str) | |
684 | char *str; | |
685 | { | |
686 | char *s; | |
687 | const struct powerpc_opcode *opcode; | |
688 | unsigned long insn; | |
689 | const unsigned char *opindex_ptr; | |
690 | int skip_optional; | |
691 | int need_paren; | |
692 | int next_opindex; | |
693 | struct ppc_fixup fixups[MAX_INSN_FIXUPS]; | |
694 | int fc; | |
695 | char *f; | |
696 | int i; | |
4a6b2f8b | 697 | bfd_reloc_code_real_type reloc; |
882bdc69 ILT |
698 | |
699 | /* Get the opcode. */ | |
700 | for (s = str; *s != '\0' && ! isspace (*s); s++) | |
701 | ; | |
702 | if (*s != '\0') | |
703 | *s++ = '\0'; | |
704 | ||
705 | /* Look up the opcode in the hash table. */ | |
706 | opcode = (const struct powerpc_opcode *) hash_find (ppc_hash, str); | |
707 | if (opcode == (const struct powerpc_opcode *) NULL) | |
708 | { | |
709 | const struct powerpc_macro *macro; | |
710 | ||
711 | macro = (const struct powerpc_macro *) hash_find (ppc_macro_hash, str); | |
712 | if (macro == (const struct powerpc_macro *) NULL) | |
713 | as_bad ("Unrecognized opcode: `%s'", str); | |
714 | else | |
715 | ppc_macro (s, macro); | |
716 | ||
717 | return; | |
718 | } | |
719 | ||
720 | insn = opcode->opcode; | |
721 | ||
722 | str = s; | |
723 | while (isspace (*str)) | |
724 | ++str; | |
725 | ||
726 | /* PowerPC operands are just expressions. The only real issue is | |
727 | that a few operand types are optional. All cases which might use | |
728 | an optional operand separate the operands only with commas (in | |
729 | some cases parentheses are used, as in ``lwz 1,0(1)'' but such | |
730 | cases never have optional operands). There is never more than | |
731 | one optional operand for an instruction. So, before we start | |
732 | seriously parsing the operands, we check to see if we have an | |
733 | optional operand, and, if we do, we count the number of commas to | |
734 | see whether the operand should be omitted. */ | |
735 | skip_optional = 0; | |
736 | for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++) | |
737 | { | |
738 | const struct powerpc_operand *operand; | |
739 | ||
740 | operand = &powerpc_operands[*opindex_ptr]; | |
741 | if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0) | |
742 | { | |
743 | unsigned int opcount; | |
744 | ||
745 | /* There is an optional operand. Count the number of | |
746 | commas in the input line. */ | |
747 | if (*str == '\0') | |
748 | opcount = 0; | |
749 | else | |
750 | { | |
751 | opcount = 1; | |
752 | s = str; | |
753 | while ((s = strchr (s, ',')) != (char *) NULL) | |
754 | { | |
755 | ++opcount; | |
756 | ++s; | |
757 | } | |
758 | } | |
759 | ||
760 | /* If there are fewer operands in the line then are called | |
761 | for by the instruction, we want to skip the optional | |
762 | operand. */ | |
763 | if (opcount < strlen (opcode->operands)) | |
764 | skip_optional = 1; | |
765 | ||
766 | break; | |
767 | } | |
768 | } | |
769 | ||
770 | /* Gather the operands. */ | |
771 | need_paren = 0; | |
772 | next_opindex = 0; | |
773 | fc = 0; | |
774 | for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++) | |
775 | { | |
776 | const struct powerpc_operand *operand; | |
777 | const char *errmsg; | |
778 | char *hold; | |
779 | expressionS ex; | |
780 | char endc; | |
781 | ||
782 | if (next_opindex == 0) | |
783 | operand = &powerpc_operands[*opindex_ptr]; | |
784 | else | |
785 | { | |
786 | operand = &powerpc_operands[next_opindex]; | |
787 | next_opindex = 0; | |
788 | } | |
789 | ||
790 | errmsg = NULL; | |
791 | ||
792 | /* If this is a fake operand, then we do not expect anything | |
793 | from the input. */ | |
794 | if ((operand->flags & PPC_OPERAND_FAKE) != 0) | |
795 | { | |
796 | insn = (*operand->insert) (insn, 0L, &errmsg); | |
797 | if (errmsg != (const char *) NULL) | |
798 | as_warn (errmsg); | |
799 | continue; | |
800 | } | |
801 | ||
802 | /* If this is an optional operand, and we are skipping it, just | |
803 | insert a zero. */ | |
804 | if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0 | |
805 | && skip_optional) | |
806 | { | |
807 | if (operand->insert) | |
808 | { | |
809 | insn = (*operand->insert) (insn, 0L, &errmsg); | |
810 | if (errmsg != (const char *) NULL) | |
811 | as_warn (errmsg); | |
812 | } | |
813 | if ((operand->flags & PPC_OPERAND_NEXT) != 0) | |
814 | next_opindex = *opindex_ptr + 1; | |
815 | continue; | |
816 | } | |
817 | ||
818 | /* Gather the operand. */ | |
819 | hold = input_line_pointer; | |
820 | input_line_pointer = str; | |
821 | expression (&ex); | |
822 | str = input_line_pointer; | |
823 | input_line_pointer = hold; | |
824 | ||
825 | if (ex.X_op == O_illegal) | |
826 | as_bad ("illegal operand"); | |
827 | else if (ex.X_op == O_absent) | |
828 | as_bad ("missing operand"); | |
829 | else if (ex.X_op == O_constant) | |
840886d8 MM |
830 | { |
831 | #ifdef OBJ_ELF | |
832 | /* Allow @HA, @L, @H on constants. */ | |
833 | char *orig_str = str; | |
834 | if ((reloc = ppc_elf_suffix (&str)) != BFD_RELOC_UNUSED) | |
835 | switch (reloc) | |
836 | { | |
837 | default: | |
838 | str = orig_str; | |
839 | break; | |
840 | ||
841 | case BFD_RELOC_LO16: | |
842 | ex.X_add_number = ((ex.X_add_number & 0xffff) ^ 0x8000) - 0x8000; | |
843 | break; | |
844 | ||
845 | case BFD_RELOC_HI16: | |
846 | ex.X_add_number = (ex.X_add_number >> 16) & 0xffff; | |
847 | break; | |
848 | ||
849 | case BFD_RELOC_HI16_S: | |
850 | ex.X_add_number = ((ex.X_add_number >> 16) & 0xffff) | |
851 | + ((ex.X_add_number >> 15) & 1); | |
852 | break; | |
853 | } | |
854 | #endif | |
855 | insn = ppc_insert_operand (insn, operand, ex.X_add_number, | |
856 | (char *) NULL, 0); | |
857 | } | |
4a6b2f8b MM |
858 | |
859 | #ifdef OBJ_ELF | |
860 | else if ((reloc = ppc_elf_suffix (&str)) != BFD_RELOC_UNUSED) | |
861 | { | |
862 | /* We need to generate a fixup for this expression. */ | |
863 | if (fc >= MAX_INSN_FIXUPS) | |
864 | as_fatal ("too many fixups"); | |
865 | fixups[fc].exp = ex; | |
866 | fixups[fc].opindex = 0; | |
867 | fixups[fc].reloc = reloc; | |
868 | ++fc; | |
869 | } | |
870 | #endif /* OBJ_ELF */ | |
871 | ||
882bdc69 ILT |
872 | else |
873 | { | |
874 | /* We need to generate a fixup for this expression. */ | |
875 | if (fc >= MAX_INSN_FIXUPS) | |
876 | as_fatal ("too many fixups"); | |
877 | fixups[fc].exp = ex; | |
878 | fixups[fc].opindex = *opindex_ptr; | |
4a6b2f8b | 879 | fixups[fc].reloc = BFD_RELOC_UNUSED; |
882bdc69 ILT |
880 | ++fc; |
881 | } | |
882 | ||
883 | if (need_paren) | |
884 | { | |
885 | endc = ')'; | |
886 | need_paren = 0; | |
887 | } | |
888 | else if ((operand->flags & PPC_OPERAND_PARENS) != 0) | |
889 | { | |
890 | endc = '('; | |
891 | need_paren = 1; | |
892 | } | |
893 | else | |
894 | endc = ','; | |
895 | ||
896 | /* The call to expression should have advanced str past any | |
897 | whitespace. */ | |
898 | if (*str != endc | |
899 | && (endc != ',' || *str != '\0')) | |
900 | { | |
901 | as_bad ("syntax error; found `%c' but expected `%c'", *str, endc); | |
902 | break; | |
903 | } | |
904 | ||
905 | if (*str != '\0') | |
906 | ++str; | |
907 | } | |
908 | ||
909 | while (isspace (*str)) | |
910 | ++str; | |
911 | ||
912 | if (*str != '\0') | |
913 | as_bad ("junk at end of line: `%s'", str); | |
914 | ||
915 | /* Write out the instruction. */ | |
916 | f = frag_more (4); | |
917 | md_number_to_chars (f, insn, 4); | |
918 | ||
919 | /* Create any fixups. At this point we do not use a | |
99146659 MM |
920 | bfd_reloc_code_real_type, but instead just use the |
921 | BFD_RELOC_UNUSED plus the operand index. This lets us easily | |
922 | handle fixups for any operand type, although that is admittedly | |
923 | not a very exciting feature. We pick a BFD reloc type in | |
924 | md_apply_fix. */ | |
882bdc69 ILT |
925 | for (i = 0; i < fc; i++) |
926 | { | |
927 | const struct powerpc_operand *operand; | |
928 | ||
929 | operand = &powerpc_operands[fixups[i].opindex]; | |
4a6b2f8b MM |
930 | if (fixups[i].reloc != BFD_RELOC_UNUSED) |
931 | { | |
932 | reloc_howto_type *reloc_howto = bfd_reloc_type_lookup (stdoutput, fixups[i].reloc); | |
99146659 MM |
933 | int size = (!reloc_howto) ? 0 : bfd_get_reloc_size (reloc_howto); |
934 | int offset = target_big_endian ? (4 - size) : 0; | |
840886d8 | 935 | fixS *fixP; |
4a6b2f8b | 936 | |
99146659 MM |
937 | if (size > 4) |
938 | abort(); | |
4a6b2f8b | 939 | |
840886d8 MM |
940 | fixP = fix_new_exp (frag_now, f - frag_now->fr_literal + offset, size, |
941 | &fixups[i].exp, (reloc_howto && reloc_howto->pc_relative), | |
942 | fixups[i].reloc); | |
943 | ||
944 | /* Turn off complaints that the addend is too large for things like | |
945 | foo+100000@ha. */ | |
946 | switch (fixups[i].reloc) | |
947 | { | |
948 | case BFD_RELOC_LO16: | |
949 | case BFD_RELOC_HI16: | |
950 | case BFD_RELOC_HI16_S: | |
951 | fixP->fx_no_overflow = 1; | |
952 | break; | |
953 | } | |
4a6b2f8b MM |
954 | } |
955 | else | |
956 | fix_new_exp (frag_now, f - frag_now->fr_literal, 4, | |
957 | &fixups[i].exp, | |
958 | (operand->flags & PPC_OPERAND_RELATIVE) != 0, | |
959 | ((bfd_reloc_code_real_type) | |
960 | (fixups[i].opindex + (int) BFD_RELOC_UNUSED))); | |
882bdc69 ILT |
961 | } |
962 | } | |
963 | ||
4a6b2f8b MM |
964 | #ifndef WORKING_DOT_WORD |
965 | /* Handle long and short jumps */ | |
966 | void | |
967 | md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) | |
968 | char *ptr; | |
969 | addressT from_addr, to_addr; | |
970 | fragS *frag; | |
971 | symbolS *to_symbol; | |
972 | { | |
973 | abort (); | |
974 | } | |
975 | ||
976 | void | |
977 | md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol) | |
978 | char *ptr; | |
979 | addressT from_addr, to_addr; | |
980 | fragS *frag; | |
981 | symbolS *to_symbol; | |
982 | { | |
983 | abort (); | |
984 | } | |
985 | #endif | |
986 | ||
882bdc69 ILT |
987 | /* Handle a macro. Gather all the operands, transform them as |
988 | described by the macro, and call md_assemble recursively. All the | |
989 | operands are separated by commas; we don't accept parentheses | |
990 | around operands here. */ | |
991 | ||
992 | static void | |
993 | ppc_macro (str, macro) | |
994 | char *str; | |
995 | const struct powerpc_macro *macro; | |
996 | { | |
997 | char *operands[10]; | |
998 | int count; | |
999 | char *s; | |
1000 | unsigned int len; | |
1001 | const char *format; | |
1002 | int arg; | |
1003 | char *send; | |
1004 | char *complete; | |
1005 | ||
1006 | /* Gather the users operands into the operands array. */ | |
1007 | count = 0; | |
1008 | s = str; | |
1009 | while (1) | |
1010 | { | |
1011 | if (count >= sizeof operands / sizeof operands[0]) | |
1012 | break; | |
1013 | operands[count++] = s; | |
1014 | s = strchr (s, ','); | |
1015 | if (s == (char *) NULL) | |
1016 | break; | |
1017 | *s++ = '\0'; | |
1018 | } | |
1019 | ||
1020 | if (count != macro->operands) | |
1021 | { | |
1022 | as_bad ("wrong number of operands"); | |
1023 | return; | |
1024 | } | |
1025 | ||
1026 | /* Work out how large the string must be (the size is unbounded | |
1027 | because it includes user input). */ | |
1028 | len = 0; | |
1029 | format = macro->format; | |
1030 | while (*format != '\0') | |
1031 | { | |
1032 | if (*format != '%') | |
1033 | { | |
1034 | ++len; | |
1035 | ++format; | |
1036 | } | |
1037 | else | |
1038 | { | |
1039 | arg = strtol (format + 1, &send, 10); | |
1040 | know (send != format && arg >= 0 && arg < count); | |
1041 | len += strlen (operands[arg]); | |
1042 | format = send; | |
1043 | } | |
1044 | } | |
1045 | ||
1046 | /* Put the string together. */ | |
1047 | complete = s = (char *) alloca (len + 1); | |
1048 | format = macro->format; | |
1049 | while (*format != '\0') | |
1050 | { | |
1051 | if (*format != '%') | |
1052 | *s++ = *format++; | |
1053 | else | |
1054 | { | |
1055 | arg = strtol (format + 1, &send, 10); | |
1056 | strcpy (s, operands[arg]); | |
1057 | s += strlen (s); | |
1058 | format = send; | |
1059 | } | |
1060 | } | |
1061 | *s = '\0'; | |
1062 | ||
1063 | /* Assemble the constructed instruction. */ | |
1064 | md_assemble (complete); | |
1065 | } | |
1066 | \f | |
1067 | /* Pseudo-op handling. */ | |
1068 | ||
1069 | /* The .byte pseudo-op. This is similar to the normal .byte | |
1070 | pseudo-op, but it can also take a single ASCII string. */ | |
1071 | ||
1072 | static void | |
1073 | ppc_byte (ignore) | |
1074 | int ignore; | |
1075 | { | |
1076 | if (*input_line_pointer != '\"') | |
1077 | { | |
1078 | cons (1); | |
1079 | return; | |
1080 | } | |
1081 | ||
1082 | /* Gather characters. A real double quote is doubled. Unusual | |
1083 | characters are not permitted. */ | |
1084 | ++input_line_pointer; | |
1085 | while (1) | |
1086 | { | |
1087 | char c; | |
1088 | ||
1089 | c = *input_line_pointer++; | |
1090 | ||
1091 | if (c == '\"') | |
1092 | { | |
1093 | if (*input_line_pointer != '\"') | |
1094 | break; | |
1095 | ++input_line_pointer; | |
1096 | } | |
1097 | ||
1098 | FRAG_APPEND_1_CHAR (c); | |
1099 | } | |
1100 | ||
1101 | demand_empty_rest_of_line (); | |
1102 | } | |
1103 | \f | |
1104 | #ifdef OBJ_COFF | |
1105 | ||
1106 | /* XCOFF specific pseudo-op handling. */ | |
1107 | ||
1108 | /* The .comm and .lcomm pseudo-ops for XCOFF. XCOFF puts common | |
1109 | symbols in the .bss segment as though they were local common | |
1110 | symbols, and uses a different smclas. */ | |
1111 | ||
1112 | static void | |
1113 | ppc_comm (lcomm) | |
1114 | int lcomm; | |
1115 | { | |
1116 | asection *current_seg = now_seg; | |
1117 | subsegT current_subseg = now_subseg; | |
1118 | char *name; | |
1119 | char endc; | |
1120 | char *end_name; | |
1121 | offsetT size; | |
1122 | offsetT align; | |
1123 | symbolS *lcomm_sym = NULL; | |
1124 | symbolS *sym; | |
1125 | char *pfrag; | |
1126 | ||
1127 | name = input_line_pointer; | |
1128 | endc = get_symbol_end (); | |
1129 | end_name = input_line_pointer; | |
1130 | *end_name = endc; | |
1131 | ||
1132 | if (*input_line_pointer != ',') | |
1133 | { | |
1134 | as_bad ("missing size"); | |
1135 | ignore_rest_of_line (); | |
1136 | return; | |
1137 | } | |
1138 | ++input_line_pointer; | |
1139 | ||
1140 | size = get_absolute_expression (); | |
1141 | if (size < 0) | |
1142 | { | |
1143 | as_bad ("negative size"); | |
1144 | ignore_rest_of_line (); | |
1145 | return; | |
1146 | } | |
1147 | ||
1148 | if (! lcomm) | |
1149 | { | |
1150 | /* The third argument to .comm is the alignment. */ | |
1151 | if (*input_line_pointer != ',') | |
1152 | align = 3; | |
1153 | else | |
1154 | { | |
1155 | ++input_line_pointer; | |
1156 | align = get_absolute_expression (); | |
1157 | if (align <= 0) | |
1158 | { | |
1159 | as_warn ("ignoring bad alignment"); | |
1160 | align = 3; | |
1161 | } | |
1162 | } | |
1163 | } | |
1164 | else | |
1165 | { | |
1166 | char *lcomm_name; | |
1167 | char lcomm_endc; | |
1168 | ||
1169 | if (size <= 1) | |
1170 | align = 0; | |
1171 | else if (size <= 2) | |
1172 | align = 1; | |
1173 | else if (size <= 4) | |
1174 | align = 2; | |
1175 | else | |
1176 | align = 3; | |
1177 | ||
1178 | /* The third argument to .lcomm appears to be the real local | |
1179 | common symbol to create. References to the symbol named in | |
1180 | the first argument are turned into references to the third | |
1181 | argument. */ | |
1182 | if (*input_line_pointer != ',') | |
1183 | { | |
1184 | as_bad ("missing real symbol name"); | |
1185 | ignore_rest_of_line (); | |
1186 | return; | |
1187 | } | |
1188 | ++input_line_pointer; | |
1189 | ||
1190 | lcomm_name = input_line_pointer; | |
1191 | lcomm_endc = get_symbol_end (); | |
1192 | ||
1193 | lcomm_sym = symbol_find_or_make (lcomm_name); | |
1194 | ||
1195 | *input_line_pointer = lcomm_endc; | |
1196 | } | |
1197 | ||
1198 | *end_name = '\0'; | |
1199 | sym = symbol_find_or_make (name); | |
1200 | *end_name = endc; | |
1201 | ||
1202 | if (S_IS_DEFINED (sym) | |
1203 | || S_GET_VALUE (sym) != 0) | |
1204 | { | |
1205 | as_bad ("attempt to redefine symbol"); | |
1206 | ignore_rest_of_line (); | |
1207 | return; | |
1208 | } | |
1209 | ||
1210 | record_alignment (bss_section, align); | |
1211 | ||
1212 | if (! lcomm | |
1213 | || ! S_IS_DEFINED (lcomm_sym)) | |
1214 | { | |
1215 | symbolS *def_sym; | |
1216 | offsetT def_size; | |
1217 | ||
1218 | if (! lcomm) | |
1219 | { | |
1220 | def_sym = sym; | |
1221 | def_size = size; | |
1222 | S_SET_EXTERNAL (sym); | |
1223 | } | |
1224 | else | |
1225 | { | |
1226 | lcomm_sym->sy_tc.output = 1; | |
1227 | def_sym = lcomm_sym; | |
1228 | def_size = 0; | |
1229 | } | |
1230 | ||
1231 | subseg_set (bss_section, 1); | |
1232 | frag_align (align, 0); | |
1233 | ||
1234 | def_sym->sy_frag = frag_now; | |
1235 | pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, def_sym, | |
1236 | def_size, (char *) NULL); | |
1237 | *pfrag = 0; | |
1238 | S_SET_SEGMENT (def_sym, bss_section); | |
1239 | def_sym->sy_tc.align = align; | |
1240 | } | |
1241 | else if (lcomm) | |
1242 | { | |
1243 | /* Align the size of lcomm_sym. */ | |
1244 | lcomm_sym->sy_frag->fr_offset = | |
1245 | ((lcomm_sym->sy_frag->fr_offset + (1 << align) - 1) | |
1246 | &~ ((1 << align) - 1)); | |
1247 | if (align > lcomm_sym->sy_tc.align) | |
1248 | lcomm_sym->sy_tc.align = align; | |
1249 | } | |
1250 | ||
1251 | if (lcomm) | |
1252 | { | |
1253 | /* Make sym an offset from lcomm_sym. */ | |
1254 | S_SET_SEGMENT (sym, bss_section); | |
1255 | sym->sy_frag = lcomm_sym->sy_frag; | |
1256 | S_SET_VALUE (sym, lcomm_sym->sy_frag->fr_offset); | |
1257 | lcomm_sym->sy_frag->fr_offset += size; | |
1258 | } | |
1259 | ||
1260 | subseg_set (current_seg, current_subseg); | |
1261 | ||
1262 | demand_empty_rest_of_line (); | |
1263 | } | |
1264 | ||
1265 | /* The .csect pseudo-op. This switches us into a different | |
1266 | subsegment. The first argument is a symbol whose value is the | |
1267 | start of the .csect. In COFF, csect symbols get special aux | |
1268 | entries defined by the x_csect field of union internal_auxent. The | |
1269 | optional second argument is the alignment (the default is 2). */ | |
1270 | ||
1271 | static void | |
1272 | ppc_csect (ignore) | |
1273 | int ignore; | |
1274 | { | |
1275 | char *name; | |
1276 | char endc; | |
1277 | symbolS *sym; | |
1278 | ||
1279 | name = input_line_pointer; | |
1280 | endc = get_symbol_end (); | |
1281 | ||
1282 | sym = symbol_find_or_make (name); | |
1283 | ||
1284 | *input_line_pointer = endc; | |
1285 | ||
1286 | if (S_IS_DEFINED (sym)) | |
1287 | subseg_set (S_GET_SEGMENT (sym), sym->sy_tc.subseg); | |
1288 | else | |
1289 | { | |
1290 | symbolS **list_ptr; | |
1291 | int after_toc; | |
1292 | symbolS *list; | |
1293 | ||
1294 | /* This is a new csect. We need to look at the symbol class to | |
1295 | figure out whether it should go in the text section or the | |
1296 | data section. */ | |
1297 | after_toc = 0; | |
1298 | switch (sym->sy_tc.class) | |
1299 | { | |
1300 | case XMC_PR: | |
1301 | case XMC_RO: | |
1302 | case XMC_DB: | |
1303 | case XMC_GL: | |
1304 | case XMC_XO: | |
1305 | case XMC_SV: | |
1306 | case XMC_TI: | |
1307 | case XMC_TB: | |
1308 | S_SET_SEGMENT (sym, text_section); | |
1309 | sym->sy_tc.subseg = ppc_text_subsegment; | |
1310 | ++ppc_text_subsegment; | |
1311 | list_ptr = &ppc_text_csects; | |
1312 | break; | |
1313 | case XMC_RW: | |
1314 | case XMC_TC0: | |
1315 | case XMC_TC: | |
1316 | case XMC_DS: | |
1317 | case XMC_UA: | |
1318 | case XMC_BS: | |
1319 | case XMC_UC: | |
1320 | if (ppc_toc_csect->sy_tc.subseg + 1 == ppc_data_subsegment) | |
1321 | after_toc = 1; | |
1322 | S_SET_SEGMENT (sym, data_section); | |
1323 | sym->sy_tc.subseg = ppc_data_subsegment; | |
1324 | ++ppc_data_subsegment; | |
1325 | list_ptr = &ppc_data_csects; | |
1326 | break; | |
1327 | default: | |
1328 | abort (); | |
1329 | } | |
1330 | ||
1331 | subseg_new (segment_name (S_GET_SEGMENT (sym)), sym->sy_tc.subseg); | |
1332 | if (after_toc) | |
1333 | ppc_after_toc_frag = frag_now; | |
1334 | ||
1335 | sym->sy_frag = frag_now; | |
1336 | S_SET_VALUE (sym, (valueT) frag_now_fix ()); | |
1337 | ||
1338 | sym->sy_tc.align = 2; | |
1339 | sym->sy_tc.output = 1; | |
1340 | sym->sy_tc.within = sym; | |
1341 | ||
1342 | for (list = *list_ptr; | |
1343 | list->sy_tc.next != (symbolS *) NULL; | |
1344 | list = list->sy_tc.next) | |
1345 | ; | |
1346 | list->sy_tc.next = sym; | |
1347 | ||
1348 | symbol_remove (sym, &symbol_rootP, &symbol_lastP); | |
1349 | symbol_append (sym, list->sy_tc.within, &symbol_rootP, &symbol_lastP); | |
1350 | } | |
1351 | ||
1352 | if (*input_line_pointer == ',') | |
1353 | { | |
1354 | ++input_line_pointer; | |
1355 | sym->sy_tc.align = get_absolute_expression (); | |
1356 | } | |
1357 | ||
1358 | ppc_current_csect = sym; | |
1359 | ||
1360 | demand_empty_rest_of_line (); | |
1361 | } | |
1362 | ||
1363 | /* The .extern pseudo-op. We create an undefined symbol. */ | |
1364 | ||
1365 | static void | |
1366 | ppc_extern (ignore) | |
1367 | int ignore; | |
1368 | { | |
1369 | char *name; | |
1370 | char endc; | |
1371 | ||
1372 | name = input_line_pointer; | |
1373 | endc = get_symbol_end (); | |
1374 | ||
1375 | (void) symbol_find_or_make (name); | |
1376 | ||
1377 | *input_line_pointer = endc; | |
1378 | ||
1379 | demand_empty_rest_of_line (); | |
1380 | } | |
1381 | ||
1382 | /* The .lglobl pseudo-op. I think the RS/6000 assembler only needs | |
1383 | this because it can't handle undefined symbols. I think we can | |
1384 | just ignore it. */ | |
1385 | ||
1386 | static void | |
1387 | ppc_lglobl (ignore) | |
1388 | int ignore; | |
1389 | { | |
1390 | s_ignore (0); | |
1391 | } | |
1392 | ||
1393 | /* The .rename pseudo-op. The RS/6000 assembler can rename symbols, | |
1394 | although I don't know why it bothers. */ | |
1395 | ||
1396 | static void | |
1397 | ppc_rename (ignore) | |
1398 | int ignore; | |
1399 | { | |
1400 | char *name; | |
1401 | char endc; | |
1402 | symbolS *sym; | |
1403 | int len; | |
1404 | ||
1405 | name = input_line_pointer; | |
1406 | endc = get_symbol_end (); | |
1407 | ||
1408 | sym = symbol_find_or_make (name); | |
1409 | ||
1410 | *input_line_pointer = endc; | |
1411 | ||
1412 | if (*input_line_pointer != ',') | |
1413 | { | |
1414 | as_bad ("missing rename string"); | |
1415 | ignore_rest_of_line (); | |
1416 | return; | |
1417 | } | |
1418 | ++input_line_pointer; | |
1419 | ||
1420 | sym->sy_tc.real_name = demand_copy_C_string (&len); | |
1421 | ||
1422 | demand_empty_rest_of_line (); | |
1423 | } | |
1424 | ||
1425 | /* The .stabx pseudo-op. This is similar to a normal .stabs | |
1426 | pseudo-op, but slightly different. A sample is | |
1427 | .stabx "main:F-1",.main,142,0 | |
1428 | The first argument is the symbol name to create. The second is the | |
1429 | value, and the third is the storage class. The fourth seems to be | |
1430 | always zero, and I am assuming it is the type. */ | |
1431 | ||
1432 | static void | |
1433 | ppc_stabx (ignore) | |
1434 | int ignore; | |
1435 | { | |
1436 | char *name; | |
1437 | int len; | |
1438 | symbolS *sym; | |
1eeb357e | 1439 | expressionS exp; |
882bdc69 ILT |
1440 | |
1441 | name = demand_copy_C_string (&len); | |
1442 | ||
1443 | if (*input_line_pointer != ',') | |
1444 | { | |
1445 | as_bad ("missing value"); | |
1446 | return; | |
1447 | } | |
1448 | ++input_line_pointer; | |
1449 | ||
1450 | sym = symbol_make (name); | |
1eeb357e ILT |
1451 | |
1452 | (void) expression (&exp); | |
1453 | ||
1454 | switch (exp.X_op) | |
1455 | { | |
1456 | case O_illegal: | |
1457 | case O_absent: | |
1458 | case O_big: | |
1459 | as_bad ("illegal .stabx expression; zero assumed"); | |
1460 | exp.X_add_number = 0; | |
1461 | /* Fall through. */ | |
1462 | case O_constant: | |
1463 | S_SET_VALUE (sym, (valueT) exp.X_add_number); | |
1464 | sym->sy_frag = &zero_address_frag; | |
1465 | break; | |
1466 | ||
1467 | case O_symbol: | |
1468 | if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section) | |
1469 | sym->sy_value = exp; | |
1470 | else | |
1471 | { | |
1472 | S_SET_VALUE (sym, | |
1473 | exp.X_add_number + S_GET_VALUE (exp.X_add_symbol)); | |
1474 | sym->sy_frag = exp.X_add_symbol->sy_frag; | |
1475 | } | |
1476 | break; | |
1477 | ||
1478 | default: | |
1479 | /* The value is some complex expression. This will probably | |
1480 | fail at some later point, but this is probably the right | |
1481 | thing to do here. */ | |
1482 | sym->sy_value = exp; | |
1483 | break; | |
1484 | } | |
882bdc69 ILT |
1485 | |
1486 | S_SET_SEGMENT (sym, ppc_coff_debug_section); | |
1487 | sym->bsym->flags |= BSF_DEBUGGING; | |
1488 | ||
1489 | if (*input_line_pointer != ',') | |
1490 | { | |
1491 | as_bad ("missing class"); | |
1492 | return; | |
1493 | } | |
1494 | ++input_line_pointer; | |
1495 | ||
1496 | S_SET_STORAGE_CLASS (sym, get_absolute_expression ()); | |
1497 | ||
1498 | if (*input_line_pointer != ',') | |
1499 | { | |
1500 | as_bad ("missing type"); | |
1501 | return; | |
1502 | } | |
1503 | ++input_line_pointer; | |
1504 | ||
1505 | S_SET_DATA_TYPE (sym, get_absolute_expression ()); | |
1506 | ||
1507 | sym->sy_tc.output = 1; | |
1eeb357e ILT |
1508 | |
1509 | if (S_GET_STORAGE_CLASS (sym) == C_STSYM) | |
1510 | sym->sy_tc.within = ppc_current_block; | |
1511 | ||
1512 | if (exp.X_op != O_symbol | |
1513 | || ! S_IS_EXTERNAL (exp.X_add_symbol) | |
1514 | || S_GET_SEGMENT (exp.X_add_symbol) != bss_section) | |
1515 | ppc_frob_label (sym); | |
1516 | else | |
1517 | { | |
1518 | symbol_remove (sym, &symbol_rootP, &symbol_lastP); | |
1519 | symbol_append (sym, exp.X_add_symbol, &symbol_rootP, &symbol_lastP); | |
1520 | if (ppc_current_csect->sy_tc.within == exp.X_add_symbol) | |
1521 | ppc_current_csect->sy_tc.within = sym; | |
1522 | } | |
882bdc69 ILT |
1523 | |
1524 | if (strlen (name) > SYMNMLEN) | |
1525 | { | |
1526 | /* For some reason, each name is preceded by a two byte length | |
1527 | and followed by a null byte. */ | |
1528 | ppc_debug_name_section_size += strlen (name) + 3; | |
1529 | } | |
1530 | ||
1531 | demand_empty_rest_of_line (); | |
1532 | } | |
1533 | ||
1534 | /* The .function pseudo-op. This takes several arguments. The first | |
1535 | argument seems to be the external name of the symbol. The second | |
1536 | argment seems to be the label for the start of the function. gcc | |
1537 | uses the same name for both. I have no idea what the third and | |
1538 | fourth arguments are meant to be. The optional fifth argument is | |
1539 | an expression for the size of the function. In COFF this symbol | |
1540 | gets an aux entry like that used for a csect. */ | |
1541 | ||
1542 | static void | |
1543 | ppc_function (ignore) | |
1544 | int ignore; | |
1545 | { | |
1546 | char *name; | |
1547 | char endc; | |
1548 | char *s; | |
1549 | symbolS *ext_sym; | |
1550 | symbolS *lab_sym; | |
1551 | ||
1552 | name = input_line_pointer; | |
1553 | endc = get_symbol_end (); | |
1554 | ||
1555 | /* Ignore any [PR] suffix. */ | |
1556 | name = ppc_canonicalize_symbol_name (name); | |
1557 | s = strchr (name, '['); | |
1558 | if (s != (char *) NULL | |
1559 | && strcmp (s + 1, "PR]") == 0) | |
1560 | *s = '\0'; | |
1561 | ||
1562 | ext_sym = symbol_find_or_make (name); | |
1563 | ||
1564 | *input_line_pointer = endc; | |
1565 | ||
1566 | if (*input_line_pointer != ',') | |
1567 | { | |
1568 | as_bad ("missing symbol name"); | |
1569 | ignore_rest_of_line (); | |
1570 | return; | |
1571 | } | |
1572 | ++input_line_pointer; | |
1573 | ||
1574 | name = input_line_pointer; | |
1575 | endc = get_symbol_end (); | |
1576 | ||
1577 | lab_sym = symbol_find_or_make (name); | |
1578 | ||
1579 | *input_line_pointer = endc; | |
1580 | ||
1581 | if (ext_sym != lab_sym) | |
1582 | { | |
1583 | ext_sym->sy_value.X_op = O_symbol; | |
1584 | ext_sym->sy_value.X_add_symbol = lab_sym; | |
1585 | ext_sym->sy_value.X_op_symbol = NULL; | |
1586 | ext_sym->sy_value.X_add_number = 0; | |
1587 | } | |
1588 | ||
1589 | if (ext_sym->sy_tc.class == -1) | |
1590 | ext_sym->sy_tc.class = XMC_PR; | |
1591 | ext_sym->sy_tc.output = 1; | |
1592 | ||
1593 | if (*input_line_pointer == ',') | |
1594 | { | |
1595 | expressionS ignore; | |
1596 | ||
1597 | /* Ignore the third argument. */ | |
1598 | ++input_line_pointer; | |
1599 | expression (&ignore); | |
1600 | if (*input_line_pointer == ',') | |
1601 | { | |
1602 | /* Ignore the fourth argument. */ | |
1603 | ++input_line_pointer; | |
1604 | expression (&ignore); | |
1605 | if (*input_line_pointer == ',') | |
1606 | { | |
1607 | /* The fifth argument is the function size. */ | |
1608 | ++input_line_pointer; | |
1609 | ext_sym->sy_tc.size = symbol_new ("L0\001", | |
1610 | absolute_section, | |
1611 | (valueT) 0, | |
1612 | &zero_address_frag); | |
1613 | pseudo_set (ext_sym->sy_tc.size); | |
1614 | } | |
1615 | } | |
1616 | } | |
1617 | ||
1618 | S_SET_DATA_TYPE (ext_sym, DT_FCN << N_BTSHFT); | |
1619 | SF_SET_FUNCTION (ext_sym); | |
1620 | SF_SET_PROCESS (ext_sym); | |
1621 | coff_add_linesym (ext_sym); | |
1622 | ||
1623 | demand_empty_rest_of_line (); | |
1624 | } | |
1625 | ||
1626 | /* The .bf pseudo-op. This is just like a COFF C_FCN symbol named | |
1627 | ".bf". */ | |
1628 | ||
1629 | static void | |
1630 | ppc_bf (ignore) | |
1631 | int ignore; | |
1632 | { | |
1633 | symbolS *sym; | |
882bdc69 ILT |
1634 | |
1635 | sym = symbol_make (".bf"); | |
1636 | S_SET_SEGMENT (sym, text_section); | |
1637 | sym->sy_frag = frag_now; | |
1638 | S_SET_VALUE (sym, frag_now_fix ()); | |
1639 | S_SET_STORAGE_CLASS (sym, C_FCN); | |
1640 | ||
1eeb357e | 1641 | coff_line_base = get_absolute_expression (); |
882bdc69 ILT |
1642 | |
1643 | S_SET_NUMBER_AUXILIARY (sym, 1); | |
1644 | SA_SET_SYM_LNNO (sym, coff_line_base); | |
1645 | ||
1646 | sym->sy_tc.output = 1; | |
1647 | ||
1648 | ppc_frob_label (sym); | |
1649 | ||
1650 | demand_empty_rest_of_line (); | |
1651 | } | |
1652 | ||
1653 | /* The .ef pseudo-op. This is just like a COFF C_FCN symbol named | |
1654 | ".ef", except that the line number is absolute, not relative to the | |
1655 | most recent ".bf" symbol. */ | |
1656 | ||
1657 | static void | |
1658 | ppc_ef (ignore) | |
1659 | int ignore; | |
1660 | { | |
1661 | symbolS *sym; | |
1662 | ||
1663 | sym = symbol_make (".ef"); | |
1664 | S_SET_SEGMENT (sym, text_section); | |
1665 | sym->sy_frag = frag_now; | |
1666 | S_SET_VALUE (sym, frag_now_fix ()); | |
1667 | S_SET_STORAGE_CLASS (sym, C_FCN); | |
1668 | S_SET_NUMBER_AUXILIARY (sym, 1); | |
1669 | SA_SET_SYM_LNNO (sym, get_absolute_expression ()); | |
1670 | sym->sy_tc.output = 1; | |
1671 | ||
1672 | ppc_frob_label (sym); | |
1673 | ||
1674 | demand_empty_rest_of_line (); | |
1675 | } | |
1676 | ||
1677 | /* The .bi and .ei pseudo-ops. These take a string argument and | |
1678 | generates a C_BINCL or C_EINCL symbol, which goes at the start of | |
1679 | the symbol list. */ | |
1680 | ||
1681 | static void | |
1682 | ppc_biei (ei) | |
1683 | int ei; | |
1684 | { | |
1685 | char *name; | |
1686 | int len; | |
1687 | symbolS *sym; | |
1688 | symbolS *look; | |
1689 | ||
1690 | name = demand_copy_C_string (&len); | |
1691 | ||
1692 | sym = symbol_make (name); | |
1693 | S_SET_SEGMENT (sym, ppc_coff_debug_section); | |
1694 | sym->bsym->flags |= BSF_DEBUGGING; | |
1695 | ||
1696 | /* FIXME: The value of the .bi or .ei symbol is supposed to be the | |
1697 | offset in the file to the line number entry to use. That is | |
1698 | quite difficult to implement using BFD, so I'm just not doing it. | |
1699 | Sorry. Please add it if you can figure out how. Note that this | |
1700 | approach is the only way to support multiple files in COFF, since | |
1701 | line numbers are associated with function symbols. Note further | |
1702 | that it still doesn't work, since the line numbers are stored as | |
1703 | offsets from a base line number. */ | |
1704 | ||
1705 | S_SET_STORAGE_CLASS (sym, ei ? C_EINCL : C_BINCL); | |
1706 | sym->sy_tc.output = 1; | |
1707 | ||
1708 | for (look = symbol_rootP; | |
1709 | (look != (symbolS *) NULL | |
1710 | && (S_GET_STORAGE_CLASS (look) == C_FILE | |
1711 | || S_GET_STORAGE_CLASS (look) == C_BINCL | |
1712 | || S_GET_STORAGE_CLASS (look) == C_EINCL)); | |
1713 | look = symbol_next (look)) | |
1714 | ; | |
1715 | if (look != (symbolS *) NULL) | |
1716 | { | |
1717 | symbol_remove (sym, &symbol_rootP, &symbol_lastP); | |
1718 | symbol_insert (sym, look, &symbol_rootP, &symbol_lastP); | |
1719 | } | |
1720 | ||
1721 | demand_empty_rest_of_line (); | |
1722 | } | |
1723 | ||
1724 | /* The .bs pseudo-op. This generates a C_BSTAT symbol named ".bs". | |
1725 | There is one argument, which is a csect symbol. The value of the | |
1726 | .bs symbol is the index of this csect symbol. */ | |
1727 | ||
1728 | static void | |
1729 | ppc_bs (ignore) | |
1730 | int ignore; | |
1731 | { | |
1732 | char *name; | |
1733 | char endc; | |
1734 | symbolS *csect; | |
1735 | symbolS *sym; | |
1736 | ||
1eeb357e ILT |
1737 | if (ppc_current_block != NULL) |
1738 | as_bad ("nested .bs blocks"); | |
1739 | ||
882bdc69 ILT |
1740 | name = input_line_pointer; |
1741 | endc = get_symbol_end (); | |
1742 | ||
1743 | csect = symbol_find_or_make (name); | |
1744 | ||
1745 | *input_line_pointer = endc; | |
1746 | ||
1747 | sym = symbol_make (".bs"); | |
1748 | S_SET_SEGMENT (sym, now_seg); | |
1749 | S_SET_STORAGE_CLASS (sym, C_BSTAT); | |
1750 | sym->bsym->flags |= BSF_DEBUGGING; | |
1751 | sym->sy_tc.output = 1; | |
1752 | ||
1753 | sym->sy_tc.within = csect; | |
1754 | ||
1755 | ppc_frob_label (sym); | |
1756 | ||
1eeb357e ILT |
1757 | ppc_current_block = sym; |
1758 | ||
882bdc69 ILT |
1759 | demand_empty_rest_of_line (); |
1760 | } | |
1761 | ||
1762 | /* The .es pseudo-op. Generate a C_ESTART symbol named .es. */ | |
1763 | ||
1764 | static void | |
1765 | ppc_es (ignore) | |
1766 | int ignore; | |
1767 | { | |
1768 | symbolS *sym; | |
1769 | ||
1eeb357e ILT |
1770 | if (ppc_current_block == NULL) |
1771 | as_bad (".es without preceding .bs"); | |
1772 | ||
882bdc69 ILT |
1773 | sym = symbol_make (".es"); |
1774 | S_SET_SEGMENT (sym, now_seg); | |
1775 | S_SET_STORAGE_CLASS (sym, C_ESTAT); | |
1776 | sym->bsym->flags |= BSF_DEBUGGING; | |
1777 | sym->sy_tc.output = 1; | |
1778 | ||
1779 | ppc_frob_label (sym); | |
1780 | ||
1eeb357e ILT |
1781 | ppc_current_block = NULL; |
1782 | ||
882bdc69 ILT |
1783 | demand_empty_rest_of_line (); |
1784 | } | |
1785 | ||
1786 | /* The .bb pseudo-op. Generate a C_BLOCK symbol named .bb, with a | |
1787 | line number. */ | |
1788 | ||
1789 | static void | |
1790 | ppc_bb (ignore) | |
1791 | int ignore; | |
1792 | { | |
1793 | symbolS *sym; | |
1794 | ||
1795 | sym = symbol_make (".bb"); | |
1796 | S_SET_SEGMENT (sym, text_section); | |
1797 | sym->sy_frag = frag_now; | |
1798 | S_SET_VALUE (sym, frag_now_fix ()); | |
1799 | S_SET_STORAGE_CLASS (sym, C_BLOCK); | |
1800 | ||
1801 | S_SET_NUMBER_AUXILIARY (sym, 1); | |
1802 | SA_SET_SYM_LNNO (sym, get_absolute_expression ()); | |
1803 | ||
1804 | sym->sy_tc.output = 1; | |
1805 | ||
1806 | ppc_frob_label (sym); | |
1807 | ||
1808 | demand_empty_rest_of_line (); | |
1809 | } | |
1810 | ||
1811 | /* The .eb pseudo-op. Generate a C_BLOCK symbol named .eb, with a | |
1812 | line number. */ | |
1813 | ||
1814 | static void | |
1815 | ppc_eb (ignore) | |
1816 | int ignore; | |
1817 | { | |
1818 | symbolS *sym; | |
1819 | ||
1820 | sym = symbol_make (".eb"); | |
1821 | S_SET_SEGMENT (sym, text_section); | |
1822 | sym->sy_frag = frag_now; | |
1823 | S_SET_VALUE (sym, frag_now_fix ()); | |
1824 | S_SET_STORAGE_CLASS (sym, C_FCN); | |
1825 | S_SET_NUMBER_AUXILIARY (sym, 1); | |
1826 | SA_SET_SYM_LNNO (sym, get_absolute_expression ()); | |
1827 | sym->sy_tc.output = 1; | |
1828 | ||
1829 | ppc_frob_label (sym); | |
1830 | ||
1831 | demand_empty_rest_of_line (); | |
1832 | } | |
1833 | ||
1834 | /* The .toc pseudo-op. Switch to the .toc subsegment. */ | |
1835 | ||
1836 | static void | |
1837 | ppc_toc (ignore) | |
1838 | int ignore; | |
1839 | { | |
1840 | if (ppc_toc_csect != (symbolS *) NULL) | |
1841 | subseg_set (data_section, ppc_toc_csect->sy_tc.subseg); | |
1842 | else | |
1843 | { | |
1844 | subsegT subseg; | |
1845 | symbolS *sym; | |
1846 | symbolS *list; | |
1847 | ||
1848 | subseg = ppc_data_subsegment; | |
1849 | ++ppc_data_subsegment; | |
1850 | ||
1851 | subseg_new (segment_name (data_section), subseg); | |
1852 | ppc_toc_frag = frag_now; | |
1853 | ||
1854 | sym = symbol_find_or_make ("TOC[TC0]"); | |
1855 | sym->sy_frag = frag_now; | |
1856 | S_SET_SEGMENT (sym, data_section); | |
1857 | S_SET_VALUE (sym, (valueT) frag_now_fix ()); | |
1858 | sym->sy_tc.subseg = subseg; | |
1859 | sym->sy_tc.output = 1; | |
1860 | sym->sy_tc.within = sym; | |
1861 | ||
1862 | ppc_toc_csect = sym; | |
1863 | ||
1864 | for (list = ppc_data_csects; | |
1865 | list->sy_tc.next != (symbolS *) NULL; | |
1866 | list = list->sy_tc.next) | |
1867 | ; | |
1868 | list->sy_tc.next = sym; | |
1869 | ||
1870 | symbol_remove (sym, &symbol_rootP, &symbol_lastP); | |
1871 | symbol_append (sym, list->sy_tc.within, &symbol_rootP, &symbol_lastP); | |
1872 | } | |
1873 | ||
1874 | ppc_current_csect = ppc_toc_csect; | |
1875 | ||
1876 | demand_empty_rest_of_line (); | |
1877 | } | |
1878 | ||
1879 | #endif /* OBJ_COFF */ | |
1880 | \f | |
1881 | /* The .tc pseudo-op. This is used when generating either XCOFF or | |
1882 | ELF. This takes two or more arguments. | |
1883 | ||
1884 | When generating XCOFF output, the first argument is the name to | |
1885 | give to this location in the toc; this will be a symbol with class | |
1886 | TC. The rest of the arguments are 4 byte values to actually put at | |
1887 | this location in the TOC; often there is just one more argument, a | |
1888 | relocateable symbol reference. | |
1889 | ||
1890 | When not generating XCOFF output, the arguments are the same, but | |
1891 | the first argument is simply ignored. */ | |
1892 | ||
1893 | static void | |
1894 | ppc_tc (ignore) | |
1895 | int ignore; | |
1896 | { | |
1897 | #ifdef OBJ_COFF | |
1898 | ||
1899 | /* Define the TOC symbol name. */ | |
1900 | { | |
1901 | char *name; | |
1902 | char endc; | |
1903 | symbolS *sym; | |
1904 | ||
1905 | if (ppc_toc_csect == (symbolS *) NULL | |
1906 | || ppc_toc_csect != ppc_current_csect) | |
1907 | { | |
1908 | as_bad (".tc not in .toc section"); | |
1909 | ignore_rest_of_line (); | |
1910 | return; | |
1911 | } | |
1912 | ||
1913 | name = input_line_pointer; | |
1914 | endc = get_symbol_end (); | |
1915 | ||
1916 | sym = symbol_find_or_make (name); | |
1917 | ||
1918 | *input_line_pointer = endc; | |
1919 | ||
1920 | if (S_IS_DEFINED (sym)) | |
1921 | { | |
1922 | symbolS *label; | |
1923 | ||
1924 | label = ppc_current_csect->sy_tc.within; | |
1925 | if (label->sy_tc.class != XMC_TC0) | |
1926 | { | |
1927 | as_warn (".tc with no label"); | |
1928 | ignore_rest_of_line (); | |
1929 | return; | |
1930 | } | |
1931 | ||
1932 | S_SET_SEGMENT (label, S_GET_SEGMENT (sym)); | |
1933 | label->sy_frag = sym->sy_frag; | |
1934 | S_SET_VALUE (label, S_GET_VALUE (sym)); | |
1935 | ||
1936 | while (! is_end_of_line[(unsigned char) *input_line_pointer]) | |
1937 | ++input_line_pointer; | |
1938 | ||
1939 | return; | |
1940 | } | |
1941 | ||
1942 | S_SET_SEGMENT (sym, now_seg); | |
1943 | sym->sy_frag = frag_now; | |
1944 | S_SET_VALUE (sym, (valueT) frag_now_fix ()); | |
1945 | sym->sy_tc.class = XMC_TC; | |
1946 | sym->sy_tc.output = 1; | |
1947 | ||
1948 | ppc_frob_label (sym); | |
1949 | } | |
1950 | ||
1951 | #else /* ! defined (OBJ_COFF) */ | |
1952 | ||
1953 | /* Skip the TOC symbol name. */ | |
1954 | while (is_part_of_name (*input_line_pointer) | |
1955 | || *input_line_pointer == '[' | |
1956 | || *input_line_pointer == ']' | |
1957 | || *input_line_pointer == '{' | |
1958 | || *input_line_pointer == '}') | |
1959 | ++input_line_pointer; | |
1960 | ||
1eeb357e ILT |
1961 | /* Align to a four byte boundary. */ |
1962 | frag_align (2, 0); | |
1963 | record_alignment (now_seg, 2); | |
1964 | ||
882bdc69 ILT |
1965 | #endif /* ! defined (OBJ_COFF) */ |
1966 | ||
1967 | if (*input_line_pointer != ',') | |
1968 | demand_empty_rest_of_line (); | |
1969 | else | |
1970 | { | |
1971 | ++input_line_pointer; | |
1972 | cons (4); | |
1973 | } | |
1974 | } | |
1975 | \f | |
1976 | #ifdef OBJ_COFF | |
1977 | ||
1978 | /* XCOFF specific symbol and file handling. */ | |
1979 | ||
1980 | /* Canonicalize the symbol name. We use the to force the suffix, if | |
1981 | any, to use square brackets, and to be in upper case. */ | |
1982 | ||
1983 | char * | |
1984 | ppc_canonicalize_symbol_name (name) | |
1985 | char *name; | |
1986 | { | |
1987 | char *s; | |
1988 | ||
1989 | for (s = name; *s != '\0' && *s != '{' && *s != '['; s++) | |
1990 | ; | |
1991 | if (*s != '\0') | |
1992 | { | |
1993 | char brac; | |
1994 | ||
1995 | if (*s == '[') | |
1996 | brac = ']'; | |
1997 | else | |
1998 | { | |
1999 | *s = '['; | |
2000 | brac = '}'; | |
2001 | } | |
2002 | ||
2003 | for (s++; *s != '\0' && *s != brac; s++) | |
2004 | if (islower (*s)) | |
2005 | *s = toupper (*s); | |
2006 | ||
2007 | if (*s == '\0' || s[1] != '\0') | |
2008 | as_bad ("bad symbol suffix"); | |
2009 | ||
2010 | *s = ']'; | |
2011 | } | |
2012 | ||
2013 | return name; | |
2014 | } | |
2015 | ||
2016 | /* Set the class of a symbol based on the suffix, if any. This is | |
2017 | called whenever a new symbol is created. */ | |
2018 | ||
2019 | void | |
2020 | ppc_symbol_new_hook (sym) | |
2021 | symbolS *sym; | |
2022 | { | |
2023 | const char *s; | |
2024 | ||
2025 | sym->sy_tc.next = NULL; | |
2026 | sym->sy_tc.output = 0; | |
2027 | sym->sy_tc.class = -1; | |
2028 | sym->sy_tc.real_name = NULL; | |
2029 | sym->sy_tc.subseg = 0; | |
2030 | sym->sy_tc.align = 0; | |
2031 | sym->sy_tc.size = NULL; | |
2032 | sym->sy_tc.within = NULL; | |
2033 | ||
2034 | s = strchr (S_GET_NAME (sym), '['); | |
2035 | if (s == (const char *) NULL) | |
2036 | { | |
2037 | /* There is no suffix. */ | |
2038 | return; | |
2039 | } | |
2040 | ||
2041 | ++s; | |
2042 | ||
2043 | switch (s[0]) | |
2044 | { | |
2045 | case 'B': | |
2046 | if (strcmp (s, "BS]") == 0) | |
2047 | sym->sy_tc.class = XMC_BS; | |
2048 | break; | |
2049 | case 'D': | |
2050 | if (strcmp (s, "DB]") == 0) | |
2051 | sym->sy_tc.class = XMC_DB; | |
2052 | else if (strcmp (s, "DS]") == 0) | |
2053 | sym->sy_tc.class = XMC_DS; | |
2054 | break; | |
2055 | case 'G': | |
2056 | if (strcmp (s, "GL]") == 0) | |
2057 | sym->sy_tc.class = XMC_GL; | |
2058 | break; | |
2059 | case 'P': | |
2060 | if (strcmp (s, "PR]") == 0) | |
2061 | sym->sy_tc.class = XMC_PR; | |
2062 | break; | |
2063 | case 'R': | |
2064 | if (strcmp (s, "RO]") == 0) | |
2065 | sym->sy_tc.class = XMC_RO; | |
2066 | else if (strcmp (s, "RW]") == 0) | |
2067 | sym->sy_tc.class = XMC_RW; | |
2068 | break; | |
2069 | case 'S': | |
2070 | if (strcmp (s, "SV]") == 0) | |
2071 | sym->sy_tc.class = XMC_SV; | |
2072 | break; | |
2073 | case 'T': | |
2074 | if (strcmp (s, "TC]") == 0) | |
2075 | sym->sy_tc.class = XMC_TC; | |
2076 | else if (strcmp (s, "TI]") == 0) | |
2077 | sym->sy_tc.class = XMC_TI; | |
2078 | else if (strcmp (s, "TB]") == 0) | |
2079 | sym->sy_tc.class = XMC_TB; | |
4a6b2f8b | 2080 | else if (strcmp (s, "TC0]") == 0 || strcmp (s, "T0]") == 0) |
882bdc69 ILT |
2081 | sym->sy_tc.class = XMC_TC0; |
2082 | break; | |
2083 | case 'U': | |
2084 | if (strcmp (s, "UA]") == 0) | |
2085 | sym->sy_tc.class = XMC_UA; | |
2086 | else if (strcmp (s, "UC]") == 0) | |
2087 | sym->sy_tc.class = XMC_UC; | |
2088 | break; | |
2089 | case 'X': | |
2090 | if (strcmp (s, "XO]") == 0) | |
2091 | sym->sy_tc.class = XMC_XO; | |
2092 | break; | |
2093 | } | |
2094 | ||
2095 | if (sym->sy_tc.class == -1) | |
2096 | as_bad ("Unrecognized symbol suffix"); | |
2097 | } | |
2098 | ||
2099 | /* Set the class of a label based on where it is defined. This | |
2100 | handles symbols without suffixes. Also, move the symbol so that it | |
2101 | follows the csect symbol. */ | |
2102 | ||
2103 | void | |
2104 | ppc_frob_label (sym) | |
2105 | symbolS *sym; | |
2106 | { | |
2107 | if (ppc_current_csect != (symbolS *) NULL) | |
2108 | { | |
2109 | if (sym->sy_tc.class == -1) | |
2110 | sym->sy_tc.class = ppc_current_csect->sy_tc.class; | |
2111 | ||
2112 | symbol_remove (sym, &symbol_rootP, &symbol_lastP); | |
2113 | symbol_append (sym, ppc_current_csect->sy_tc.within, &symbol_rootP, | |
2114 | &symbol_lastP); | |
2115 | ppc_current_csect->sy_tc.within = sym; | |
2116 | } | |
2117 | } | |
2118 | ||
2119 | /* Change the name of a symbol just before writing it out. Set the | |
2120 | real name if the .rename pseudo-op was used. Otherwise, remove any | |
2121 | class suffix. Return 1 if the symbol should not be included in the | |
2122 | symbol table. */ | |
2123 | ||
2124 | int | |
2125 | ppc_frob_symbol (sym) | |
2126 | symbolS *sym; | |
2127 | { | |
2128 | static symbolS *ppc_last_function; | |
2129 | static symbolS *set_end; | |
2130 | ||
2131 | /* Discard symbols that should not be included in the output symbol | |
2132 | table. */ | |
2133 | if (! sym->sy_used_in_reloc | |
2134 | && ((sym->bsym->flags & BSF_SECTION_SYM) != 0 | |
2135 | || (! S_IS_EXTERNAL (sym) | |
2136 | && ! sym->sy_tc.output | |
2137 | && S_GET_STORAGE_CLASS (sym) != C_FILE))) | |
2138 | return 1; | |
2139 | ||
2140 | if (sym->sy_tc.real_name != (char *) NULL) | |
2141 | S_SET_NAME (sym, sym->sy_tc.real_name); | |
2142 | else | |
2143 | { | |
2144 | const char *name; | |
2145 | const char *s; | |
2146 | ||
2147 | name = S_GET_NAME (sym); | |
2148 | s = strchr (name, '['); | |
2149 | if (s != (char *) NULL) | |
2150 | { | |
2151 | unsigned int len; | |
2152 | char *snew; | |
2153 | ||
2154 | len = s - name; | |
2155 | snew = xmalloc (len + 1); | |
2156 | memcpy (snew, name, len); | |
2157 | snew[len] = '\0'; | |
2158 | ||
2159 | S_SET_NAME (sym, snew); | |
2160 | } | |
2161 | } | |
2162 | ||
2163 | if (set_end != (symbolS *) NULL) | |
2164 | { | |
2165 | SA_SET_SYM_ENDNDX (set_end, sym); | |
2166 | set_end = NULL; | |
2167 | } | |
2168 | ||
2169 | if (SF_GET_FUNCTION (sym)) | |
2170 | { | |
2171 | if (ppc_last_function != (symbolS *) NULL) | |
2172 | as_warn ("two .function pseudo-ops with no intervening .ef"); | |
2173 | ppc_last_function = sym; | |
2174 | if (sym->sy_tc.size != (symbolS *) NULL) | |
2175 | { | |
2176 | resolve_symbol_value (sym->sy_tc.size); | |
2177 | SA_SET_SYM_FSIZE (sym, (long) S_GET_VALUE (sym->sy_tc.size)); | |
2178 | } | |
2179 | } | |
2180 | else if (S_GET_STORAGE_CLASS (sym) == C_FCN | |
2181 | && strcmp (S_GET_NAME (sym), ".ef") == 0) | |
2182 | { | |
2183 | if (ppc_last_function == (symbolS *) NULL) | |
2184 | as_warn (".ef with no preceding .function"); | |
2185 | else | |
2186 | { | |
2187 | set_end = ppc_last_function; | |
2188 | ppc_last_function = NULL; | |
2189 | ||
2190 | /* We don't have a C_EFCN symbol, but we need to force the | |
2191 | COFF backend to believe that it has seen one. */ | |
2192 | coff_last_function = NULL; | |
2193 | } | |
2194 | } | |
2195 | ||
2196 | if (! S_IS_EXTERNAL (sym) | |
2197 | && (sym->bsym->flags & BSF_SECTION_SYM) == 0 | |
2198 | && S_GET_STORAGE_CLASS (sym) != C_FILE | |
2199 | && S_GET_STORAGE_CLASS (sym) != C_FCN | |
2200 | && S_GET_STORAGE_CLASS (sym) != C_BSTAT | |
2201 | && S_GET_STORAGE_CLASS (sym) != C_ESTAT | |
2202 | && S_GET_SEGMENT (sym) != ppc_coff_debug_section) | |
2203 | S_SET_STORAGE_CLASS (sym, C_HIDEXT); | |
2204 | ||
2205 | if (S_GET_STORAGE_CLASS (sym) == C_EXT | |
2206 | || S_GET_STORAGE_CLASS (sym) == C_HIDEXT) | |
2207 | { | |
2208 | int i; | |
2209 | union internal_auxent *a; | |
2210 | ||
2211 | /* Create a csect aux. */ | |
2212 | i = S_GET_NUMBER_AUXILIARY (sym); | |
2213 | S_SET_NUMBER_AUXILIARY (sym, i + 1); | |
2214 | a = &coffsymbol (sym->bsym)->native[i + 1].u.auxent; | |
2215 | if (sym->sy_tc.class == XMC_TC0) | |
2216 | { | |
2217 | /* This is the TOC table. */ | |
2218 | know (strcmp (S_GET_NAME (sym), "TOC") == 0); | |
2219 | a->x_csect.x_scnlen.l = 0; | |
2220 | a->x_csect.x_smtyp = (2 << 3) | XTY_SD; | |
2221 | } | |
2222 | else if (sym->sy_tc.subseg != 0) | |
2223 | { | |
2224 | /* This is a csect symbol. x_scnlen is the size of the | |
2225 | csect. */ | |
2226 | if (sym->sy_tc.next == (symbolS *) NULL) | |
2227 | a->x_csect.x_scnlen.l = (bfd_section_size (stdoutput, | |
2228 | S_GET_SEGMENT (sym)) | |
2229 | - S_GET_VALUE (sym)); | |
2230 | else | |
2231 | { | |
2232 | resolve_symbol_value (sym->sy_tc.next); | |
2233 | a->x_csect.x_scnlen.l = (S_GET_VALUE (sym->sy_tc.next) | |
2234 | - S_GET_VALUE (sym)); | |
2235 | } | |
2236 | a->x_csect.x_smtyp = (sym->sy_tc.align << 3) | XTY_SD; | |
2237 | } | |
2238 | else if (S_GET_SEGMENT (sym) == bss_section) | |
2239 | { | |
2240 | /* This is a common symbol. */ | |
2241 | a->x_csect.x_scnlen.l = sym->sy_frag->fr_offset; | |
2242 | a->x_csect.x_smtyp = (sym->sy_tc.align << 3) | XTY_CM; | |
2243 | if (S_IS_EXTERNAL (sym)) | |
2244 | sym->sy_tc.class = XMC_RW; | |
2245 | else | |
2246 | sym->sy_tc.class = XMC_BS; | |
2247 | } | |
2248 | else if (! S_IS_DEFINED (sym)) | |
2249 | { | |
2250 | /* This is an external symbol. */ | |
2251 | a->x_csect.x_scnlen.l = 0; | |
2252 | a->x_csect.x_smtyp = XTY_ER; | |
2253 | } | |
2254 | else if (sym->sy_tc.class == XMC_TC) | |
2255 | { | |
2256 | symbolS *next; | |
2257 | ||
2258 | /* This is a TOC definition. x_scnlen is the size of the | |
2259 | TOC entry. */ | |
2260 | next = symbol_next (sym); | |
2261 | while (next->sy_tc.class == XMC_TC0) | |
2262 | next = symbol_next (next); | |
2263 | if (next == (symbolS *) NULL | |
2264 | || next->sy_tc.class != XMC_TC) | |
2265 | { | |
2266 | if (ppc_after_toc_frag == (fragS *) NULL) | |
2267 | a->x_csect.x_scnlen.l = (bfd_section_size (stdoutput, | |
2268 | data_section) | |
2269 | - S_GET_VALUE (sym)); | |
2270 | else | |
2271 | a->x_csect.x_scnlen.l = (ppc_after_toc_frag->fr_address | |
2272 | - S_GET_VALUE (sym)); | |
2273 | } | |
2274 | else | |
2275 | { | |
2276 | resolve_symbol_value (next); | |
2277 | a->x_csect.x_scnlen.l = (S_GET_VALUE (next) | |
2278 | - S_GET_VALUE (sym)); | |
2279 | } | |
2280 | a->x_csect.x_smtyp = (2 << 3) | XTY_SD; | |
2281 | } | |
2282 | else | |
2283 | { | |
2284 | symbolS *csect; | |
2285 | ||
2286 | /* This is a normal symbol definition. x_scnlen is the | |
2287 | symbol index of the containing csect. */ | |
2288 | if (S_GET_SEGMENT (sym) == text_section) | |
2289 | csect = ppc_text_csects; | |
2290 | else if (S_GET_SEGMENT (sym) == data_section) | |
2291 | csect = ppc_data_csects; | |
2292 | else | |
2293 | abort (); | |
2294 | ||
2295 | /* Skip the initial dummy symbol. */ | |
2296 | csect = csect->sy_tc.next; | |
2297 | ||
2298 | if (csect == (symbolS *) NULL) | |
2299 | a->x_csect.x_scnlen.l = 0; | |
2300 | else | |
2301 | { | |
2302 | while (csect->sy_tc.next != (symbolS *) NULL) | |
2303 | { | |
2304 | resolve_symbol_value (csect->sy_tc.next); | |
2305 | if (S_GET_VALUE (csect->sy_tc.next) > S_GET_VALUE (sym)) | |
2306 | break; | |
2307 | csect = csect->sy_tc.next; | |
2308 | } | |
2309 | ||
2310 | a->x_csect.x_scnlen.p = coffsymbol (csect->bsym)->native; | |
2311 | coffsymbol (sym->bsym)->native[i + 1].fix_scnlen = 1; | |
2312 | } | |
2313 | a->x_csect.x_smtyp = XTY_LD; | |
2314 | } | |
2315 | ||
2316 | a->x_csect.x_parmhash = 0; | |
2317 | a->x_csect.x_snhash = 0; | |
2318 | if (sym->sy_tc.class == -1) | |
2319 | a->x_csect.x_smclas = XMC_PR; | |
2320 | else | |
2321 | a->x_csect.x_smclas = sym->sy_tc.class; | |
2322 | a->x_csect.x_stab = 0; | |
2323 | a->x_csect.x_snstab = 0; | |
2324 | } | |
2325 | else if (S_GET_STORAGE_CLASS (sym) == C_BSTAT) | |
2326 | { | |
2327 | /* We want the value to be the symbol index of the referenced | |
2328 | csect symbol. BFD will do that for us if we set the right | |
2329 | flags. */ | |
2330 | S_SET_VALUE (sym, | |
2331 | (valueT) coffsymbol (sym->sy_tc.within->bsym)->native); | |
2332 | coffsymbol (sym->bsym)->native->fix_value = 1; | |
2333 | } | |
1eeb357e ILT |
2334 | else if (S_GET_STORAGE_CLASS (sym) == C_STSYM) |
2335 | { | |
2336 | symbolS *block; | |
2337 | symbolS *csect; | |
2338 | ||
2339 | /* The value is the offset from the enclosing csect. */ | |
2340 | block = sym->sy_tc.within; | |
2341 | csect = block->sy_tc.within; | |
2342 | resolve_symbol_value (csect); | |
2343 | S_SET_VALUE (sym, S_GET_VALUE (sym) - S_GET_VALUE (csect)); | |
2344 | } | |
882bdc69 ILT |
2345 | |
2346 | return 0; | |
2347 | } | |
2348 | ||
2349 | /* Set the VMA for a section. This is called on all the sections in | |
2350 | turn. */ | |
2351 | ||
2352 | void | |
2353 | ppc_frob_section (sec) | |
2354 | asection *sec; | |
2355 | { | |
2356 | static bfd_size_type vma = 0; | |
2357 | ||
2358 | bfd_set_section_vma (stdoutput, sec, vma); | |
2359 | vma += bfd_section_size (stdoutput, sec); | |
2360 | } | |
2361 | ||
2362 | /* Adjust the file by adding a .debug section if needed. */ | |
2363 | ||
2364 | void | |
2365 | ppc_frob_file () | |
2366 | { | |
2367 | if (ppc_debug_name_section_size > 0) | |
2368 | { | |
2369 | asection *sec; | |
2370 | ||
2371 | sec = bfd_make_section (stdoutput, ".debug"); | |
2372 | if (sec == (asection *) NULL | |
2373 | || ! bfd_set_section_size (stdoutput, sec, | |
2374 | ppc_debug_name_section_size) | |
2375 | || ! bfd_set_section_flags (stdoutput, sec, | |
2376 | SEC_HAS_CONTENTS | SEC_LOAD)) | |
2377 | as_fatal ("can't make .debug section"); | |
2378 | } | |
2379 | } | |
2380 | ||
2381 | #endif /* OBJ_COFF */ | |
2382 | \f | |
2383 | /* Turn a string in input_line_pointer into a floating point constant | |
2384 | of type type, and store the appropriate bytes in *litp. The number | |
2385 | of LITTLENUMS emitted is stored in *sizep . An error message is | |
2386 | returned, or NULL on OK. */ | |
2387 | ||
2388 | char * | |
2389 | md_atof (type, litp, sizep) | |
2390 | int type; | |
2391 | char *litp; | |
2392 | int *sizep; | |
2393 | { | |
2394 | int prec; | |
2395 | LITTLENUM_TYPE words[4]; | |
2396 | char *t; | |
2397 | int i; | |
2398 | ||
2399 | switch (type) | |
2400 | { | |
2401 | case 'f': | |
2402 | prec = 2; | |
2403 | break; | |
2404 | ||
2405 | case 'd': | |
2406 | prec = 4; | |
2407 | break; | |
2408 | ||
2409 | default: | |
2410 | *sizep = 0; | |
2411 | return "bad call to md_atof"; | |
2412 | } | |
2413 | ||
2414 | t = atof_ieee (input_line_pointer, type, words); | |
2415 | if (t) | |
2416 | input_line_pointer = t; | |
2417 | ||
2418 | *sizep = prec * 2; | |
2419 | ||
99146659 | 2420 | if (target_big_endian) |
882bdc69 ILT |
2421 | { |
2422 | for (i = 0; i < prec; i++) | |
2423 | { | |
2424 | md_number_to_chars (litp, (valueT) words[i], 2); | |
2425 | litp += 2; | |
2426 | } | |
2427 | } | |
2428 | else | |
2429 | { | |
2430 | for (i = prec - 1; i >= 0; i--) | |
2431 | { | |
2432 | md_number_to_chars (litp, (valueT) words[i], 2); | |
2433 | litp += 2; | |
2434 | } | |
2435 | } | |
2436 | ||
2437 | return NULL; | |
2438 | } | |
2439 | ||
2440 | /* Write a value out to the object file, using the appropriate | |
2441 | endianness. */ | |
2442 | ||
2443 | void | |
2444 | md_number_to_chars (buf, val, n) | |
2445 | char *buf; | |
2446 | valueT val; | |
2447 | int n; | |
2448 | { | |
99146659 | 2449 | if (target_big_endian) |
882bdc69 ILT |
2450 | number_to_chars_bigendian (buf, val, n); |
2451 | else | |
2452 | number_to_chars_littleendian (buf, val, n); | |
2453 | } | |
2454 | ||
2455 | /* Align a section (I don't know why this is machine dependent). */ | |
2456 | ||
2457 | valueT | |
2458 | md_section_align (seg, addr) | |
2459 | asection *seg; | |
2460 | valueT addr; | |
2461 | { | |
2462 | int align = bfd_get_section_alignment (stdoutput, seg); | |
2463 | ||
2464 | return ((addr + (1 << align) - 1) & (-1 << align)); | |
2465 | } | |
2466 | ||
2467 | /* We don't have any form of relaxing. */ | |
2468 | ||
2469 | int | |
2470 | md_estimate_size_before_relax (fragp, seg) | |
2471 | fragS *fragp; | |
2472 | asection *seg; | |
2473 | { | |
2474 | abort (); | |
2475 | } | |
2476 | ||
882bdc69 ILT |
2477 | /* Convert a machine dependent frag. We never generate these. */ |
2478 | ||
2479 | void | |
2480 | md_convert_frag (abfd, sec, fragp) | |
2481 | bfd *abfd; | |
2482 | asection *sec; | |
2483 | fragS *fragp; | |
2484 | { | |
2485 | abort (); | |
2486 | } | |
2487 | ||
882bdc69 ILT |
2488 | /* We have no need to default values of symbols. */ |
2489 | ||
2490 | /*ARGSUSED*/ | |
2491 | symbolS * | |
2492 | md_undefined_symbol (name) | |
2493 | char *name; | |
2494 | { | |
2495 | return 0; | |
2496 | } | |
2497 | \f | |
2498 | /* Functions concerning relocs. */ | |
2499 | ||
2500 | /* The location from which a PC relative jump should be calculated, | |
2501 | given a PC relative reloc. */ | |
2502 | ||
2503 | long | |
2504 | md_pcrel_from (fixp) | |
2505 | fixS *fixp; | |
2506 | { | |
2507 | #ifdef OBJ_ELF | |
2508 | if (fixp->fx_addsy != (symbolS *) NULL | |
2509 | && ! S_IS_DEFINED (fixp->fx_addsy)) | |
2510 | return 0; | |
2511 | #endif | |
2512 | ||
2513 | return fixp->fx_frag->fr_address + fixp->fx_where; | |
2514 | } | |
2515 | ||
2516 | #ifdef OBJ_COFF | |
2517 | ||
2518 | /* This is called to see whether a fixup should be adjusted to use a | |
2519 | section symbol. We take the opportunity to change a fixup against | |
2520 | a symbol in the TOC subsegment into a reloc against the | |
1eeb357e | 2521 | corresponding .tc symbol. */ |
882bdc69 ILT |
2522 | |
2523 | int | |
2524 | ppc_fix_adjustable (fix) | |
2525 | fixS *fix; | |
2526 | { | |
2527 | valueT val; | |
2528 | ||
1eeb357e ILT |
2529 | resolve_symbol_value (fix->fx_addsy); |
2530 | val = S_GET_VALUE (fix->fx_addsy); | |
882bdc69 ILT |
2531 | if (ppc_toc_csect != (symbolS *) NULL |
2532 | && fix->fx_addsy != (symbolS *) NULL | |
2533 | && fix->fx_addsy != ppc_toc_csect | |
2534 | && S_GET_SEGMENT (fix->fx_addsy) == data_section | |
2535 | && val >= ppc_toc_frag->fr_address | |
2536 | && (ppc_after_toc_frag == (fragS *) NULL | |
2537 | || val < ppc_after_toc_frag->fr_address)) | |
2538 | { | |
2539 | symbolS *sy; | |
2540 | ||
2541 | for (sy = symbol_next (ppc_toc_csect); | |
2542 | sy != (symbolS *) NULL; | |
2543 | sy = symbol_next (sy)) | |
2544 | { | |
2545 | if (sy->sy_tc.class == XMC_TC0) | |
2546 | continue; | |
2547 | if (sy->sy_tc.class != XMC_TC) | |
2548 | break; | |
1eeb357e ILT |
2549 | resolve_symbol_value (sy); |
2550 | if (val == S_GET_VALUE (sy)) | |
882bdc69 ILT |
2551 | { |
2552 | fix->fx_addsy = sy; | |
2553 | fix->fx_addnumber = val - ppc_toc_frag->fr_address; | |
2554 | return 0; | |
2555 | } | |
2556 | } | |
2557 | ||
2558 | as_bad_where (fix->fx_file, fix->fx_line, | |
2559 | "symbol in .toc does not match any .tc"); | |
2560 | } | |
2561 | ||
2562 | /* Possibly adjust the reloc to be against the csect. */ | |
2563 | if (fix->fx_addsy != (symbolS *) NULL | |
2564 | && fix->fx_addsy->sy_tc.subseg == 0 | |
2565 | && fix->fx_addsy->sy_tc.class != XMC_TC0 | |
2566 | && fix->fx_addsy->sy_tc.class != XMC_TC | |
2567 | && S_GET_SEGMENT (fix->fx_addsy) != bss_section) | |
2568 | { | |
2569 | symbolS *csect; | |
2570 | ||
2571 | if (S_GET_SEGMENT (fix->fx_addsy) == text_section) | |
2572 | csect = ppc_text_csects; | |
2573 | else if (S_GET_SEGMENT (fix->fx_addsy) == data_section) | |
2574 | csect = ppc_data_csects; | |
2575 | else | |
2576 | abort (); | |
2577 | ||
2578 | /* Skip the initial dummy symbol. */ | |
2579 | csect = csect->sy_tc.next; | |
2580 | ||
2581 | if (csect != (symbolS *) NULL) | |
2582 | { | |
2583 | while (csect->sy_tc.next != (symbolS *) NULL | |
2584 | && (csect->sy_tc.next->sy_frag->fr_address | |
2585 | <= fix->fx_addsy->sy_frag->fr_address)) | |
2586 | csect = csect->sy_tc.next; | |
2587 | ||
2588 | fix->fx_offset += (S_GET_VALUE (fix->fx_addsy) | |
1eeb357e | 2589 | - csect->sy_frag->fr_address); |
882bdc69 ILT |
2590 | fix->fx_addsy = csect; |
2591 | } | |
2592 | } | |
2593 | ||
2594 | /* Adjust a reloc against a .lcomm symbol to be against the base | |
2595 | .lcomm. */ | |
2596 | if (fix->fx_addsy != (symbolS *) NULL | |
2597 | && S_GET_SEGMENT (fix->fx_addsy) == bss_section | |
2598 | && ! S_IS_EXTERNAL (fix->fx_addsy)) | |
2599 | { | |
1eeb357e ILT |
2600 | resolve_symbol_value (fix->fx_addsy->sy_frag->fr_symbol); |
2601 | fix->fx_offset += (S_GET_VALUE (fix->fx_addsy) | |
2602 | - S_GET_VALUE (fix->fx_addsy->sy_frag->fr_symbol)); | |
882bdc69 ILT |
2603 | fix->fx_addsy = fix->fx_addsy->sy_frag->fr_symbol; |
2604 | } | |
2605 | ||
2606 | return 0; | |
2607 | } | |
2608 | ||
2609 | #endif | |
2610 | ||
2611 | /* See whether a symbol is in the TOC section. */ | |
2612 | ||
2613 | static int | |
2614 | ppc_is_toc_sym (sym) | |
2615 | symbolS *sym; | |
2616 | { | |
2617 | #ifdef OBJ_COFF | |
2618 | return sym->sy_tc.class == XMC_TC; | |
2619 | #else | |
2620 | return strcmp (segment_name (S_GET_SEGMENT (sym)), ".got") == 0; | |
2621 | #endif | |
2622 | } | |
2623 | ||
2624 | /* Apply a fixup to the object code. This is called for all the | |
2625 | fixups we generated by the call to fix_new_exp, above. In the call | |
2626 | above we used a reloc code which was the largest legal reloc code | |
2627 | plus the operand index. Here we undo that to recover the operand | |
2628 | index. At this point all symbol values should be fully resolved, | |
2629 | and we attempt to completely resolve the reloc. If we can not do | |
2630 | that, we determine the correct reloc code and put it back in the | |
2631 | fixup. */ | |
2632 | ||
2633 | int | |
3f81f3cf | 2634 | md_apply_fix3 (fixp, valuep, seg) |
882bdc69 ILT |
2635 | fixS *fixp; |
2636 | valueT *valuep; | |
3f81f3cf | 2637 | segT seg; |
882bdc69 ILT |
2638 | { |
2639 | valueT value; | |
2640 | ||
2641 | /* FIXME FIXME FIXME: The value we are passed in *valuep includes | |
2642 | the symbol values. Since we are using BFD_ASSEMBLER, if we are | |
2643 | doing this relocation the code in write.c is going to call | |
2644 | bfd_perform_relocation, which is also going to use the symbol | |
2645 | value. That means that if the reloc is fully resolved we want to | |
2646 | use *valuep since bfd_perform_relocation is not being used. | |
2647 | However, if the reloc is not fully resolved we do not want to use | |
2648 | *valuep, and must use fx_offset instead. However, if the reloc | |
2649 | is PC relative, we do want to use *valuep since it includes the | |
2650 | result of md_pcrel_from. This is confusing. */ | |
2651 | ||
2652 | if (fixp->fx_addsy == (symbolS *) NULL) | |
2653 | { | |
2654 | value = *valuep; | |
2655 | fixp->fx_done = 1; | |
2656 | } | |
2657 | else if (fixp->fx_pcrel) | |
2658 | value = *valuep; | |
2659 | else | |
2660 | { | |
2661 | value = fixp->fx_offset; | |
2662 | if (fixp->fx_subsy != (symbolS *) NULL) | |
2663 | { | |
2664 | if (S_GET_SEGMENT (fixp->fx_subsy) == absolute_section) | |
2665 | value -= S_GET_VALUE (fixp->fx_subsy); | |
2666 | else | |
2667 | { | |
2668 | /* We can't actually support subtracting a symbol. */ | |
2669 | as_bad_where (fixp->fx_file, fixp->fx_line, | |
2670 | "expression too complex"); | |
2671 | } | |
2672 | } | |
2673 | } | |
2674 | ||
2675 | if ((int) fixp->fx_r_type >= (int) BFD_RELOC_UNUSED) | |
2676 | { | |
2677 | int opindex; | |
2678 | const struct powerpc_operand *operand; | |
2679 | char *where; | |
2680 | unsigned long insn; | |
2681 | ||
2682 | opindex = (int) fixp->fx_r_type - (int) BFD_RELOC_UNUSED; | |
2683 | ||
2684 | operand = &powerpc_operands[opindex]; | |
2685 | ||
1eeb357e ILT |
2686 | #ifdef OBJ_COFF |
2687 | /* It appears that an instruction like | |
2688 | l 9,LC..1(30) | |
2689 | when LC..1 is not a TOC symbol does not generate a reloc. It | |
2690 | uses the offset of LC..1 within its csect. However, .long | |
2691 | LC..1 will generate a reloc. I can't find any documentation | |
2692 | on how these cases are to be distinguished, so this is a wild | |
2693 | guess. These cases are generated by gcc -mminimal-toc. */ | |
2694 | if ((operand->flags & PPC_OPERAND_PARENS) != 0 | |
2695 | && operand->bits == 16 | |
2696 | && operand->shift == 0 | |
2697 | && operand->insert == NULL | |
2698 | && fixp->fx_addsy != NULL | |
2699 | && fixp->fx_addsy->sy_tc.subseg != 0 | |
2700 | && fixp->fx_addsy->sy_tc.class != XMC_TC | |
2701 | && fixp->fx_addsy->sy_tc.class != XMC_TC0 | |
2702 | && S_GET_SEGMENT (fixp->fx_addsy) != bss_section) | |
2703 | { | |
2704 | value = fixp->fx_offset; | |
2705 | fixp->fx_done = 1; | |
2706 | } | |
2707 | #endif | |
2708 | ||
882bdc69 ILT |
2709 | /* Fetch the instruction, insert the fully resolved operand |
2710 | value, and stuff the instruction back again. */ | |
2711 | where = fixp->fx_frag->fr_literal + fixp->fx_where; | |
99146659 | 2712 | if (target_big_endian) |
882bdc69 ILT |
2713 | insn = bfd_getb32 ((unsigned char *) where); |
2714 | else | |
2715 | insn = bfd_getl32 ((unsigned char *) where); | |
2716 | insn = ppc_insert_operand (insn, operand, (offsetT) value, | |
2717 | fixp->fx_file, fixp->fx_line); | |
99146659 | 2718 | if (target_big_endian) |
882bdc69 ILT |
2719 | bfd_putb32 ((bfd_vma) insn, (unsigned char *) where); |
2720 | else | |
2721 | bfd_putl32 ((bfd_vma) insn, (unsigned char *) where); | |
2722 | ||
2723 | if (fixp->fx_done) | |
2724 | { | |
2725 | /* Nothing else to do here. */ | |
2726 | return 1; | |
2727 | } | |
2728 | ||
2729 | /* Determine a BFD reloc value based on the operand information. | |
2730 | We are only prepared to turn a few of the operands into | |
2731 | relocs. | |
2732 | FIXME: We need to handle the DS field at the very least. | |
2733 | FIXME: Handling 16 bit branches would also be reasonable. | |
2734 | FIXME: Selecting the reloc type is a bit haphazard; perhaps | |
2735 | there should be a new field in the operand table. */ | |
2736 | if ((operand->flags & PPC_OPERAND_RELATIVE) != 0 | |
2737 | && operand->bits == 26 | |
2738 | && operand->shift == 0) | |
2739 | fixp->fx_r_type = BFD_RELOC_PPC_B26; | |
2740 | else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0 | |
2741 | && operand->bits == 26 | |
2742 | && operand->shift == 0) | |
2743 | fixp->fx_r_type = BFD_RELOC_PPC_BA26; | |
2744 | else if ((operand->flags & PPC_OPERAND_PARENS) != 0 | |
2745 | && operand->bits == 16 | |
2746 | && operand->shift == 0 | |
2747 | && operand->insert == NULL | |
2748 | && fixp->fx_addsy != NULL | |
2749 | && ppc_is_toc_sym (fixp->fx_addsy)) | |
2750 | { | |
2751 | fixp->fx_size = 2; | |
99146659 | 2752 | if (target_big_endian) |
882bdc69 ILT |
2753 | fixp->fx_where += 2; |
2754 | fixp->fx_r_type = BFD_RELOC_PPC_TOC16; | |
2755 | } | |
2756 | else | |
2757 | { | |
2758 | as_bad_where (fixp->fx_file, fixp->fx_line, | |
2759 | "unresolved expression that must be resolved"); | |
2760 | fixp->fx_done = 1; | |
2761 | return 1; | |
2762 | } | |
2763 | } | |
2764 | else | |
2765 | { | |
3f81f3cf MM |
2766 | #ifdef OBJ_ELF |
2767 | ppc_elf_validate_fix (fixp, seg); | |
2768 | #endif | |
882bdc69 ILT |
2769 | switch (fixp->fx_r_type) |
2770 | { | |
2771 | case BFD_RELOC_32: | |
840886d8 | 2772 | case BFD_RELOC_CTOR: |
3f81f3cf MM |
2773 | if (fixp->fx_pcrel) |
2774 | { | |
2775 | fixp->fx_r_type = BFD_RELOC_32_PCREL; | |
2776 | value += fixp->fx_frag->fr_address + fixp->fx_where; | |
2777 | } /* fall through */ | |
2778 | ||
4a6b2f8b | 2779 | case BFD_RELOC_32_PCREL: |
882bdc69 ILT |
2780 | md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, |
2781 | value, 4); | |
2782 | break; | |
840886d8 | 2783 | |
4a6b2f8b MM |
2784 | case BFD_RELOC_LO16: |
2785 | case BFD_RELOC_HI16: | |
2786 | case BFD_RELOC_HI16_S: | |
2787 | case BFD_RELOC_PPC_TOC16: | |
882bdc69 | 2788 | case BFD_RELOC_16: |
840886d8 | 2789 | case BFD_RELOC_GPREL16: |
3f81f3cf MM |
2790 | if (fixp->fx_pcrel) |
2791 | abort (); | |
2792 | ||
882bdc69 ILT |
2793 | md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, |
2794 | value, 2); | |
2795 | break; | |
3f81f3cf | 2796 | |
882bdc69 | 2797 | case BFD_RELOC_8: |
3f81f3cf MM |
2798 | if (fixp->fx_pcrel) |
2799 | abort (); | |
2800 | ||
882bdc69 ILT |
2801 | md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, |
2802 | value, 1); | |
2803 | break; | |
840886d8 | 2804 | |
882bdc69 ILT |
2805 | default: |
2806 | abort (); | |
2807 | } | |
2808 | } | |
2809 | ||
2810 | #ifdef OBJ_ELF | |
2811 | fixp->fx_addnumber = value; | |
2812 | #else | |
2813 | if (fixp->fx_r_type != BFD_RELOC_PPC_TOC16) | |
2814 | fixp->fx_addnumber = 0; | |
2815 | else | |
2816 | { | |
2817 | /* We want to use the offset within the data segment of the | |
2818 | symbol, not the actual VMA of the symbol. */ | |
2819 | fixp->fx_addnumber = | |
2820 | - bfd_get_section_vma (stdoutput, S_GET_SEGMENT (fixp->fx_addsy)); | |
2821 | } | |
2822 | #endif | |
2823 | ||
2824 | return 1; | |
2825 | } | |
2826 | ||
2827 | /* Generate a reloc for a fixup. */ | |
2828 | ||
2829 | arelent * | |
2830 | tc_gen_reloc (seg, fixp) | |
2831 | asection *seg; | |
2832 | fixS *fixp; | |
2833 | { | |
2834 | arelent *reloc; | |
2835 | ||
2836 | reloc = (arelent *) bfd_alloc_by_size_t (stdoutput, sizeof (arelent)); | |
2837 | ||
2838 | reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym; | |
2839 | reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; | |
2840 | reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); | |
2841 | if (reloc->howto == (reloc_howto_type *) NULL) | |
2842 | { | |
2843 | as_bad_where (fixp->fx_file, fixp->fx_line, | |
4a6b2f8b | 2844 | "reloc %d not supported by object file format", (int)fixp->fx_r_type); |
882bdc69 ILT |
2845 | return NULL; |
2846 | } | |
2847 | reloc->addend = fixp->fx_addnumber; | |
2848 | ||
882bdc69 ILT |
2849 | return reloc; |
2850 | } |