| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#include <stdio.h> |
| 32 |
#include "as.h" |
| 33 |
#include "safe-ctype.h" |
| 34 |
#include "subsegs.h" |
| 35 |
#include "struc-symbol.h" |
| 36 |
|
| 37 |
#include "opcode/i370.h" |
| 38 |
|
| 39 |
#ifdef OBJ_ELF |
| 40 |
#include "elf/i370.h" |
| 41 |
#endif |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
extern int target_big_endian; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
#ifdef OBJ_ELF |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
static const char i370_eabi_comment_chars[] = "#"; |
| 58 |
|
| 59 |
const char *i370_comment_chars = i370_eabi_comment_chars; |
| 60 |
#else |
| 61 |
const char comment_chars[] = "#"; |
| 62 |
#endif |
| 63 |
|
| 64 |
|
| 65 |
const char line_comment_chars[] = "#*"; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
const char line_separator_chars[] = ";"; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
const char EXP_CHARS[] = "eE"; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
const char FLT_CHARS[] = "dD"; |
| 78 |
|
| 79 |
void |
| 80 |
md_show_usage (stream) |
| 81 |
FILE *stream; |
| 82 |
{ |
| 83 |
fprintf (stream, "\ |
| 84 |
S/370 options: (these have not yet been tested and may not work) \n\ |
| 85 |
-u ignored\n\ |
| 86 |
-mregnames Allow symbolic names for registers\n\ |
| 87 |
-mno-regnames Do not allow symbolic names for registers\n"); |
| 88 |
#ifdef OBJ_ELF |
| 89 |
fprintf (stream, "\ |
| 90 |
-mrelocatable support for GCC's -mrelocatble option\n\ |
| 91 |
-mrelocatable-lib support for GCC's -mrelocatble-lib option\n\ |
| 92 |
-V print assembler version number\n"); |
| 93 |
#endif |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
static void i370_byte PARAMS ((int)); |
| 98 |
static void i370_tc PARAMS ((int)); |
| 99 |
static void i370_ebcdic PARAMS ((int)); |
| 100 |
|
| 101 |
static void i370_dc PARAMS ((int)); |
| 102 |
static void i370_ds PARAMS ((int)); |
| 103 |
static void i370_rmode PARAMS ((int)); |
| 104 |
static void i370_csect PARAMS ((int)); |
| 105 |
static void i370_dsect PARAMS ((int)); |
| 106 |
static void i370_ltorg PARAMS ((int)); |
| 107 |
static void i370_using PARAMS ((int)); |
| 108 |
static void i370_drop PARAMS ((int)); |
| 109 |
static void i370_make_relative PARAMS ((expressionS *exp, expressionS *baseaddr)); |
| 110 |
|
| 111 |
#ifdef OBJ_ELF |
| 112 |
static bfd_reloc_code_real_type i370_elf_suffix PARAMS ((char **, expressionS *)); |
| 113 |
static void i370_elf_cons PARAMS ((int)); |
| 114 |
static void i370_elf_rdata PARAMS ((int)); |
| 115 |
static void i370_elf_lcomm PARAMS ((int)); |
| 116 |
static void i370_elf_validate_fix PARAMS ((fixS *, segT)); |
| 117 |
#endif |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
const pseudo_typeS md_pseudo_table[] = |
| 123 |
{ |
| 124 |
|
| 125 |
{ "byte", i370_byte, 0 }, |
| 126 |
|
| 127 |
{ "dc", i370_dc, 0 }, |
| 128 |
{ "ds", i370_ds, 0 }, |
| 129 |
{ "rmode", i370_rmode, 0 }, |
| 130 |
{ "csect", i370_csect, 0 }, |
| 131 |
{ "dsect", i370_dsect, 0 }, |
| 132 |
|
| 133 |
|
| 134 |
{ "ebcdic", i370_ebcdic, 0 }, |
| 135 |
|
| 136 |
#ifdef OBJ_ELF |
| 137 |
{ "long", i370_elf_cons, 4 }, |
| 138 |
{ "word", i370_elf_cons, 4 }, |
| 139 |
{ "short", i370_elf_cons, 2 }, |
| 140 |
{ "rdata", i370_elf_rdata, 0 }, |
| 141 |
{ "rodata", i370_elf_rdata, 0 }, |
| 142 |
{ "lcomm", i370_elf_lcomm, 0 }, |
| 143 |
#endif |
| 144 |
|
| 145 |
|
| 146 |
{ "tc", i370_tc, 0 }, |
| 147 |
|
| 148 |
|
| 149 |
{ "ltorg", i370_ltorg, 0 }, |
| 150 |
|
| 151 |
|
| 152 |
{ "using", i370_using, 0 }, |
| 153 |
{ "drop", i370_drop, 0 }, |
| 154 |
|
| 155 |
{ NULL, NULL, 0 } |
| 156 |
}; |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
#define TARGET_REG_NAMES_P TRUE |
| 162 |
|
| 163 |
static bfd_boolean reg_names_p = TARGET_REG_NAMES_P; |
| 164 |
|
| 165 |
static bfd_boolean register_name PARAMS ((expressionS *)); |
| 166 |
static void i370_set_cpu PARAMS ((void)); |
| 167 |
static i370_insn_t i370_insert_operand |
| 168 |
PARAMS ((i370_insn_t insn, const struct i370_operand *operand, offsetT val)); |
| 169 |
static void i370_macro PARAMS ((char *str, const struct i370_macro *macro)); |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
struct pd_reg |
| 177 |
{ |
| 178 |
char *name; |
| 179 |
int value; |
| 180 |
}; |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
static const struct pd_reg pre_defined_registers[] = |
| 208 |
{ |
| 209 |
{ "arg", 11 }, |
| 210 |
{ "base", 3 }, |
| 211 |
|
| 212 |
{ "f.0", 0 }, |
| 213 |
{ "f.2", 2 }, |
| 214 |
{ "f.4", 4 }, |
| 215 |
{ "f.6", 6 }, |
| 216 |
|
| 217 |
{ "f0", 0 }, |
| 218 |
{ "f2", 2 }, |
| 219 |
{ "f4", 4 }, |
| 220 |
{ "f6", 6 }, |
| 221 |
|
| 222 |
{ "dsa",13 }, |
| 223 |
{ "lr", 14 }, |
| 224 |
{ "pgt", 4 }, |
| 225 |
|
| 226 |
{ "r.0", 0 }, |
| 227 |
{ "r.1", 1 }, |
| 228 |
{ "r.10", 10 }, |
| 229 |
{ "r.11", 11 }, |
| 230 |
{ "r.12", 12 }, |
| 231 |
{ "r.13", 13 }, |
| 232 |
{ "r.14", 14 }, |
| 233 |
{ "r.15", 15 }, |
| 234 |
{ "r.2", 2 }, |
| 235 |
{ "r.3", 3 }, |
| 236 |
{ "r.4", 4 }, |
| 237 |
{ "r.5", 5 }, |
| 238 |
{ "r.6", 6 }, |
| 239 |
{ "r.7", 7 }, |
| 240 |
{ "r.8", 8 }, |
| 241 |
{ "r.9", 9 }, |
| 242 |
|
| 243 |
{ "r.arg", 11 }, |
| 244 |
{ "r.base", 3 }, |
| 245 |
{ "r.dsa", 13 }, |
| 246 |
{ "r.pgt", 4 }, |
| 247 |
{ "r.sp", 13 }, |
| 248 |
|
| 249 |
{ "r.tca", 12 }, |
| 250 |
{ "r.toc", 12 }, |
| 251 |
|
| 252 |
{ "r0", 0 }, |
| 253 |
{ "r1", 1 }, |
| 254 |
{ "r10", 10 }, |
| 255 |
{ "r11", 11 }, |
| 256 |
{ "r12", 12 }, |
| 257 |
{ "r13", 13 }, |
| 258 |
{ "r14", 14 }, |
| 259 |
{ "r15", 15 }, |
| 260 |
{ "r2", 2 }, |
| 261 |
{ "r3", 3 }, |
| 262 |
{ "r4", 4 }, |
| 263 |
{ "r5", 5 }, |
| 264 |
{ "r6", 6 }, |
| 265 |
{ "r7", 7 }, |
| 266 |
{ "r8", 8 }, |
| 267 |
{ "r9", 9 }, |
| 268 |
|
| 269 |
{ "rbase", 3 }, |
| 270 |
|
| 271 |
{ "rtca", 12 }, |
| 272 |
{ "rtoc", 12 }, |
| 273 |
|
| 274 |
{ "sp", 13 }, |
| 275 |
|
| 276 |
}; |
| 277 |
|
| 278 |
#define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg)) |
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
static int reg_name_search |
| 284 |
PARAMS ((const struct pd_reg *, int, const char * name)); |
| 285 |
|
| 286 |
static int |
| 287 |
reg_name_search (regs, regcount, name) |
| 288 |
const struct pd_reg *regs; |
| 289 |
int regcount; |
| 290 |
const char *name; |
| 291 |
{ |
| 292 |
int middle, low, high; |
| 293 |
int cmp; |
| 294 |
|
| 295 |
low = 0; |
| 296 |
high = regcount - 1; |
| 297 |
|
| 298 |
do |
| 299 |
{ |
| 300 |
middle = (low + high) / 2; |
| 301 |
cmp = strcasecmp (name, regs[middle].name); |
| 302 |
if (cmp < 0) |
| 303 |
high = middle - 1; |
| 304 |
else if (cmp > 0) |
| 305 |
low = middle + 1; |
| 306 |
else |
| 307 |
return regs[middle].value; |
| 308 |
} |
| 309 |
while (low <= high); |
| 310 |
|
| 311 |
return -1; |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
static bfd_boolean |
| 327 |
register_name (expressionP) |
| 328 |
expressionS *expressionP; |
| 329 |
{ |
| 330 |
int reg_number; |
| 331 |
char *name; |
| 332 |
char *start; |
| 333 |
char c; |
| 334 |
|
| 335 |
|
| 336 |
start = name = input_line_pointer; |
| 337 |
if (name[0] == '%' && ISALPHA (name[1])) |
| 338 |
name = ++input_line_pointer; |
| 339 |
|
| 340 |
else if (!reg_names_p) |
| 341 |
return FALSE; |
| 342 |
|
| 343 |
while (' ' == *name) |
| 344 |
name = ++input_line_pointer; |
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
if (!ISALPHA (name[0])) |
| 349 |
{ |
| 350 |
reg_number = get_single_number (); |
| 351 |
} |
| 352 |
else |
| 353 |
{ |
| 354 |
c = get_symbol_end (); |
| 355 |
reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT, name); |
| 356 |
|
| 357 |
|
| 358 |
*input_line_pointer = c; |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
if ((0 <= reg_number) && (16 >= reg_number)) |
| 363 |
{ |
| 364 |
expressionP->X_op = O_register; |
| 365 |
expressionP->X_add_number = reg_number; |
| 366 |
|
| 367 |
|
| 368 |
expressionP->X_add_symbol = NULL; |
| 369 |
expressionP->X_op_symbol = NULL; |
| 370 |
return TRUE; |
| 371 |
} |
| 372 |
|
| 373 |
|
| 374 |
input_line_pointer = start; |
| 375 |
return FALSE; |
| 376 |
} |
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
static int i370_cpu = 0; |
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
static int i370_using_text_regno = -1; |
| 404 |
static int i370_using_other_regno = -1; |
| 405 |
|
| 406 |
|
| 407 |
static expressionS i370_using_text_baseaddr; |
| 408 |
static expressionS i370_using_other_baseaddr; |
| 409 |
|
| 410 |
|
| 411 |
static segT i370_other_section = undefined_section; |
| 412 |
|
| 413 |
|
| 414 |
static struct hash_control *i370_hash; |
| 415 |
|
| 416 |
|
| 417 |
static struct hash_control *i370_macro_hash; |
| 418 |
|
| 419 |
#ifdef OBJ_ELF |
| 420 |
|
| 421 |
static enum { SHLIB_NONE, SHLIB_PIC, SHILB_MRELOCATABLE } shlib = SHLIB_NONE; |
| 422 |
#endif |
| 423 |
|
| 424 |
|
| 425 |
static flagword i370_flags = 0; |
| 426 |
|
| 427 |
#ifndef WORKING_DOT_WORD |
| 428 |
int md_short_jump_size = 4; |
| 429 |
int md_long_jump_size = 4; |
| 430 |
#endif |
| 431 |
|
| 432 |
#ifdef OBJ_ELF |
| 433 |
const char *md_shortopts = "l:um:K:VQ:"; |
| 434 |
#else |
| 435 |
const char *md_shortopts = "um:"; |
| 436 |
#endif |
| 437 |
struct option md_longopts[] = |
| 438 |
{ |
| 439 |
{NULL, no_argument, NULL, 0} |
| 440 |
}; |
| 441 |
size_t md_longopts_size = sizeof (md_longopts); |
| 442 |
|
| 443 |
int |
| 444 |
md_parse_option (c, arg) |
| 445 |
int c; |
| 446 |
char *arg; |
| 447 |
{ |
| 448 |
switch (c) |
| 449 |
{ |
| 450 |
case 'u': |
| 451 |
|
| 452 |
|
| 453 |
break; |
| 454 |
|
| 455 |
#ifdef OBJ_ELF |
| 456 |
case 'K': |
| 457 |
|
| 458 |
if (strcmp (arg, "PIC") == 0 || strcmp (arg, "pic") == 0) |
| 459 |
{ |
| 460 |
shlib = SHLIB_PIC; |
| 461 |
i370_flags |= EF_I370_RELOCATABLE_LIB; |
| 462 |
} |
| 463 |
else |
| 464 |
return 0; |
| 465 |
|
| 466 |
break; |
| 467 |
#endif |
| 468 |
|
| 469 |
case 'm': |
| 470 |
|
| 471 |
|
| 472 |
if (strcmp (arg, "360") == 0 || strcmp (arg, "i360") == 0) |
| 473 |
i370_cpu = I370_OPCODE_360; |
| 474 |
|
| 475 |
else if (strcmp (arg, "xa") == 0) |
| 476 |
i370_cpu = I370_OPCODE_370_XA; |
| 477 |
|
| 478 |
else if (strcmp (arg, "any") == 0) |
| 479 |
i370_cpu = I370_OPCODE_370; |
| 480 |
|
| 481 |
else if (strcmp (arg, "regnames") == 0) |
| 482 |
reg_names_p = TRUE; |
| 483 |
|
| 484 |
else if (strcmp (arg, "no-regnames") == 0) |
| 485 |
reg_names_p = FALSE; |
| 486 |
|
| 487 |
#ifdef OBJ_ELF |
| 488 |
|
| 489 |
else if (strcmp (arg, "relocatable") == 0) |
| 490 |
{ |
| 491 |
shlib = SHILB_MRELOCATABLE; |
| 492 |
i370_flags |= EF_I370_RELOCATABLE; |
| 493 |
} |
| 494 |
|
| 495 |
else if (strcmp (arg, "relocatable-lib") == 0) |
| 496 |
{ |
| 497 |
shlib = SHILB_MRELOCATABLE; |
| 498 |
i370_flags |= EF_I370_RELOCATABLE_LIB; |
| 499 |
} |
| 500 |
|
| 501 |
#endif |
| 502 |
else |
| 503 |
{ |
| 504 |
as_bad ("invalid switch -m%s", arg); |
| 505 |
return 0; |
| 506 |
} |
| 507 |
break; |
| 508 |
|
| 509 |
#ifdef OBJ_ELF |
| 510 |
|
| 511 |
case 'V': |
| 512 |
print_version_id (); |
| 513 |
break; |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
case 'Q': |
| 518 |
break; |
| 519 |
|
| 520 |
#endif |
| 521 |
|
| 522 |
default: |
| 523 |
return 0; |
| 524 |
} |
| 525 |
|
| 526 |
return 1; |
| 527 |
} |
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
static void |
| 535 |
i370_set_cpu () |
| 536 |
{ |
| 537 |
const char *default_os = TARGET_OS; |
| 538 |
const char *default_cpu = TARGET_CPU; |
| 539 |
|
| 540 |
|
| 541 |
i370_cpu = I370_OPCODE_ESA390_SUPERSET; |
| 542 |
if (i370_cpu == 0) |
| 543 |
{ |
| 544 |
if (strcmp (default_cpu, "i360") == 0) |
| 545 |
i370_cpu = I370_OPCODE_360; |
| 546 |
else if (strcmp (default_cpu, "i370") == 0) |
| 547 |
i370_cpu = I370_OPCODE_370; |
| 548 |
else if (strcmp (default_cpu, "XA") == 0) |
| 549 |
i370_cpu = I370_OPCODE_370_XA; |
| 550 |
else |
| 551 |
as_fatal ("Unknown default cpu = %s, os = %s", default_cpu, default_os); |
| 552 |
} |
| 553 |
} |
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
enum bfd_architecture |
| 559 |
i370_arch () |
| 560 |
{ |
| 561 |
return bfd_arch_i370; |
| 562 |
} |
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
void |
| 569 |
md_begin () |
| 570 |
{ |
| 571 |
register const struct i370_opcode *op; |
| 572 |
const struct i370_opcode *op_end; |
| 573 |
const struct i370_macro *macro; |
| 574 |
const struct i370_macro *macro_end; |
| 575 |
bfd_boolean dup_insn = FALSE; |
| 576 |
|
| 577 |
i370_set_cpu (); |
| 578 |
|
| 579 |
#ifdef OBJ_ELF |
| 580 |
|
| 581 |
if (i370_flags) |
| 582 |
bfd_set_private_flags (stdoutput, i370_flags); |
| 583 |
#endif |
| 584 |
|
| 585 |
|
| 586 |
i370_hash = hash_new (); |
| 587 |
|
| 588 |
op_end = i370_opcodes + i370_num_opcodes; |
| 589 |
for (op = i370_opcodes; op < op_end; op++) |
| 590 |
{ |
| 591 |
know ((op->opcode.i[0] & op->mask.i[0]) == op->opcode.i[0] |
| 592 |
&& (op->opcode.i[1] & op->mask.i[1]) == op->opcode.i[1]); |
| 593 |
|
| 594 |
if ((op->flags & i370_cpu) != 0) |
| 595 |
{ |
| 596 |
const char *retval; |
| 597 |
|
| 598 |
retval = hash_insert (i370_hash, op->name, (PTR) op); |
| 599 |
if (retval != (const char *) NULL) |
| 600 |
{ |
| 601 |
as_bad ("Internal assembler error for instruction %s", op->name); |
| 602 |
dup_insn = TRUE; |
| 603 |
} |
| 604 |
} |
| 605 |
} |
| 606 |
|
| 607 |
|
| 608 |
i370_macro_hash = hash_new (); |
| 609 |
|
| 610 |
macro_end = i370_macros + i370_num_macros; |
| 611 |
for (macro = i370_macros; macro < macro_end; macro++) |
| 612 |
{ |
| 613 |
if ((macro->flags & i370_cpu) != 0) |
| 614 |
{ |
| 615 |
const char *retval; |
| 616 |
|
| 617 |
retval = hash_insert (i370_macro_hash, macro->name, (PTR) macro); |
| 618 |
if (retval != (const char *) NULL) |
| 619 |
{ |
| 620 |
as_bad ("Internal assembler error for macro %s", macro->name); |
| 621 |
dup_insn = TRUE; |
| 622 |
} |
| 623 |
} |
| 624 |
} |
| 625 |
|
| 626 |
if (dup_insn) |
| 627 |
abort (); |
| 628 |
} |
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
static i370_insn_t |
| 633 |
i370_insert_operand (insn, operand, val) |
| 634 |
i370_insn_t insn; |
| 635 |
const struct i370_operand *operand; |
| 636 |
offsetT val; |
| 637 |
{ |
| 638 |
if (operand->insert) |
| 639 |
{ |
| 640 |
const char *errmsg; |
| 641 |
|
| 642 |
|
| 643 |
errmsg = NULL; |
| 644 |
insn = (*operand->insert) (insn, (long) val, &errmsg); |
| 645 |
if (errmsg) |
| 646 |
as_bad ("%s", errmsg); |
| 647 |
} |
| 648 |
else |
| 649 |
{ |
| 650 |
|
| 651 |
insn.i[0] |= (((long) val & ((1 << operand->bits) - 1)) |
| 652 |
<< operand->shift); |
| 653 |
} |
| 654 |
|
| 655 |
return insn; |
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
#ifdef OBJ_ELF |
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
static bfd_reloc_code_real_type |
| 669 |
i370_elf_suffix (str_p, exp_p) |
| 670 |
char **str_p; |
| 671 |
expressionS *exp_p; |
| 672 |
{ |
| 673 |
struct map_bfd |
| 674 |
{ |
| 675 |
char *string; |
| 676 |
int length; |
| 677 |
bfd_reloc_code_real_type reloc; |
| 678 |
}; |
| 679 |
|
| 680 |
char ident[20]; |
| 681 |
char *str = *str_p; |
| 682 |
char *str2; |
| 683 |
int ch; |
| 684 |
int len; |
| 685 |
struct map_bfd *ptr; |
| 686 |
|
| 687 |
#define MAP(str,reloc) { str, sizeof (str)-1, reloc } |
| 688 |
|
| 689 |
static struct map_bfd mapping[] = |
| 690 |
{ |
| 691 |
|
| 692 |
MAP ("fixup", BFD_RELOC_CTOR), |
| 693 |
{ (char *)0, 0, BFD_RELOC_UNUSED } |
| 694 |
}; |
| 695 |
|
| 696 |
if (*str++ != '@') |
| 697 |
return BFD_RELOC_UNUSED; |
| 698 |
|
| 699 |
for (ch = *str, str2 = ident; |
| 700 |
(str2 < ident + sizeof (ident) - 1 |
| 701 |
&& (ISALNUM (ch) || ch == '@')); |
| 702 |
ch = *++str) |
| 703 |
{ |
| 704 |
*str2++ = TOLOWER (ch); |
| 705 |
} |
| 706 |
|
| 707 |
*str2 = '\0'; |
| 708 |
len = str2 - ident; |
| 709 |
|
| 710 |
ch = ident[0]; |
| 711 |
for (ptr = &mapping[0]; ptr->length > 0; ptr++) |
| 712 |
if (ch == ptr->string[0] |
| 713 |
&& len == ptr->length |
| 714 |
&& memcmp (ident, ptr->string, ptr->length) == 0) |
| 715 |
{ |
| 716 |
if (exp_p->X_add_number != 0 |
| 717 |
&& (ptr->reloc == BFD_RELOC_16_GOTOFF |
| 718 |
|| ptr->reloc == BFD_RELOC_LO16_GOTOFF |
| 719 |
|| ptr->reloc == BFD_RELOC_HI16_GOTOFF |
| 720 |
|| ptr->reloc == BFD_RELOC_HI16_S_GOTOFF)) |
| 721 |
as_warn ("identifier+constant@got means identifier@got+constant"); |
| 722 |
|
| 723 |
|
| 724 |
if (*str == '-' || *str == '+') |
| 725 |
{ |
| 726 |
char *orig_line = input_line_pointer; |
| 727 |
expressionS new_exp; |
| 728 |
|
| 729 |
input_line_pointer = str; |
| 730 |
expression (&new_exp); |
| 731 |
if (new_exp.X_op == O_constant) |
| 732 |
{ |
| 733 |
exp_p->X_add_number += new_exp.X_add_number; |
| 734 |
str = input_line_pointer; |
| 735 |
} |
| 736 |
|
| 737 |
if (&input_line_pointer != str_p) |
| 738 |
input_line_pointer = orig_line; |
| 739 |
} |
| 740 |
|
| 741 |
*str_p = str; |
| 742 |
return ptr->reloc; |
| 743 |
} |
| 744 |
|
| 745 |
return BFD_RELOC_UNUSED; |
| 746 |
} |
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
static void |
| 751 |
i370_elf_cons (nbytes) |
| 752 |
register int nbytes; |
| 753 |
{ |
| 754 |
expressionS exp; |
| 755 |
bfd_reloc_code_real_type reloc; |
| 756 |
|
| 757 |
if (is_it_end_of_statement ()) |
| 758 |
{ |
| 759 |
demand_empty_rest_of_line (); |
| 760 |
return; |
| 761 |
} |
| 762 |
|
| 763 |
do |
| 764 |
{ |
| 765 |
expression (&exp); |
| 766 |
if (exp.X_op == O_symbol |
| 767 |
&& *input_line_pointer == '@' |
| 768 |
&& (reloc = i370_elf_suffix (&input_line_pointer, &exp)) != BFD_RELOC_UNUSED) |
| 769 |
{ |
| 770 |
reloc_howto_type *reloc_howto = bfd_reloc_type_lookup (stdoutput, reloc); |
| 771 |
int size = bfd_get_reloc_size (reloc_howto); |
| 772 |
|
| 773 |
if (size > nbytes) |
| 774 |
as_bad ("%s relocations do not fit in %d bytes\n", reloc_howto->name, nbytes); |
| 775 |
|
| 776 |
else |
| 777 |
{ |
| 778 |
register char *p = frag_more ((int) nbytes); |
| 779 |
int offset = nbytes - size; |
| 780 |
|
| 781 |
fix_new_exp (frag_now, p - frag_now->fr_literal + offset, size, &exp, 0, reloc); |
| 782 |
} |
| 783 |
} |
| 784 |
else |
| 785 |
emit_expr (&exp, (unsigned int) nbytes); |
| 786 |
} |
| 787 |
while (*input_line_pointer++ == ','); |
| 788 |
|
| 789 |
input_line_pointer--; |
| 790 |
demand_empty_rest_of_line (); |
| 791 |
} |
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
static unsigned char ascebc[256] = |
| 796 |
{ |
| 797 |
|
| 798 |
0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, |
| 799 |
|
| 800 |
0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
| 801 |
|
| 802 |
0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, |
| 803 |
|
| 804 |
0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, |
| 805 |
|
| 806 |
0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, |
| 807 |
|
| 808 |
0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, |
| 809 |
|
| 810 |
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, |
| 811 |
|
| 812 |
0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, |
| 813 |
|
| 814 |
0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, |
| 815 |
|
| 816 |
0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, |
| 817 |
|
| 818 |
0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, |
| 819 |
|
| 820 |
0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, |
| 821 |
|
| 822 |
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, |
| 823 |
|
| 824 |
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, |
| 825 |
|
| 826 |
0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, |
| 827 |
|
| 828 |
0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, |
| 829 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 830 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 831 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 832 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 833 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 834 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 835 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 836 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 837 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 838 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 839 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 840 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 841 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 842 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 843 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 844 |
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF |
| 845 |
}; |
| 846 |
|
| 847 |
|
| 848 |
unsigned char ebcasc[256] = |
| 849 |
{ |
| 850 |
|
| 851 |
0x00, 0x01, 0x02, 0x03, 0x00, 0x09, 0x00, 0x7F, |
| 852 |
|
| 853 |
0x00, 0x00, 0x00, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
| 854 |
|
| 855 |
0x10, 0x11, 0x12, 0x13, 0x14, 0x0A, 0x08, 0x00, |
| 856 |
|
| 857 |
0x18, 0x19, 0x00, 0x00, 0x1C, 0x1D, 0x1E, 0x1F, |
| 858 |
|
| 859 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x17, 0x1B, |
| 860 |
|
| 861 |
0x00, 0x00, 0x00, 0x00, 0x05, 0x06, 0x07, 0x00, |
| 862 |
|
| 863 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, |
| 864 |
|
| 865 |
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x00, 0x1A, |
| 866 |
|
| 867 |
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 868 |
|
| 869 |
0x00, 0x00, 0x00, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, |
| 870 |
|
| 871 |
0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 872 |
|
| 873 |
0x00, 0x00, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, |
| 874 |
|
| 875 |
0x2D, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 876 |
|
| 877 |
0x00, 0x00, 0x00, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, |
| 878 |
|
| 879 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 880 |
|
| 881 |
0x00, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, |
| 882 |
|
| 883 |
0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, |
| 884 |
|
| 885 |
0x68, 0x69, 0x00, 0x7B, 0x00, 0x00, 0x00, 0x00, |
| 886 |
|
| 887 |
0x00, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, |
| 888 |
|
| 889 |
0x71, 0x72, 0x00, 0x7D, 0x00, 0x00, 0x00, 0x00, |
| 890 |
|
| 891 |
0x00, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, |
| 892 |
|
| 893 |
0x79, 0x7A, 0x00, 0x00, 0x00, 0x5B, 0x00, 0x00, |
| 894 |
|
| 895 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 896 |
|
| 897 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, |
| 898 |
|
| 899 |
0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, |
| 900 |
|
| 901 |
0x48, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 902 |
|
| 903 |
0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, |
| 904 |
|
| 905 |
0x51, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 906 |
|
| 907 |
0x5C, 0x00, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, |
| 908 |
|
| 909 |
0x59, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 910 |
|
| 911 |
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, |
| 912 |
|
| 913 |
0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF |
| 914 |
}; |
| 915 |
|
| 916 |
|
| 917 |
static void |
| 918 |
i370_ebcdic (unused) |
| 919 |
int unused ATTRIBUTE_UNUSED; |
| 920 |
{ |
| 921 |
char *p, *end; |
| 922 |
char delim = 0; |
| 923 |
size_t nbytes; |
| 924 |
|
| 925 |
nbytes = strlen (input_line_pointer); |
| 926 |
end = input_line_pointer + nbytes; |
| 927 |
while ('\r' == *end) end --; |
| 928 |
while ('\n' == *end) end --; |
| 929 |
|
| 930 |
delim = *input_line_pointer; |
| 931 |
if (('\'' == delim) || ('\"' == delim)) { |
| 932 |
input_line_pointer ++; |
| 933 |
end = rindex (input_line_pointer, delim); |
| 934 |
} |
| 935 |
|
| 936 |
if (end > input_line_pointer) |
| 937 |
{ |
| 938 |
nbytes = end - input_line_pointer +1; |
| 939 |
p = frag_more (nbytes); |
| 940 |
while (end > input_line_pointer) |
| 941 |
{ |
| 942 |
*p = ascebc [(unsigned char) (*input_line_pointer)]; |
| 943 |
++p; ++input_line_pointer; |
| 944 |
} |
| 945 |
*p = '\0'; |
| 946 |
} |
| 947 |
if (delim == *input_line_pointer) ++input_line_pointer; |
| 948 |
} |
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
static void |
| 953 |
i370_rmode (unused) |
| 954 |
int unused ATTRIBUTE_UNUSED; |
| 955 |
{ |
| 956 |
as_tsktsk ("rmode ignored"); |
| 957 |
} |
| 958 |
|
| 959 |
static void |
| 960 |
i370_dsect (sect) |
| 961 |
int sect; |
| 962 |
{ |
| 963 |
char *save_line = input_line_pointer; |
| 964 |
static char section[] = ".data\n"; |
| 965 |
|
| 966 |
|
| 967 |
input_line_pointer = section; |
| 968 |
obj_elf_section (sect); |
| 969 |
|
| 970 |
input_line_pointer = save_line; |
| 971 |
} |
| 972 |
|
| 973 |
static void |
| 974 |
i370_csect (unused) |
| 975 |
int unused ATTRIBUTE_UNUSED; |
| 976 |
{ |
| 977 |
as_tsktsk ("csect not supported"); |
| 978 |
} |
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
static void |
| 988 |
i370_dc (unused) |
| 989 |
int unused ATTRIBUTE_UNUSED; |
| 990 |
{ |
| 991 |
char * p, tmp[50]; |
| 992 |
int nbytes=0; |
| 993 |
expressionS exp; |
| 994 |
char type=0; |
| 995 |
|
| 996 |
if (is_it_end_of_statement ()) |
| 997 |
{ |
| 998 |
demand_empty_rest_of_line (); |
| 999 |
return; |
| 1000 |
} |
| 1001 |
|
| 1002 |
|
| 1003 |
type = *input_line_pointer++; |
| 1004 |
switch (type) |
| 1005 |
{ |
| 1006 |
case 'H': |
| 1007 |
nbytes = 2; |
| 1008 |
break; |
| 1009 |
case 'E': |
| 1010 |
case 'F': |
| 1011 |
nbytes = 4; |
| 1012 |
break; |
| 1013 |
case 'D': |
| 1014 |
nbytes = 8; |
| 1015 |
break; |
| 1016 |
default: |
| 1017 |
as_bad ("unsupported DC type"); |
| 1018 |
return; |
| 1019 |
} |
| 1020 |
|
| 1021 |
|
| 1022 |
if ('\'' == *input_line_pointer) |
| 1023 |
{ |
| 1024 |
char * close; |
| 1025 |
++input_line_pointer; |
| 1026 |
close = strchr (input_line_pointer, '\''); |
| 1027 |
if (close) |
| 1028 |
*close= ' '; |
| 1029 |
else |
| 1030 |
as_bad ("missing end-quote"); |
| 1031 |
} |
| 1032 |
if ('\"' == *input_line_pointer) |
| 1033 |
{ |
| 1034 |
char * close; |
| 1035 |
++input_line_pointer; |
| 1036 |
close = strchr (input_line_pointer, '\"'); |
| 1037 |
if (close) |
| 1038 |
*close= ' '; |
| 1039 |
else |
| 1040 |
as_bad ("missing end-quote"); |
| 1041 |
} |
| 1042 |
|
| 1043 |
switch (type) |
| 1044 |
{ |
| 1045 |
case 'H': |
| 1046 |
case 'F': |
| 1047 |
expression (&exp); |
| 1048 |
emit_expr (&exp, nbytes); |
| 1049 |
break; |
| 1050 |
case 'E': |
| 1051 |
case 'D': |
| 1052 |
md_atof (type, tmp, &nbytes); |
| 1053 |
p = frag_more (nbytes); |
| 1054 |
memcpy (p, tmp, nbytes); |
| 1055 |
break; |
| 1056 |
default: |
| 1057 |
as_bad ("unsupported DC type"); |
| 1058 |
return; |
| 1059 |
} |
| 1060 |
|
| 1061 |
demand_empty_rest_of_line (); |
| 1062 |
} |
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
static void |
| 1067 |
i370_ds (unused) |
| 1068 |
int unused ATTRIBUTE_UNUSED; |
| 1069 |
{ |
| 1070 |
|
| 1071 |
if ('0' == *input_line_pointer) |
| 1072 |
{ |
| 1073 |
int alignment = 0; |
| 1074 |
input_line_pointer ++; |
| 1075 |
switch (*input_line_pointer++) |
| 1076 |
{ |
| 1077 |
case 'H': |
| 1078 |
alignment = 1; |
| 1079 |
break; |
| 1080 |
case 'F': |
| 1081 |
alignment = 2; |
| 1082 |
break; |
| 1083 |
case 'D': |
| 1084 |
alignment = 3; |
| 1085 |
break; |
| 1086 |
default: |
| 1087 |
as_bad ("unsupported alignment"); |
| 1088 |
return; |
| 1089 |
} |
| 1090 |
frag_align (alignment, 0, 0); |
| 1091 |
record_alignment (now_seg, alignment); |
| 1092 |
} |
| 1093 |
else |
| 1094 |
{ |
| 1095 |
as_bad ("this DS form not yet supported"); |
| 1096 |
} |
| 1097 |
} |
| 1098 |
|
| 1099 |
|
| 1100 |
static void |
| 1101 |
i370_elf_rdata (sect) |
| 1102 |
int sect; |
| 1103 |
{ |
| 1104 |
char *save_line = input_line_pointer; |
| 1105 |
static char section[] = ".rodata\n"; |
| 1106 |
|
| 1107 |
|
| 1108 |
input_line_pointer = section; |
| 1109 |
obj_elf_section (sect); |
| 1110 |
|
| 1111 |
input_line_pointer = save_line; |
| 1112 |
} |
| 1113 |
|
| 1114 |
|
| 1115 |
static void |
| 1116 |
i370_elf_lcomm (unused) |
| 1117 |
int unused ATTRIBUTE_UNUSED; |
| 1118 |
{ |
| 1119 |
register char *name; |
| 1120 |
register char c; |
| 1121 |
register char *p; |
| 1122 |
offsetT size; |
| 1123 |
register symbolS *symbolP; |
| 1124 |
offsetT align; |
| 1125 |
segT old_sec; |
| 1126 |
int old_subsec; |
| 1127 |
char *pfrag; |
| 1128 |
int align2; |
| 1129 |
|
| 1130 |
name = input_line_pointer; |
| 1131 |
c = get_symbol_end (); |
| 1132 |
|
| 1133 |
|
| 1134 |
p = input_line_pointer; |
| 1135 |
*p = c; |
| 1136 |
SKIP_WHITESPACE (); |
| 1137 |
if (*input_line_pointer != ',') |
| 1138 |
{ |
| 1139 |
as_bad ("Expected comma after symbol-name: rest of line ignored."); |
| 1140 |
ignore_rest_of_line (); |
| 1141 |
return; |
| 1142 |
} |
| 1143 |
|
| 1144 |
input_line_pointer++; |
| 1145 |
if ((size = get_absolute_expression ()) < 0) |
| 1146 |
{ |
| 1147 |
as_warn (".COMMon length (%ld.) <0! Ignored.", (long) size); |
| 1148 |
ignore_rest_of_line (); |
| 1149 |
return; |
| 1150 |
} |
| 1151 |
|
| 1152 |
|
| 1153 |
if (*input_line_pointer != ',') |
| 1154 |
align = 8; |
| 1155 |
else |
| 1156 |
{ |
| 1157 |
++input_line_pointer; |
| 1158 |
align = get_absolute_expression (); |
| 1159 |
if (align <= 0) |
| 1160 |
{ |
| 1161 |
as_warn ("ignoring bad alignment"); |
| 1162 |
align = 8; |
| 1163 |
} |
| 1164 |
} |
| 1165 |
|
| 1166 |
*p = 0; |
| 1167 |
symbolP = symbol_find_or_make (name); |
| 1168 |
*p = c; |
| 1169 |
|
| 1170 |
if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP)) |
| 1171 |
{ |
| 1172 |
as_bad ("Ignoring attempt to re-define symbol `%s'.", |
| 1173 |
S_GET_NAME (symbolP)); |
| 1174 |
ignore_rest_of_line (); |
| 1175 |
return; |
| 1176 |
} |
| 1177 |
|
| 1178 |
if (S_GET_VALUE (symbolP) && S_GET_VALUE (symbolP) != (valueT) size) |
| 1179 |
{ |
| 1180 |
as_bad ("Length of .lcomm \"%s\" is already %ld. Not changed to %ld.", |
| 1181 |
S_GET_NAME (symbolP), |
| 1182 |
(long) S_GET_VALUE (symbolP), |
| 1183 |
(long) size); |
| 1184 |
|
| 1185 |
ignore_rest_of_line (); |
| 1186 |
return; |
| 1187 |
} |
| 1188 |
|
| 1189 |
|
| 1190 |
old_sec = now_seg; |
| 1191 |
old_subsec = now_subseg; |
| 1192 |
if (align) |
| 1193 |
{ |
| 1194 |
|
| 1195 |
for (align2 = 0; (align & 1) == 0; align >>= 1, ++align2) |
| 1196 |
; |
| 1197 |
if (align != 1) |
| 1198 |
{ |
| 1199 |
as_bad ("Common alignment not a power of 2"); |
| 1200 |
ignore_rest_of_line (); |
| 1201 |
return; |
| 1202 |
} |
| 1203 |
} |
| 1204 |
else |
| 1205 |
align2 = 0; |
| 1206 |
|
| 1207 |
record_alignment (bss_section, align2); |
| 1208 |
subseg_set (bss_section, 0); |
| 1209 |
if (align2) |
| 1210 |
frag_align (align2, 0, 0); |
| 1211 |
if (S_GET_SEGMENT (symbolP) == bss_section) |
| 1212 |
symbol_get_frag (symbolP)->fr_symbol = 0; |
| 1213 |
symbol_set_frag (symbolP, frag_now); |
| 1214 |
pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size, |
| 1215 |
(char *) 0); |
| 1216 |
*pfrag = 0; |
| 1217 |
S_SET_SIZE (symbolP, size); |
| 1218 |
S_SET_SEGMENT (symbolP, bss_section); |
| 1219 |
subseg_set (old_sec, old_subsec); |
| 1220 |
demand_empty_rest_of_line (); |
| 1221 |
} |
| 1222 |
|
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
static void |
| 1227 |
i370_elf_validate_fix (fixp, seg) |
| 1228 |
fixS *fixp; |
| 1229 |
segT seg; |
| 1230 |
{ |
| 1231 |
if (fixp->fx_done || fixp->fx_pcrel) |
| 1232 |
return; |
| 1233 |
|
| 1234 |
switch (shlib) |
| 1235 |
{ |
| 1236 |
case SHLIB_NONE: |
| 1237 |
case SHLIB_PIC: |
| 1238 |
return; |
| 1239 |
|
| 1240 |
case SHILB_MRELOCATABLE: |
| 1241 |
if (fixp->fx_r_type <= BFD_RELOC_UNUSED |
| 1242 |
&& fixp->fx_r_type != BFD_RELOC_16_GOTOFF |
| 1243 |
&& fixp->fx_r_type != BFD_RELOC_HI16_GOTOFF |
| 1244 |
&& fixp->fx_r_type != BFD_RELOC_LO16_GOTOFF |
| 1245 |
&& fixp->fx_r_type != BFD_RELOC_HI16_S_GOTOFF |
| 1246 |
&& fixp->fx_r_type != BFD_RELOC_32_BASEREL |
| 1247 |
&& fixp->fx_r_type != BFD_RELOC_LO16_BASEREL |
| 1248 |
&& fixp->fx_r_type != BFD_RELOC_HI16_BASEREL |
| 1249 |
&& fixp->fx_r_type != BFD_RELOC_HI16_S_BASEREL |
| 1250 |
&& strcmp (segment_name (seg), ".got2") != 0 |
| 1251 |
&& strcmp (segment_name (seg), ".dtors") != 0 |
| 1252 |
&& strcmp (segment_name (seg), ".ctors") != 0 |
| 1253 |
&& strcmp (segment_name (seg), ".fixup") != 0 |
| 1254 |
&& strcmp (segment_name (seg), ".stab") != 0 |
| 1255 |
&& strcmp (segment_name (seg), ".gcc_except_table") != 0 |
| 1256 |
&& strcmp (segment_name (seg), ".ex_shared") != 0) |
| 1257 |
{ |
| 1258 |
if ((seg->flags & (SEC_READONLY | SEC_CODE)) != 0 |
| 1259 |
|| fixp->fx_r_type != BFD_RELOC_CTOR) |
| 1260 |
{ |
| 1261 |
as_bad_where (fixp->fx_file, fixp->fx_line, |
| 1262 |
"Relocation cannot be done when using -mrelocatable"); |
| 1263 |
} |
| 1264 |
} |
| 1265 |
return; |
| 1266 |
} |
| 1267 |
} |
| 1268 |
#endif |
| 1269 |
|
| 1270 |
|
| 1271 |
#define LITERAL_POOL_SUPPORT |
| 1272 |
#ifdef LITERAL_POOL_SUPPORT |
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
#define MAX_LITERAL_POOL_SIZE 1024 |
| 1289 |
|
| 1290 |
typedef struct literalS |
| 1291 |
{ |
| 1292 |
struct expressionS exp; |
| 1293 |
char * sym_name; |
| 1294 |
char size; |
| 1295 |
short offset; |
| 1296 |
} literalT; |
| 1297 |
|
| 1298 |
literalT literals[MAX_LITERAL_POOL_SIZE]; |
| 1299 |
int next_literal_pool_place = 0; |
| 1300 |
|
| 1301 |
static symbolS *longlong_poolP = NULL; |
| 1302 |
static symbolS *word_poolP = NULL; |
| 1303 |
static symbolS *short_poolP = NULL; |
| 1304 |
static symbolS *byte_poolP = NULL; |
| 1305 |
|
| 1306 |
static int lit_pool_num = 1; |
| 1307 |
|
| 1308 |
|
| 1309 |
static symbolS * |
| 1310 |
symbol_make_empty (void) |
| 1311 |
{ |
| 1312 |
return symbol_create (FAKE_LABEL_NAME, undefined_section, |
| 1313 |
(valueT) 0, &zero_address_frag); |
| 1314 |
} |
| 1315 |
|
| 1316 |
|
| 1317 |
static void |
| 1318 |
add_to_lit_pool (expressionS *exx, char *name, int sz) |
| 1319 |
{ |
| 1320 |
int lit_count = 0; |
| 1321 |
int offset_in_pool = 0; |
| 1322 |
|
| 1323 |
|
| 1324 |
if (8 == sz && NULL == longlong_poolP) |
| 1325 |
longlong_poolP = symbol_make_empty (); |
| 1326 |
else if (4 == sz && NULL == word_poolP) |
| 1327 |
word_poolP = symbol_make_empty (); |
| 1328 |
else if (2 == sz && NULL == short_poolP) |
| 1329 |
short_poolP = symbol_make_empty (); |
| 1330 |
else if (1 == sz && NULL == byte_poolP) |
| 1331 |
byte_poolP = symbol_make_empty (); |
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
while (lit_count < next_literal_pool_place) |
| 1340 |
{ |
| 1341 |
if (exx->X_op == O_constant |
| 1342 |
&& literals[lit_count].exp.X_op == exx->X_op |
| 1343 |
&& literals[lit_count].exp.X_add_number == exx->X_add_number |
| 1344 |
&& literals[lit_count].exp.X_unsigned == exx->X_unsigned |
| 1345 |
&& literals[lit_count].size == sz) |
| 1346 |
break; |
| 1347 |
else if (literals[lit_count].sym_name |
| 1348 |
&& name |
| 1349 |
&& !strcmp (name, literals[lit_count].sym_name)) |
| 1350 |
break; |
| 1351 |
if (sz == literals[lit_count].size) |
| 1352 |
offset_in_pool += sz; |
| 1353 |
lit_count ++; |
| 1354 |
} |
| 1355 |
|
| 1356 |
if (lit_count == next_literal_pool_place) |
| 1357 |
{ |
| 1358 |
if (next_literal_pool_place > MAX_LITERAL_POOL_SIZE) |
| 1359 |
{ |
| 1360 |
as_bad ("Literal Pool Overflow"); |
| 1361 |
} |
| 1362 |
|
| 1363 |
literals[next_literal_pool_place].exp = *exx; |
| 1364 |
literals[next_literal_pool_place].size = sz; |
| 1365 |
literals[next_literal_pool_place].offset = offset_in_pool; |
| 1366 |
if (name) |
| 1367 |
{ |
| 1368 |
literals[next_literal_pool_place].sym_name = strdup (name); |
| 1369 |
} |
| 1370 |
else |
| 1371 |
{ |
| 1372 |
literals[next_literal_pool_place].sym_name = NULL; |
| 1373 |
} |
| 1374 |
next_literal_pool_place++; |
| 1375 |
} |
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
if (8 == sz) |
| 1384 |
exx->X_add_symbol = longlong_poolP; |
| 1385 |
else if (4 == sz) |
| 1386 |
exx->X_add_symbol = word_poolP; |
| 1387 |
else if (2 == sz) |
| 1388 |
exx->X_add_symbol = short_poolP; |
| 1389 |
else if (1 == sz) |
| 1390 |
exx->X_add_symbol = byte_poolP; |
| 1391 |
exx->X_add_number = offset_in_pool; |
| 1392 |
exx->X_op_symbol = NULL; |
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
if (0 < i370_using_other_regno) |
| 1397 |
{ |
| 1398 |
i370_make_relative (exx, &i370_using_other_baseaddr); |
| 1399 |
} |
| 1400 |
else |
| 1401 |
{ |
| 1402 |
i370_make_relative (exx, &i370_using_text_baseaddr); |
| 1403 |
} |
| 1404 |
} |
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
static void symbol_locate |
| 1416 |
PARAMS ((symbolS *, const char *, segT, valueT, fragS *)); |
| 1417 |
|
| 1418 |
static void |
| 1419 |
symbol_locate (symbolP, name, segment, valu, frag) |
| 1420 |
symbolS *symbolP; |
| 1421 |
const char *name; |
| 1422 |
segT segment; |
| 1423 |
valueT valu; |
| 1424 |
fragS *frag; |
| 1425 |
{ |
| 1426 |
size_t name_length; |
| 1427 |
char *preserved_copy_of_name; |
| 1428 |
|
| 1429 |
name_length = strlen (name) + 1; |
| 1430 |
obstack_grow (¬es, name, name_length); |
| 1431 |
preserved_copy_of_name = obstack_finish (¬es); |
| 1432 |
|
| 1433 |
S_SET_NAME (symbolP, preserved_copy_of_name); |
| 1434 |
|
| 1435 |
S_SET_SEGMENT (symbolP, segment); |
| 1436 |
S_SET_VALUE (symbolP, valu); |
| 1437 |
symbol_clear_list_pointers (symbolP); |
| 1438 |
|
| 1439 |
symbol_set_frag (symbolP, frag); |
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
{ |
| 1445 |
extern int symbol_table_frozen; |
| 1446 |
if (symbol_table_frozen) |
| 1447 |
abort (); |
| 1448 |
} |
| 1449 |
|
| 1450 |
symbol_append (symbolP, symbol_lastP, &symbol_rootP, &symbol_lastP); |
| 1451 |
|
| 1452 |
obj_symbol_new_hook (symbolP); |
| 1453 |
|
| 1454 |
#ifdef tc_symbol_new_hook |
| 1455 |
tc_symbol_new_hook (symbolP); |
| 1456 |
#endif |
| 1457 |
|
| 1458 |
#define DEBUG_SYMS |
| 1459 |
#ifdef DEBUG_SYMS |
| 1460 |
verify_symbol_chain(symbol_rootP, symbol_lastP); |
| 1461 |
#endif |
| 1462 |
} |
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
static bfd_boolean |
| 1480 |
i370_addr_offset (expressionS *exx) |
| 1481 |
{ |
| 1482 |
char *dot, *lab; |
| 1483 |
int islabel = 0; |
| 1484 |
int all_digits = 0; |
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
lab = input_line_pointer; |
| 1489 |
while (*lab && (',' != *lab) && ('(' != *lab)) |
| 1490 |
{ |
| 1491 |
if (ISDIGIT (*lab)) |
| 1492 |
{ |
| 1493 |
all_digits = 1; |
| 1494 |
} |
| 1495 |
else if (ISALPHA (*lab)) |
| 1496 |
{ |
| 1497 |
if (!all_digits) |
| 1498 |
{ |
| 1499 |
islabel = 1; |
| 1500 |
break; |
| 1501 |
} |
| 1502 |
else if (('f' == *lab) || ('b' == *lab)) |
| 1503 |
{ |
| 1504 |
islabel = 1; |
| 1505 |
break; |
| 1506 |
} |
| 1507 |
if (all_digits) |
| 1508 |
break; |
| 1509 |
} |
| 1510 |
else if ('.' != *lab) |
| 1511 |
break; |
| 1512 |
++lab; |
| 1513 |
} |
| 1514 |
|
| 1515 |
|
| 1516 |
dot = strchr (input_line_pointer, '*'); |
| 1517 |
|
| 1518 |
if (!dot && !islabel) |
| 1519 |
return FALSE; |
| 1520 |
|
| 1521 |
|
| 1522 |
if (dot) |
| 1523 |
*dot = '.'; |
| 1524 |
expression (exx); |
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
if (0 == strncmp (now_seg->name, ".text", 5) || 0 > i370_using_other_regno) |
| 1529 |
{ |
| 1530 |
i370_make_relative (exx, &i370_using_text_baseaddr); |
| 1531 |
} |
| 1532 |
else |
| 1533 |
{ |
| 1534 |
i370_make_relative (exx, &i370_using_other_baseaddr); |
| 1535 |
} |
| 1536 |
|
| 1537 |
|
| 1538 |
if (dot) |
| 1539 |
*dot = '*'; |
| 1540 |
|
| 1541 |
return TRUE; |
| 1542 |
} |
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
static bfd_boolean |
| 1553 |
i370_addr_cons (expressionS *exp) |
| 1554 |
{ |
| 1555 |
char *name; |
| 1556 |
char *sym_name, delim; |
| 1557 |
int name_len; |
| 1558 |
int hex_len=0; |
| 1559 |
int cons_len=0; |
| 1560 |
|
| 1561 |
name = input_line_pointer; |
| 1562 |
sym_name = input_line_pointer; |
| 1563 |
|
| 1564 |
if (name[0] == '=' && ISALPHA (name[1])) |
| 1565 |
{ |
| 1566 |
name = ++input_line_pointer; |
| 1567 |
} |
| 1568 |
else |
| 1569 |
{ |
| 1570 |
return FALSE; |
| 1571 |
} |
| 1572 |
switch (name[0]) |
| 1573 |
{ |
| 1574 |
case 'A': |
| 1575 |
case 'V': |
| 1576 |
|
| 1577 |
|
| 1578 |
++input_line_pointer; |
| 1579 |
expression (exp); |
| 1580 |
|
| 1581 |
|
| 1582 |
|
| 1583 |
|
| 1584 |
name_len = strcspn (sym_name, ", "); |
| 1585 |
delim = *(sym_name + name_len); |
| 1586 |
*(sym_name + name_len) = 0x0; |
| 1587 |
add_to_lit_pool (exp, sym_name, 4); |
| 1588 |
*(sym_name + name_len) = delim; |
| 1589 |
|
| 1590 |
break; |
| 1591 |
case 'H': |
| 1592 |
case 'F': |
| 1593 |
case 'X': |
| 1594 |
case 'E': |
| 1595 |
case 'D': |
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
if ('H' == name[0]) cons_len = 2; |
| 1601 |
else if ('F' == name[0]) cons_len = 4; |
| 1602 |
else if ('X' == name[0]) cons_len = -1; |
| 1603 |
else if ('E' == name[0]) cons_len = 4; |
| 1604 |
else if ('D' == name[0]) cons_len = 8; |
| 1605 |
|
| 1606 |
|
| 1607 |
|
| 1608 |
if ('L' == name[1]) |
| 1609 |
{ |
| 1610 |
cons_len = name[2] - '0'; |
| 1611 |
input_line_pointer += 2; |
| 1612 |
} |
| 1613 |
|
| 1614 |
++input_line_pointer; |
| 1615 |
|
| 1616 |
|
| 1617 |
if ('\'' == *input_line_pointer) |
| 1618 |
{ |
| 1619 |
char * close; |
| 1620 |
++input_line_pointer; |
| 1621 |
close = strchr (input_line_pointer, '\''); |
| 1622 |
if (close) |
| 1623 |
*close= ' '; |
| 1624 |
else |
| 1625 |
as_bad ("missing end-quote"); |
| 1626 |
} |
| 1627 |
if ('\"' == *input_line_pointer) |
| 1628 |
{ |
| 1629 |
char * close; |
| 1630 |
++input_line_pointer; |
| 1631 |
close = strchr (input_line_pointer, '\"'); |
| 1632 |
if (close) |
| 1633 |
*close= ' '; |
| 1634 |
else |
| 1635 |
as_bad ("missing end-quote"); |
| 1636 |
} |
| 1637 |
if (('X' == name[0]) || ('E' == name[0]) || ('D' == name[0])) |
| 1638 |
{ |
| 1639 |
char tmp[50]; |
| 1640 |
char *save; |
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
if (('X' == name[0]) && (0 > cons_len)) |
| 1650 |
{ |
| 1651 |
save = input_line_pointer; |
| 1652 |
while (*save) |
| 1653 |
{ |
| 1654 |
if (ISXDIGIT (*save)) |
| 1655 |
hex_len++; |
| 1656 |
save++; |
| 1657 |
} |
| 1658 |
cons_len = (hex_len+1) /2; |
| 1659 |
} |
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
tmp[0] = '0'; |
| 1666 |
tmp[1] = name[0]; |
| 1667 |
tmp[2] = 0; |
| 1668 |
strcat (tmp, input_line_pointer); |
| 1669 |
save = input_line_pointer; |
| 1670 |
input_line_pointer = tmp; |
| 1671 |
expression (exp); |
| 1672 |
input_line_pointer = save + (input_line_pointer-tmp-2); |
| 1673 |
|
| 1674 |
|
| 1675 |
if (O_big == exp->X_op) |
| 1676 |
{ |
| 1677 |
exp->X_add_number = cons_len / CHARS_PER_LITTLENUM; |
| 1678 |
} |
| 1679 |
} |
| 1680 |
else |
| 1681 |
{ |
| 1682 |
expression (exp); |
| 1683 |
} |
| 1684 |
|
| 1685 |
if ((exp->X_op != O_constant) && (exp->X_op != O_big)) |
| 1686 |
{ |
| 1687 |
as_bad ("expression not a constant"); |
| 1688 |
return FALSE; |
| 1689 |
} |
| 1690 |
add_to_lit_pool (exp, 0x0, cons_len); |
| 1691 |
break; |
| 1692 |
|
| 1693 |
default: |
| 1694 |
as_bad ("Unknown/unsupported address literal type"); |
| 1695 |
return FALSE; |
| 1696 |
} |
| 1697 |
|
| 1698 |
return TRUE; |
| 1699 |
} |
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
static void |
| 1707 |
i370_ltorg (ignore) |
| 1708 |
int ignore ATTRIBUTE_UNUSED; |
| 1709 |
{ |
| 1710 |
int litsize; |
| 1711 |
int lit_count = 0; |
| 1712 |
int biggest_literal_size = 0; |
| 1713 |
int biggest_align = 0; |
| 1714 |
char pool_name[20]; |
| 1715 |
|
| 1716 |
if (strncmp (now_seg->name, ".text", 5)) |
| 1717 |
{ |
| 1718 |
if (i370_other_section == undefined_section) |
| 1719 |
{ |
| 1720 |
as_bad (".ltorg without prior .using in section %s", |
| 1721 |
now_seg->name); |
| 1722 |
} |
| 1723 |
if (i370_other_section != now_seg) |
| 1724 |
{ |
| 1725 |
as_bad (".ltorg in section %s paired to .using in section %s", |
| 1726 |
now_seg->name, i370_other_section->name); |
| 1727 |
} |
| 1728 |
} |
| 1729 |
if (! longlong_poolP |
| 1730 |
&& ! word_poolP |
| 1731 |
&& ! short_poolP |
| 1732 |
&& ! byte_poolP) |
| 1733 |
{ |
| 1734 |
|
| 1735 |
|
| 1736 |
return; |
| 1737 |
} |
| 1738 |
|
| 1739 |
|
| 1740 |
lit_count = 0; |
| 1741 |
while (lit_count < next_literal_pool_place) |
| 1742 |
{ |
| 1743 |
if (biggest_literal_size < literals[lit_count].size) |
| 1744 |
biggest_literal_size = literals[lit_count].size; |
| 1745 |
lit_count ++; |
| 1746 |
} |
| 1747 |
if (1 == biggest_literal_size) biggest_align = 0; |
| 1748 |
else if (2 == biggest_literal_size) biggest_align = 1; |
| 1749 |
else if (4 == biggest_literal_size) biggest_align = 2; |
| 1750 |
else if (8 == biggest_literal_size) biggest_align = 3; |
| 1751 |
else as_bad ("bad alignment of %d bytes in literal pool", biggest_literal_size); |
| 1752 |
if (0 == biggest_align) biggest_align = 1; |
| 1753 |
|
| 1754 |
|
| 1755 |
frag_align (biggest_align, 0, 0); |
| 1756 |
record_alignment (now_seg, biggest_align); |
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
for (litsize=8; litsize; litsize /=2) |
| 1763 |
{ |
| 1764 |
symbolS *current_poolP = NULL; |
| 1765 |
switch (litsize) |
| 1766 |
{ |
| 1767 |
case 8: |
| 1768 |
current_poolP = longlong_poolP; break; |
| 1769 |
case 4: |
| 1770 |
current_poolP = word_poolP; break; |
| 1771 |
case 2: |
| 1772 |
current_poolP = short_poolP; break; |
| 1773 |
case 1: |
| 1774 |
current_poolP = byte_poolP; break; |
| 1775 |
default: |
| 1776 |
as_bad ("bad literal size\n"); |
| 1777 |
} |
| 1778 |
if (NULL == current_poolP) |
| 1779 |
continue; |
| 1780 |
sprintf (pool_name, ".LITP%01d%06d", litsize, lit_pool_num); |
| 1781 |
symbol_locate (current_poolP, pool_name, now_seg, |
| 1782 |
(valueT) frag_now_fix (), frag_now); |
| 1783 |
symbol_table_insert (current_poolP); |
| 1784 |
|
| 1785 |
lit_count = 0; |
| 1786 |
while (lit_count < next_literal_pool_place) |
| 1787 |
{ |
| 1788 |
if (litsize == literals[lit_count].size) |
| 1789 |
{ |
| 1790 |
#define EMIT_ADDR_CONS_SYMBOLS |
| 1791 |
#ifdef EMIT_ADDR_CONS_SYMBOLS |
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
if (literals[lit_count].sym_name) |
| 1798 |
{ |
| 1799 |
symbolS * symP = symbol_make_empty (); |
| 1800 |
symbol_locate (symP, literals[lit_count].sym_name, now_seg, |
| 1801 |
(valueT) frag_now_fix (), frag_now); |
| 1802 |
symbol_table_insert (symP); |
| 1803 |
} |
| 1804 |
#endif |
| 1805 |
|
| 1806 |
emit_expr (&(literals[lit_count].exp), literals[lit_count].size); |
| 1807 |
} |
| 1808 |
lit_count ++; |
| 1809 |
} |
| 1810 |
} |
| 1811 |
|
| 1812 |
next_literal_pool_place = 0; |
| 1813 |
longlong_poolP = NULL; |
| 1814 |
word_poolP = NULL; |
| 1815 |
short_poolP = NULL; |
| 1816 |
byte_poolP = NULL; |
| 1817 |
lit_pool_num++; |
| 1818 |
} |
| 1819 |
|
| 1820 |
#endif |
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
static void |
| 1831 |
i370_using (ignore) |
| 1832 |
int ignore ATTRIBUTE_UNUSED; |
| 1833 |
{ |
| 1834 |
expressionS ex, baseaddr; |
| 1835 |
int iregno; |
| 1836 |
char *star; |
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
star = strchr (input_line_pointer, '*'); |
| 1841 |
if (star) |
| 1842 |
*star = '.'; |
| 1843 |
|
| 1844 |
|
| 1845 |
|
| 1846 |
expression (&baseaddr); |
| 1847 |
if (star) |
| 1848 |
*star = '*'; |
| 1849 |
if (O_constant != baseaddr.X_op |
| 1850 |
&& O_symbol != baseaddr.X_op |
| 1851 |
&& O_uminus != baseaddr.X_op) |
| 1852 |
{ |
| 1853 |
as_bad (".using: base address expression illegal or too complex"); |
| 1854 |
} |
| 1855 |
|
| 1856 |
if (*input_line_pointer != '\0') ++input_line_pointer; |
| 1857 |
|
| 1858 |
|
| 1859 |
register_name (&ex); |
| 1860 |
demand_empty_rest_of_line (); |
| 1861 |
iregno = ex.X_add_number; |
| 1862 |
|
| 1863 |
if (0 == strncmp (now_seg->name, ".text", 5)) |
| 1864 |
{ |
| 1865 |
i370_using_text_baseaddr = baseaddr; |
| 1866 |
i370_using_text_regno = iregno; |
| 1867 |
} |
| 1868 |
else |
| 1869 |
{ |
| 1870 |
i370_using_other_baseaddr = baseaddr; |
| 1871 |
i370_using_other_regno = iregno; |
| 1872 |
i370_other_section = now_seg; |
| 1873 |
} |
| 1874 |
} |
| 1875 |
|
| 1876 |
static void |
| 1877 |
i370_drop (ignore) |
| 1878 |
int ignore ATTRIBUTE_UNUSED; |
| 1879 |
{ |
| 1880 |
expressionS ex; |
| 1881 |
int iregno; |
| 1882 |
|
| 1883 |
register_name (&ex); |
| 1884 |
demand_empty_rest_of_line (); |
| 1885 |
iregno = ex.X_add_number; |
| 1886 |
|
| 1887 |
if (0 == strncmp (now_seg->name, ".text", 5)) |
| 1888 |
{ |
| 1889 |
if (iregno != i370_using_text_regno) |
| 1890 |
{ |
| 1891 |
as_bad ("droping register %d in section %s does not match using register %d", |
| 1892 |
iregno, now_seg->name, i370_using_text_regno); |
| 1893 |
} |
| 1894 |
i370_using_text_regno = -1; |
| 1895 |
i370_using_text_baseaddr.X_op = O_absent; |
| 1896 |
} |
| 1897 |
else |
| 1898 |
{ |
| 1899 |
if (iregno != i370_using_other_regno) |
| 1900 |
{ |
| 1901 |
as_bad ("droping register %d in section %s does not match using register %d", |
| 1902 |
iregno, now_seg->name, i370_using_other_regno); |
| 1903 |
} |
| 1904 |
if (i370_other_section != now_seg) |
| 1905 |
{ |
| 1906 |
as_bad ("droping register %d in section %s previously used in section %s", |
| 1907 |
iregno, now_seg->name, i370_other_section->name); |
| 1908 |
} |
| 1909 |
i370_using_other_regno = -1; |
| 1910 |
i370_using_other_baseaddr.X_op = O_absent; |
| 1911 |
i370_other_section = undefined_section; |
| 1912 |
} |
| 1913 |
} |
| 1914 |
|
| 1915 |
|
| 1916 |
|
| 1917 |
|
| 1918 |
static void |
| 1919 |
i370_make_relative (expressionS *exx, expressionS *baseaddr) |
| 1920 |
{ |
| 1921 |
|
| 1922 |
if (O_constant == baseaddr->X_op) |
| 1923 |
{ |
| 1924 |
exx->X_op = O_symbol; |
| 1925 |
exx->X_add_number -= baseaddr->X_add_number; |
| 1926 |
} |
| 1927 |
else if (O_symbol == baseaddr->X_op) |
| 1928 |
{ |
| 1929 |
exx->X_op = O_subtract; |
| 1930 |
exx->X_op_symbol = baseaddr->X_add_symbol; |
| 1931 |
exx->X_add_number -= baseaddr->X_add_number; |
| 1932 |
} |
| 1933 |
else if (O_uminus == baseaddr->X_op) |
| 1934 |
{ |
| 1935 |
exx->X_op = O_add; |
| 1936 |
exx->X_op_symbol = baseaddr->X_add_symbol; |
| 1937 |
exx->X_add_number += baseaddr->X_add_number; |
| 1938 |
} |
| 1939 |
else |
| 1940 |
{ |
| 1941 |
as_bad ("Missing or bad .using directive"); |
| 1942 |
} |
| 1943 |
} |
| 1944 |
|
| 1945 |
|
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
struct i370_fixup |
| 1950 |
{ |
| 1951 |
expressionS exp; |
| 1952 |
int opindex; |
| 1953 |
bfd_reloc_code_real_type reloc; |
| 1954 |
}; |
| 1955 |
|
| 1956 |
#define MAX_INSN_FIXUPS (5) |
| 1957 |
|
| 1958 |
|
| 1959 |
|
| 1960 |
void |
| 1961 |
md_assemble (str) |
| 1962 |
char *str; |
| 1963 |
{ |
| 1964 |
char *s, *opcode_str; |
| 1965 |
const struct i370_opcode *opcode; |
| 1966 |
i370_insn_t insn; |
| 1967 |
const unsigned char *opindex_ptr; |
| 1968 |
int have_optional_index, have_optional_basereg, have_optional_reg; |
| 1969 |
int skip_optional_index, skip_optional_basereg, skip_optional_reg; |
| 1970 |
int use_text=0, use_other=0; |
| 1971 |
int off_by_one; |
| 1972 |
struct i370_fixup fixups[MAX_INSN_FIXUPS]; |
| 1973 |
int fc; |
| 1974 |
char *f; |
| 1975 |
int i; |
| 1976 |
#ifdef OBJ_ELF |
| 1977 |
bfd_reloc_code_real_type reloc; |
| 1978 |
#endif |
| 1979 |
|
| 1980 |
|
| 1981 |
for (s = str; *s != '\0' && ! ISSPACE (*s); s++) |
| 1982 |
; |
| 1983 |
if (*s != '\0') |
| 1984 |
*s++ = '\0'; |
| 1985 |
opcode_str = str; |
| 1986 |
|
| 1987 |
|
| 1988 |
opcode = (const struct i370_opcode *) hash_find (i370_hash, str); |
| 1989 |
if (opcode == (const struct i370_opcode *) NULL) |
| 1990 |
{ |
| 1991 |
const struct i370_macro *macro; |
| 1992 |
|
| 1993 |
assert (i370_macro_hash); |
| 1994 |
macro = (const struct i370_macro *) hash_find (i370_macro_hash, str); |
| 1995 |
if (macro == (const struct i370_macro *) NULL) |
| 1996 |
as_bad ("Unrecognized opcode: `%s'", str); |
| 1997 |
else |
| 1998 |
i370_macro (s, macro); |
| 1999 |
|
| 2000 |
return; |
| 2001 |
} |
| 2002 |
|
| 2003 |
insn = opcode->opcode; |
| 2004 |
|
| 2005 |
str = s; |
| 2006 |
while (ISSPACE (*str)) |
| 2007 |
++str; |
| 2008 |
|
| 2009 |
|
| 2010 |
|
| 2011 |
|
| 2012 |
|
| 2013 |
|
| 2014 |
|
| 2015 |
|
| 2016 |
|
| 2017 |
|
| 2018 |
|
| 2019 |
|
| 2020 |
|
| 2021 |
have_optional_index = have_optional_basereg = have_optional_reg = 0; |
| 2022 |
for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++) |
| 2023 |
{ |
| 2024 |
const struct i370_operand *operand; |
| 2025 |
operand = &i370_operands[*opindex_ptr]; |
| 2026 |
if ((operand->flags & I370_OPERAND_INDEX) != 0) |
| 2027 |
have_optional_index = 1; |
| 2028 |
if ((operand->flags & I370_OPERAND_BASE) != 0) |
| 2029 |
have_optional_basereg = 1; |
| 2030 |
if ((operand->flags & I370_OPERAND_OPTIONAL) != 0) |
| 2031 |
have_optional_reg = 1; |
| 2032 |
} |
| 2033 |
|
| 2034 |
skip_optional_index = skip_optional_basereg = skip_optional_reg = 0; |
| 2035 |
if (have_optional_index || have_optional_basereg) |
| 2036 |
{ |
| 2037 |
unsigned int opcount, nwanted; |
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
if (*str == '\0') |
| 2042 |
opcount = 0; |
| 2043 |
else |
| 2044 |
{ |
| 2045 |
opcount = 1; |
| 2046 |
s = str; |
| 2047 |
while ((s = strpbrk (s, ",(=")) != (char *) NULL) |
| 2048 |
{ |
| 2049 |
++opcount; |
| 2050 |
++s; |
| 2051 |
if (',' == *s) ++s; |
| 2052 |
if ('=' == *s) { ++s; --opcount; } |
| 2053 |
} |
| 2054 |
} |
| 2055 |
|
| 2056 |
|
| 2057 |
|
| 2058 |
|
| 2059 |
nwanted = strlen ((char *) opcode->operands); |
| 2060 |
if (have_optional_index) |
| 2061 |
{ |
| 2062 |
if (opcount < nwanted) |
| 2063 |
skip_optional_index = 1; |
| 2064 |
if (have_optional_basereg && ((opcount+1) < nwanted)) |
| 2065 |
skip_optional_basereg = 1; |
| 2066 |
if (have_optional_reg && ((opcount+1) < nwanted)) |
| 2067 |
skip_optional_reg = 1; |
| 2068 |
} |
| 2069 |
else |
| 2070 |
{ |
| 2071 |
if (have_optional_basereg && (opcount < nwanted)) |
| 2072 |
skip_optional_basereg = 1; |
| 2073 |
if (have_optional_reg && (opcount < nwanted)) |
| 2074 |
skip_optional_reg = 1; |
| 2075 |
} |
| 2076 |
} |
| 2077 |
|
| 2078 |
|
| 2079 |
|
| 2080 |
|
| 2081 |
|
| 2082 |
|
| 2083 |
|
| 2084 |
|
| 2085 |
off_by_one = 0; |
| 2086 |
if (0 == strcasecmp ("CLC", opcode->name) |
| 2087 |
|| 0 == strcasecmp ("ED", opcode->name) |
| 2088 |
|| 0 == strcasecmp ("EDMK", opcode->name) |
| 2089 |
|| 0 == strcasecmp ("MVC", opcode->name) |
| 2090 |
|| 0 == strcasecmp ("MVCIN", opcode->name) |
| 2091 |
|| 0 == strcasecmp ("MVN", opcode->name) |
| 2092 |
|| 0 == strcasecmp ("MVZ", opcode->name) |
| 2093 |
|| 0 == strcasecmp ("NC", opcode->name) |
| 2094 |
|| 0 == strcasecmp ("OC", opcode->name) |
| 2095 |
|| 0 == strcasecmp ("XC", opcode->name)) |
| 2096 |
off_by_one = 1; |
| 2097 |
|
| 2098 |
|
| 2099 |
fc = 0; |
| 2100 |
for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++) |
| 2101 |
{ |
| 2102 |
const struct i370_operand *operand; |
| 2103 |
const char *errmsg; |
| 2104 |
char *hold; |
| 2105 |
expressionS ex; |
| 2106 |
|
| 2107 |
operand = &i370_operands[*opindex_ptr]; |
| 2108 |
errmsg = NULL; |
| 2109 |
|
| 2110 |
|
| 2111 |
|
| 2112 |
if (skip_optional_index && |
| 2113 |
((operand->flags & I370_OPERAND_INDEX) != 0)) |
| 2114 |
{ |
| 2115 |
insn = i370_insert_operand (insn, operand, 0); |
| 2116 |
continue; |
| 2117 |
} |
| 2118 |
|
| 2119 |
|
| 2120 |
|
| 2121 |
if (skip_optional_basereg && |
| 2122 |
((operand->flags & I370_OPERAND_BASE) != 0)) |
| 2123 |
{ |
| 2124 |
int basereg = -1; |
| 2125 |
if (use_text) |
| 2126 |
{ |
| 2127 |
if (0 == strncmp (now_seg->name, ".text", 5) |
| 2128 |
|| 0 > i370_using_other_regno) |
| 2129 |
{ |
| 2130 |
basereg = i370_using_text_regno; |
| 2131 |
} |
| 2132 |
else |
| 2133 |
{ |
| 2134 |
basereg = i370_using_other_regno; |
| 2135 |
} |
| 2136 |
} |
| 2137 |
else if (use_other) |
| 2138 |
{ |
| 2139 |
if (0 > i370_using_other_regno) |
| 2140 |
{ |
| 2141 |
basereg = i370_using_text_regno; |
| 2142 |
} |
| 2143 |
else |
| 2144 |
{ |
| 2145 |
basereg = i370_using_other_regno; |
| 2146 |
} |
| 2147 |
} |
| 2148 |
if (0 > basereg) |
| 2149 |
{ |
| 2150 |
as_bad ("not using any base register"); |
| 2151 |
} |
| 2152 |
insn = i370_insert_operand (insn, operand, basereg); |
| 2153 |
continue; |
| 2154 |
} |
| 2155 |
|
| 2156 |
|
| 2157 |
|
| 2158 |
if (skip_optional_reg |
| 2159 |
&& ((operand->flags & I370_OPERAND_OPTIONAL) != 0)) |
| 2160 |
{ |
| 2161 |
insn = i370_insert_operand (insn, operand, 0); |
| 2162 |
continue; |
| 2163 |
} |
| 2164 |
|
| 2165 |
|
| 2166 |
hold = input_line_pointer; |
| 2167 |
input_line_pointer = str; |
| 2168 |
|
| 2169 |
|
| 2170 |
if ((operand->flags & I370_OPERAND_GPR) != 0) |
| 2171 |
{ |
| 2172 |
|
| 2173 |
if (skip_optional_index && (',' == *input_line_pointer)) |
| 2174 |
{ |
| 2175 |
*input_line_pointer = ' '; |
| 2176 |
input_line_pointer ++; |
| 2177 |
} |
| 2178 |
if (! register_name (&ex)) |
| 2179 |
{ |
| 2180 |
as_bad ("expecting a register for operand %d", |
| 2181 |
opindex_ptr - opcode->operands + 1); |
| 2182 |
} |
| 2183 |
} |
| 2184 |
|
| 2185 |
|
| 2186 |
|
| 2187 |
|
| 2188 |
else if (i370_addr_cons (&ex)) |
| 2189 |
use_other=1; |
| 2190 |
else if (i370_addr_offset (&ex)) |
| 2191 |
use_text=1; |
| 2192 |
else expression (&ex); |
| 2193 |
|
| 2194 |
str = input_line_pointer; |
| 2195 |
input_line_pointer = hold; |
| 2196 |
|
| 2197 |
|
| 2198 |
|
| 2199 |
|
| 2200 |
|
| 2201 |
|
| 2202 |
|
| 2203 |
if (off_by_one && (0 == strcasecmp ("SS L", operand->name))) |
| 2204 |
{ |
| 2205 |
ex.X_add_number --; |
| 2206 |
} |
| 2207 |
|
| 2208 |
if (ex.X_op == O_illegal) |
| 2209 |
as_bad ("illegal operand"); |
| 2210 |
else if (ex.X_op == O_absent) |
| 2211 |
as_bad ("missing operand"); |
| 2212 |
else if (ex.X_op == O_register) |
| 2213 |
{ |
| 2214 |
insn = i370_insert_operand (insn, operand, ex.X_add_number); |
| 2215 |
} |
| 2216 |
else if (ex.X_op == O_constant) |
| 2217 |
{ |
| 2218 |
#ifdef OBJ_ELF |
| 2219 |
|
| 2220 |
|
| 2221 |
|
| 2222 |
|
| 2223 |
char *orig_str = str; |
| 2224 |
|
| 2225 |
if ((reloc = i370_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED) |
| 2226 |
switch (reloc) |
| 2227 |
{ |
| 2228 |
default: |
| 2229 |
str = orig_str; |
| 2230 |
break; |
| 2231 |
|
| 2232 |
case BFD_RELOC_LO16: |
| 2233 |
|
| 2234 |
|
| 2235 |
|
| 2236 |
ex.X_add_number = (((ex.X_add_number & 0xffff) |
| 2237 |
^ 0x8000) |
| 2238 |
- 0x8000); |
| 2239 |
break; |
| 2240 |
|
| 2241 |
case BFD_RELOC_HI16: |
| 2242 |
ex.X_add_number = (ex.X_add_number >> 16) & 0xffff; |
| 2243 |
break; |
| 2244 |
|
| 2245 |
case BFD_RELOC_HI16_S: |
| 2246 |
ex.X_add_number = (((ex.X_add_number >> 16) & 0xffff) |
| 2247 |
+ ((ex.X_add_number >> 15) & 1)); |
| 2248 |
break; |
| 2249 |
} |
| 2250 |
#endif |
| 2251 |
insn = i370_insert_operand (insn, operand, ex.X_add_number); |
| 2252 |
} |
| 2253 |
#ifdef OBJ_ELF |
| 2254 |
else if ((reloc = i370_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED) |
| 2255 |
{ |
| 2256 |
as_tsktsk ("md_assemble(): suffixed relocations not supported\n"); |
| 2257 |
|
| 2258 |
|
| 2259 |
if (fc >= MAX_INSN_FIXUPS) |
| 2260 |
as_fatal ("too many fixups"); |
| 2261 |
fixups[fc].exp = ex; |
| 2262 |
fixups[fc].opindex = 0; |
| 2263 |
fixups[fc].reloc = reloc; |
| 2264 |
++fc; |
| 2265 |
} |
| 2266 |
#endif |
| 2267 |
|
| 2268 |
else |
| 2269 |
{ |
| 2270 |
|
| 2271 |
|
| 2272 |
|
| 2273 |
|
| 2274 |
|
| 2275 |
|
| 2276 |
if (fc >= MAX_INSN_FIXUPS) |
| 2277 |
as_fatal ("too many fixups"); |
| 2278 |
fixups[fc].exp = ex; |
| 2279 |
fixups[fc].opindex = *opindex_ptr; |
| 2280 |
fixups[fc].reloc = BFD_RELOC_UNUSED; |
| 2281 |
++fc; |
| 2282 |
} |
| 2283 |
|
| 2284 |
|
| 2285 |
if ((')' == *str) && (',' == *(str+1))) |
| 2286 |
++str; |
| 2287 |
if (*str != '\0') |
| 2288 |
++str; |
| 2289 |
} |
| 2290 |
|
| 2291 |
while (ISSPACE (*str)) |
| 2292 |
++str; |
| 2293 |
|
| 2294 |
if (*str != '\0') |
| 2295 |
as_bad ("junk at end of line: `%s'", str); |
| 2296 |
|
| 2297 |
|
| 2298 |
f = frag_more (opcode->len); |
| 2299 |
if (4 >= opcode->len) |
| 2300 |
{ |
| 2301 |
md_number_to_chars (f, insn.i[0], opcode->len); |
| 2302 |
} |
| 2303 |
else |
| 2304 |
{ |
| 2305 |
md_number_to_chars (f, insn.i[0], 4); |
| 2306 |
if (6 == opcode->len) |
| 2307 |
{ |
| 2308 |
md_number_to_chars ((f+4), ((insn.i[1])>>16), 2); |
| 2309 |
} |
| 2310 |
else |
| 2311 |
{ |
| 2312 |
|
| 2313 |
as_bad ("Internal Error: bad instruction length"); |
| 2314 |
md_number_to_chars ((f+4), insn.i[1], opcode->len -4); |
| 2315 |
} |
| 2316 |
} |
| 2317 |
|
| 2318 |
|
| 2319 |
|
| 2320 |
|
| 2321 |
|
| 2322 |
|
| 2323 |
|
| 2324 |
for (i = 0; i < fc; i++) |
| 2325 |
{ |
| 2326 |
const struct i370_operand *operand; |
| 2327 |
|
| 2328 |
operand = &i370_operands[fixups[i].opindex]; |
| 2329 |
if (fixups[i].reloc != BFD_RELOC_UNUSED) |
| 2330 |
{ |
| 2331 |
reloc_howto_type *reloc_howto = bfd_reloc_type_lookup (stdoutput, fixups[i].reloc); |
| 2332 |
int size; |
| 2333 |
fixS *fixP; |
| 2334 |
|
| 2335 |
if (!reloc_howto) |
| 2336 |
abort (); |
| 2337 |
|
| 2338 |
size = bfd_get_reloc_size (reloc_howto); |
| 2339 |
|
| 2340 |
if (size < 1 || size > 4) |
| 2341 |
abort (); |
| 2342 |
|
| 2343 |
printf (" gwana doo fixup %d \n", i); |
| 2344 |
fixP = fix_new_exp (frag_now, f - frag_now->fr_literal, size, |
| 2345 |
&fixups[i].exp, reloc_howto->pc_relative, |
| 2346 |
fixups[i].reloc); |
| 2347 |
|
| 2348 |
|
| 2349 |
|
| 2350 |
switch (fixups[i].reloc) |
| 2351 |
{ |
| 2352 |
case BFD_RELOC_16_GOTOFF: |
| 2353 |
case BFD_RELOC_LO16: |
| 2354 |
case BFD_RELOC_HI16: |
| 2355 |
case BFD_RELOC_HI16_S: |
| 2356 |
fixP->fx_no_overflow = 1; |
| 2357 |
break; |
| 2358 |
default: |
| 2359 |
break; |
| 2360 |
} |
| 2361 |
} |
| 2362 |
else |
| 2363 |
{ |
| 2364 |
fix_new_exp (frag_now, f - frag_now->fr_literal, opcode->len, |
| 2365 |
&fixups[i].exp, |
| 2366 |
(operand->flags & I370_OPERAND_RELATIVE) != 0, |
| 2367 |
((bfd_reloc_code_real_type) |
| 2368 |
(fixups[i].opindex + (int) BFD_RELOC_UNUSED))); |
| 2369 |
} |
| 2370 |
} |
| 2371 |
} |
| 2372 |
|
| 2373 |
|
| 2374 |
|
| 2375 |
|
| 2376 |
|
| 2377 |
|
| 2378 |
static void |
| 2379 |
i370_macro (str, macro) |
| 2380 |
char *str; |
| 2381 |
const struct i370_macro *macro; |
| 2382 |
{ |
| 2383 |
char *operands[10]; |
| 2384 |
unsigned int count; |
| 2385 |
char *s; |
| 2386 |
unsigned int len; |
| 2387 |
const char *format; |
| 2388 |
int arg; |
| 2389 |
char *send; |
| 2390 |
char *complete; |
| 2391 |
|
| 2392 |
|
| 2393 |
count = 0; |
| 2394 |
s = str; |
| 2395 |
while (1) |
| 2396 |
{ |
| 2397 |
if (count >= sizeof operands / sizeof operands[0]) |
| 2398 |
break; |
| 2399 |
operands[count++] = s; |
| 2400 |
s = strchr (s, ','); |
| 2401 |
if (s == (char *) NULL) |
| 2402 |
break; |
| 2403 |
*s++ = '\0'; |
| 2404 |
} |
| 2405 |
|
| 2406 |
if (count != macro->operands) |
| 2407 |
{ |
| 2408 |
as_bad ("wrong number of operands"); |
| 2409 |
return; |
| 2410 |
} |
| 2411 |
|
| 2412 |
|
| 2413 |
|
| 2414 |
len = 0; |
| 2415 |
format = macro->format; |
| 2416 |
while (*format != '\0') |
| 2417 |
{ |
| 2418 |
if (*format != '%') |
| 2419 |
{ |
| 2420 |
++len; |
| 2421 |
++format; |
| 2422 |
} |
| 2423 |
else |
| 2424 |
{ |
| 2425 |
arg = strtol (format + 1, &send, 10); |
| 2426 |
know (send != format && arg >= 0 && (unsigned) arg < count); |
| 2427 |
len += strlen (operands[arg]); |
| 2428 |
format = send; |
| 2429 |
} |
| 2430 |
} |
| 2431 |
|
| 2432 |
|
| 2433 |
complete = s = (char *) alloca (len + 1); |
| 2434 |
format = macro->format; |
| 2435 |
while (*format != '\0') |
| 2436 |
{ |
| 2437 |
if (*format != '%') |
| 2438 |
*s++ = *format++; |
| 2439 |
else |
| 2440 |
{ |
| 2441 |
arg = strtol (format + 1, &send, 10); |
| 2442 |
strcpy (s, operands[arg]); |
| 2443 |
s += strlen (s); |
| 2444 |
format = send; |
| 2445 |
} |
| 2446 |
} |
| 2447 |
*s = '\0'; |
| 2448 |
|
| 2449 |
|
| 2450 |
md_assemble (complete); |
| 2451 |
} |
| 2452 |
|
| 2453 |
|
| 2454 |
|
| 2455 |
|
| 2456 |
|
| 2457 |
|
| 2458 |
static void |
| 2459 |
i370_byte (ignore) |
| 2460 |
int ignore ATTRIBUTE_UNUSED; |
| 2461 |
{ |
| 2462 |
if (*input_line_pointer != '\"') |
| 2463 |
{ |
| 2464 |
cons (1); |
| 2465 |
return; |
| 2466 |
} |
| 2467 |
|
| 2468 |
|
| 2469 |
|
| 2470 |
++input_line_pointer; |
| 2471 |
while (1) |
| 2472 |
{ |
| 2473 |
char c; |
| 2474 |
|
| 2475 |
c = *input_line_pointer++; |
| 2476 |
|
| 2477 |
if (c == '\"') |
| 2478 |
{ |
| 2479 |
if (*input_line_pointer != '\"') |
| 2480 |
break; |
| 2481 |
++input_line_pointer; |
| 2482 |
} |
| 2483 |
|
| 2484 |
FRAG_APPEND_1_CHAR (c); |
| 2485 |
} |
| 2486 |
|
| 2487 |
demand_empty_rest_of_line (); |
| 2488 |
} |
| 2489 |
|
| 2490 |
|
| 2491 |
|
| 2492 |
|
| 2493 |
|
| 2494 |
|
| 2495 |
|
| 2496 |
|
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
|
| 2501 |
|
| 2502 |
static void |
| 2503 |
i370_tc (ignore) |
| 2504 |
int ignore ATTRIBUTE_UNUSED; |
| 2505 |
{ |
| 2506 |
|
| 2507 |
|
| 2508 |
while (is_part_of_name (*input_line_pointer) |
| 2509 |
|| *input_line_pointer == '[' |
| 2510 |
|| *input_line_pointer == ']' |
| 2511 |
|| *input_line_pointer == '{' |
| 2512 |
|| *input_line_pointer == '}') |
| 2513 |
++input_line_pointer; |
| 2514 |
|
| 2515 |
|
| 2516 |
frag_align (2, 0, 0); |
| 2517 |
record_alignment (now_seg, 2); |
| 2518 |
|
| 2519 |
if (*input_line_pointer != ',') |
| 2520 |
demand_empty_rest_of_line (); |
| 2521 |
else |
| 2522 |
{ |
| 2523 |
++input_line_pointer; |
| 2524 |
cons (4); |
| 2525 |
} |
| 2526 |
} |
| 2527 |
|
| 2528 |
|
| 2529 |
|
| 2530 |
|
| 2531 |
|
| 2532 |
|
| 2533 |
char * |
| 2534 |
md_atof (type, litp, sizep) |
| 2535 |
int type; |
| 2536 |
char *litp; |
| 2537 |
int *sizep; |
| 2538 |
{ |
| 2539 |
int prec; |
| 2540 |
LITTLENUM_TYPE words[4]; |
| 2541 |
char *t; |
| 2542 |
int i; |
| 2543 |
|
| 2544 |
switch (type) |
| 2545 |
{ |
| 2546 |
case 'f': |
| 2547 |
case 'E': |
| 2548 |
type = 'f'; |
| 2549 |
prec = 2; |
| 2550 |
break; |
| 2551 |
|
| 2552 |
case 'd': |
| 2553 |
case 'D': |
| 2554 |
type = 'd'; |
| 2555 |
prec = 4; |
| 2556 |
break; |
| 2557 |
|
| 2558 |
default: |
| 2559 |
*sizep = 0; |
| 2560 |
return "bad call to md_atof"; |
| 2561 |
} |
| 2562 |
|
| 2563 |
|
| 2564 |
|
| 2565 |
t = atof_ieee (input_line_pointer, type, words); |
| 2566 |
if (t) |
| 2567 |
input_line_pointer = t; |
| 2568 |
|
| 2569 |
*sizep = prec * 2; |
| 2570 |
|
| 2571 |
for (i = 0; i < prec; i++) |
| 2572 |
{ |
| 2573 |
md_number_to_chars (litp, (valueT) words[i], 2); |
| 2574 |
litp += 2; |
| 2575 |
} |
| 2576 |
|
| 2577 |
return NULL; |
| 2578 |
} |
| 2579 |
|
| 2580 |
|
| 2581 |
|
| 2582 |
|
| 2583 |
void |
| 2584 |
md_number_to_chars (buf, val, n) |
| 2585 |
char *buf; |
| 2586 |
valueT val; |
| 2587 |
int n; |
| 2588 |
{ |
| 2589 |
number_to_chars_bigendian (buf, val, n); |
| 2590 |
} |
| 2591 |
|
| 2592 |
|
| 2593 |
|
| 2594 |
valueT |
| 2595 |
md_section_align (seg, addr) |
| 2596 |
asection *seg; |
| 2597 |
valueT addr; |
| 2598 |
{ |
| 2599 |
int align = bfd_get_section_alignment (stdoutput, seg); |
| 2600 |
|
| 2601 |
return (addr + (1 << align) - 1) & (-1 << align); |
| 2602 |
} |
| 2603 |
|
| 2604 |
|
| 2605 |
|
| 2606 |
int |
| 2607 |
md_estimate_size_before_relax (fragp, seg) |
| 2608 |
fragS *fragp ATTRIBUTE_UNUSED; |
| 2609 |
asection *seg ATTRIBUTE_UNUSED; |
| 2610 |
{ |
| 2611 |
abort (); |
| 2612 |
return 0; |
| 2613 |
} |
| 2614 |
|
| 2615 |
|
| 2616 |
|
| 2617 |
void |
| 2618 |
md_convert_frag (abfd, sec, fragp) |
| 2619 |
bfd *abfd ATTRIBUTE_UNUSED; |
| 2620 |
asection *sec ATTRIBUTE_UNUSED; |
| 2621 |
fragS *fragp ATTRIBUTE_UNUSED; |
| 2622 |
{ |
| 2623 |
abort (); |
| 2624 |
} |
| 2625 |
|
| 2626 |
|
| 2627 |
|
| 2628 |
symbolS * |
| 2629 |
md_undefined_symbol (name) |
| 2630 |
char *name ATTRIBUTE_UNUSED; |
| 2631 |
{ |
| 2632 |
return 0; |
| 2633 |
} |
| 2634 |
|
| 2635 |
|
| 2636 |
|
| 2637 |
|
| 2638 |
|
| 2639 |
|
| 2640 |
long |
| 2641 |
md_pcrel_from_section (fixp, sec) |
| 2642 |
fixS *fixp; |
| 2643 |
segT sec ATTRIBUTE_UNUSED; |
| 2644 |
{ |
| 2645 |
return fixp->fx_frag->fr_address + fixp->fx_where; |
| 2646 |
} |
| 2647 |
|
| 2648 |
|
| 2649 |
|
| 2650 |
|
| 2651 |
|
| 2652 |
|
| 2653 |
|
| 2654 |
|
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
|
| 2661 |
void |
| 2662 |
md_apply_fix3 (fixP, valP, seg) |
| 2663 |
fixS *fixP; |
| 2664 |
valueT * valP; |
| 2665 |
segT seg; |
| 2666 |
{ |
| 2667 |
valueT value = * valP; |
| 2668 |
|
| 2669 |
if (fixP->fx_addsy != NULL) |
| 2670 |
{ |
| 2671 |
#ifdef DEBUG |
| 2672 |
printf ("\nmd_apply_fix3: symbol %s at 0x%x (%s:%d) val=0x%x addend=0x%x\n", |
| 2673 |
S_GET_NAME (fixP->fx_addsy), |
| 2674 |
fixP->fx_frag->fr_address + fixP->fx_where, |
| 2675 |
fixP->fx_file, fixP->fx_line, |
| 2676 |
S_GET_VALUE (fixP->fx_addsy), value); |
| 2677 |
#endif |
| 2678 |
} |
| 2679 |
else |
| 2680 |
fixP->fx_done = 1; |
| 2681 |
|
| 2682 |
|
| 2683 |
|
| 2684 |
|
| 2685 |
if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED) |
| 2686 |
{ |
| 2687 |
int opindex; |
| 2688 |
const struct i370_operand *operand; |
| 2689 |
char *where; |
| 2690 |
i370_insn_t insn; |
| 2691 |
|
| 2692 |
opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED; |
| 2693 |
|
| 2694 |
operand = &i370_operands[opindex]; |
| 2695 |
|
| 2696 |
#ifdef DEBUG |
| 2697 |
printf ("\nmd_apply_fix3: fixup operand %s at 0x%x in %s:%d addend=0x%x\n", |
| 2698 |
operand->name, |
| 2699 |
fixP->fx_frag->fr_address + fixP->fx_where, |
| 2700 |
fixP->fx_file, fixP->fx_line, |
| 2701 |
value); |
| 2702 |
#endif |
| 2703 |
|
| 2704 |
|
| 2705 |
|
| 2706 |
where = fixP->fx_frag->fr_literal + fixP->fx_where; |
| 2707 |
insn.i[0] = bfd_getb32 ((unsigned char *) where); |
| 2708 |
|
| 2709 |
if (6 <= fixP->fx_size) |
| 2710 |
|
| 2711 |
insn.i[1] = bfd_getb32 (((unsigned char *) where)+4); |
| 2712 |
|
| 2713 |
insn = i370_insert_operand (insn, operand, (offsetT) value); |
| 2714 |
bfd_putb32 ((bfd_vma) insn.i[0], (unsigned char *) where); |
| 2715 |
|
| 2716 |
if (6 <= fixP->fx_size) |
| 2717 |
|
| 2718 |
bfd_putb32 ((bfd_vma) insn.i[1], (((unsigned char *) where)+4)); |
| 2719 |
|
| 2720 |
|
| 2721 |
fixP->fx_done = 1; |
| 2722 |
if (fixP->fx_done) |
| 2723 |
|
| 2724 |
return; |
| 2725 |
|
| 2726 |
|
| 2727 |
|
| 2728 |
|
| 2729 |
|
| 2730 |
|
| 2731 |
|
| 2732 |
{ |
| 2733 |
char *sfile; |
| 2734 |
unsigned int sline; |
| 2735 |
|
| 2736 |
|
| 2737 |
|
| 2738 |
if (expr_symbol_where (fixP->fx_addsy, &sfile, &sline)) |
| 2739 |
as_bad_where (fixP->fx_file, fixP->fx_line, |
| 2740 |
"unresolved expression that must be resolved"); |
| 2741 |
else |
| 2742 |
as_bad_where (fixP->fx_file, fixP->fx_line, |
| 2743 |
"unsupported relocation type"); |
| 2744 |
fixP->fx_done = 1; |
| 2745 |
return; |
| 2746 |
} |
| 2747 |
} |
| 2748 |
else |
| 2749 |
{ |
| 2750 |
|
| 2751 |
|
| 2752 |
|
| 2753 |
#ifdef OBJ_ELF |
| 2754 |
i370_elf_validate_fix (fixP, seg); |
| 2755 |
#endif |
| 2756 |
#ifdef DEBUG |
| 2757 |
printf ("md_apply_fix3: reloc case %d in segment %s %s:%d\n", |
| 2758 |
fixP->fx_r_type, segment_name (seg), fixP->fx_file, fixP->fx_line); |
| 2759 |
printf ("\tcurrent fixup value is 0x%x \n", value); |
| 2760 |
#endif |
| 2761 |
switch (fixP->fx_r_type) |
| 2762 |
{ |
| 2763 |
case BFD_RELOC_32: |
| 2764 |
case BFD_RELOC_CTOR: |
| 2765 |
if (fixP->fx_pcrel) |
| 2766 |
fixP->fx_r_type = BFD_RELOC_32_PCREL; |
| 2767 |
|
| 2768 |
|
| 2769 |
case BFD_RELOC_RVA: |
| 2770 |
case BFD_RELOC_32_PCREL: |
| 2771 |
case BFD_RELOC_32_BASEREL: |
| 2772 |
#ifdef DEBUG |
| 2773 |
printf ("\t32 bit relocation at 0x%x\n", |
| 2774 |
fixP->fx_frag->fr_address + fixP->fx_where); |
| 2775 |
#endif |
| 2776 |
md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where, |
| 2777 |
value, 4); |
| 2778 |
break; |
| 2779 |
|
| 2780 |
case BFD_RELOC_LO16: |
| 2781 |
case BFD_RELOC_16: |
| 2782 |
if (fixP->fx_pcrel) |
| 2783 |
as_bad_where (fixP->fx_file, fixP->fx_line, |
| 2784 |
"cannot emit PC relative %s relocation%s%s", |
| 2785 |
bfd_get_reloc_code_name (fixP->fx_r_type), |
| 2786 |
fixP->fx_addsy != NULL ? " against " : "", |
| 2787 |
(fixP->fx_addsy != NULL |
| 2788 |
? S_GET_NAME (fixP->fx_addsy) |
| 2789 |
: "")); |
| 2790 |
|
| 2791 |
md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where, |
| 2792 |
value, 2); |
| 2793 |
break; |
| 2794 |
|
| 2795 |
|
| 2796 |
|
| 2797 |
|
| 2798 |
case BFD_RELOC_HI16: |
| 2799 |
if (fixP->fx_pcrel) |
| 2800 |
abort (); |
| 2801 |
md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where, |
| 2802 |
value >> 16, 2); |
| 2803 |
break; |
| 2804 |
case BFD_RELOC_HI16_S: |
| 2805 |
if (fixP->fx_pcrel) |
| 2806 |
abort (); |
| 2807 |
md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where, |
| 2808 |
(value + 0x8000) >> 16, 2); |
| 2809 |
break; |
| 2810 |
|
| 2811 |
case BFD_RELOC_8: |
| 2812 |
if (fixP->fx_pcrel) |
| 2813 |
abort (); |
| 2814 |
|
| 2815 |
md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where, |
| 2816 |
value, 1); |
| 2817 |
break; |
| 2818 |
|
| 2819 |
default: |
| 2820 |
fprintf (stderr, |
| 2821 |
"Gas failure, reloc value %d\n", fixP->fx_r_type); |
| 2822 |
fflush (stderr); |
| 2823 |
abort (); |
| 2824 |
} |
| 2825 |
} |
| 2826 |
|
| 2827 |
fixP->fx_addnumber = value; |
| 2828 |
} |
| 2829 |
|
| 2830 |
|
| 2831 |
|
| 2832 |
arelent * |
| 2833 |
tc_gen_reloc (seg, fixp) |
| 2834 |
asection *seg ATTRIBUTE_UNUSED; |
| 2835 |
fixS *fixp; |
| 2836 |
{ |
| 2837 |
arelent *reloc; |
| 2838 |
|
| 2839 |
reloc = (arelent *) xmalloc (sizeof (arelent)); |
| 2840 |
|
| 2841 |
reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
| 2842 |
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); |
| 2843 |
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; |
| 2844 |
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); |
| 2845 |
if (reloc->howto == (reloc_howto_type *) NULL) |
| 2846 |
{ |
| 2847 |
as_bad_where (fixp->fx_file, fixp->fx_line, |
| 2848 |
"reloc %d not supported by object file format", (int)fixp->fx_r_type); |
| 2849 |
return NULL; |
| 2850 |
} |
| 2851 |
reloc->addend = fixp->fx_addnumber; |
| 2852 |
|
| 2853 |
#ifdef DEBUG |
| 2854 |
printf ("\ngen_reloc(): sym %s (%s:%d) at addr 0x%x addend=0x%x\n", |
| 2855 |
fixp->fx_addsy->bsym->name, |
| 2856 |
fixp->fx_file, fixp->fx_line, |
| 2857 |
reloc->address, reloc->addend); |
| 2858 |
#endif |
| 2859 |
|
| 2860 |
return reloc; |
| 2861 |
} |