| 1 | /* ELF object file format |
| 2 | Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
| 3 | 2001, 2002, 2003 Free Software Foundation, Inc. |
| 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 |
| 9 | published by the Free Software Foundation; either version 2, |
| 10 | or (at your option) any later version. |
| 11 | |
| 12 | GAS is distributed in the hope that it will be useful, but |
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 15 | the 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 the Free |
| 19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
| 20 | 02111-1307, USA. */ |
| 21 | |
| 22 | #define OBJ_HEADER "obj-elf.h" |
| 23 | #include "as.h" |
| 24 | #include "safe-ctype.h" |
| 25 | #include "subsegs.h" |
| 26 | #include "obstack.h" |
| 27 | #include "struc-symbol.h" |
| 28 | #include "dwarf2dbg.h" |
| 29 | |
| 30 | #ifndef ECOFF_DEBUGGING |
| 31 | #define ECOFF_DEBUGGING 0 |
| 32 | #else |
| 33 | #define NEED_ECOFF_DEBUG |
| 34 | #endif |
| 35 | |
| 36 | #ifdef NEED_ECOFF_DEBUG |
| 37 | #include "ecoff.h" |
| 38 | #endif |
| 39 | |
| 40 | #ifdef TC_ALPHA |
| 41 | #include "elf/alpha.h" |
| 42 | #endif |
| 43 | |
| 44 | #ifdef TC_MIPS |
| 45 | #include "elf/mips.h" |
| 46 | #endif |
| 47 | |
| 48 | #ifdef TC_PPC |
| 49 | #include "elf/ppc.h" |
| 50 | #endif |
| 51 | |
| 52 | #ifdef TC_I370 |
| 53 | #include "elf/i370.h" |
| 54 | #endif |
| 55 | |
| 56 | static bfd_vma elf_s_get_size PARAMS ((symbolS *)); |
| 57 | static void elf_s_set_size PARAMS ((symbolS *, bfd_vma)); |
| 58 | static bfd_vma elf_s_get_align PARAMS ((symbolS *)); |
| 59 | static void elf_s_set_align PARAMS ((symbolS *, bfd_vma)); |
| 60 | static void elf_s_set_other PARAMS ((symbolS *, int)); |
| 61 | static int elf_sec_sym_ok_for_reloc PARAMS ((asection *)); |
| 62 | static void adjust_stab_sections PARAMS ((bfd *, asection *, PTR)); |
| 63 | static void build_group_lists PARAMS ((bfd *, asection *, PTR)); |
| 64 | static int elf_separate_stab_sections PARAMS ((void)); |
| 65 | static void elf_init_stab_section PARAMS ((segT)); |
| 66 | static symbolS *elf_common PARAMS ((int)); |
| 67 | |
| 68 | #ifdef NEED_ECOFF_DEBUG |
| 69 | static bfd_boolean elf_get_extr PARAMS ((asymbol *, EXTR *)); |
| 70 | static void elf_set_index PARAMS ((asymbol *, bfd_size_type)); |
| 71 | #endif |
| 72 | |
| 73 | static void obj_elf_line PARAMS ((int)); |
| 74 | void obj_elf_version PARAMS ((int)); |
| 75 | static void obj_elf_size PARAMS ((int)); |
| 76 | static void obj_elf_type PARAMS ((int)); |
| 77 | static void obj_elf_ident PARAMS ((int)); |
| 78 | static void obj_elf_weak PARAMS ((int)); |
| 79 | static void obj_elf_local PARAMS ((int)); |
| 80 | static void obj_elf_visibility PARAMS ((int)); |
| 81 | static int obj_elf_parse_section_letters PARAMS ((char *, size_t)); |
| 82 | static int obj_elf_section_word PARAMS ((char *, size_t)); |
| 83 | static char *obj_elf_section_name PARAMS ((void)); |
| 84 | static int obj_elf_section_type PARAMS ((char *, size_t)); |
| 85 | static void obj_elf_symver PARAMS ((int)); |
| 86 | static void obj_elf_subsection PARAMS ((int)); |
| 87 | static void obj_elf_popsection PARAMS ((int)); |
| 88 | static void obj_elf_tls_common PARAMS ((int)); |
| 89 | |
| 90 | static const pseudo_typeS elf_pseudo_table[] = |
| 91 | { |
| 92 | {"comm", obj_elf_common, 0}, |
| 93 | {"common", obj_elf_common, 1}, |
| 94 | {"ident", obj_elf_ident, 0}, |
| 95 | {"local", obj_elf_local, 0}, |
| 96 | {"previous", obj_elf_previous, 0}, |
| 97 | {"section", obj_elf_section, 0}, |
| 98 | {"section.s", obj_elf_section, 0}, |
| 99 | {"sect", obj_elf_section, 0}, |
| 100 | {"sect.s", obj_elf_section, 0}, |
| 101 | {"pushsection", obj_elf_section, 1}, |
| 102 | {"popsection", obj_elf_popsection, 0}, |
| 103 | {"size", obj_elf_size, 0}, |
| 104 | {"type", obj_elf_type, 0}, |
| 105 | {"version", obj_elf_version, 0}, |
| 106 | {"weak", obj_elf_weak, 0}, |
| 107 | |
| 108 | /* These define symbol visibility. */ |
| 109 | {"internal", obj_elf_visibility, STV_INTERNAL}, |
| 110 | {"hidden", obj_elf_visibility, STV_HIDDEN}, |
| 111 | {"protected", obj_elf_visibility, STV_PROTECTED}, |
| 112 | |
| 113 | /* These are used for stabs-in-elf configurations. */ |
| 114 | {"line", obj_elf_line, 0}, |
| 115 | |
| 116 | /* This is a GNU extension to handle symbol versions. */ |
| 117 | {"symver", obj_elf_symver, 0}, |
| 118 | |
| 119 | /* A GNU extension to change subsection only. */ |
| 120 | {"subsection", obj_elf_subsection, 0}, |
| 121 | |
| 122 | /* These are GNU extensions to aid in garbage collecting C++ vtables. */ |
| 123 | {"vtable_inherit", (void (*) PARAMS ((int))) &obj_elf_vtable_inherit, 0}, |
| 124 | {"vtable_entry", (void (*) PARAMS ((int))) &obj_elf_vtable_entry, 0}, |
| 125 | |
| 126 | /* These are used for dwarf. */ |
| 127 | {"2byte", cons, 2}, |
| 128 | {"4byte", cons, 4}, |
| 129 | {"8byte", cons, 8}, |
| 130 | /* These are used for dwarf2. */ |
| 131 | { "file", (void (*) PARAMS ((int))) dwarf2_directive_file, 0 }, |
| 132 | { "loc", dwarf2_directive_loc, 0 }, |
| 133 | |
| 134 | /* We need to trap the section changing calls to handle .previous. */ |
| 135 | {"data", obj_elf_data, 0}, |
| 136 | {"text", obj_elf_text, 0}, |
| 137 | |
| 138 | {"tls_common", obj_elf_tls_common, 0}, |
| 139 | |
| 140 | /* End sentinel. */ |
| 141 | {NULL, NULL, 0}, |
| 142 | }; |
| 143 | |
| 144 | static const pseudo_typeS ecoff_debug_pseudo_table[] = |
| 145 | { |
| 146 | #ifdef NEED_ECOFF_DEBUG |
| 147 | /* COFF style debugging information for ECOFF. .ln is not used; .loc |
| 148 | is used instead. */ |
| 149 | { "def", ecoff_directive_def, 0 }, |
| 150 | { "dim", ecoff_directive_dim, 0 }, |
| 151 | { "endef", ecoff_directive_endef, 0 }, |
| 152 | { "file", ecoff_directive_file, 0 }, |
| 153 | { "scl", ecoff_directive_scl, 0 }, |
| 154 | { "tag", ecoff_directive_tag, 0 }, |
| 155 | { "val", ecoff_directive_val, 0 }, |
| 156 | |
| 157 | /* COFF debugging requires pseudo-ops .size and .type, but ELF |
| 158 | already has meanings for those. We use .esize and .etype |
| 159 | instead. These are only generated by gcc anyhow. */ |
| 160 | { "esize", ecoff_directive_size, 0 }, |
| 161 | { "etype", ecoff_directive_type, 0 }, |
| 162 | |
| 163 | /* ECOFF specific debugging information. */ |
| 164 | { "begin", ecoff_directive_begin, 0 }, |
| 165 | { "bend", ecoff_directive_bend, 0 }, |
| 166 | { "end", ecoff_directive_end, 0 }, |
| 167 | { "ent", ecoff_directive_ent, 0 }, |
| 168 | { "fmask", ecoff_directive_fmask, 0 }, |
| 169 | { "frame", ecoff_directive_frame, 0 }, |
| 170 | { "loc", ecoff_directive_loc, 0 }, |
| 171 | { "mask", ecoff_directive_mask, 0 }, |
| 172 | |
| 173 | /* Other ECOFF directives. */ |
| 174 | { "extern", ecoff_directive_extern, 0 }, |
| 175 | |
| 176 | /* These are used on Irix. I don't know how to implement them. */ |
| 177 | { "alias", s_ignore, 0 }, |
| 178 | { "bgnb", s_ignore, 0 }, |
| 179 | { "endb", s_ignore, 0 }, |
| 180 | { "lab", s_ignore, 0 }, |
| 181 | { "noalias", s_ignore, 0 }, |
| 182 | { "verstamp", s_ignore, 0 }, |
| 183 | { "vreg", s_ignore, 0 }, |
| 184 | #endif |
| 185 | |
| 186 | {NULL, NULL, 0} /* end sentinel */ |
| 187 | }; |
| 188 | |
| 189 | #undef NO_RELOC |
| 190 | #include "aout/aout64.h" |
| 191 | |
| 192 | /* This is called when the assembler starts. */ |
| 193 | |
| 194 | void |
| 195 | elf_begin () |
| 196 | { |
| 197 | /* Add symbols for the known sections to the symbol table. */ |
| 198 | symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput, |
| 199 | TEXT_SECTION_NAME))); |
| 200 | symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput, |
| 201 | DATA_SECTION_NAME))); |
| 202 | symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput, |
| 203 | BSS_SECTION_NAME))); |
| 204 | } |
| 205 | |
| 206 | void |
| 207 | elf_pop_insert () |
| 208 | { |
| 209 | pop_insert (elf_pseudo_table); |
| 210 | if (ECOFF_DEBUGGING) |
| 211 | pop_insert (ecoff_debug_pseudo_table); |
| 212 | } |
| 213 | |
| 214 | static bfd_vma |
| 215 | elf_s_get_size (sym) |
| 216 | symbolS *sym; |
| 217 | { |
| 218 | return S_GET_SIZE (sym); |
| 219 | } |
| 220 | |
| 221 | static void |
| 222 | elf_s_set_size (sym, sz) |
| 223 | symbolS *sym; |
| 224 | bfd_vma sz; |
| 225 | { |
| 226 | S_SET_SIZE (sym, sz); |
| 227 | } |
| 228 | |
| 229 | static bfd_vma |
| 230 | elf_s_get_align (sym) |
| 231 | symbolS *sym; |
| 232 | { |
| 233 | return S_GET_ALIGN (sym); |
| 234 | } |
| 235 | |
| 236 | static void |
| 237 | elf_s_set_align (sym, align) |
| 238 | symbolS *sym; |
| 239 | bfd_vma align; |
| 240 | { |
| 241 | S_SET_ALIGN (sym, align); |
| 242 | } |
| 243 | |
| 244 | int |
| 245 | elf_s_get_other (sym) |
| 246 | symbolS *sym; |
| 247 | { |
| 248 | return elf_symbol (symbol_get_bfdsym (sym))->internal_elf_sym.st_other; |
| 249 | } |
| 250 | |
| 251 | static void |
| 252 | elf_s_set_other (sym, other) |
| 253 | symbolS *sym; |
| 254 | int other; |
| 255 | { |
| 256 | S_SET_OTHER (sym, other); |
| 257 | } |
| 258 | |
| 259 | static int |
| 260 | elf_sec_sym_ok_for_reloc (sec) |
| 261 | asection *sec; |
| 262 | { |
| 263 | return obj_sec_sym_ok_for_reloc (sec); |
| 264 | } |
| 265 | |
| 266 | void |
| 267 | elf_file_symbol (s) |
| 268 | const char *s; |
| 269 | { |
| 270 | symbolS *sym; |
| 271 | |
| 272 | sym = symbol_new (s, absolute_section, (valueT) 0, (struct frag *) 0); |
| 273 | symbol_set_frag (sym, &zero_address_frag); |
| 274 | symbol_get_bfdsym (sym)->flags |= BSF_FILE; |
| 275 | |
| 276 | if (symbol_rootP != sym) |
| 277 | { |
| 278 | symbol_remove (sym, &symbol_rootP, &symbol_lastP); |
| 279 | symbol_insert (sym, symbol_rootP, &symbol_rootP, &symbol_lastP); |
| 280 | #ifdef DEBUG |
| 281 | verify_symbol_chain (symbol_rootP, symbol_lastP); |
| 282 | #endif |
| 283 | } |
| 284 | |
| 285 | #ifdef NEED_ECOFF_DEBUG |
| 286 | ecoff_new_file (s); |
| 287 | #endif |
| 288 | } |
| 289 | |
| 290 | static symbolS * |
| 291 | elf_common (is_common) |
| 292 | int is_common; |
| 293 | { |
| 294 | char *name; |
| 295 | char c; |
| 296 | char *p; |
| 297 | offsetT temp, size, sign; |
| 298 | symbolS *symbolP; |
| 299 | int have_align; |
| 300 | expressionS exp; |
| 301 | |
| 302 | if (flag_mri && is_common) |
| 303 | { |
| 304 | s_mri_common (0); |
| 305 | return NULL; |
| 306 | } |
| 307 | |
| 308 | name = input_line_pointer; |
| 309 | c = get_symbol_end (); |
| 310 | /* just after name is now '\0' */ |
| 311 | p = input_line_pointer; |
| 312 | *p = c; |
| 313 | SKIP_WHITESPACE (); |
| 314 | if (*input_line_pointer != ',') |
| 315 | { |
| 316 | as_bad (_("expected comma after symbol-name")); |
| 317 | ignore_rest_of_line (); |
| 318 | return NULL; |
| 319 | } |
| 320 | input_line_pointer++; /* skip ',' */ |
| 321 | temp = get_absolute_expr (&exp); |
| 322 | sign = (offsetT) 1 << (stdoutput->arch_info->bits_per_address - 1); |
| 323 | size = temp & ((sign << 1) - 1); |
| 324 | if (temp != size || !exp.X_unsigned) |
| 325 | { |
| 326 | as_bad (_(".COMMon length (%ld) out of range, ignored."), (long) temp); |
| 327 | ignore_rest_of_line (); |
| 328 | return NULL; |
| 329 | } |
| 330 | *p = 0; |
| 331 | symbolP = symbol_find_or_make (name); |
| 332 | *p = c; |
| 333 | if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP)) |
| 334 | { |
| 335 | as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP)); |
| 336 | ignore_rest_of_line (); |
| 337 | return NULL; |
| 338 | } |
| 339 | if (S_GET_VALUE (symbolP) != 0) |
| 340 | { |
| 341 | if (S_GET_VALUE (symbolP) != (valueT) size) |
| 342 | { |
| 343 | as_warn (_("length of .comm \"%s\" is already %ld; not changed to %ld"), |
| 344 | S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), |
| 345 | (long) size); |
| 346 | } |
| 347 | } |
| 348 | know (symbolP->sy_frag == &zero_address_frag); |
| 349 | if (*input_line_pointer != ',') |
| 350 | have_align = 0; |
| 351 | else |
| 352 | { |
| 353 | have_align = 1; |
| 354 | input_line_pointer++; |
| 355 | SKIP_WHITESPACE (); |
| 356 | } |
| 357 | if (! have_align || *input_line_pointer != '"') |
| 358 | { |
| 359 | if (! have_align) |
| 360 | temp = 0; |
| 361 | else |
| 362 | { |
| 363 | temp = get_absolute_expr (&exp); |
| 364 | if (!exp.X_unsigned) |
| 365 | { |
| 366 | temp = 0; |
| 367 | as_warn (_("common alignment negative; 0 assumed")); |
| 368 | } |
| 369 | } |
| 370 | if (symbol_get_obj (symbolP)->local) |
| 371 | { |
| 372 | segT old_sec; |
| 373 | int old_subsec; |
| 374 | char *pfrag; |
| 375 | int align; |
| 376 | |
| 377 | /* allocate_bss: */ |
| 378 | old_sec = now_seg; |
| 379 | old_subsec = now_subseg; |
| 380 | if (temp) |
| 381 | { |
| 382 | /* convert to a power of 2 alignment */ |
| 383 | for (align = 0; (temp & 1) == 0; temp >>= 1, ++align); |
| 384 | if (temp != 1) |
| 385 | { |
| 386 | as_bad (_("common alignment not a power of 2")); |
| 387 | ignore_rest_of_line (); |
| 388 | return NULL; |
| 389 | } |
| 390 | } |
| 391 | else |
| 392 | align = 0; |
| 393 | record_alignment (bss_section, align); |
| 394 | subseg_set (bss_section, 0); |
| 395 | if (align) |
| 396 | frag_align (align, 0, 0); |
| 397 | if (S_GET_SEGMENT (symbolP) == bss_section) |
| 398 | symbol_get_frag (symbolP)->fr_symbol = 0; |
| 399 | symbol_set_frag (symbolP, frag_now); |
| 400 | pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, |
| 401 | (offsetT) size, (char *) 0); |
| 402 | *pfrag = 0; |
| 403 | S_SET_SIZE (symbolP, size); |
| 404 | S_SET_SEGMENT (symbolP, bss_section); |
| 405 | S_CLEAR_EXTERNAL (symbolP); |
| 406 | subseg_set (old_sec, old_subsec); |
| 407 | } |
| 408 | else |
| 409 | { |
| 410 | allocate_common: |
| 411 | S_SET_VALUE (symbolP, (valueT) size); |
| 412 | S_SET_ALIGN (symbolP, temp); |
| 413 | S_SET_EXTERNAL (symbolP); |
| 414 | S_SET_SEGMENT (symbolP, bfd_com_section_ptr); |
| 415 | } |
| 416 | } |
| 417 | else |
| 418 | { |
| 419 | input_line_pointer++; |
| 420 | /* @@ Some use the dot, some don't. Can we get some consistency?? */ |
| 421 | if (*input_line_pointer == '.') |
| 422 | input_line_pointer++; |
| 423 | /* @@ Some say data, some say bss. */ |
| 424 | if (strncmp (input_line_pointer, "bss\"", 4) |
| 425 | && strncmp (input_line_pointer, "data\"", 5)) |
| 426 | { |
| 427 | while (*--input_line_pointer != '"') |
| 428 | ; |
| 429 | input_line_pointer--; |
| 430 | goto bad_common_segment; |
| 431 | } |
| 432 | while (*input_line_pointer++ != '"') |
| 433 | ; |
| 434 | goto allocate_common; |
| 435 | } |
| 436 | |
| 437 | symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; |
| 438 | |
| 439 | demand_empty_rest_of_line (); |
| 440 | return symbolP; |
| 441 | |
| 442 | { |
| 443 | bad_common_segment: |
| 444 | p = input_line_pointer; |
| 445 | while (*p && *p != '\n') |
| 446 | p++; |
| 447 | c = *p; |
| 448 | *p = '\0'; |
| 449 | as_bad (_("bad .common segment %s"), input_line_pointer + 1); |
| 450 | *p = c; |
| 451 | input_line_pointer = p; |
| 452 | ignore_rest_of_line (); |
| 453 | return NULL; |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | void |
| 458 | obj_elf_common (is_common) |
| 459 | int is_common; |
| 460 | { |
| 461 | elf_common (is_common); |
| 462 | } |
| 463 | |
| 464 | static void |
| 465 | obj_elf_tls_common (ignore) |
| 466 | int ignore ATTRIBUTE_UNUSED; |
| 467 | { |
| 468 | symbolS *symbolP = elf_common (0); |
| 469 | |
| 470 | if (symbolP) |
| 471 | symbol_get_bfdsym (symbolP)->flags |= BSF_THREAD_LOCAL; |
| 472 | } |
| 473 | |
| 474 | static void |
| 475 | obj_elf_local (ignore) |
| 476 | int ignore ATTRIBUTE_UNUSED; |
| 477 | { |
| 478 | char *name; |
| 479 | int c; |
| 480 | symbolS *symbolP; |
| 481 | |
| 482 | do |
| 483 | { |
| 484 | name = input_line_pointer; |
| 485 | c = get_symbol_end (); |
| 486 | symbolP = symbol_find_or_make (name); |
| 487 | *input_line_pointer = c; |
| 488 | SKIP_WHITESPACE (); |
| 489 | S_CLEAR_EXTERNAL (symbolP); |
| 490 | symbol_get_obj (symbolP)->local = 1; |
| 491 | if (c == ',') |
| 492 | { |
| 493 | input_line_pointer++; |
| 494 | SKIP_WHITESPACE (); |
| 495 | if (*input_line_pointer == '\n') |
| 496 | c = '\n'; |
| 497 | } |
| 498 | } |
| 499 | while (c == ','); |
| 500 | demand_empty_rest_of_line (); |
| 501 | } |
| 502 | |
| 503 | static void |
| 504 | obj_elf_weak (ignore) |
| 505 | int ignore ATTRIBUTE_UNUSED; |
| 506 | { |
| 507 | char *name; |
| 508 | int c; |
| 509 | symbolS *symbolP; |
| 510 | |
| 511 | do |
| 512 | { |
| 513 | name = input_line_pointer; |
| 514 | c = get_symbol_end (); |
| 515 | symbolP = symbol_find_or_make (name); |
| 516 | *input_line_pointer = c; |
| 517 | SKIP_WHITESPACE (); |
| 518 | S_SET_WEAK (symbolP); |
| 519 | symbol_get_obj (symbolP)->local = 1; |
| 520 | if (c == ',') |
| 521 | { |
| 522 | input_line_pointer++; |
| 523 | SKIP_WHITESPACE (); |
| 524 | if (*input_line_pointer == '\n') |
| 525 | c = '\n'; |
| 526 | } |
| 527 | } |
| 528 | while (c == ','); |
| 529 | demand_empty_rest_of_line (); |
| 530 | } |
| 531 | |
| 532 | static void |
| 533 | obj_elf_visibility (visibility) |
| 534 | int visibility; |
| 535 | { |
| 536 | char *name; |
| 537 | int c; |
| 538 | symbolS *symbolP; |
| 539 | asymbol *bfdsym; |
| 540 | elf_symbol_type *elfsym; |
| 541 | |
| 542 | do |
| 543 | { |
| 544 | name = input_line_pointer; |
| 545 | c = get_symbol_end (); |
| 546 | symbolP = symbol_find_or_make (name); |
| 547 | *input_line_pointer = c; |
| 548 | |
| 549 | SKIP_WHITESPACE (); |
| 550 | |
| 551 | bfdsym = symbol_get_bfdsym (symbolP); |
| 552 | elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym); |
| 553 | |
| 554 | assert (elfsym); |
| 555 | |
| 556 | elfsym->internal_elf_sym.st_other &= ~3; |
| 557 | elfsym->internal_elf_sym.st_other |= visibility; |
| 558 | |
| 559 | if (c == ',') |
| 560 | { |
| 561 | input_line_pointer ++; |
| 562 | |
| 563 | SKIP_WHITESPACE (); |
| 564 | |
| 565 | if (*input_line_pointer == '\n') |
| 566 | c = '\n'; |
| 567 | } |
| 568 | } |
| 569 | while (c == ','); |
| 570 | |
| 571 | demand_empty_rest_of_line (); |
| 572 | } |
| 573 | |
| 574 | static segT previous_section; |
| 575 | static int previous_subsection; |
| 576 | |
| 577 | struct section_stack |
| 578 | { |
| 579 | struct section_stack *next; |
| 580 | segT seg, prev_seg; |
| 581 | int subseg, prev_subseg; |
| 582 | }; |
| 583 | |
| 584 | static struct section_stack *section_stack; |
| 585 | |
| 586 | /* Handle the .section pseudo-op. This code supports two different |
| 587 | syntaxes. |
| 588 | |
| 589 | The first is found on Solaris, and looks like |
| 590 | .section ".sec1",#alloc,#execinstr,#write |
| 591 | Here the names after '#' are the SHF_* flags to turn on for the |
| 592 | section. I'm not sure how it determines the SHT_* type (BFD |
| 593 | doesn't really give us control over the type, anyhow). |
| 594 | |
| 595 | The second format is found on UnixWare, and probably most SVR4 |
| 596 | machines, and looks like |
| 597 | .section .sec1,"a",@progbits |
| 598 | The quoted string may contain any combination of a, w, x, and |
| 599 | represents the SHF_* flags to turn on for the section. The string |
| 600 | beginning with '@' can be progbits or nobits. There should be |
| 601 | other possibilities, but I don't know what they are. In any case, |
| 602 | BFD doesn't really let us set the section type. */ |
| 603 | |
| 604 | void |
| 605 | obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push) |
| 606 | const char *name; |
| 607 | int type; |
| 608 | int attr; |
| 609 | int entsize; |
| 610 | const char *group_name; |
| 611 | int linkonce; |
| 612 | int push; |
| 613 | { |
| 614 | asection *old_sec; |
| 615 | segT sec; |
| 616 | flagword flags; |
| 617 | int def_type; |
| 618 | int def_attr; |
| 619 | |
| 620 | #ifdef md_flush_pending_output |
| 621 | md_flush_pending_output (); |
| 622 | #endif |
| 623 | |
| 624 | /* Switch to the section, creating it if necessary. */ |
| 625 | if (push) |
| 626 | { |
| 627 | struct section_stack *elt; |
| 628 | elt = xmalloc (sizeof (struct section_stack)); |
| 629 | elt->next = section_stack; |
| 630 | elt->seg = now_seg; |
| 631 | elt->prev_seg = previous_section; |
| 632 | elt->subseg = now_subseg; |
| 633 | elt->prev_subseg = previous_subsection; |
| 634 | section_stack = elt; |
| 635 | } |
| 636 | previous_section = now_seg; |
| 637 | previous_subsection = now_subseg; |
| 638 | |
| 639 | old_sec = bfd_get_section_by_name (stdoutput, name); |
| 640 | sec = subseg_new (name, 0); |
| 641 | |
| 642 | if (_bfd_elf_get_sec_type_attr (stdoutput, name, &def_type, |
| 643 | &def_attr)) |
| 644 | { |
| 645 | if (type == SHT_NULL) |
| 646 | type = def_type; |
| 647 | else if (type != def_type) |
| 648 | { |
| 649 | if (old_sec == NULL |
| 650 | /* FIXME: gcc, as of 2002-10-22, will emit |
| 651 | |
| 652 | .section .init_array,"aw",@progbits |
| 653 | |
| 654 | for __attribute__ ((section (".init_array"))). |
| 655 | "@progbits" is incorrect. */ |
| 656 | && def_type != SHT_INIT_ARRAY |
| 657 | && def_type != SHT_FINI_ARRAY |
| 658 | && def_type != SHT_PREINIT_ARRAY) |
| 659 | { |
| 660 | /* We allow to specify any type for a .note section. */ |
| 661 | if (def_type != SHT_NOTE) |
| 662 | as_warn (_("setting incorrect section type for %s"), |
| 663 | name); |
| 664 | } |
| 665 | else |
| 666 | { |
| 667 | as_warn (_("ignoring incorrect section type for %s"), |
| 668 | name); |
| 669 | type = def_type; |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | if (old_sec == NULL && (attr &~ def_attr) != 0) |
| 674 | { |
| 675 | /* As a GNU extension, we permit a .note section to be |
| 676 | allocatable. If the linker sees an allocateable .note |
| 677 | section, it will create a PT_NOTE segment in the output |
| 678 | file. We also allow "x" for .note.GNU-stack. */ |
| 679 | if (!(def_type == SHT_NOTE |
| 680 | && (attr == SHF_ALLOC || attr == SHF_EXECINSTR))) |
| 681 | as_warn (_("setting incorrect section attributes for %s"), |
| 682 | name); |
| 683 | } |
| 684 | attr |= def_attr; |
| 685 | } |
| 686 | |
| 687 | if (type != SHT_NULL) |
| 688 | elf_section_type (sec) = type; |
| 689 | if (attr != 0) |
| 690 | elf_section_flags (sec) = attr; |
| 691 | |
| 692 | /* Convert ELF type and flags to BFD flags. */ |
| 693 | flags = (SEC_RELOC |
| 694 | | ((attr & SHF_WRITE) ? 0 : SEC_READONLY) |
| 695 | | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0) |
| 696 | | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0) |
| 697 | | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0) |
| 698 | | ((attr & SHF_MERGE) ? SEC_MERGE : 0) |
| 699 | | ((attr & SHF_STRINGS) ? SEC_STRINGS : 0) |
| 700 | | ((attr & SHF_TLS) ? SEC_THREAD_LOCAL : 0)); |
| 701 | #ifdef md_elf_section_flags |
| 702 | flags = md_elf_section_flags (flags, attr, type); |
| 703 | #endif |
| 704 | |
| 705 | if (old_sec == NULL) |
| 706 | { |
| 707 | symbolS *secsym; |
| 708 | |
| 709 | /* Prevent SEC_HAS_CONTENTS from being inadvertently set. */ |
| 710 | if (type == SHT_NOBITS) |
| 711 | seg_info (sec)->bss = 1; |
| 712 | |
| 713 | if (linkonce) |
| 714 | flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; |
| 715 | bfd_set_section_flags (stdoutput, sec, flags); |
| 716 | if (flags & SEC_MERGE) |
| 717 | sec->entsize = entsize; |
| 718 | elf_group_name (sec) = group_name; |
| 719 | |
| 720 | /* Add a symbol for this section to the symbol table. */ |
| 721 | secsym = symbol_find (name); |
| 722 | if (secsym != NULL) |
| 723 | symbol_set_bfdsym (secsym, sec->symbol); |
| 724 | else |
| 725 | symbol_table_insert (section_symbol (sec)); |
| 726 | } |
| 727 | else if (attr != 0) |
| 728 | { |
| 729 | /* If section attributes are specified the second time we see a |
| 730 | particular section, then check that they are the same as we |
| 731 | saw the first time. */ |
| 732 | if (((old_sec->flags ^ flags) |
| 733 | & (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE |
| 734 | | SEC_EXCLUDE | SEC_SORT_ENTRIES | SEC_MERGE | SEC_STRINGS |
| 735 | | SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD |
| 736 | | SEC_THREAD_LOCAL))) |
| 737 | as_warn (_("ignoring changed section attributes for %s"), name); |
| 738 | if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize) |
| 739 | as_warn (_("ignoring changed section entity size for %s"), name); |
| 740 | if ((attr & SHF_GROUP) != 0 |
| 741 | && strcmp (elf_group_name (old_sec), group_name) != 0) |
| 742 | as_warn (_("ignoring new section group for %s"), name); |
| 743 | } |
| 744 | |
| 745 | #ifdef md_elf_section_change_hook |
| 746 | md_elf_section_change_hook (); |
| 747 | #endif |
| 748 | } |
| 749 | |
| 750 | static int |
| 751 | obj_elf_parse_section_letters (str, len) |
| 752 | char *str; |
| 753 | size_t len; |
| 754 | { |
| 755 | int attr = 0; |
| 756 | |
| 757 | while (len > 0) |
| 758 | { |
| 759 | switch (*str) |
| 760 | { |
| 761 | case 'a': |
| 762 | attr |= SHF_ALLOC; |
| 763 | break; |
| 764 | case 'w': |
| 765 | attr |= SHF_WRITE; |
| 766 | break; |
| 767 | case 'x': |
| 768 | attr |= SHF_EXECINSTR; |
| 769 | break; |
| 770 | case 'M': |
| 771 | attr |= SHF_MERGE; |
| 772 | break; |
| 773 | case 'S': |
| 774 | attr |= SHF_STRINGS; |
| 775 | break; |
| 776 | case 'G': |
| 777 | attr |= SHF_GROUP; |
| 778 | break; |
| 779 | case 'T': |
| 780 | attr |= SHF_TLS; |
| 781 | break; |
| 782 | /* Compatibility. */ |
| 783 | case 'm': |
| 784 | if (*(str - 1) == 'a') |
| 785 | { |
| 786 | attr |= SHF_MERGE; |
| 787 | if (len > 1 && str[1] == 's') |
| 788 | { |
| 789 | attr |= SHF_STRINGS; |
| 790 | str++, len--; |
| 791 | } |
| 792 | break; |
| 793 | } |
| 794 | default: |
| 795 | { |
| 796 | char *bad_msg = _("unrecognized .section attribute: want a,w,x,M,S,G,T"); |
| 797 | #ifdef md_elf_section_letter |
| 798 | int md_attr = md_elf_section_letter (*str, &bad_msg); |
| 799 | if (md_attr >= 0) |
| 800 | attr |= md_attr; |
| 801 | else |
| 802 | #endif |
| 803 | as_fatal ("%s", bad_msg); |
| 804 | } |
| 805 | break; |
| 806 | } |
| 807 | str++, len--; |
| 808 | } |
| 809 | |
| 810 | return attr; |
| 811 | } |
| 812 | |
| 813 | static int |
| 814 | obj_elf_section_word (str, len) |
| 815 | char *str; |
| 816 | size_t len; |
| 817 | { |
| 818 | if (len == 5 && strncmp (str, "write", 5) == 0) |
| 819 | return SHF_WRITE; |
| 820 | if (len == 5 && strncmp (str, "alloc", 5) == 0) |
| 821 | return SHF_ALLOC; |
| 822 | if (len == 9 && strncmp (str, "execinstr", 9) == 0) |
| 823 | return SHF_EXECINSTR; |
| 824 | if (len == 3 && strncmp (str, "tls", 3) == 0) |
| 825 | return SHF_TLS; |
| 826 | |
| 827 | #ifdef md_elf_section_word |
| 828 | { |
| 829 | int md_attr = md_elf_section_word (str, len); |
| 830 | if (md_attr >= 0) |
| 831 | return md_attr; |
| 832 | } |
| 833 | #endif |
| 834 | |
| 835 | as_warn (_("unrecognized section attribute")); |
| 836 | return 0; |
| 837 | } |
| 838 | |
| 839 | static int |
| 840 | obj_elf_section_type (str, len) |
| 841 | char *str; |
| 842 | size_t len; |
| 843 | { |
| 844 | if (len == 8 && strncmp (str, "progbits", 8) == 0) |
| 845 | return SHT_PROGBITS; |
| 846 | if (len == 6 && strncmp (str, "nobits", 6) == 0) |
| 847 | return SHT_NOBITS; |
| 848 | if (len == 4 && strncmp (str, "note", 4) == 0) |
| 849 | return SHT_NOTE; |
| 850 | |
| 851 | #ifdef md_elf_section_type |
| 852 | { |
| 853 | int md_type = md_elf_section_type (str, len); |
| 854 | if (md_type >= 0) |
| 855 | return md_type; |
| 856 | } |
| 857 | #endif |
| 858 | |
| 859 | as_warn (_("unrecognized section type")); |
| 860 | return 0; |
| 861 | } |
| 862 | |
| 863 | /* Get name of section. */ |
| 864 | static char * |
| 865 | obj_elf_section_name () |
| 866 | { |
| 867 | char *name; |
| 868 | |
| 869 | SKIP_WHITESPACE (); |
| 870 | if (*input_line_pointer == '"') |
| 871 | { |
| 872 | int dummy; |
| 873 | |
| 874 | name = demand_copy_C_string (&dummy); |
| 875 | if (name == NULL) |
| 876 | { |
| 877 | ignore_rest_of_line (); |
| 878 | return NULL; |
| 879 | } |
| 880 | } |
| 881 | else |
| 882 | { |
| 883 | char *end = input_line_pointer; |
| 884 | |
| 885 | while (0 == strchr ("\n\t,; ", *end)) |
| 886 | end++; |
| 887 | if (end == input_line_pointer) |
| 888 | { |
| 889 | as_warn (_("missing name")); |
| 890 | ignore_rest_of_line (); |
| 891 | return NULL; |
| 892 | } |
| 893 | |
| 894 | name = xmalloc (end - input_line_pointer + 1); |
| 895 | memcpy (name, input_line_pointer, end - input_line_pointer); |
| 896 | name[end - input_line_pointer] = '\0'; |
| 897 | #ifdef tc_canonicalize_section_name |
| 898 | name = tc_canonicalize_section_name (name); |
| 899 | #endif |
| 900 | input_line_pointer = end; |
| 901 | } |
| 902 | SKIP_WHITESPACE (); |
| 903 | return name; |
| 904 | } |
| 905 | |
| 906 | void |
| 907 | obj_elf_section (push) |
| 908 | int push; |
| 909 | { |
| 910 | char *name, *group_name, *beg; |
| 911 | int type, attr, dummy; |
| 912 | int entsize; |
| 913 | int linkonce; |
| 914 | |
| 915 | #ifndef TC_I370 |
| 916 | if (flag_mri) |
| 917 | { |
| 918 | char mri_type; |
| 919 | |
| 920 | #ifdef md_flush_pending_output |
| 921 | md_flush_pending_output (); |
| 922 | #endif |
| 923 | |
| 924 | previous_section = now_seg; |
| 925 | previous_subsection = now_subseg; |
| 926 | |
| 927 | s_mri_sect (&mri_type); |
| 928 | |
| 929 | #ifdef md_elf_section_change_hook |
| 930 | md_elf_section_change_hook (); |
| 931 | #endif |
| 932 | |
| 933 | return; |
| 934 | } |
| 935 | #endif /* ! defined (TC_I370) */ |
| 936 | |
| 937 | name = obj_elf_section_name (); |
| 938 | if (name == NULL) |
| 939 | return; |
| 940 | type = SHT_NULL; |
| 941 | attr = 0; |
| 942 | group_name = NULL; |
| 943 | entsize = 0; |
| 944 | linkonce = 0; |
| 945 | |
| 946 | if (*input_line_pointer == ',') |
| 947 | { |
| 948 | /* Skip the comma. */ |
| 949 | ++input_line_pointer; |
| 950 | SKIP_WHITESPACE (); |
| 951 | |
| 952 | if (*input_line_pointer == '"') |
| 953 | { |
| 954 | beg = demand_copy_C_string (&dummy); |
| 955 | if (beg == NULL) |
| 956 | { |
| 957 | ignore_rest_of_line (); |
| 958 | return; |
| 959 | } |
| 960 | attr |= obj_elf_parse_section_letters (beg, strlen (beg)); |
| 961 | |
| 962 | SKIP_WHITESPACE (); |
| 963 | if (*input_line_pointer == ',') |
| 964 | { |
| 965 | char c; |
| 966 | char *save = input_line_pointer; |
| 967 | |
| 968 | ++input_line_pointer; |
| 969 | SKIP_WHITESPACE (); |
| 970 | c = *input_line_pointer; |
| 971 | if (c == '"') |
| 972 | { |
| 973 | beg = demand_copy_C_string (&dummy); |
| 974 | if (beg == NULL) |
| 975 | { |
| 976 | ignore_rest_of_line (); |
| 977 | return; |
| 978 | } |
| 979 | type = obj_elf_section_type (beg, strlen (beg)); |
| 980 | } |
| 981 | else if (c == '@' || c == '%') |
| 982 | { |
| 983 | beg = ++input_line_pointer; |
| 984 | c = get_symbol_end (); |
| 985 | *input_line_pointer = c; |
| 986 | type = obj_elf_section_type (beg, input_line_pointer - beg); |
| 987 | } |
| 988 | else |
| 989 | input_line_pointer = save; |
| 990 | } |
| 991 | |
| 992 | SKIP_WHITESPACE (); |
| 993 | if ((attr & SHF_MERGE) != 0 && *input_line_pointer == ',') |
| 994 | { |
| 995 | ++input_line_pointer; |
| 996 | SKIP_WHITESPACE (); |
| 997 | entsize = get_absolute_expression (); |
| 998 | SKIP_WHITESPACE (); |
| 999 | if (entsize < 0) |
| 1000 | { |
| 1001 | as_warn (_("invalid merge entity size")); |
| 1002 | attr &= ~SHF_MERGE; |
| 1003 | entsize = 0; |
| 1004 | } |
| 1005 | } |
| 1006 | else if ((attr & SHF_MERGE) != 0) |
| 1007 | { |
| 1008 | as_warn (_("entity size for SHF_MERGE not specified")); |
| 1009 | attr &= ~SHF_MERGE; |
| 1010 | } |
| 1011 | |
| 1012 | if ((attr & SHF_GROUP) != 0 && *input_line_pointer == ',') |
| 1013 | { |
| 1014 | ++input_line_pointer; |
| 1015 | group_name = obj_elf_section_name (); |
| 1016 | if (group_name == NULL) |
| 1017 | attr &= ~SHF_GROUP; |
| 1018 | else if (strncmp (input_line_pointer, ",comdat", 7) == 0) |
| 1019 | { |
| 1020 | input_line_pointer += 7; |
| 1021 | linkonce = 1; |
| 1022 | } |
| 1023 | else if (strncmp (name, ".gnu.linkonce", 13) == 0) |
| 1024 | linkonce = 1; |
| 1025 | } |
| 1026 | else if ((attr & SHF_GROUP) != 0) |
| 1027 | { |
| 1028 | as_warn (_("group name for SHF_GROUP not specified")); |
| 1029 | attr &= ~SHF_GROUP; |
| 1030 | } |
| 1031 | } |
| 1032 | else |
| 1033 | { |
| 1034 | do |
| 1035 | { |
| 1036 | char c; |
| 1037 | |
| 1038 | SKIP_WHITESPACE (); |
| 1039 | if (*input_line_pointer != '#') |
| 1040 | { |
| 1041 | as_warn (_("character following name is not '#'")); |
| 1042 | ignore_rest_of_line (); |
| 1043 | return; |
| 1044 | } |
| 1045 | beg = ++input_line_pointer; |
| 1046 | c = get_symbol_end (); |
| 1047 | *input_line_pointer = c; |
| 1048 | |
| 1049 | attr |= obj_elf_section_word (beg, input_line_pointer - beg); |
| 1050 | |
| 1051 | SKIP_WHITESPACE (); |
| 1052 | } |
| 1053 | while (*input_line_pointer++ == ','); |
| 1054 | --input_line_pointer; |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | demand_empty_rest_of_line (); |
| 1059 | |
| 1060 | obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push); |
| 1061 | } |
| 1062 | |
| 1063 | /* Change to the .data section. */ |
| 1064 | |
| 1065 | void |
| 1066 | obj_elf_data (i) |
| 1067 | int i; |
| 1068 | { |
| 1069 | #ifdef md_flush_pending_output |
| 1070 | md_flush_pending_output (); |
| 1071 | #endif |
| 1072 | |
| 1073 | previous_section = now_seg; |
| 1074 | previous_subsection = now_subseg; |
| 1075 | s_data (i); |
| 1076 | |
| 1077 | #ifdef md_elf_section_change_hook |
| 1078 | md_elf_section_change_hook (); |
| 1079 | #endif |
| 1080 | } |
| 1081 | |
| 1082 | /* Change to the .text section. */ |
| 1083 | |
| 1084 | void |
| 1085 | obj_elf_text (i) |
| 1086 | int i; |
| 1087 | { |
| 1088 | #ifdef md_flush_pending_output |
| 1089 | md_flush_pending_output (); |
| 1090 | #endif |
| 1091 | |
| 1092 | previous_section = now_seg; |
| 1093 | previous_subsection = now_subseg; |
| 1094 | s_text (i); |
| 1095 | |
| 1096 | #ifdef md_elf_section_change_hook |
| 1097 | md_elf_section_change_hook (); |
| 1098 | #endif |
| 1099 | } |
| 1100 | |
| 1101 | static void |
| 1102 | obj_elf_subsection (ignore) |
| 1103 | int ignore ATTRIBUTE_UNUSED; |
| 1104 | { |
| 1105 | register int temp; |
| 1106 | |
| 1107 | #ifdef md_flush_pending_output |
| 1108 | md_flush_pending_output (); |
| 1109 | #endif |
| 1110 | |
| 1111 | previous_section = now_seg; |
| 1112 | previous_subsection = now_subseg; |
| 1113 | |
| 1114 | temp = get_absolute_expression (); |
| 1115 | subseg_set (now_seg, (subsegT) temp); |
| 1116 | demand_empty_rest_of_line (); |
| 1117 | |
| 1118 | #ifdef md_elf_section_change_hook |
| 1119 | md_elf_section_change_hook (); |
| 1120 | #endif |
| 1121 | } |
| 1122 | |
| 1123 | /* This can be called from the processor backends if they change |
| 1124 | sections. */ |
| 1125 | |
| 1126 | void |
| 1127 | obj_elf_section_change_hook () |
| 1128 | { |
| 1129 | previous_section = now_seg; |
| 1130 | previous_subsection = now_subseg; |
| 1131 | } |
| 1132 | |
| 1133 | void |
| 1134 | obj_elf_previous (ignore) |
| 1135 | int ignore ATTRIBUTE_UNUSED; |
| 1136 | { |
| 1137 | segT new_section; |
| 1138 | int new_subsection; |
| 1139 | |
| 1140 | if (previous_section == 0) |
| 1141 | { |
| 1142 | as_warn (_(".previous without corresponding .section; ignored")); |
| 1143 | return; |
| 1144 | } |
| 1145 | |
| 1146 | #ifdef md_flush_pending_output |
| 1147 | md_flush_pending_output (); |
| 1148 | #endif |
| 1149 | |
| 1150 | new_section = previous_section; |
| 1151 | new_subsection = previous_subsection; |
| 1152 | previous_section = now_seg; |
| 1153 | previous_subsection = now_subseg; |
| 1154 | subseg_set (new_section, new_subsection); |
| 1155 | |
| 1156 | #ifdef md_elf_section_change_hook |
| 1157 | md_elf_section_change_hook (); |
| 1158 | #endif |
| 1159 | } |
| 1160 | |
| 1161 | static void |
| 1162 | obj_elf_popsection (xxx) |
| 1163 | int xxx ATTRIBUTE_UNUSED; |
| 1164 | { |
| 1165 | struct section_stack *top = section_stack; |
| 1166 | |
| 1167 | if (top == NULL) |
| 1168 | { |
| 1169 | as_warn (_(".popsection without corresponding .pushsection; ignored")); |
| 1170 | return; |
| 1171 | } |
| 1172 | |
| 1173 | #ifdef md_flush_pending_output |
| 1174 | md_flush_pending_output (); |
| 1175 | #endif |
| 1176 | |
| 1177 | section_stack = top->next; |
| 1178 | previous_section = top->prev_seg; |
| 1179 | previous_subsection = top->prev_subseg; |
| 1180 | subseg_set (top->seg, top->subseg); |
| 1181 | free (top); |
| 1182 | |
| 1183 | #ifdef md_elf_section_change_hook |
| 1184 | md_elf_section_change_hook (); |
| 1185 | #endif |
| 1186 | } |
| 1187 | |
| 1188 | static void |
| 1189 | obj_elf_line (ignore) |
| 1190 | int ignore ATTRIBUTE_UNUSED; |
| 1191 | { |
| 1192 | /* Assume delimiter is part of expression. BSD4.2 as fails with |
| 1193 | delightful bug, so we are not being incompatible here. */ |
| 1194 | new_logical_line ((char *) NULL, (int) (get_absolute_expression ())); |
| 1195 | demand_empty_rest_of_line (); |
| 1196 | } |
| 1197 | |
| 1198 | /* This handles the .symver pseudo-op, which is used to specify a |
| 1199 | symbol version. The syntax is ``.symver NAME,SYMVERNAME''. |
| 1200 | SYMVERNAME may contain ELF_VER_CHR ('@') characters. This |
| 1201 | pseudo-op causes the assembler to emit a symbol named SYMVERNAME |
| 1202 | with the same value as the symbol NAME. */ |
| 1203 | |
| 1204 | static void |
| 1205 | obj_elf_symver (ignore) |
| 1206 | int ignore ATTRIBUTE_UNUSED; |
| 1207 | { |
| 1208 | char *name; |
| 1209 | char c; |
| 1210 | char old_lexat; |
| 1211 | symbolS *sym; |
| 1212 | |
| 1213 | name = input_line_pointer; |
| 1214 | c = get_symbol_end (); |
| 1215 | |
| 1216 | sym = symbol_find_or_make (name); |
| 1217 | |
| 1218 | *input_line_pointer = c; |
| 1219 | |
| 1220 | SKIP_WHITESPACE (); |
| 1221 | if (*input_line_pointer != ',') |
| 1222 | { |
| 1223 | as_bad (_("expected comma after name in .symver")); |
| 1224 | ignore_rest_of_line (); |
| 1225 | return; |
| 1226 | } |
| 1227 | |
| 1228 | ++input_line_pointer; |
| 1229 | SKIP_WHITESPACE (); |
| 1230 | name = input_line_pointer; |
| 1231 | |
| 1232 | /* Temporarily include '@' in symbol names. */ |
| 1233 | old_lexat = lex_type[(unsigned char) '@']; |
| 1234 | lex_type[(unsigned char) '@'] |= LEX_NAME; |
| 1235 | c = get_symbol_end (); |
| 1236 | lex_type[(unsigned char) '@'] = old_lexat; |
| 1237 | |
| 1238 | if (symbol_get_obj (sym)->versioned_name == NULL) |
| 1239 | { |
| 1240 | symbol_get_obj (sym)->versioned_name = xstrdup (name); |
| 1241 | |
| 1242 | *input_line_pointer = c; |
| 1243 | |
| 1244 | if (strchr (symbol_get_obj (sym)->versioned_name, |
| 1245 | ELF_VER_CHR) == NULL) |
| 1246 | { |
| 1247 | as_bad (_("missing version name in `%s' for symbol `%s'"), |
| 1248 | symbol_get_obj (sym)->versioned_name, |
| 1249 | S_GET_NAME (sym)); |
| 1250 | ignore_rest_of_line (); |
| 1251 | return; |
| 1252 | } |
| 1253 | } |
| 1254 | else |
| 1255 | { |
| 1256 | if (strcmp (symbol_get_obj (sym)->versioned_name, name)) |
| 1257 | { |
| 1258 | as_bad (_("multiple versions [`%s'|`%s'] for symbol `%s'"), |
| 1259 | name, symbol_get_obj (sym)->versioned_name, |
| 1260 | S_GET_NAME (sym)); |
| 1261 | ignore_rest_of_line (); |
| 1262 | return; |
| 1263 | } |
| 1264 | |
| 1265 | *input_line_pointer = c; |
| 1266 | } |
| 1267 | |
| 1268 | demand_empty_rest_of_line (); |
| 1269 | } |
| 1270 | |
| 1271 | /* This handles the .vtable_inherit pseudo-op, which is used to indicate |
| 1272 | to the linker the hierarchy in which a particular table resides. The |
| 1273 | syntax is ".vtable_inherit CHILDNAME, PARENTNAME". */ |
| 1274 | |
| 1275 | struct fix * |
| 1276 | obj_elf_vtable_inherit (ignore) |
| 1277 | int ignore ATTRIBUTE_UNUSED; |
| 1278 | { |
| 1279 | char *cname, *pname; |
| 1280 | symbolS *csym, *psym; |
| 1281 | char c, bad = 0; |
| 1282 | |
| 1283 | if (*input_line_pointer == '#') |
| 1284 | ++input_line_pointer; |
| 1285 | |
| 1286 | cname = input_line_pointer; |
| 1287 | c = get_symbol_end (); |
| 1288 | csym = symbol_find (cname); |
| 1289 | |
| 1290 | /* GCFIXME: should check that we don't have two .vtable_inherits for |
| 1291 | the same child symbol. Also, we can currently only do this if the |
| 1292 | child symbol is already exists and is placed in a fragment. */ |
| 1293 | |
| 1294 | if (csym == NULL || symbol_get_frag (csym) == NULL) |
| 1295 | { |
| 1296 | as_bad ("expected `%s' to have already been set for .vtable_inherit", |
| 1297 | cname); |
| 1298 | bad = 1; |
| 1299 | } |
| 1300 | |
| 1301 | *input_line_pointer = c; |
| 1302 | |
| 1303 | SKIP_WHITESPACE (); |
| 1304 | if (*input_line_pointer != ',') |
| 1305 | { |
| 1306 | as_bad ("expected comma after name in .vtable_inherit"); |
| 1307 | ignore_rest_of_line (); |
| 1308 | return NULL; |
| 1309 | } |
| 1310 | |
| 1311 | ++input_line_pointer; |
| 1312 | SKIP_WHITESPACE (); |
| 1313 | |
| 1314 | if (*input_line_pointer == '#') |
| 1315 | ++input_line_pointer; |
| 1316 | |
| 1317 | if (input_line_pointer[0] == '0' |
| 1318 | && (input_line_pointer[1] == '\0' |
| 1319 | || ISSPACE (input_line_pointer[1]))) |
| 1320 | { |
| 1321 | psym = section_symbol (absolute_section); |
| 1322 | ++input_line_pointer; |
| 1323 | } |
| 1324 | else |
| 1325 | { |
| 1326 | pname = input_line_pointer; |
| 1327 | c = get_symbol_end (); |
| 1328 | psym = symbol_find_or_make (pname); |
| 1329 | *input_line_pointer = c; |
| 1330 | } |
| 1331 | |
| 1332 | demand_empty_rest_of_line (); |
| 1333 | |
| 1334 | if (bad) |
| 1335 | return NULL; |
| 1336 | |
| 1337 | assert (symbol_get_value_expression (csym)->X_op == O_constant); |
| 1338 | return fix_new (symbol_get_frag (csym), |
| 1339 | symbol_get_value_expression (csym)->X_add_number, |
| 1340 | 0, psym, 0, 0, BFD_RELOC_VTABLE_INHERIT); |
| 1341 | } |
| 1342 | |
| 1343 | /* This handles the .vtable_entry pseudo-op, which is used to indicate |
| 1344 | to the linker that a vtable slot was used. The syntax is |
| 1345 | ".vtable_entry tablename, offset". */ |
| 1346 | |
| 1347 | struct fix * |
| 1348 | obj_elf_vtable_entry (ignore) |
| 1349 | int ignore ATTRIBUTE_UNUSED; |
| 1350 | { |
| 1351 | char *name; |
| 1352 | symbolS *sym; |
| 1353 | offsetT offset; |
| 1354 | char c; |
| 1355 | |
| 1356 | if (*input_line_pointer == '#') |
| 1357 | ++input_line_pointer; |
| 1358 | |
| 1359 | name = input_line_pointer; |
| 1360 | c = get_symbol_end (); |
| 1361 | sym = symbol_find_or_make (name); |
| 1362 | *input_line_pointer = c; |
| 1363 | |
| 1364 | SKIP_WHITESPACE (); |
| 1365 | if (*input_line_pointer != ',') |
| 1366 | { |
| 1367 | as_bad ("expected comma after name in .vtable_entry"); |
| 1368 | ignore_rest_of_line (); |
| 1369 | return NULL; |
| 1370 | } |
| 1371 | |
| 1372 | ++input_line_pointer; |
| 1373 | if (*input_line_pointer == '#') |
| 1374 | ++input_line_pointer; |
| 1375 | |
| 1376 | offset = get_absolute_expression (); |
| 1377 | |
| 1378 | demand_empty_rest_of_line (); |
| 1379 | |
| 1380 | return fix_new (frag_now, frag_now_fix (), 0, sym, offset, 0, |
| 1381 | BFD_RELOC_VTABLE_ENTRY); |
| 1382 | } |
| 1383 | |
| 1384 | void |
| 1385 | elf_obj_read_begin_hook () |
| 1386 | { |
| 1387 | #ifdef NEED_ECOFF_DEBUG |
| 1388 | if (ECOFF_DEBUGGING) |
| 1389 | ecoff_read_begin_hook (); |
| 1390 | #endif |
| 1391 | } |
| 1392 | |
| 1393 | void |
| 1394 | elf_obj_symbol_new_hook (symbolP) |
| 1395 | symbolS *symbolP; |
| 1396 | { |
| 1397 | struct elf_obj_sy *sy_obj; |
| 1398 | |
| 1399 | sy_obj = symbol_get_obj (symbolP); |
| 1400 | sy_obj->size = NULL; |
| 1401 | sy_obj->versioned_name = NULL; |
| 1402 | |
| 1403 | #ifdef NEED_ECOFF_DEBUG |
| 1404 | if (ECOFF_DEBUGGING) |
| 1405 | ecoff_symbol_new_hook (symbolP); |
| 1406 | #endif |
| 1407 | } |
| 1408 | |
| 1409 | /* When setting one symbol equal to another, by default we probably |
| 1410 | want them to have the same "size", whatever it means in the current |
| 1411 | context. */ |
| 1412 | |
| 1413 | void |
| 1414 | elf_copy_symbol_attributes (dest, src) |
| 1415 | symbolS *dest, *src; |
| 1416 | { |
| 1417 | struct elf_obj_sy *srcelf = symbol_get_obj (src); |
| 1418 | struct elf_obj_sy *destelf = symbol_get_obj (dest); |
| 1419 | if (srcelf->size) |
| 1420 | { |
| 1421 | if (destelf->size == NULL) |
| 1422 | destelf->size = |
| 1423 | (expressionS *) xmalloc (sizeof (expressionS)); |
| 1424 | *destelf->size = *srcelf->size; |
| 1425 | } |
| 1426 | else |
| 1427 | { |
| 1428 | if (destelf->size != NULL) |
| 1429 | free (destelf->size); |
| 1430 | destelf->size = NULL; |
| 1431 | } |
| 1432 | S_SET_SIZE (dest, S_GET_SIZE (src)); |
| 1433 | /* Don't copy visibility. */ |
| 1434 | S_SET_OTHER (dest, (ELF_ST_VISIBILITY (S_GET_OTHER (dest)) |
| 1435 | | (S_GET_OTHER (src) & ~ELF_ST_VISIBILITY (-1)))); |
| 1436 | } |
| 1437 | |
| 1438 | void |
| 1439 | obj_elf_version (ignore) |
| 1440 | int ignore ATTRIBUTE_UNUSED; |
| 1441 | { |
| 1442 | char *name; |
| 1443 | unsigned int c; |
| 1444 | char *p; |
| 1445 | asection *seg = now_seg; |
| 1446 | subsegT subseg = now_subseg; |
| 1447 | Elf_Internal_Note i_note; |
| 1448 | Elf_External_Note e_note; |
| 1449 | asection *note_secp = (asection *) NULL; |
| 1450 | int len; |
| 1451 | |
| 1452 | SKIP_WHITESPACE (); |
| 1453 | if (*input_line_pointer == '\"') |
| 1454 | { |
| 1455 | ++input_line_pointer; /* -> 1st char of string. */ |
| 1456 | name = input_line_pointer; |
| 1457 | |
| 1458 | while (is_a_char (c = next_char_of_string ())) |
| 1459 | ; |
| 1460 | c = *input_line_pointer; |
| 1461 | *input_line_pointer = '\0'; |
| 1462 | *(input_line_pointer - 1) = '\0'; |
| 1463 | *input_line_pointer = c; |
| 1464 | |
| 1465 | /* create the .note section */ |
| 1466 | |
| 1467 | note_secp = subseg_new (".note", 0); |
| 1468 | bfd_set_section_flags (stdoutput, |
| 1469 | note_secp, |
| 1470 | SEC_HAS_CONTENTS | SEC_READONLY); |
| 1471 | |
| 1472 | /* process the version string */ |
| 1473 | |
| 1474 | len = strlen (name); |
| 1475 | |
| 1476 | i_note.namesz = ((len + 1) + 3) & ~3; /* round this to word boundary */ |
| 1477 | i_note.descsz = 0; /* no description */ |
| 1478 | i_note.type = NT_VERSION; |
| 1479 | p = frag_more (sizeof (e_note.namesz)); |
| 1480 | md_number_to_chars (p, (valueT) i_note.namesz, sizeof (e_note.namesz)); |
| 1481 | p = frag_more (sizeof (e_note.descsz)); |
| 1482 | md_number_to_chars (p, (valueT) i_note.descsz, sizeof (e_note.descsz)); |
| 1483 | p = frag_more (sizeof (e_note.type)); |
| 1484 | md_number_to_chars (p, (valueT) i_note.type, sizeof (e_note.type)); |
| 1485 | p = frag_more (len + 1); |
| 1486 | strcpy (p, name); |
| 1487 | |
| 1488 | frag_align (2, 0, 0); |
| 1489 | |
| 1490 | subseg_set (seg, subseg); |
| 1491 | } |
| 1492 | else |
| 1493 | { |
| 1494 | as_bad (_("expected quoted string")); |
| 1495 | } |
| 1496 | demand_empty_rest_of_line (); |
| 1497 | } |
| 1498 | |
| 1499 | static void |
| 1500 | obj_elf_size (ignore) |
| 1501 | int ignore ATTRIBUTE_UNUSED; |
| 1502 | { |
| 1503 | char *name = input_line_pointer; |
| 1504 | char c = get_symbol_end (); |
| 1505 | char *p; |
| 1506 | expressionS exp; |
| 1507 | symbolS *sym; |
| 1508 | |
| 1509 | p = input_line_pointer; |
| 1510 | *p = c; |
| 1511 | SKIP_WHITESPACE (); |
| 1512 | if (*input_line_pointer != ',') |
| 1513 | { |
| 1514 | *p = 0; |
| 1515 | as_bad (_("expected comma after name `%s' in .size directive"), name); |
| 1516 | *p = c; |
| 1517 | ignore_rest_of_line (); |
| 1518 | return; |
| 1519 | } |
| 1520 | input_line_pointer++; |
| 1521 | expression (&exp); |
| 1522 | if (exp.X_op == O_absent) |
| 1523 | { |
| 1524 | as_bad (_("missing expression in .size directive")); |
| 1525 | exp.X_op = O_constant; |
| 1526 | exp.X_add_number = 0; |
| 1527 | } |
| 1528 | *p = 0; |
| 1529 | sym = symbol_find_or_make (name); |
| 1530 | *p = c; |
| 1531 | if (exp.X_op == O_constant) |
| 1532 | { |
| 1533 | S_SET_SIZE (sym, exp.X_add_number); |
| 1534 | if (symbol_get_obj (sym)->size) |
| 1535 | { |
| 1536 | xfree (symbol_get_obj (sym)->size); |
| 1537 | symbol_get_obj (sym)->size = NULL; |
| 1538 | } |
| 1539 | } |
| 1540 | else |
| 1541 | { |
| 1542 | symbol_get_obj (sym)->size = |
| 1543 | (expressionS *) xmalloc (sizeof (expressionS)); |
| 1544 | *symbol_get_obj (sym)->size = exp; |
| 1545 | } |
| 1546 | demand_empty_rest_of_line (); |
| 1547 | } |
| 1548 | |
| 1549 | /* Handle the ELF .type pseudo-op. This sets the type of a symbol. |
| 1550 | There are five syntaxes: |
| 1551 | |
| 1552 | The first (used on Solaris) is |
| 1553 | .type SYM,#function |
| 1554 | The second (used on UnixWare) is |
| 1555 | .type SYM,@function |
| 1556 | The third (reportedly to be used on Irix 6.0) is |
| 1557 | .type SYM STT_FUNC |
| 1558 | The fourth (used on NetBSD/Arm and Linux/ARM) is |
| 1559 | .type SYM,%function |
| 1560 | The fifth (used on SVR4/860) is |
| 1561 | .type SYM,"function" |
| 1562 | */ |
| 1563 | |
| 1564 | static void |
| 1565 | obj_elf_type (ignore) |
| 1566 | int ignore ATTRIBUTE_UNUSED; |
| 1567 | { |
| 1568 | char *name; |
| 1569 | char c; |
| 1570 | int type; |
| 1571 | const char *typename; |
| 1572 | symbolS *sym; |
| 1573 | elf_symbol_type *elfsym; |
| 1574 | |
| 1575 | name = input_line_pointer; |
| 1576 | c = get_symbol_end (); |
| 1577 | sym = symbol_find_or_make (name); |
| 1578 | elfsym = (elf_symbol_type *) symbol_get_bfdsym (sym); |
| 1579 | *input_line_pointer = c; |
| 1580 | |
| 1581 | SKIP_WHITESPACE (); |
| 1582 | if (*input_line_pointer == ',') |
| 1583 | ++input_line_pointer; |
| 1584 | |
| 1585 | SKIP_WHITESPACE (); |
| 1586 | if ( *input_line_pointer == '#' |
| 1587 | || *input_line_pointer == '@' |
| 1588 | || *input_line_pointer == '"' |
| 1589 | || *input_line_pointer == '%') |
| 1590 | ++input_line_pointer; |
| 1591 | |
| 1592 | typename = input_line_pointer; |
| 1593 | c = get_symbol_end (); |
| 1594 | |
| 1595 | type = 0; |
| 1596 | if (strcmp (typename, "function") == 0 |
| 1597 | || strcmp (typename, "STT_FUNC") == 0) |
| 1598 | type = BSF_FUNCTION; |
| 1599 | else if (strcmp (typename, "object") == 0 |
| 1600 | || strcmp (typename, "STT_OBJECT") == 0) |
| 1601 | type = BSF_OBJECT; |
| 1602 | else if (strcmp (typename, "tls_object") == 0 |
| 1603 | || strcmp (typename, "STT_TLS") == 0) |
| 1604 | type = BSF_OBJECT | BSF_THREAD_LOCAL; |
| 1605 | else if (strcmp (typename, "notype") == 0 |
| 1606 | || strcmp (typename, "STT_NOTYPE") == 0) |
| 1607 | ; |
| 1608 | #ifdef md_elf_symbol_type |
| 1609 | else if ((type = md_elf_symbol_type (typename, sym, elfsym)) != -1) |
| 1610 | ; |
| 1611 | #endif |
| 1612 | else |
| 1613 | as_bad (_("unrecognized symbol type \"%s\""), typename); |
| 1614 | |
| 1615 | *input_line_pointer = c; |
| 1616 | |
| 1617 | if (*input_line_pointer == '"') |
| 1618 | ++input_line_pointer; |
| 1619 | |
| 1620 | elfsym->symbol.flags |= type; |
| 1621 | |
| 1622 | demand_empty_rest_of_line (); |
| 1623 | } |
| 1624 | |
| 1625 | static void |
| 1626 | obj_elf_ident (ignore) |
| 1627 | int ignore ATTRIBUTE_UNUSED; |
| 1628 | { |
| 1629 | static segT comment_section; |
| 1630 | segT old_section = now_seg; |
| 1631 | int old_subsection = now_subseg; |
| 1632 | |
| 1633 | #ifdef md_flush_pending_output |
| 1634 | md_flush_pending_output (); |
| 1635 | #endif |
| 1636 | |
| 1637 | if (!comment_section) |
| 1638 | { |
| 1639 | char *p; |
| 1640 | comment_section = subseg_new (".comment", 0); |
| 1641 | bfd_set_section_flags (stdoutput, comment_section, |
| 1642 | SEC_READONLY | SEC_HAS_CONTENTS); |
| 1643 | p = frag_more (1); |
| 1644 | *p = 0; |
| 1645 | } |
| 1646 | else |
| 1647 | subseg_set (comment_section, 0); |
| 1648 | stringer (1); |
| 1649 | subseg_set (old_section, old_subsection); |
| 1650 | } |
| 1651 | |
| 1652 | #ifdef INIT_STAB_SECTION |
| 1653 | |
| 1654 | /* The first entry in a .stabs section is special. */ |
| 1655 | |
| 1656 | void |
| 1657 | obj_elf_init_stab_section (seg) |
| 1658 | segT seg; |
| 1659 | { |
| 1660 | char *file; |
| 1661 | char *p; |
| 1662 | char *stabstr_name; |
| 1663 | unsigned int stroff; |
| 1664 | |
| 1665 | /* Force the section to align to a longword boundary. Without this, |
| 1666 | UnixWare ar crashes. */ |
| 1667 | bfd_set_section_alignment (stdoutput, seg, 2); |
| 1668 | |
| 1669 | /* Make space for this first symbol. */ |
| 1670 | p = frag_more (12); |
| 1671 | /* Zero it out. */ |
| 1672 | memset (p, 0, 12); |
| 1673 | as_where (&file, (unsigned int *) NULL); |
| 1674 | stabstr_name = (char *) xmalloc (strlen (segment_name (seg)) + 4); |
| 1675 | strcpy (stabstr_name, segment_name (seg)); |
| 1676 | strcat (stabstr_name, "str"); |
| 1677 | stroff = get_stab_string_offset (file, stabstr_name); |
| 1678 | know (stroff == 1); |
| 1679 | md_number_to_chars (p, stroff, 4); |
| 1680 | seg_info (seg)->stabu.p = p; |
| 1681 | } |
| 1682 | |
| 1683 | #endif |
| 1684 | |
| 1685 | /* Fill in the counts in the first entry in a .stabs section. */ |
| 1686 | |
| 1687 | static void |
| 1688 | adjust_stab_sections (abfd, sec, xxx) |
| 1689 | bfd *abfd; |
| 1690 | asection *sec; |
| 1691 | PTR xxx ATTRIBUTE_UNUSED; |
| 1692 | { |
| 1693 | char *name; |
| 1694 | asection *strsec; |
| 1695 | char *p; |
| 1696 | int strsz, nsyms; |
| 1697 | |
| 1698 | if (strncmp (".stab", sec->name, 5)) |
| 1699 | return; |
| 1700 | if (!strcmp ("str", sec->name + strlen (sec->name) - 3)) |
| 1701 | return; |
| 1702 | |
| 1703 | name = (char *) alloca (strlen (sec->name) + 4); |
| 1704 | strcpy (name, sec->name); |
| 1705 | strcat (name, "str"); |
| 1706 | strsec = bfd_get_section_by_name (abfd, name); |
| 1707 | if (strsec) |
| 1708 | strsz = bfd_section_size (abfd, strsec); |
| 1709 | else |
| 1710 | strsz = 0; |
| 1711 | nsyms = bfd_section_size (abfd, sec) / 12 - 1; |
| 1712 | |
| 1713 | p = seg_info (sec)->stabu.p; |
| 1714 | assert (p != 0); |
| 1715 | |
| 1716 | bfd_h_put_16 (abfd, (bfd_vma) nsyms, (bfd_byte *) p + 6); |
| 1717 | bfd_h_put_32 (abfd, (bfd_vma) strsz, (bfd_byte *) p + 8); |
| 1718 | } |
| 1719 | |
| 1720 | #ifdef NEED_ECOFF_DEBUG |
| 1721 | |
| 1722 | /* This function is called by the ECOFF code. It is supposed to |
| 1723 | record the external symbol information so that the backend can |
| 1724 | write it out correctly. The ELF backend doesn't actually handle |
| 1725 | this at the moment, so we do it ourselves. We save the information |
| 1726 | in the symbol. */ |
| 1727 | |
| 1728 | void |
| 1729 | elf_ecoff_set_ext (sym, ext) |
| 1730 | symbolS *sym; |
| 1731 | struct ecoff_extr *ext; |
| 1732 | { |
| 1733 | symbol_get_bfdsym (sym)->udata.p = (PTR) ext; |
| 1734 | } |
| 1735 | |
| 1736 | /* This function is called by bfd_ecoff_debug_externals. It is |
| 1737 | supposed to *EXT to the external symbol information, and return |
| 1738 | whether the symbol should be used at all. */ |
| 1739 | |
| 1740 | static bfd_boolean |
| 1741 | elf_get_extr (sym, ext) |
| 1742 | asymbol *sym; |
| 1743 | EXTR *ext; |
| 1744 | { |
| 1745 | if (sym->udata.p == NULL) |
| 1746 | return FALSE; |
| 1747 | *ext = *(EXTR *) sym->udata.p; |
| 1748 | return TRUE; |
| 1749 | } |
| 1750 | |
| 1751 | /* This function is called by bfd_ecoff_debug_externals. It has |
| 1752 | nothing to do for ELF. */ |
| 1753 | |
| 1754 | /*ARGSUSED*/ |
| 1755 | static void |
| 1756 | elf_set_index (sym, indx) |
| 1757 | asymbol *sym ATTRIBUTE_UNUSED; |
| 1758 | bfd_size_type indx ATTRIBUTE_UNUSED; |
| 1759 | { |
| 1760 | } |
| 1761 | |
| 1762 | #endif /* NEED_ECOFF_DEBUG */ |
| 1763 | |
| 1764 | void |
| 1765 | elf_frob_symbol (symp, puntp) |
| 1766 | symbolS *symp; |
| 1767 | int *puntp; |
| 1768 | { |
| 1769 | struct elf_obj_sy *sy_obj; |
| 1770 | |
| 1771 | #ifdef NEED_ECOFF_DEBUG |
| 1772 | if (ECOFF_DEBUGGING) |
| 1773 | ecoff_frob_symbol (symp); |
| 1774 | #endif |
| 1775 | |
| 1776 | sy_obj = symbol_get_obj (symp); |
| 1777 | |
| 1778 | if (sy_obj->size != NULL) |
| 1779 | { |
| 1780 | switch (sy_obj->size->X_op) |
| 1781 | { |
| 1782 | case O_subtract: |
| 1783 | S_SET_SIZE (symp, |
| 1784 | (S_GET_VALUE (sy_obj->size->X_add_symbol) |
| 1785 | + sy_obj->size->X_add_number |
| 1786 | - S_GET_VALUE (sy_obj->size->X_op_symbol))); |
| 1787 | break; |
| 1788 | case O_constant: |
| 1789 | S_SET_SIZE (symp, |
| 1790 | (S_GET_VALUE (sy_obj->size->X_add_symbol) |
| 1791 | + sy_obj->size->X_add_number)); |
| 1792 | break; |
| 1793 | default: |
| 1794 | as_bad (_(".size expression too complicated to fix up")); |
| 1795 | break; |
| 1796 | } |
| 1797 | free (sy_obj->size); |
| 1798 | sy_obj->size = NULL; |
| 1799 | } |
| 1800 | |
| 1801 | if (sy_obj->versioned_name != NULL) |
| 1802 | { |
| 1803 | char *p; |
| 1804 | |
| 1805 | p = strchr (sy_obj->versioned_name, ELF_VER_CHR); |
| 1806 | know (p != NULL); |
| 1807 | |
| 1808 | /* This symbol was given a new name with the .symver directive. |
| 1809 | |
| 1810 | If this is an external reference, just rename the symbol to |
| 1811 | include the version string. This will make the relocs be |
| 1812 | against the correct versioned symbol. |
| 1813 | |
| 1814 | If this is a definition, add an alias. FIXME: Using an alias |
| 1815 | will permit the debugging information to refer to the right |
| 1816 | symbol. However, it's not clear whether it is the best |
| 1817 | approach. */ |
| 1818 | |
| 1819 | if (! S_IS_DEFINED (symp)) |
| 1820 | { |
| 1821 | /* Verify that the name isn't using the @@ syntax--this is |
| 1822 | reserved for definitions of the default version to link |
| 1823 | against. */ |
| 1824 | if (p[1] == ELF_VER_CHR) |
| 1825 | { |
| 1826 | as_bad (_("invalid attempt to declare external version name as default in symbol `%s'"), |
| 1827 | sy_obj->versioned_name); |
| 1828 | *puntp = TRUE; |
| 1829 | } |
| 1830 | S_SET_NAME (symp, sy_obj->versioned_name); |
| 1831 | } |
| 1832 | else |
| 1833 | { |
| 1834 | if (p [1] == ELF_VER_CHR && p [2] == ELF_VER_CHR) |
| 1835 | { |
| 1836 | size_t l; |
| 1837 | |
| 1838 | /* The @@@ syntax is a special case. It renames the |
| 1839 | symbol name to versioned_name with one `@' removed. */ |
| 1840 | l = strlen (&p[3]) + 1; |
| 1841 | memmove (&p [2], &p[3], l); |
| 1842 | S_SET_NAME (symp, sy_obj->versioned_name); |
| 1843 | } |
| 1844 | else |
| 1845 | { |
| 1846 | symbolS *symp2; |
| 1847 | |
| 1848 | /* FIXME: Creating a new symbol here is risky. We're |
| 1849 | in the final loop over the symbol table. We can |
| 1850 | get away with it only because the symbol goes to |
| 1851 | the end of the list, where the loop will still see |
| 1852 | it. It would probably be better to do this in |
| 1853 | obj_frob_file_before_adjust. */ |
| 1854 | |
| 1855 | symp2 = symbol_find_or_make (sy_obj->versioned_name); |
| 1856 | |
| 1857 | /* Now we act as though we saw symp2 = sym. */ |
| 1858 | |
| 1859 | S_SET_SEGMENT (symp2, S_GET_SEGMENT (symp)); |
| 1860 | |
| 1861 | /* Subtracting out the frag address here is a hack |
| 1862 | because we are in the middle of the final loop. */ |
| 1863 | S_SET_VALUE (symp2, |
| 1864 | (S_GET_VALUE (symp) |
| 1865 | - symbol_get_frag (symp)->fr_address)); |
| 1866 | |
| 1867 | symbol_set_frag (symp2, symbol_get_frag (symp)); |
| 1868 | |
| 1869 | /* This will copy over the size information. */ |
| 1870 | copy_symbol_attributes (symp2, symp); |
| 1871 | |
| 1872 | S_SET_OTHER (symp2, S_GET_OTHER (symp)); |
| 1873 | |
| 1874 | if (S_IS_WEAK (symp)) |
| 1875 | S_SET_WEAK (symp2); |
| 1876 | |
| 1877 | if (S_IS_EXTERNAL (symp)) |
| 1878 | S_SET_EXTERNAL (symp2); |
| 1879 | } |
| 1880 | } |
| 1881 | } |
| 1882 | |
| 1883 | /* Double check weak symbols. */ |
| 1884 | if (S_IS_WEAK (symp)) |
| 1885 | { |
| 1886 | if (S_IS_COMMON (symp)) |
| 1887 | as_bad (_("symbol `%s' can not be both weak and common"), |
| 1888 | S_GET_NAME (symp)); |
| 1889 | } |
| 1890 | |
| 1891 | #ifdef TC_MIPS |
| 1892 | /* The Irix 5 and 6 assemblers set the type of any common symbol and |
| 1893 | any undefined non-function symbol to STT_OBJECT. We try to be |
| 1894 | compatible, since newer Irix 5 and 6 linkers care. However, we |
| 1895 | only set undefined symbols to be STT_OBJECT if we are on Irix, |
| 1896 | because that is the only time gcc will generate the necessary |
| 1897 | .global directives to mark functions. */ |
| 1898 | |
| 1899 | if (S_IS_COMMON (symp)) |
| 1900 | symbol_get_bfdsym (symp)->flags |= BSF_OBJECT; |
| 1901 | |
| 1902 | if (strstr (TARGET_OS, "irix") != NULL |
| 1903 | && ! S_IS_DEFINED (symp) |
| 1904 | && (symbol_get_bfdsym (symp)->flags & BSF_FUNCTION) == 0) |
| 1905 | symbol_get_bfdsym (symp)->flags |= BSF_OBJECT; |
| 1906 | #endif |
| 1907 | |
| 1908 | #if 0 /* TC_PPC */ |
| 1909 | /* If TC_PPC is defined, we used to force the type of a symbol to be |
| 1910 | BSF_OBJECT if it was otherwise unset. This was required by some |
| 1911 | version of VxWorks. Thomas de Lellis <tdel@windriver.com> says |
| 1912 | that this is no longer needed, so it is now commented out. */ |
| 1913 | if ((symbol_get_bfdsym (symp)->flags |
| 1914 | & (BSF_FUNCTION | BSF_FILE | BSF_SECTION_SYM)) == 0 |
| 1915 | && S_IS_DEFINED (symp)) |
| 1916 | symbol_get_bfdsym (symp)->flags |= BSF_OBJECT; |
| 1917 | #endif |
| 1918 | } |
| 1919 | |
| 1920 | struct group_list |
| 1921 | { |
| 1922 | asection **head; /* Section lists. */ |
| 1923 | unsigned int *elt_count; /* Number of sections in each list. */ |
| 1924 | unsigned int num_group; /* Number of lists. */ |
| 1925 | }; |
| 1926 | |
| 1927 | /* Called via bfd_map_over_sections. If SEC is a member of a group, |
| 1928 | add it to a list of sections belonging to the group. INF is a |
| 1929 | pointer to a struct group_list, which is where we store the head of |
| 1930 | each list. */ |
| 1931 | |
| 1932 | static void |
| 1933 | build_group_lists (abfd, sec, inf) |
| 1934 | bfd *abfd ATTRIBUTE_UNUSED; |
| 1935 | asection *sec; |
| 1936 | PTR inf; |
| 1937 | { |
| 1938 | struct group_list *list = (struct group_list *) inf; |
| 1939 | const char *group_name = elf_group_name (sec); |
| 1940 | unsigned int i; |
| 1941 | |
| 1942 | if (group_name == NULL) |
| 1943 | return; |
| 1944 | |
| 1945 | /* If this group already has a list, add the section to the head of |
| 1946 | the list. */ |
| 1947 | for (i = 0; i < list->num_group; i++) |
| 1948 | { |
| 1949 | if (strcmp (group_name, elf_group_name (list->head[i])) == 0) |
| 1950 | { |
| 1951 | elf_next_in_group (sec) = list->head[i]; |
| 1952 | list->head[i] = sec; |
| 1953 | list->elt_count[i] += 1; |
| 1954 | return; |
| 1955 | } |
| 1956 | } |
| 1957 | |
| 1958 | /* New group. Make the arrays bigger in chunks to minimize calls to |
| 1959 | realloc. */ |
| 1960 | i = list->num_group; |
| 1961 | if ((i & 127) == 0) |
| 1962 | { |
| 1963 | unsigned int newsize = i + 128; |
| 1964 | list->head = xrealloc (list->head, newsize * sizeof (*list->head)); |
| 1965 | list->elt_count = xrealloc (list->elt_count, |
| 1966 | newsize * sizeof (*list->elt_count)); |
| 1967 | } |
| 1968 | list->head[i] = sec; |
| 1969 | list->elt_count[i] = 1; |
| 1970 | list->num_group += 1; |
| 1971 | } |
| 1972 | |
| 1973 | void |
| 1974 | elf_frob_file () |
| 1975 | { |
| 1976 | struct group_list list; |
| 1977 | unsigned int i; |
| 1978 | |
| 1979 | bfd_map_over_sections (stdoutput, adjust_stab_sections, (PTR) 0); |
| 1980 | |
| 1981 | /* Go find section groups. */ |
| 1982 | list.num_group = 0; |
| 1983 | list.head = NULL; |
| 1984 | list.elt_count = NULL; |
| 1985 | bfd_map_over_sections (stdoutput, build_group_lists, (PTR) &list); |
| 1986 | |
| 1987 | /* Make the SHT_GROUP sections that describe each section group. We |
| 1988 | can't set up the section contents here yet, because elf section |
| 1989 | indices have yet to be calculated. elf.c:set_group_contents does |
| 1990 | the rest of the work. */ |
| 1991 | for (i = 0; i < list.num_group; i++) |
| 1992 | { |
| 1993 | const char *group_name = elf_group_name (list.head[i]); |
| 1994 | const char *sec_name; |
| 1995 | asection *s; |
| 1996 | flagword flags; |
| 1997 | struct symbol *sy; |
| 1998 | int has_sym; |
| 1999 | |
| 2000 | flags = SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_GROUP; |
| 2001 | for (s = list.head[i]; s != NULL; s = elf_next_in_group (s)) |
| 2002 | if ((s->flags ^ flags) & SEC_LINK_ONCE) |
| 2003 | { |
| 2004 | flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; |
| 2005 | if (s != list.head[i]) |
| 2006 | { |
| 2007 | as_warn (_("assuming all members of group `%s' are COMDAT"), |
| 2008 | group_name); |
| 2009 | break; |
| 2010 | } |
| 2011 | } |
| 2012 | |
| 2013 | sec_name = group_name; |
| 2014 | sy = symbol_find_exact (group_name); |
| 2015 | has_sym = 0; |
| 2016 | if (sy != NULL |
| 2017 | && (sy == symbol_lastP |
| 2018 | || (sy->sy_next != NULL |
| 2019 | && sy->sy_next->sy_previous == sy))) |
| 2020 | { |
| 2021 | has_sym = 1; |
| 2022 | sec_name = ".group"; |
| 2023 | } |
| 2024 | s = subseg_force_new (sec_name, 0); |
| 2025 | if (s == NULL |
| 2026 | || !bfd_set_section_flags (stdoutput, s, flags) |
| 2027 | || !bfd_set_section_alignment (stdoutput, s, 2)) |
| 2028 | { |
| 2029 | as_fatal (_("can't create group: %s"), |
| 2030 | bfd_errmsg (bfd_get_error ())); |
| 2031 | } |
| 2032 | elf_section_type (s) = SHT_GROUP; |
| 2033 | |
| 2034 | /* Pass a pointer to the first section in this group. */ |
| 2035 | elf_next_in_group (s) = list.head[i]; |
| 2036 | if (has_sym) |
| 2037 | elf_group_id (s) = sy->bsym; |
| 2038 | |
| 2039 | s->_raw_size = 4 * (list.elt_count[i] + 1); |
| 2040 | s->contents = frag_more (s->_raw_size); |
| 2041 | frag_now->fr_fix = frag_now_fix_octets (); |
| 2042 | } |
| 2043 | |
| 2044 | #ifdef elf_tc_final_processing |
| 2045 | elf_tc_final_processing (); |
| 2046 | #endif |
| 2047 | } |
| 2048 | |
| 2049 | /* It removes any unneeded versioned symbols from the symbol table. */ |
| 2050 | |
| 2051 | void |
| 2052 | elf_frob_file_before_adjust () |
| 2053 | { |
| 2054 | if (symbol_rootP) |
| 2055 | { |
| 2056 | symbolS *symp; |
| 2057 | |
| 2058 | for (symp = symbol_rootP; symp; symp = symbol_next (symp)) |
| 2059 | if (!S_IS_DEFINED (symp)) |
| 2060 | { |
| 2061 | if (symbol_get_obj (symp)->versioned_name) |
| 2062 | { |
| 2063 | char *p; |
| 2064 | |
| 2065 | /* The @@@ syntax is a special case. If the symbol is |
| 2066 | not defined, 2 `@'s will be removed from the |
| 2067 | versioned_name. */ |
| 2068 | |
| 2069 | p = strchr (symbol_get_obj (symp)->versioned_name, |
| 2070 | ELF_VER_CHR); |
| 2071 | know (p != NULL); |
| 2072 | if (p [1] == ELF_VER_CHR && p [2] == ELF_VER_CHR) |
| 2073 | { |
| 2074 | size_t l = strlen (&p[3]) + 1; |
| 2075 | memmove (&p [1], &p[3], l); |
| 2076 | } |
| 2077 | if (symbol_used_p (symp) == 0 |
| 2078 | && symbol_used_in_reloc_p (symp) == 0) |
| 2079 | symbol_remove (symp, &symbol_rootP, &symbol_lastP); |
| 2080 | } |
| 2081 | |
| 2082 | /* If there was .weak foo, but foo was neither defined nor |
| 2083 | used anywhere, remove it. */ |
| 2084 | |
| 2085 | else if (S_IS_WEAK (symp) |
| 2086 | && symbol_used_p (symp) == 0 |
| 2087 | && symbol_used_in_reloc_p (symp) == 0) |
| 2088 | symbol_remove (symp, &symbol_rootP, &symbol_lastP); |
| 2089 | } |
| 2090 | } |
| 2091 | } |
| 2092 | |
| 2093 | /* It is required that we let write_relocs have the opportunity to |
| 2094 | optimize away fixups before output has begun, since it is possible |
| 2095 | to eliminate all fixups for a section and thus we never should |
| 2096 | have generated the relocation section. */ |
| 2097 | |
| 2098 | void |
| 2099 | elf_frob_file_after_relocs () |
| 2100 | { |
| 2101 | #ifdef NEED_ECOFF_DEBUG |
| 2102 | if (ECOFF_DEBUGGING) |
| 2103 | /* Generate the ECOFF debugging information. */ |
| 2104 | { |
| 2105 | const struct ecoff_debug_swap *debug_swap; |
| 2106 | struct ecoff_debug_info debug; |
| 2107 | char *buf; |
| 2108 | asection *sec; |
| 2109 | |
| 2110 | debug_swap |
| 2111 | = get_elf_backend_data (stdoutput)->elf_backend_ecoff_debug_swap; |
| 2112 | know (debug_swap != (const struct ecoff_debug_swap *) NULL); |
| 2113 | ecoff_build_debug (&debug.symbolic_header, &buf, debug_swap); |
| 2114 | |
| 2115 | /* Set up the pointers in debug. */ |
| 2116 | #define SET(ptr, offset, type) \ |
| 2117 | debug.ptr = (type) (buf + debug.symbolic_header.offset) |
| 2118 | |
| 2119 | SET (line, cbLineOffset, unsigned char *); |
| 2120 | SET (external_dnr, cbDnOffset, PTR); |
| 2121 | SET (external_pdr, cbPdOffset, PTR); |
| 2122 | SET (external_sym, cbSymOffset, PTR); |
| 2123 | SET (external_opt, cbOptOffset, PTR); |
| 2124 | SET (external_aux, cbAuxOffset, union aux_ext *); |
| 2125 | SET (ss, cbSsOffset, char *); |
| 2126 | SET (external_fdr, cbFdOffset, PTR); |
| 2127 | SET (external_rfd, cbRfdOffset, PTR); |
| 2128 | /* ssext and external_ext are set up just below. */ |
| 2129 | |
| 2130 | #undef SET |
| 2131 | |
| 2132 | /* Set up the external symbols. */ |
| 2133 | debug.ssext = debug.ssext_end = NULL; |
| 2134 | debug.external_ext = debug.external_ext_end = NULL; |
| 2135 | if (! bfd_ecoff_debug_externals (stdoutput, &debug, debug_swap, TRUE, |
| 2136 | elf_get_extr, elf_set_index)) |
| 2137 | as_fatal (_("failed to set up debugging information: %s"), |
| 2138 | bfd_errmsg (bfd_get_error ())); |
| 2139 | |
| 2140 | sec = bfd_get_section_by_name (stdoutput, ".mdebug"); |
| 2141 | assert (sec != NULL); |
| 2142 | |
| 2143 | know (!stdoutput->output_has_begun); |
| 2144 | |
| 2145 | /* We set the size of the section, call bfd_set_section_contents |
| 2146 | to force the ELF backend to allocate a file position, and then |
| 2147 | write out the data. FIXME: Is this really the best way to do |
| 2148 | this? */ |
| 2149 | sec->_raw_size = bfd_ecoff_debug_size (stdoutput, &debug, debug_swap); |
| 2150 | |
| 2151 | /* Pass BUF to bfd_set_section_contents because this will |
| 2152 | eventually become a call to fwrite, and ISO C prohibits |
| 2153 | passing a NULL pointer to a stdio function even if the |
| 2154 | pointer will not be used. */ |
| 2155 | if (! bfd_set_section_contents (stdoutput, sec, (PTR) buf, |
| 2156 | (file_ptr) 0, (bfd_size_type) 0)) |
| 2157 | as_fatal (_("can't start writing .mdebug section: %s"), |
| 2158 | bfd_errmsg (bfd_get_error ())); |
| 2159 | |
| 2160 | know (stdoutput->output_has_begun); |
| 2161 | know (sec->filepos != 0); |
| 2162 | |
| 2163 | if (! bfd_ecoff_write_debug (stdoutput, &debug, debug_swap, |
| 2164 | sec->filepos)) |
| 2165 | as_fatal (_("could not write .mdebug section: %s"), |
| 2166 | bfd_errmsg (bfd_get_error ())); |
| 2167 | } |
| 2168 | #endif /* NEED_ECOFF_DEBUG */ |
| 2169 | } |
| 2170 | |
| 2171 | #ifdef SCO_ELF |
| 2172 | |
| 2173 | /* Heavily plagarized from obj_elf_version. The idea is to emit the |
| 2174 | SCO specific identifier in the .notes section to satisfy the SCO |
| 2175 | linker. |
| 2176 | |
| 2177 | This looks more complicated than it really is. As opposed to the |
| 2178 | "obvious" solution, this should handle the cross dev cases |
| 2179 | correctly. (i.e, hosting on a 64 bit big endian processor, but |
| 2180 | generating SCO Elf code) Efficiency isn't a concern, as there |
| 2181 | should be exactly one of these sections per object module. |
| 2182 | |
| 2183 | SCO OpenServer 5 identifies it's ELF modules with a standard ELF |
| 2184 | .note section. |
| 2185 | |
| 2186 | int_32 namesz = 4 ; Name size |
| 2187 | int_32 descsz = 12 ; Descriptive information |
| 2188 | int_32 type = 1 ; |
| 2189 | char name[4] = "SCO" ; Originator name ALWAYS SCO + NULL |
| 2190 | int_32 version = (major ver # << 16) | version of tools ; |
| 2191 | int_32 source = (tool_id << 16 ) | 1 ; |
| 2192 | int_32 info = 0 ; These are set by the SCO tools, but we |
| 2193 | don't know enough about the source |
| 2194 | environment to set them. SCO ld currently |
| 2195 | ignores them, and recommends we set them |
| 2196 | to zero. */ |
| 2197 | |
| 2198 | #define SCO_MAJOR_VERSION 0x1 |
| 2199 | #define SCO_MINOR_VERSION 0x1 |
| 2200 | |
| 2201 | void |
| 2202 | sco_id () |
| 2203 | { |
| 2204 | |
| 2205 | char *name; |
| 2206 | unsigned int c; |
| 2207 | char ch; |
| 2208 | char *p; |
| 2209 | asection *seg = now_seg; |
| 2210 | subsegT subseg = now_subseg; |
| 2211 | Elf_Internal_Note i_note; |
| 2212 | Elf_External_Note e_note; |
| 2213 | asection *note_secp = (asection *) NULL; |
| 2214 | int i, len; |
| 2215 | |
| 2216 | /* create the .note section */ |
| 2217 | |
| 2218 | note_secp = subseg_new (".note", 0); |
| 2219 | bfd_set_section_flags (stdoutput, |
| 2220 | note_secp, |
| 2221 | SEC_HAS_CONTENTS | SEC_READONLY); |
| 2222 | |
| 2223 | /* process the version string */ |
| 2224 | |
| 2225 | i_note.namesz = 4; |
| 2226 | i_note.descsz = 12; /* 12 descriptive bytes */ |
| 2227 | i_note.type = NT_VERSION; /* Contains a version string */ |
| 2228 | |
| 2229 | p = frag_more (sizeof (i_note.namesz)); |
| 2230 | md_number_to_chars (p, (valueT) i_note.namesz, 4); |
| 2231 | |
| 2232 | p = frag_more (sizeof (i_note.descsz)); |
| 2233 | md_number_to_chars (p, (valueT) i_note.descsz, 4); |
| 2234 | |
| 2235 | p = frag_more (sizeof (i_note.type)); |
| 2236 | md_number_to_chars (p, (valueT) i_note.type, 4); |
| 2237 | |
| 2238 | p = frag_more (4); |
| 2239 | strcpy (p, "SCO"); |
| 2240 | |
| 2241 | /* Note: this is the version number of the ELF we're representing */ |
| 2242 | p = frag_more (4); |
| 2243 | md_number_to_chars (p, (SCO_MAJOR_VERSION << 16) | (SCO_MINOR_VERSION), 4); |
| 2244 | |
| 2245 | /* Here, we pick a magic number for ourselves (yes, I "registered" |
| 2246 | it with SCO. The bottom bit shows that we are compat with the |
| 2247 | SCO ABI. */ |
| 2248 | p = frag_more (4); |
| 2249 | md_number_to_chars (p, 0x4c520000 | 0x0001, 4); |
| 2250 | |
| 2251 | /* If we knew (or cared) what the source language options were, we'd |
| 2252 | fill them in here. SCO has given us permission to ignore these |
| 2253 | and just set them to zero. */ |
| 2254 | p = frag_more (4); |
| 2255 | md_number_to_chars (p, 0x0000, 4); |
| 2256 | |
| 2257 | frag_align (2, 0, 0); |
| 2258 | |
| 2259 | /* We probably can't restore the current segment, for there likely |
| 2260 | isn't one yet... */ |
| 2261 | if (seg && subseg) |
| 2262 | subseg_set (seg, subseg); |
| 2263 | |
| 2264 | } |
| 2265 | |
| 2266 | #endif /* SCO_ELF */ |
| 2267 | |
| 2268 | static int |
| 2269 | elf_separate_stab_sections () |
| 2270 | { |
| 2271 | #ifdef NEED_ECOFF_DEBUG |
| 2272 | return (!ECOFF_DEBUGGING); |
| 2273 | #else |
| 2274 | return 1; |
| 2275 | #endif |
| 2276 | } |
| 2277 | |
| 2278 | static void |
| 2279 | elf_init_stab_section (seg) |
| 2280 | segT seg; |
| 2281 | { |
| 2282 | #ifdef NEED_ECOFF_DEBUG |
| 2283 | if (!ECOFF_DEBUGGING) |
| 2284 | #endif |
| 2285 | obj_elf_init_stab_section (seg); |
| 2286 | } |
| 2287 | |
| 2288 | const struct format_ops elf_format_ops = |
| 2289 | { |
| 2290 | bfd_target_elf_flavour, |
| 2291 | 0, /* dfl_leading_underscore */ |
| 2292 | 1, /* emit_section_symbols */ |
| 2293 | elf_begin, |
| 2294 | elf_file_symbol, |
| 2295 | elf_frob_symbol, |
| 2296 | elf_frob_file, |
| 2297 | elf_frob_file_before_adjust, |
| 2298 | 0, /* obj_frob_file_before_fix */ |
| 2299 | elf_frob_file_after_relocs, |
| 2300 | elf_s_get_size, elf_s_set_size, |
| 2301 | elf_s_get_align, elf_s_set_align, |
| 2302 | elf_s_get_other, |
| 2303 | elf_s_set_other, |
| 2304 | 0, /* s_get_desc */ |
| 2305 | 0, /* s_set_desc */ |
| 2306 | 0, /* s_get_type */ |
| 2307 | 0, /* s_set_type */ |
| 2308 | elf_copy_symbol_attributes, |
| 2309 | #ifdef NEED_ECOFF_DEBUG |
| 2310 | ecoff_generate_asm_lineno, |
| 2311 | ecoff_stab, |
| 2312 | #else |
| 2313 | 0, /* generate_asm_lineno */ |
| 2314 | 0, /* process_stab */ |
| 2315 | #endif |
| 2316 | elf_separate_stab_sections, |
| 2317 | elf_init_stab_section, |
| 2318 | elf_sec_sym_ok_for_reloc, |
| 2319 | elf_pop_insert, |
| 2320 | #ifdef NEED_ECOFF_DEBUG |
| 2321 | elf_ecoff_set_ext, |
| 2322 | #else |
| 2323 | 0, /* ecoff_set_ext */ |
| 2324 | #endif |
| 2325 | elf_obj_read_begin_hook, |
| 2326 | elf_obj_symbol_new_hook |
| 2327 | }; |