Changeset 609 for branches/GNU/src/binutils/bfd/xcofflink.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/xcofflink.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* POWER/PowerPC XCOFF linker support. 2 Copyright 1995, 1996, 1997, 1998, 1999, 2000 2 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support. 5 5 6 This file is part of BFD, the Binary File Descriptor library.7 8 This program is free software; you can redistribute it and/or modify9 it under the terms of the GNU General Public License as published by10 the Free Software Foundation; either version 2 of the License, or11 (at your option) any later version.12 13 This program is distributed in the hope that it will be useful,14 but WITHOUT ANY WARRANTY; without even the implied warranty of15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 GNU General Public License for more details.17 18 You should have received a copy of the GNU General Public License19 along with this program; if not, write to the Free Software20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */6 This file is part of BFD, the Binary File Descriptor library. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 21 22 22 #include "bfd.h" … … 25 25 #include "libbfd.h" 26 26 #include "coff/internal.h" 27 #include "coff/xcoff.h" 27 28 #include "libcoff.h" 29 #include "libxcoff.h" 28 30 29 31 /* This file holds the XCOFF linker code. */ 30 32 31 33 #define STRING_SIZE_SIZE (4) 32 33 /* Get the XCOFF hash table entries for a BFD. */34 #define obj_xcoff_sym_hashes(bfd) \35 ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd))36 37 /* XCOFF relocation types. These probably belong in a header file38 somewhere. The relocations are described in the function39 _bfd_ppc_xcoff_relocate_section in this file. */40 41 #define R_POS (0x00)42 #define R_NEG (0x01)43 #define R_REL (0x02)44 #define R_TOC (0x03)45 #define R_RTB (0x04)46 #define R_GL (0x05)47 #define R_TCL (0x06)48 #define R_BA (0x08)49 #define R_BR (0x0a)50 #define R_RL (0x0c)51 #define R_RLA (0x0d)52 #define R_REF (0x0f)53 #define R_TRL (0x12)54 #define R_TRLA (0x13)55 #define R_RRTBI (0x14)56 #define R_RRTBA (0x15)57 #define R_CAI (0x16)58 #define R_CREL (0x17)59 #define R_RBA (0x18)60 #define R_RBAC (0x19)61 #define R_RBR (0x1a)62 #define R_RBRC (0x1b)63 64 /* The first word of global linkage code. This must be modified by65 filling in the correct TOC offset. */66 67 #define XCOFF_GLINK_FIRST (0x81820000) /* lwz r12,0(r2) */68 69 /* The remaining words of global linkage code. */70 71 static unsigned long xcoff_glink_code[] = {72 0x90410014, /* stw r2,20(r1) */73 0x800c0000, /* lwz r0,0(r12) */74 0x804c0004, /* lwz r2,4(r12) */75 0x7c0903a6, /* mtctr r0 */76 0x4e800420, /* bctr */77 0x0, /* start of traceback table */78 0x000c8000, /* traceback table */79 0x0 /* traceback table */80 };81 82 #define XCOFF_GLINK_SIZE \83 (((sizeof xcoff_glink_code / sizeof xcoff_glink_code[0]) * 4) + 4)84 34 85 35 /* We reuse the SEC_ROM flag as a mark flag for garbage collection. … … 88 38 #define SEC_MARK (SEC_ROM) 89 39 90 /* The ldhdr structure. This appears at the start of the .loader91 section. */92 93 struct internal_ldhdr {94 /* The version number: currently always 1. */95 unsigned long l_version;96 /* The number of symbol table entries. */97 bfd_size_type l_nsyms;98 /* The number of relocation table entries. */99 bfd_size_type l_nreloc;100 /* The length of the import file string table. */101 bfd_size_type l_istlen;102 /* The number of import files. */103 bfd_size_type l_nimpid;104 /* The offset from the start of the .loader section to the first105 entry in the import file table. */106 bfd_size_type l_impoff;107 /* The length of the string table. */108 bfd_size_type l_stlen;109 /* The offset from the start of the .loader section to the first110 entry in the string table. */111 bfd_size_type l_stoff;112 };113 114 struct external_ldhdr {115 bfd_byte l_version[4];116 bfd_byte l_nsyms[4];117 bfd_byte l_nreloc[4];118 bfd_byte l_istlen[4];119 bfd_byte l_nimpid[4];120 bfd_byte l_impoff[4];121 bfd_byte l_stlen[4];122 bfd_byte l_stoff[4];123 };124 125 #define LDHDRSZ (8 * 4)126 127 /* The ldsym structure. This is used to represent a symbol in the128 .loader section. */129 130 struct internal_ldsym {131 union {132 /* The symbol name if <= SYMNMLEN characters. */133 char _l_name[SYMNMLEN];134 struct {135 /* Zero if the symbol name is more than SYMNMLEN characters. */136 long _l_zeroes;137 /* The offset in the string table if the symbol name is more138 than SYMNMLEN characters. */139 long _l_offset;140 } _l_l;141 } _l;142 /* The symbol value. */143 bfd_vma l_value;144 /* The symbol section number. */145 short l_scnum;146 /* The symbol type and flags. */147 char l_smtype;148 /* The symbol storage class. */149 char l_smclas;150 /* The import file ID. */151 bfd_size_type l_ifile;152 /* Offset to the parameter type check string. */153 bfd_size_type l_parm;154 };155 156 struct external_ldsym {157 union {158 bfd_byte _l_name[SYMNMLEN];159 struct {160 bfd_byte _l_zeroes[4];161 bfd_byte _l_offset[4];162 } _l_l;163 } _l;164 bfd_byte l_value[4];165 bfd_byte l_scnum[2];166 bfd_byte l_smtype[1];167 bfd_byte l_smclas[1];168 bfd_byte l_ifile[4];169 bfd_byte l_parm[4];170 };171 172 #define LDSYMSZ (8 + 3 * 4 + 2 + 2)173 174 /* These flags are for the l_smtype field (the lower three bits are an175 XTY_* value). */176 177 /* Imported symbol. */178 #define L_IMPORT (0x40)179 /* Entry point. */180 #define L_ENTRY (0x20)181 /* Exported symbol. */182 #define L_EXPORT (0x10)183 184 /* The ldrel structure. This is used to represent a reloc in the185 .loader section. */186 187 struct internal_ldrel {188 /* The reloc address. */189 bfd_vma l_vaddr;190 /* The symbol table index in the .loader section symbol table. */191 bfd_size_type l_symndx;192 /* The relocation type and size. */193 short l_rtype;194 /* The section number this relocation applies to. */195 short l_rsecnm;196 };197 198 struct external_ldrel {199 bfd_byte l_vaddr[4];200 bfd_byte l_symndx[4];201 bfd_byte l_rtype[2];202 bfd_byte l_rsecnm[2];203 };204 205 #define LDRELSZ (2 * 4 + 2 * 2)206 207 40 /* The list of import files. */ 208 41 209 struct xcoff_import_file { 42 struct xcoff_import_file 43 { 210 44 /* The next entry in the list. */ 211 45 struct xcoff_import_file *next; … … 218 52 }; 219 53 220 /* An entry in the XCOFF linker hash table. */221 222 struct xcoff_link_hash_entry {223 struct bfd_link_hash_entry root;224 225 /* Symbol index in output file. Set to -1 initially. Set to -2 if226 there is a reloc against this symbol. */227 long indx;228 229 /* If we have created a TOC entry for this symbol, this is the .tc230 section which holds it. */231 asection *toc_section;232 233 union {234 /* If we have created a TOC entry (the XCOFF_SET_TOC flag is set),235 this is the offset in toc_section. */236 bfd_vma toc_offset;237 /* If the TOC entry comes from an input file, this is set to the238 symbol index of the C_HIDEXT XMC_TC or XMC_TD symbol. */239 long toc_indx;240 } u;241 242 /* If this symbol is a function entry point which is called, this243 field holds a pointer to the function descriptor. If this symbol244 is a function descriptor, this field holds a pointer to the245 function entry point. */246 struct xcoff_link_hash_entry *descriptor;247 248 /* The .loader symbol table entry, if there is one. */249 struct internal_ldsym *ldsym;250 251 /* If XCOFF_BUILT_LDSYM is set, this is the .loader symbol table252 index. If XCOFF_BUILD_LDSYM is clear, and XCOFF_IMPORT is set,253 this is the l_ifile value. */254 long ldindx;255 256 /* Some linker flags. */257 unsigned short flags;258 /* Symbol is referenced by a regular object. */259 #define XCOFF_REF_REGULAR (01)260 /* Symbol is defined by a regular object. */261 #define XCOFF_DEF_REGULAR (02)262 /* Symbol is defined by a dynamic object. */263 #define XCOFF_DEF_DYNAMIC (04)264 /* Symbol is used in a reloc being copied into the .loader section. */265 #define XCOFF_LDREL (010)266 /* Symbol is the entry point. */267 #define XCOFF_ENTRY (020)268 /* Symbol is called; this is, it appears in a R_BR reloc. */269 #define XCOFF_CALLED (040)270 /* Symbol needs the TOC entry filled in. */271 #define XCOFF_SET_TOC (0100)272 /* Symbol is explicitly imported. */273 #define XCOFF_IMPORT (0200)274 /* Symbol is explicitly exported. */275 #define XCOFF_EXPORT (0400)276 /* Symbol has been processed by xcoff_build_ldsyms. */277 #define XCOFF_BUILT_LDSYM (01000)278 /* Symbol is mentioned by a section which was not garbage collected. */279 #define XCOFF_MARK (02000)280 /* Symbol size is recorded in size_list list from hash table. */281 #define XCOFF_HAS_SIZE (04000)282 /* Symbol is a function descriptor. */283 #define XCOFF_DESCRIPTOR (010000)284 /* Multiple definitions have been for the symbol. */285 #define XCOFF_MULTIPLY_DEFINED (020000)286 287 /* The storage mapping class. */288 unsigned char smclas;289 };290 291 /* The XCOFF linker hash table. */292 293 struct xcoff_link_hash_table {294 struct bfd_link_hash_table root;295 296 /* The .debug string hash table. We need to compute this while297 reading the input files, so that we know how large the .debug298 section will be before we assign section positions. */299 struct bfd_strtab_hash *debug_strtab;300 301 /* The .debug section we will use for the final output. */302 asection *debug_section;303 304 /* The .loader section we will use for the final output. */305 asection *loader_section;306 307 /* A count of non TOC relative relocs which will need to be308 allocated in the .loader section. */309 size_t ldrel_count;310 311 /* The .loader section header. */312 struct internal_ldhdr ldhdr;313 314 /* The .gl section we use to hold global linkage code. */315 asection *linkage_section;316 317 /* The .tc section we use to hold toc entries we build for global318 linkage code. */319 asection *toc_section;320 321 /* The .ds section we use to hold function descriptors which we322 create for exported symbols. */323 asection *descriptor_section;324 325 /* The list of import files. */326 struct xcoff_import_file *imports;327 328 /* Required alignment of sections within the output file. */329 unsigned long file_align;330 331 /* Whether the .text section must be read-only. */332 boolean textro;333 334 /* Whether garbage collection was done. */335 boolean gc;336 337 /* A linked list of symbols for which we have size information. */338 struct xcoff_link_size_list {339 struct xcoff_link_size_list *next;340 struct xcoff_link_hash_entry *h;341 bfd_size_type size;342 } *size_list;343 344 /* Magic sections: _text, _etext, _data, _edata, _end, end. */345 asection *special_sections[6];346 };347 348 54 /* Information we keep for each section in the output file during the 349 55 final link phase. */ 350 56 351 struct xcoff_link_section_info { 57 struct xcoff_link_section_info 58 { 352 59 /* The relocs to be output. */ 353 60 struct internal_reloc *relocs; … … 368 75 /* Information that we pass around while doing the final link step. */ 369 76 370 struct xcoff_final_link_info { 77 struct xcoff_final_link_info 78 { 371 79 /* General link information. */ 372 80 struct bfd_link_info *info; … … 385 93 long toc_symindx; 386 94 /* Start of .loader symbols. */ 387 struct external_ldsym*ldsym;95 bfd_byte *ldsym; 388 96 /* Next .loader reloc to swap out. */ 389 struct external_ldrel*ldrel;97 bfd_byte *ldrel; 390 98 /* File position of start of line numbers. */ 391 99 file_ptr line_filepos; … … 406 114 }; 407 115 408 static void xcoff_swap_ldhdr_in409 PARAMS ((bfd *, const struct external_ldhdr *, struct internal_ldhdr *));410 static void xcoff_swap_ldhdr_out411 PARAMS ((bfd *, const struct internal_ldhdr *, struct external_ldhdr *));412 static void xcoff_swap_ldsym_in413 PARAMS ((bfd *, const struct external_ldsym *, struct internal_ldsym *));414 static void xcoff_swap_ldsym_out415 PARAMS ((bfd *, const struct internal_ldsym *, struct external_ldsym *));416 static void xcoff_swap_ldrel_in417 PARAMS ((bfd *, const struct external_ldrel *, struct internal_ldrel *));418 static void xcoff_swap_ldrel_out419 PARAMS ((bfd *, const struct internal_ldrel *, struct external_ldrel *));420 116 static struct bfd_hash_entry *xcoff_link_hash_newfunc 421 117 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 422 static b oolean xcoff_get_section_contents PARAMS ((bfd *, asection *));118 static bfd_boolean xcoff_get_section_contents PARAMS ((bfd *, asection *)); 423 119 static struct internal_reloc *xcoff_read_internal_relocs 424 PARAMS ((bfd *, asection *, b oolean, bfd_byte *,boolean,120 PARAMS ((bfd *, asection *, bfd_boolean, bfd_byte *, bfd_boolean, 425 121 struct internal_reloc *)); 426 static b oolean xcoff_link_add_object_symbols122 static bfd_boolean xcoff_link_add_object_symbols 427 123 PARAMS ((bfd *, struct bfd_link_info *)); 428 static b oolean xcoff_link_check_archive_element429 PARAMS ((bfd *, struct bfd_link_info *, b oolean *));430 static b oolean xcoff_link_check_ar_symbols431 PARAMS ((bfd *, struct bfd_link_info *, b oolean *));432 static b oolean xcoff_link_check_dynamic_ar_symbols433 PARAMS ((bfd *, struct bfd_link_info *, b oolean *));124 static bfd_boolean xcoff_link_check_archive_element 125 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *)); 126 static bfd_boolean xcoff_link_check_ar_symbols 127 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *)); 128 static bfd_boolean xcoff_link_check_dynamic_ar_symbols 129 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *)); 434 130 static bfd_size_type xcoff_find_reloc 435 131 PARAMS ((struct internal_reloc *, bfd_size_type, bfd_vma)); 436 static boolean xcoff_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *)); 437 static boolean xcoff_link_add_dynamic_symbols 132 static bfd_boolean xcoff_link_add_symbols 438 133 PARAMS ((bfd *, struct bfd_link_info *)); 439 static boolean xcoff_mark_symbol 134 static bfd_boolean xcoff_link_add_dynamic_symbols 135 PARAMS ((bfd *, struct bfd_link_info *)); 136 static bfd_boolean xcoff_mark_symbol 440 137 PARAMS ((struct bfd_link_info *, struct xcoff_link_hash_entry *)); 441 static b oolean xcoff_mark PARAMS ((struct bfd_link_info *, asection *));138 static bfd_boolean xcoff_mark PARAMS ((struct bfd_link_info *, asection *)); 442 139 static void xcoff_sweep PARAMS ((struct bfd_link_info *)); 443 static b oolean xcoff_build_ldsyms140 static bfd_boolean xcoff_build_ldsyms 444 141 PARAMS ((struct xcoff_link_hash_entry *, PTR)); 445 static b oolean xcoff_link_input_bfd142 static bfd_boolean xcoff_link_input_bfd 446 143 PARAMS ((struct xcoff_final_link_info *, bfd *)); 447 static b oolean xcoff_write_global_symbol144 static bfd_boolean xcoff_write_global_symbol 448 145 PARAMS ((struct xcoff_link_hash_entry *, PTR)); 449 static b oolean xcoff_reloc_link_order146 static bfd_boolean xcoff_reloc_link_order 450 147 PARAMS ((bfd *, struct xcoff_final_link_info *, asection *, 451 148 struct bfd_link_order *)); … … 453 150 454 151 455 /* Routines to swap information in the XCOFF .loader section. If we456 ever need to write an XCOFF loader, this stuff will need to be457 moved to another file shared by the linker (which XCOFF calls the458 ``binder'') and the loader. */459 460 /* Swap in the ldhdr structure. */461 462 static void463 xcoff_swap_ldhdr_in (abfd, src, dst)464 bfd *abfd;465 const struct external_ldhdr *src;466 struct internal_ldhdr *dst;467 {468 dst->l_version = bfd_get_32 (abfd, src->l_version);469 dst->l_nsyms = bfd_get_32 (abfd, src->l_nsyms);470 dst->l_nreloc = bfd_get_32 (abfd, src->l_nreloc);471 dst->l_istlen = bfd_get_32 (abfd, src->l_istlen);472 dst->l_nimpid = bfd_get_32 (abfd, src->l_nimpid);473 dst->l_impoff = bfd_get_32 (abfd, src->l_impoff);474 dst->l_stlen = bfd_get_32 (abfd, src->l_stlen);475 dst->l_stoff = bfd_get_32 (abfd, src->l_stoff);476 }477 478 /* Swap out the ldhdr structure. */479 480 static void481 xcoff_swap_ldhdr_out (abfd, src, dst)482 bfd *abfd;483 const struct internal_ldhdr *src;484 struct external_ldhdr *dst;485 {486 bfd_put_32 (abfd, src->l_version, dst->l_version);487 bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms);488 bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc);489 bfd_put_32 (abfd, src->l_istlen, dst->l_istlen);490 bfd_put_32 (abfd, src->l_nimpid, dst->l_nimpid);491 bfd_put_32 (abfd, src->l_impoff, dst->l_impoff);492 bfd_put_32 (abfd, src->l_stlen, dst->l_stlen);493 bfd_put_32 (abfd, src->l_stoff, dst->l_stoff);494 }495 496 /* Swap in the ldsym structure. */497 498 static void499 xcoff_swap_ldsym_in (abfd, src, dst)500 bfd *abfd;501 const struct external_ldsym *src;502 struct internal_ldsym *dst;503 {504 if (bfd_get_32 (abfd, src->_l._l_l._l_zeroes) != 0)505 memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN);506 else507 {508 dst->_l._l_l._l_zeroes = 0;509 dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->_l._l_l._l_offset);510 }511 dst->l_value = bfd_get_32 (abfd, src->l_value);512 dst->l_scnum = bfd_get_16 (abfd, src->l_scnum);513 dst->l_smtype = bfd_get_8 (abfd, src->l_smtype);514 dst->l_smclas = bfd_get_8 (abfd, src->l_smclas);515 dst->l_ifile = bfd_get_32 (abfd, src->l_ifile);516 dst->l_parm = bfd_get_32 (abfd, src->l_parm);517 }518 519 /* Swap out the ldsym structure. */520 521 static void522 xcoff_swap_ldsym_out (abfd, src, dst)523 bfd *abfd;524 const struct internal_ldsym *src;525 struct external_ldsym *dst;526 {527 if (src->_l._l_l._l_zeroes != 0)528 memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN);529 else530 {531 bfd_put_32 (abfd, 0, dst->_l._l_l._l_zeroes);532 bfd_put_32 (abfd, src->_l._l_l._l_offset, dst->_l._l_l._l_offset);533 }534 bfd_put_32 (abfd, src->l_value, dst->l_value);535 bfd_put_16 (abfd, src->l_scnum, dst->l_scnum);536 bfd_put_8 (abfd, src->l_smtype, dst->l_smtype);537 bfd_put_8 (abfd, src->l_smclas, dst->l_smclas);538 bfd_put_32 (abfd, src->l_ifile, dst->l_ifile);539 bfd_put_32 (abfd, src->l_parm, dst->l_parm);540 }541 542 /* Swap in the ldrel structure. */543 544 static void545 xcoff_swap_ldrel_in (abfd, src, dst)546 bfd *abfd;547 const struct external_ldrel *src;548 struct internal_ldrel *dst;549 {550 dst->l_vaddr = bfd_get_32 (abfd, src->l_vaddr);551 dst->l_symndx = bfd_get_32 (abfd, src->l_symndx);552 dst->l_rtype = bfd_get_16 (abfd, src->l_rtype);553 dst->l_rsecnm = bfd_get_16 (abfd, src->l_rsecnm);554 }555 556 /* Swap out the ldrel structure. */557 558 static void559 xcoff_swap_ldrel_out (abfd, src, dst)560 bfd *abfd;561 const struct internal_ldrel *src;562 struct external_ldrel *dst;563 {564 bfd_put_32 (abfd, src->l_vaddr, dst->l_vaddr);565 bfd_put_32 (abfd, src->l_symndx, dst->l_symndx);566 bfd_put_16 (abfd, src->l_rtype, dst->l_rtype);567 bfd_put_16 (abfd, src->l_rsecnm, dst->l_rsecnm);568 }569 570 152 571 153 /* Routines to read XCOFF dynamic information. This don't really … … 575 157 /* Read the contents of a section. */ 576 158 577 static b oolean159 static bfd_boolean 578 160 xcoff_get_section_contents (abfd, sec) 579 161 bfd *abfd; 580 162 asection *sec; 581 163 { 164 582 165 if (coff_section_data (abfd, sec) == NULL) 583 166 { 584 sec->used_by_bfd = bfd_zalloc (abfd,585 sizeof (struct coff_section_tdata));167 bfd_size_type amt = sizeof (struct coff_section_tdata); 168 sec->used_by_bfd = bfd_zalloc (abfd, amt); 586 169 if (sec->used_by_bfd == NULL) 587 return false;170 return FALSE; 588 171 } 589 172 590 173 if (coff_section_data (abfd, sec)->contents == NULL) 591 174 { 592 coff_section_data (abfd, sec)->contents = 593 (bfd_byte *) bfd_malloc (sec->_raw_size);175 coff_section_data (abfd, sec)->contents = ((bfd_byte *) 176 bfd_malloc (sec->_raw_size)); 594 177 if (coff_section_data (abfd, sec)->contents == NULL) 595 return false;178 return FALSE; 596 179 597 180 if (! bfd_get_section_contents (abfd, sec, 598 181 coff_section_data (abfd, sec)->contents, 599 182 (file_ptr) 0, sec->_raw_size)) 600 return false;601 } 602 603 return true;183 return FALSE; 184 } 185 186 return TRUE; 604 187 } 605 188 … … 631 214 contents = coff_section_data (abfd, lsec)->contents; 632 215 633 xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr);216 bfd_xcoff_swap_ldhdr_in (abfd, (PTR) contents, &ldhdr); 634 217 635 218 return (ldhdr.l_nsyms + 1) * sizeof (asymbol *); … … 647 230 struct internal_ldhdr ldhdr; 648 231 const char *strings; 649 struct external_ldsym*elsym, *elsymend;232 bfd_byte *elsym, *elsymend; 650 233 coff_symbol_type *symbuf; 651 234 … … 667 250 contents = coff_section_data (abfd, lsec)->contents; 668 251 669 coff_section_data (abfd, lsec)->keep_contents = true;670 671 xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *)contents, &ldhdr);252 coff_section_data (abfd, lsec)->keep_contents = TRUE; 253 254 bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr); 672 255 673 256 strings = (char *) contents + ldhdr.l_stoff; … … 678 261 return -1; 679 262 680 elsym = (struct external_ldsym *) (contents + LDHDRSZ); 681 elsymend = elsym + ldhdr.l_nsyms; 682 for (; elsym < elsymend; elsym++, symbuf++, psyms++) 263 elsym = contents + bfd_xcoff_loader_symbol_offset(abfd, &ldhdr); 264 265 elsymend = elsym + ldhdr.l_nsyms * bfd_xcoff_ldsymsz(abfd); 266 for (; elsym < elsymend; elsym += bfd_xcoff_ldsymsz(abfd), symbuf++, psyms++) 683 267 { 684 268 struct internal_ldsym ldsym; 685 269 686 xcoff_swap_ldsym_in (abfd, elsym, &ldsym);270 bfd_xcoff_swap_ldsym_in (abfd, elsym, &ldsym); 687 271 688 272 symbuf->symbol.the_bfd = abfd; … … 692 276 else 693 277 { 694 int i; 695 696 for (i = 0; i < SYMNMLEN; i++) 697 if (ldsym._l._l_name[i] == '\0') 698 break; 699 if (i < SYMNMLEN) 700 symbuf->symbol.name = (char *) elsym->_l._l_name; 701 else 702 { 703 char *c; 704 705 c = bfd_alloc (abfd, SYMNMLEN + 1); 706 if (c == NULL) 707 return -1; 708 memcpy (c, ldsym._l._l_name, SYMNMLEN); 709 c[SYMNMLEN] = '\0'; 710 symbuf->symbol.name = c; 711 } 278 char *c; 279 280 c = bfd_alloc (abfd, (bfd_size_type) SYMNMLEN + 1); 281 if (c == NULL) 282 return -1; 283 memcpy (c, ldsym._l._l_name, SYMNMLEN); 284 c[SYMNMLEN] = '\0'; 285 symbuf->symbol.name = c; 712 286 } 713 287 … … 724 298 725 299 /* FIXME: We have no way to record the other information stored 726 300 with the loader symbol. */ 727 301 728 302 *psyms = (asymbol *) symbuf; … … 761 335 contents = coff_section_data (abfd, lsec)->contents; 762 336 763 xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr);337 bfd_xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr); 764 338 765 339 return (ldhdr.l_nreloc + 1) * sizeof (arelent *); 766 340 } 767 768 /* The typical dynamic reloc. */769 770 static reloc_howto_type xcoff_dynamic_reloc =771 HOWTO (0, /* type */772 0, /* rightshift */773 2, /* size (0 = byte, 1 = short, 2 = long) */774 32, /* bitsize */775 false, /* pc_relative */776 0, /* bitpos */777 complain_overflow_bitfield, /* complain_on_overflow */778 0, /* special_function */779 "R_POS", /* name */780 true, /* partial_inplace */781 0xffffffff, /* src_mask */782 0xffffffff, /* dst_mask */783 false); /* pcrel_offset */784 341 785 342 /* Get the dynamic relocs. */ … … 795 352 struct internal_ldhdr ldhdr; 796 353 arelent *relbuf; 797 struct external_ldrel*elrel, *elrelend;354 bfd_byte *elrel, *elrelend; 798 355 799 356 if ((abfd->flags & DYNAMIC) == 0) … … 814 371 contents = coff_section_data (abfd, lsec)->contents; 815 372 816 xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *)contents, &ldhdr);373 bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr); 817 374 818 375 relbuf = (arelent *) bfd_alloc (abfd, ldhdr.l_nreloc * sizeof (arelent)); … … 820 377 return -1; 821 378 822 elrel = ((struct external_ldrel *) 823 (contents + LDHDRSZ + ldhdr.l_nsyms * LDSYMSZ)); 824 elrelend = elrel + ldhdr.l_nreloc; 825 for (; elrel < elrelend; elrel++, relbuf++, prelocs++) 379 elrel = contents + bfd_xcoff_loader_reloc_offset(abfd, &ldhdr); 380 381 elrelend = elrel + ldhdr.l_nreloc * bfd_xcoff_ldrelsz(abfd); 382 for (; elrel < elrelend; elrel += bfd_xcoff_ldrelsz(abfd), relbuf++, 383 prelocs++) 826 384 { 827 385 struct internal_ldrel ldrel; 828 386 829 xcoff_swap_ldrel_in (abfd, elrel, &ldrel);387 bfd_xcoff_swap_ldrel_in (abfd, elrel, &ldrel); 830 388 831 389 if (ldrel.l_symndx >= 3) … … 866 424 867 425 /* Most dynamic relocs have the same type. FIXME: This is only 868 869 870 relbuf->howto = &xcoff_dynamic_reloc;426 correct if ldrel.l_rtype == 0. In other cases, we should use 427 a different howto. */ 428 relbuf->howto = bfd_xcoff_dynamic_reloc_howto(abfd); 871 429 872 430 /* FIXME: We have no way to record the l_rsecnm field. */ … … 926 484 { 927 485 struct xcoff_link_hash_table *ret; 928 929 ret = ((struct xcoff_link_hash_table *) 930 bfd_alloc (abfd, sizeof (struct xcoff_link_hash_table)));486 bfd_size_type amt = sizeof (struct xcoff_link_hash_table); 487 488 ret = (struct xcoff_link_hash_table *) bfd_malloc (amt); 931 489 if (ret == (struct xcoff_link_hash_table *) NULL) 932 490 return (struct bfd_link_hash_table *) NULL; 933 491 if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc)) 934 492 { 935 bfd_release (abfd,ret);493 free (ret); 936 494 return (struct bfd_link_hash_table *) NULL; 937 495 } … … 947 505 ret->imports = NULL; 948 506 ret->file_align = 0; 949 ret->textro = false;950 ret->gc = false;507 ret->textro = FALSE; 508 ret->gc = FALSE; 951 509 memset (ret->special_sections, 0, sizeof ret->special_sections); 952 510 … … 954 512 record that fact now, before the sizeof_headers routine could be 955 513 called. */ 956 xcoff_data (abfd)->full_aouthdr = true;514 xcoff_data (abfd)->full_aouthdr = TRUE; 957 515 958 516 return &ret->root; 959 517 } 960 518 961 /* Look up an entry in an XCOFF link hash table. */ 962 963 #define xcoff_link_hash_lookup(table, string, create, copy, follow) \ 964 ((struct xcoff_link_hash_entry *) \ 965 bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\ 966 (follow))) 967 968 /* Traverse an XCOFF link hash table. */ 969 970 #define xcoff_link_hash_traverse(table, func, info) \ 971 (bfd_link_hash_traverse \ 972 (&(table)->root, \ 973 (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ 974 (info))) 975 976 /* Get the XCOFF link hash table from the info structure. This is 977 just a cast. */ 978 979 #define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash)) 519 /* Free a XCOFF link hash table. */ 520 521 void 522 _bfd_xcoff_bfd_link_hash_table_free (hash) 523 struct bfd_link_hash_table *hash; 524 { 525 struct xcoff_link_hash_table *ret = (struct xcoff_link_hash_table *) hash; 526 527 _bfd_stringtab_free (ret->debug_strtab); 528 bfd_hash_table_free (&ret->root.table); 529 free (ret); 530 } 980 531 981 532 … … 989 540 bfd *abfd; 990 541 asection *sec; 991 b oolean cache;542 bfd_boolean cache; 992 543 bfd_byte *external_relocs; 993 b oolean require_internal;544 bfd_boolean require_internal; 994 545 struct internal_reloc *internal_relocs; 995 546 { 547 996 548 if (coff_section_data (abfd, sec) != NULL 997 549 && coff_section_data (abfd, sec)->relocs == NULL … … 1008 560 && enclosing->reloc_count > 0) 1009 561 { 1010 if (_bfd_coff_read_internal_relocs (abfd, enclosing, true,1011 external_relocs, false,562 if (_bfd_coff_read_internal_relocs (abfd, enclosing, TRUE, 563 external_relocs, FALSE, 1012 564 (struct internal_reloc *) NULL) 1013 565 == NULL) … … 1023 575 off = ((sec->rel_filepos - enclosing->rel_filepos) 1024 576 / bfd_coff_relsz (abfd)); 577 1025 578 if (! require_internal) 1026 579 return coff_section_data (abfd, enclosing)->relocs + off; … … 1040 593 appropriate. */ 1041 594 1042 b oolean595 bfd_boolean 1043 596 _bfd_xcoff_bfd_link_add_symbols (abfd, info) 1044 597 bfd *abfd; 1045 598 struct bfd_link_info *info; 1046 599 { 600 1047 601 switch (bfd_get_format (abfd)) 1048 602 { … … 1052 606 case bfd_archive: 1053 607 /* If the archive has a map, do the usual search. We then need 1054 to check the archive for stripped dynamic objects, because 1055 they will not appear in the archive map even though they 1056 should, perhaps, be included. If the archive has no map, we 1057 just consider each object file in turn, since that apparently 1058 is what the AIX native linkerdoes. */608 to check the archive for dynamic objects, because they may not 609 appear in the archive map even though they should, perhaps, be 610 included. If the archive has no map, we just consider each object 611 file in turn, since that apparently is what the AIX native linker 612 does. */ 1059 613 if (bfd_has_map (abfd)) 1060 614 { 1061 615 if (! (_bfd_generic_link_add_archive_symbols 1062 616 (abfd, info, xcoff_link_check_archive_element))) 1063 return false;617 return FALSE; 1064 618 } 1065 619 … … 1071 625 { 1072 626 if (bfd_check_format (member, bfd_object) 1073 && (! bfd_has_map (abfd) 1074 || ((member->flags & DYNAMIC) != 0 1075 && (member->flags & HAS_SYMS) == 0))) 627 && (info->hash->creator == member->xvec) 628 && (! bfd_has_map (abfd) || (member->flags & DYNAMIC) != 0)) 1076 629 { 1077 boolean needed; 1078 1079 if (! xcoff_link_check_archive_element (member, info, &needed)) 1080 return false; 630 bfd_boolean needed; 631 632 if (! xcoff_link_check_archive_element (member, info, 633 &needed)) 634 return FALSE; 1081 635 if (needed) 1082 636 member->archive_pass = -1; … … 1086 640 } 1087 641 1088 return true;642 return TRUE; 1089 643 1090 644 default: 1091 645 bfd_set_error (bfd_error_wrong_format); 1092 return false;646 return FALSE; 1093 647 } 1094 648 } … … 1096 650 /* Add symbols from an XCOFF object file. */ 1097 651 1098 static b oolean652 static bfd_boolean 1099 653 xcoff_link_add_object_symbols (abfd, info) 1100 654 bfd *abfd; 1101 655 struct bfd_link_info *info; 1102 656 { 657 1103 658 if (! _bfd_coff_get_external_symbols (abfd)) 1104 return false;659 return FALSE; 1105 660 if (! xcoff_link_add_symbols (abfd, info)) 1106 return false;661 return FALSE; 1107 662 if (! info->keep_memory) 1108 663 { 1109 664 if (! _bfd_coff_free_symbols (abfd)) 1110 return false;1111 } 1112 return true;665 return FALSE; 666 } 667 return TRUE; 1113 668 } 1114 669 … … 1118 673 _bfd_generic_link_add_archive_symbols. */ 1119 674 1120 static b oolean675 static bfd_boolean 1121 676 xcoff_link_check_archive_element (abfd, info, pneeded) 1122 677 bfd *abfd; 1123 678 struct bfd_link_info *info; 1124 b oolean *pneeded;679 bfd_boolean *pneeded; 1125 680 { 681 1126 682 if (! _bfd_coff_get_external_symbols (abfd)) 1127 return false;683 return FALSE; 1128 684 1129 685 if (! xcoff_link_check_ar_symbols (abfd, info, pneeded)) 1130 return false;686 return FALSE; 1131 687 1132 688 if (*pneeded) 1133 689 { 1134 690 if (! xcoff_link_add_symbols (abfd, info)) 1135 return false;691 return FALSE; 1136 692 } 1137 693 … … 1139 695 { 1140 696 if (! _bfd_coff_free_symbols (abfd)) 1141 return false;1142 } 1143 1144 return true;697 return FALSE; 698 } 699 700 return TRUE; 1145 701 } 1146 702 … … 1148 704 included in the link. */ 1149 705 1150 static b oolean706 static bfd_boolean 1151 707 xcoff_link_check_ar_symbols (abfd, info, pneeded) 1152 708 bfd *abfd; 1153 709 struct bfd_link_info *info; 1154 b oolean *pneeded;710 bfd_boolean *pneeded; 1155 711 { 1156 712 bfd_size_type symesz; … … 1158 714 bfd_byte *esym_end; 1159 715 1160 *pneeded = false;716 *pneeded = FALSE; 1161 717 1162 718 if ((abfd->flags & DYNAMIC) != 0 … … 1181 737 1182 738 /* This symbol is externally visible, and is defined by this 1183 739 object file. */ 1184 740 1185 741 name = _bfd_coff_internal_syment_name (abfd, &sym, buf); 742 1186 743 if (name == NULL) 1187 return false;1188 h = bfd_link_hash_lookup (info->hash, name, false, false, true);744 return FALSE; 745 h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE); 1189 746 1190 747 /* We are only interested in symbols that are currently … … 1195 752 if (h != (struct bfd_link_hash_entry *) NULL 1196 753 && h->type == bfd_link_hash_undefined 1197 && (info->hash->creator != abfd->xvec754 && (info->hash->creator != abfd->xvec 1198 755 || (((struct xcoff_link_hash_entry *) h)->flags 1199 756 & XCOFF_DEF_DYNAMIC) == 0)) 1200 757 { 1201 758 if (! (*info->callbacks->add_archive_element) (info, abfd, name)) 1202 return false;1203 *pneeded = true;1204 return true;759 return FALSE; 760 *pneeded = TRUE; 761 return TRUE; 1205 762 } 1206 763 } … … 1210 767 1211 768 /* We do not need this object file. */ 1212 return true;769 return TRUE; 1213 770 } 1214 771 … … 1217 774 symbols, not the normal symbol table, so we do too. */ 1218 775 1219 static b oolean776 static bfd_boolean 1220 777 xcoff_link_check_dynamic_ar_symbols (abfd, info, pneeded) 1221 778 bfd *abfd; 1222 779 struct bfd_link_info *info; 1223 b oolean *pneeded;780 bfd_boolean *pneeded; 1224 781 { 1225 782 asection *lsec; 1226 bfd_byte * buf;783 bfd_byte *contents; 1227 784 struct internal_ldhdr ldhdr; 1228 785 const char *strings; 1229 struct external_ldsym*elsym, *elsymend;1230 1231 *pneeded = false;786 bfd_byte *elsym, *elsymend; 787 788 *pneeded = FALSE; 1232 789 1233 790 lsec = bfd_get_section_by_name (abfd, ".loader"); … … 1235 792 { 1236 793 /* There are no symbols, so don't try to include it. */ 1237 return true;794 return TRUE; 1238 795 } 1239 796 1240 797 if (! xcoff_get_section_contents (abfd, lsec)) 1241 return false; 1242 buf = coff_section_data (abfd, lsec)->contents; 1243 1244 xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) buf, &ldhdr); 1245 1246 strings = (char *) buf + ldhdr.l_stoff; 1247 1248 elsym = (struct external_ldsym *) (buf + LDHDRSZ); 1249 elsymend = elsym + ldhdr.l_nsyms; 1250 for (; elsym < elsymend; elsym++) 798 return FALSE; 799 contents = coff_section_data (abfd, lsec)->contents; 800 801 bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr); 802 803 strings = (char *) contents + ldhdr.l_stoff; 804 805 elsym = contents + bfd_xcoff_loader_symbol_offset(abfd, &ldhdr); 806 807 elsymend = elsym + ldhdr.l_nsyms * bfd_xcoff_ldsymsz(abfd); 808 for (; elsym < elsymend; elsym += bfd_xcoff_ldsymsz(abfd)) 1251 809 { 1252 810 struct internal_ldsym ldsym; … … 1255 813 struct bfd_link_hash_entry *h; 1256 814 1257 xcoff_swap_ldsym_in (abfd, elsym, &ldsym);815 bfd_xcoff_swap_ldsym_in (abfd, elsym, &ldsym); 1258 816 1259 817 /* We are only interested in exported symbols. */ … … 1270 828 } 1271 829 1272 h = bfd_link_hash_lookup (info->hash, name, false, false, true);830 h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE); 1273 831 1274 832 /* We are only interested in symbols that are currently 1275 1276 833 undefined. At this point we know that we are using an XCOFF 834 hash table. */ 1277 835 if (h != NULL 1278 836 && h->type == bfd_link_hash_undefined … … 1281 839 { 1282 840 if (! (*info->callbacks->add_archive_element) (info, abfd, name)) 1283 return false;1284 *pneeded = true;1285 return true;841 return FALSE; 842 *pneeded = TRUE; 843 return TRUE; 1286 844 } 1287 845 } … … 1289 847 /* We do not need this shared object. */ 1290 848 1291 if ( buf!= NULL && ! coff_section_data (abfd, lsec)->keep_contents)849 if (contents != NULL && ! coff_section_data (abfd, lsec)->keep_contents) 1292 850 { 1293 851 free (coff_section_data (abfd, lsec)->contents); … … 1295 853 } 1296 854 1297 return true;855 return TRUE; 1298 856 } 1299 857 … … 1346 904 1347 905 return min; 906 } 907 908 909 /* xcoff_link_create_extra_sections 910 911 Takes care of creating the .loader, .gl, .ds, .debug and sections. */ 912 913 static bfd_boolean 914 xcoff_link_create_extra_sections(bfd * abfd, struct bfd_link_info *info) 915 { 916 917 bfd_boolean return_value = FALSE; 918 919 if (info->hash->creator == abfd->xvec) 920 { 921 922 /* We need to build a .loader section, so we do it here. This 923 won't work if we're producing an XCOFF output file with no 924 XCOFF input files. FIXME. */ 925 926 if (xcoff_hash_table (info)->loader_section == NULL) 927 { 928 asection *lsec; 929 930 lsec = bfd_make_section_anyway (abfd, ".loader"); 931 if (lsec == NULL) 932 { 933 goto end_return; 934 } 935 xcoff_hash_table (info)->loader_section = lsec; 936 lsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY; 937 } 938 939 /* Likewise for the linkage section. */ 940 if (xcoff_hash_table (info)->linkage_section == NULL) 941 { 942 asection *lsec; 943 944 lsec = bfd_make_section_anyway (abfd, ".gl"); 945 if (lsec == NULL) 946 { 947 goto end_return; 948 } 949 950 xcoff_hash_table (info)->linkage_section = lsec; 951 lsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 952 | SEC_IN_MEMORY); 953 lsec->alignment_power = 2; 954 } 955 956 /* Likewise for the TOC section. */ 957 if (xcoff_hash_table (info)->toc_section == NULL) 958 { 959 asection *tsec; 960 961 tsec = bfd_make_section_anyway (abfd, ".tc"); 962 if (tsec == NULL) 963 { 964 goto end_return; 965 } 966 967 xcoff_hash_table (info)->toc_section = tsec; 968 tsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 969 | SEC_IN_MEMORY); 970 tsec->alignment_power = 2; 971 } 972 973 /* Likewise for the descriptor section. */ 974 if (xcoff_hash_table (info)->descriptor_section == NULL) 975 { 976 asection *dsec; 977 978 dsec = bfd_make_section_anyway (abfd, ".ds"); 979 if (dsec == NULL) 980 { 981 goto end_return; 982 } 983 984 xcoff_hash_table (info)->descriptor_section = dsec; 985 dsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 986 | SEC_IN_MEMORY); 987 dsec->alignment_power = 2; 988 } 989 990 /* Likewise for the .debug section. */ 991 if (xcoff_hash_table (info)->debug_section == NULL 992 && info->strip != strip_all) 993 { 994 asection *dsec; 995 996 dsec = bfd_make_section_anyway (abfd, ".debug"); 997 if (dsec == NULL) 998 { 999 goto end_return; 1000 } 1001 xcoff_hash_table (info)->debug_section = dsec; 1002 dsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY; 1003 } 1004 } 1005 1006 return_value = TRUE; 1007 1008 end_return: 1009 1010 return return_value; 1348 1011 } 1349 1012 … … 1366 1029 csect they belong to is to examine the address. */ 1367 1030 1368 static b oolean1031 static bfd_boolean 1369 1032 xcoff_link_add_symbols (abfd, info) 1370 1033 bfd *abfd; … … 1373 1036 unsigned int n_tmask; 1374 1037 unsigned int n_btshft; 1375 b oolean default_copy;1038 bfd_boolean default_copy; 1376 1039 bfd_size_type symcount; 1377 1040 struct xcoff_link_hash_entry **sym_hash; … … 1380 1043 asection *o; 1381 1044 asection *last_real; 1382 b oolean keep_syms;1045 bfd_boolean keep_syms; 1383 1046 asection *csect; 1384 1047 unsigned int csect_index; … … 1388 1051 bfd_byte *esym_end; 1389 1052 struct reloc_info_struct 1390 { 1391 struct internal_reloc *relocs; 1392 asection **csects; 1393 bfd_byte *linenos; 1394 } *reloc_info = NULL; 1053 { 1054 struct internal_reloc *relocs; 1055 asection **csects; 1056 bfd_byte *linenos; 1057 } *reloc_info = NULL; 1058 bfd_size_type amt; 1395 1059 1396 1060 keep_syms = obj_coff_keep_syms (abfd); … … 1400 1064 { 1401 1065 if (! xcoff_link_add_dynamic_symbols (abfd, info)) 1402 return false; 1403 } 1404 1405 if (info->hash->creator == abfd->xvec) 1406 { 1407 /* We need to build a .loader section, so we do it here. This 1408 won't work if we're producing an XCOFF output file with no 1409 XCOFF input files. FIXME. */ 1410 if (xcoff_hash_table (info)->loader_section == NULL) 1411 { 1412 asection *lsec; 1413 1414 lsec = bfd_make_section_anyway (abfd, ".loader"); 1415 if (lsec == NULL) 1416 goto error_return; 1417 xcoff_hash_table (info)->loader_section = lsec; 1418 lsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY; 1419 } 1420 /* Likewise for the linkage section. */ 1421 if (xcoff_hash_table (info)->linkage_section == NULL) 1422 { 1423 asection *lsec; 1424 1425 lsec = bfd_make_section_anyway (abfd, ".gl"); 1426 if (lsec == NULL) 1427 goto error_return; 1428 xcoff_hash_table (info)->linkage_section = lsec; 1429 lsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 1430 | SEC_IN_MEMORY); 1431 lsec->alignment_power = 2; 1432 } 1433 /* Likewise for the TOC section. */ 1434 if (xcoff_hash_table (info)->toc_section == NULL) 1435 { 1436 asection *tsec; 1437 1438 tsec = bfd_make_section_anyway (abfd, ".tc"); 1439 if (tsec == NULL) 1440 goto error_return; 1441 xcoff_hash_table (info)->toc_section = tsec; 1442 tsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 1443 | SEC_IN_MEMORY); 1444 tsec->alignment_power = 2; 1445 } 1446 /* Likewise for the descriptor section. */ 1447 if (xcoff_hash_table (info)->descriptor_section == NULL) 1448 { 1449 asection *dsec; 1450 1451 dsec = bfd_make_section_anyway (abfd, ".ds"); 1452 if (dsec == NULL) 1453 goto error_return; 1454 xcoff_hash_table (info)->descriptor_section = dsec; 1455 dsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 1456 | SEC_IN_MEMORY); 1457 dsec->alignment_power = 2; 1458 } 1459 /* Likewise for the .debug section. */ 1460 if (xcoff_hash_table (info)->debug_section == NULL 1461 && info->strip != strip_all) 1462 { 1463 asection *dsec; 1464 1465 dsec = bfd_make_section_anyway (abfd, ".debug"); 1466 if (dsec == NULL) 1467 goto error_return; 1468 xcoff_hash_table (info)->debug_section = dsec; 1469 dsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY; 1470 } 1471 } 1066 return FALSE; 1067 } 1068 1069 /* create the loader, toc, gl, ds and debug sections, if needed */ 1070 if (! xcoff_link_create_extra_sections (abfd, info)) 1071 goto error_return; 1472 1072 1473 1073 if ((abfd->flags & DYNAMIC) != 0 1474 1074 && ! info->static_link) 1475 return true;1075 return TRUE; 1476 1076 1477 1077 n_tmask = coff_data (abfd)->local_n_tmask; … … 1483 1083 1484 1084 if (info->keep_memory) 1485 default_copy = false;1085 default_copy = FALSE; 1486 1086 else 1487 default_copy = true;1087 default_copy = TRUE; 1488 1088 1489 1089 symcount = obj_raw_syment_count (abfd); … … 1491 1091 /* We keep a list of the linker hash table entries that correspond 1492 1092 to each external symbol. */ 1493 sym_hash = ((struct xcoff_link_hash_entry **) 1494 bfd_alloc (abfd, 1495 (symcount 1496 * sizeof (struct xcoff_link_hash_entry *)))); 1093 amt = symcount * sizeof (struct xcoff_link_hash_entry *); 1094 sym_hash = (struct xcoff_link_hash_entry **) bfd_zalloc (abfd, amt); 1497 1095 if (sym_hash == NULL && symcount != 0) 1498 1096 goto error_return; 1499 1097 coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash; 1500 memset (sym_hash, 0,1501 (size_t) symcount * sizeof (struct xcoff_link_hash_entry *));1502 1098 1503 1099 /* Because of the weird stuff we are doing with XCOFF csects, we can 1504 1100 not easily determine which section a symbol is in, so we store 1505 1101 the information in the tdata for the input file. */ 1506 csect_cache = ((asection **)1507 bfd_alloc (abfd, symcount * sizeof (asection *)));1102 amt = symcount * sizeof (asection *); 1103 csect_cache = (asection **) bfd_zalloc (abfd, amt); 1508 1104 if (csect_cache == NULL && symcount != 0) 1509 1105 goto error_return; 1510 1106 xcoff_data (abfd)->csects = csect_cache; 1511 memset (csect_cache, 0, (size_t) symcount * sizeof (asection *));1512 1107 1513 1108 /* While splitting sections into csects, we need to assign the … … 1516 1111 scanning along the relocs as we process the csects. We index 1517 1112 into reloc_info using the section target_index. */ 1518 reloc_info = ((struct reloc_info_struct *)1519 bfd_malloc ((abfd->section_count + 1) 1520 * sizeof (struct reloc_info_struct)));1113 amt = abfd->section_count + 1; 1114 amt *= sizeof (struct reloc_info_struct); 1115 reloc_info = (struct reloc_info_struct *) bfd_zmalloc (amt); 1521 1116 if (reloc_info == NULL) 1522 1117 goto error_return; 1523 memset ((PTR) reloc_info, 0,1524 (abfd->section_count + 1) * sizeof (struct reloc_info_struct));1525 1118 1526 1119 /* Read in the relocs and line numbers for each section. */ … … 1529 1122 for (o = abfd->sections; o != NULL; o = o->next) 1530 1123 { 1124 1531 1125 last_real = o; 1532 1126 if ((o->flags & SEC_RELOC) != 0) 1533 1127 { 1128 1534 1129 reloc_info[o->target_index].relocs = 1535 xcoff_read_internal_relocs (abfd, o, true, (bfd_byte *) NULL, 1536 false, (struct internal_reloc *) NULL); 1537 reloc_info[o->target_index].csects = 1538 (asection **) bfd_malloc (o->reloc_count * sizeof (asection *)); 1130 xcoff_read_internal_relocs (abfd, o, TRUE, (bfd_byte *) NULL, 1131 FALSE, (struct internal_reloc *) NULL); 1132 amt = o->reloc_count; 1133 amt *= sizeof (asection *); 1134 reloc_info[o->target_index].csects = (asection **) bfd_zmalloc (amt); 1539 1135 if (reloc_info[o->target_index].csects == NULL) 1540 1136 goto error_return; 1541 memset (reloc_info[o->target_index].csects, 0,1542 o->reloc_count * sizeof (asection *));1543 1137 } 1544 1138 … … 1546 1140 && o->lineno_count > 0) 1547 1141 { 1142 1548 1143 bfd_byte *linenos; 1549 1144 1550 linenos = (bfd_byte *) bfd_malloc (o->lineno_count * linesz); 1145 amt = linesz * o->lineno_count; 1146 linenos = (bfd_byte *) bfd_malloc (amt); 1551 1147 if (linenos == NULL) 1552 1148 goto error_return; 1553 1149 reloc_info[o->target_index].linenos = linenos; 1554 1150 if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0 1555 || (bfd_read (linenos, linesz, o->lineno_count, abfd) 1556 != linesz * o->lineno_count)) 1151 || bfd_bread (linenos, amt, abfd) != amt) 1557 1152 goto error_return; 1153 1558 1154 } 1559 1155 } 1560 1156 1561 1157 /* Don't let the linker relocation routines discard the symbols. */ 1562 obj_coff_keep_syms (abfd) = true;1158 obj_coff_keep_syms (abfd) = TRUE; 1563 1159 1564 1160 csect = NULL; … … 1570 1166 esym = (bfd_byte *) obj_coff_external_syms (abfd); 1571 1167 esym_end = esym + symcount * symesz; 1168 1572 1169 while (esym < esym_end) 1573 1170 { … … 1585 1182 1586 1183 /* In this pass we are only interested in symbols with csect 1587 1184 information. */ 1588 1185 if (sym.n_sclass != C_EXT && sym.n_sclass != C_HIDEXT) 1589 1186 { 1187 1188 /* Set csect_cache, 1189 Normally csect is a .pr, .rw etc. created in the loop 1190 If C_FILE or first time, handle special 1191 1192 Advance esym, sym_hash, csect_hash ptr's 1193 Keep track of the last_symndx for the current file. */ 1590 1194 if (sym.n_sclass == C_FILE && csect != NULL) 1591 1195 { … … 1606 1210 sym_hash += sym.n_numaux + 1; 1607 1211 csect_cache += sym.n_numaux + 1; 1212 1608 1213 continue; 1609 1214 } 1610 1215 1611 1216 name = _bfd_coff_internal_syment_name (abfd, &sym, buf); 1217 1612 1218 if (name == NULL) 1613 1219 goto error_return; 1614 1220 1615 1221 /* If this symbol has line number information attached to it, 1616 1617 1618 1619 1620 1222 and we're not stripping it, count the number of entries and 1223 add them to the count for this csect. In the final link pass 1224 we are going to attach line number information by symbol, 1225 rather than by section, in order to more easily handle 1226 garbage collection. */ 1621 1227 if ((info->strip == strip_none || info->strip == strip_some) 1622 1228 && sym.n_numaux > 1 … … 1624 1230 && ISFCN (sym.n_type)) 1625 1231 { 1232 1626 1233 union internal_auxent auxlin; 1627 1234 … … 1629 1236 sym.n_type, sym.n_sclass, 1630 1237 0, sym.n_numaux, (PTR) &auxlin); 1238 1631 1239 if (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0) 1632 1240 { 1633 1241 asection *enclosing; 1634 bfd_si ze_typelinoff;1242 bfd_signed_vma linoff; 1635 1243 1636 1244 enclosing = xcoff_section_data (abfd, csect)->enclosing; … … 1639 1247 (*_bfd_error_handler) 1640 1248 (_("%s: `%s' has line numbers but no enclosing section"), 1641 bfd_ get_filename (abfd), name);1249 bfd_archive_filename (abfd), name); 1642 1250 bfd_set_error (bfd_error_bad_value); 1643 1251 goto error_return; … … 1645 1253 linoff = (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr 1646 1254 - enclosing->line_filepos); 1647 if (linoff < enclosing->lineno_count * linesz) 1255 /* explict cast to bfd_signed_vma for compiler */ 1256 if (linoff < (bfd_signed_vma) (enclosing->lineno_count * linesz)) 1648 1257 { 1649 1258 struct internal_lineno lin; … … 1674 1283 csect->lineno_count += (linp - linpstart) / linesz; 1675 1284 /* The setting of line_filepos will only be 1676 1677 1678 1285 useful if all the line number entries for a 1286 csect are contiguous; this only matters for 1287 error reporting. */ 1679 1288 if (csect->line_filepos == 0) 1680 1289 csect->line_filepos = … … 1691 1300 (*_bfd_error_handler) 1692 1301 (_("%s: class %d symbol `%s' has no aux entries"), 1693 bfd_ get_filename (abfd), sym.n_sclass, name);1302 bfd_archive_filename (abfd), sym.n_sclass, name); 1694 1303 bfd_set_error (bfd_error_bad_value); 1695 1304 goto error_return; … … 1714 1323 (*_bfd_error_handler) 1715 1324 (_("%s: symbol `%s' has unrecognized csect type %d"), 1716 bfd_ get_filename (abfd), name, smtyp);1325 bfd_archive_filename (abfd), name, smtyp); 1717 1326 bfd_set_error (bfd_error_bad_value); 1718 1327 goto error_return; … … 1726 1335 (*_bfd_error_handler) 1727 1336 (_("%s: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d"), 1728 bfd_ get_filename (abfd), name, sym.n_sclass, sym.n_scnum,1337 bfd_archive_filename (abfd), name, sym.n_sclass, sym.n_scnum, 1729 1338 aux.x_csect.x_scnlen.l); 1730 1339 bfd_set_error (bfd_error_bad_value); … … 1733 1342 1734 1343 /* An XMC_XO external reference is actually a reference to 1735 1344 an absolute location. */ 1736 1345 if (aux.x_csect.x_smclas != XMC_XO) 1737 1346 section = bfd_und_section_ptr; … … 1745 1354 case XTY_SD: 1746 1355 /* This is a csect definition. */ 1747 1748 1356 if (csect != NULL) 1749 1357 { 1750 1358 xcoff_section_data (abfd, csect)->last_symndx = 1751 ((esym 1752 - (bfd_byte *) obj_coff_external_syms (abfd)) 1753 / symesz); 1359 ((esym - (bfd_byte *) obj_coff_external_syms (abfd)) / symesz); 1754 1360 } 1755 1361 1756 1362 csect = NULL; 1757 csect_index = - 1;1363 csect_index = -(unsigned) 1; 1758 1364 1759 1365 /* When we see a TOC anchor, we record the TOC value. */ … … 1765 1371 (*_bfd_error_handler) 1766 1372 (_("%s: XMC_TC0 symbol `%s' is class %d scnlen %d"), 1767 bfd_ get_filename (abfd), name, sym.n_sclass,1373 bfd_archive_filename (abfd), name, sym.n_sclass, 1768 1374 aux.x_csect.x_scnlen.l); 1769 1375 bfd_set_error (bfd_error_bad_value); … … 1775 1381 /* We must merge TOC entries for the same symbol. We can 1776 1382 merge two TOC entries if they are both C_HIDEXT, they 1777 both have the same name, they are both 4 bytes long, and1383 both have the same name, they are both 4 or 8 bytes long, and 1778 1384 they both have a relocation table entry for an external 1779 1385 symbol with the same name. Unfortunately, this means 1780 that we must look through the relocations. Ick. */ 1386 that we must look through the relocations. Ick. 1387 1388 Logic for 32 bit vs 64 bit. 1389 32 bit has a csect length of 4 for TOC 1390 64 bit has a csect length of 8 for TOC 1391 1392 The conditions to get past the if-check are not that bad. 1393 They are what is used to create the TOC csects in the first 1394 place. */ 1781 1395 if (aux.x_csect.x_smclas == XMC_TC 1782 1396 && sym.n_sclass == C_HIDEXT 1783 && aux.x_csect.x_scnlen.l == 4 1784 && info->hash->creator == abfd->xvec) 1397 && info->hash->creator == abfd->xvec 1398 && ((bfd_xcoff_is_xcoff32 (abfd) 1399 && aux.x_csect.x_scnlen.l == 4) 1400 || (bfd_xcoff_is_xcoff64 (abfd) 1401 && aux.x_csect.x_scnlen.l == 8))) 1785 1402 { 1786 1403 asection *enclosing; … … 1794 1411 1795 1412 relocs = reloc_info[enclosing->target_index].relocs; 1796 relindx = xcoff_find_reloc (relocs, enclosing->reloc_count,1797 1413 amt = enclosing->reloc_count; 1414 relindx = xcoff_find_reloc (relocs, amt, sym.n_value); 1798 1415 rel = relocs + relindx; 1416 1417 /* 32 bit R_POS r_size is 31 1418 64 bit R_POS r_size is 63 */ 1799 1419 if (relindx < enclosing->reloc_count 1800 1420 && rel->r_vaddr == (bfd_vma) sym.n_value 1801 && rel->r_size == 31 1802 && rel->r_type == R_POS) 1421 && rel->r_type == R_POS 1422 && ((bfd_xcoff_is_xcoff32 (abfd) 1423 && rel->r_size == 31) 1424 || (bfd_xcoff_is_xcoff64 (abfd) 1425 && rel->r_size == 63))) 1803 1426 { 1804 1427 bfd_byte *erelsym; 1428 1805 1429 struct internal_syment relsym; 1806 1430 … … 1812 1436 const char *relname; 1813 1437 char relbuf[SYMNMLEN + 1]; 1814 b oolean copy;1438 bfd_boolean copy; 1815 1439 struct xcoff_link_hash_entry *h; 1816 1440 1817 1441 /* At this point we know that the TOC entry is 1818 1442 for an externally visible symbol. */ 1443 1819 1444 relname = _bfd_coff_internal_syment_name (abfd, &relsym, 1820 1445 relbuf); … … 1823 1448 1824 1449 /* We only merge TOC entries if the TC name is 1825 the same as the symbol name. This handles 1826 the normal case, but not common cases like 1827 SYM.P4 which gcc generates to store SYM + 4 1828 in the TOC. FIXME. */ 1450 the same as the symbol name. This handles 1451 the normal case, but not common cases like 1452 SYM.P4 which gcc generates to store SYM + 4 1453 in the TOC. FIXME. */ 1454 1829 1455 if (strcmp (name, relname) == 0) 1830 1456 { … … 1833 1459 || relsym._n._n_n._n_offset == 0); 1834 1460 h = xcoff_link_hash_lookup (xcoff_hash_table (info), 1835 relname, true, copy,1836 false);1461 relname, TRUE, copy, 1462 FALSE); 1837 1463 if (h == NULL) 1838 1464 goto error_return; … … 1865 1491 this symbol. */ 1866 1492 set_toc = h; 1867 } 1868 } 1869 } 1870 } 1871 1872 /* We need to create a new section. We get the name from 1873 the csect storage mapping class, so that the linker can 1874 accumulate similar csects together. */ 1493 } /* merge toc reloc */ 1494 } /* c_ext */ 1495 } /* reloc */ 1496 } /* merge toc */ 1497 1875 1498 { 1876 static const char *csect_name_by_class[] = { 1877 ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo", 1878 ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0", 1879 ".td" 1880 }; 1881 const char *csect_name; 1499 1882 1500 asection *enclosing; 1883 1501 1884 if ((aux.x_csect.x_smclas >= 1885 sizeof csect_name_by_class / sizeof csect_name_by_class[0]) 1886 || csect_name_by_class[aux.x_csect.x_smclas] == NULL) 1502 /* We need to create a new section. We get the name from 1503 the csect storage mapping class, so that the linker can 1504 accumulate similar csects together. */ 1505 1506 csect = bfd_xcoff_create_csect_from_smclas(abfd, &aux, name); 1507 if (NULL == csect) 1887 1508 { 1888 (*_bfd_error_handler)1889 (_("%s: symbol `%s' has unrecognized smclas %d"),1890 bfd_get_filename (abfd), name, aux.x_csect.x_smclas);1891 bfd_set_error (bfd_error_bad_value);1892 1509 goto error_return; 1893 1510 } 1894 1511 1895 csect_name = csect_name_by_class[aux.x_csect.x_smclas]; 1896 csect = bfd_make_section_anyway (abfd, csect_name); 1897 if (csect == NULL) 1898 goto error_return; 1512 /* The enclosing section is the main section : .data, .text 1513 or .bss that the csect is coming from. */ 1899 1514 enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum); 1900 1515 if (enclosing == NULL) 1901 1516 goto error_return; 1517 1902 1518 if (! bfd_is_abs_section (enclosing) 1903 1519 && ((bfd_vma) sym.n_value < enclosing->vma … … 1907 1523 (*_bfd_error_handler) 1908 1524 (_("%s: csect `%s' not in enclosing section"), 1909 bfd_ get_filename (abfd), name);1525 bfd_archive_filename (abfd), name); 1910 1526 bfd_set_error (bfd_error_bad_value); 1911 1527 goto error_return; … … 1921 1537 /* Record the enclosing section in the tdata for this new 1922 1538 section. */ 1923 csect->used_by_bfd =1924 (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));1539 amt = sizeof (struct coff_section_tdata); 1540 csect->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); 1925 1541 if (csect->used_by_bfd == NULL) 1926 1542 goto error_return; 1927 coff_section_data (abfd, csect)->tdata =1928 bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));1543 amt = sizeof (struct xcoff_section_tdata); 1544 coff_section_data (abfd, csect)->tdata = bfd_zalloc (abfd, amt); 1929 1545 if (coff_section_data (abfd, csect)->tdata == NULL) 1930 1546 goto error_return; … … 1941 1557 1942 1558 relocs = reloc_info[enclosing->target_index].relocs; 1943 relindx = xcoff_find_reloc (relocs, enclosing->reloc_count, 1944 csect->vma); 1559 amt = enclosing->reloc_count; 1560 relindx = xcoff_find_reloc (relocs, amt, csect->vma); 1561 1945 1562 rel = relocs + relindx; 1946 1563 rel_csect = (reloc_info[enclosing->target_index].csects 1947 1564 + relindx); 1565 1948 1566 csect->rel_filepos = (enclosing->rel_filepos 1949 1567 + relindx * bfd_coff_relsz (abfd)); … … 1952 1570 && rel->r_vaddr < csect->vma + csect->_raw_size) 1953 1571 { 1572 1954 1573 *rel_csect = csect; 1955 1574 csect->flags |= SEC_RELOC; … … 1989 1608 case XTY_LD: 1990 1609 /* This is a label definition. The x_scnlen field is the 1991 symbol index of the csect. I believe that this must 1992 always follow the appropriate XTY_SD symbol, so I will 1993 insist on it.*/1610 symbol index of the csect. Usually the XTY_LD symbol will 1611 follow its appropriate XTY_SD symbol. The .set pseudo op can 1612 cause the XTY_LD to not follow the XTY_SD symbol. */ 1994 1613 { 1995 b oolean bad;1996 1997 bad = false;1614 bfd_boolean bad; 1615 1616 bad = FALSE; 1998 1617 if (aux.x_csect.x_scnlen.l < 0 1999 1618 || (aux.x_csect.x_scnlen.l 2000 1619 >= esym - (bfd_byte *) obj_coff_external_syms (abfd))) 2001 bad = true;1620 bad = TRUE; 2002 1621 if (! bad) 2003 1622 { … … 2005 1624 if (section == NULL 2006 1625 || (section->flags & SEC_HAS_CONTENTS) == 0) 2007 bad = true;1626 bad = TRUE; 2008 1627 } 2009 1628 if (bad) … … 2011 1630 (*_bfd_error_handler) 2012 1631 (_("%s: misplaced XTY_LD `%s'"), 2013 bfd_ get_filename (abfd), name);1632 bfd_archive_filename (abfd), name); 2014 1633 bfd_set_error (bfd_error_bad_value); 2015 1634 goto error_return; 2016 1635 } 2017 1636 csect = section; 2018 1637 value = sym.n_value - csect->vma; 2019 1638 } … … 2022 1641 case XTY_CM: 2023 1642 /* This is an unitialized csect. We could base the name on 2024 2025 2026 2027 2028 1643 the storage mapping class, but we don't bother except for 1644 an XMC_TD symbol. If this csect is externally visible, 1645 it is a common symbol. We put XMC_TD symbols in sections 1646 named .tocbss, and rely on the linker script to put that 1647 in the TOC area. */ 2029 1648 2030 1649 if (csect != NULL) … … 2037 1656 2038 1657 if (aux.x_csect.x_smclas == XMC_TD) 2039 csect = bfd_make_section_anyway (abfd, ".tocbss"); 1658 { 1659 /* The linker script puts the .td section in the data 1660 section after the .tc section. */ 1661 csect = bfd_make_section_anyway (abfd, ".td"); 1662 1663 } 2040 1664 else 2041 csect = bfd_make_section_anyway (abfd, ".bss"); 1665 { 1666 csect = bfd_make_section_anyway (abfd, ".bss"); 1667 } 2042 1668 if (csect == NULL) 2043 1669 goto error_return; … … 2053 1679 / symesz); 2054 1680 2055 csect->used_by_bfd =2056 (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));1681 amt = sizeof (struct coff_section_tdata); 1682 csect->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); 2057 1683 if (csect->used_by_bfd == NULL) 2058 1684 goto error_return; 2059 coff_section_data (abfd, csect)->tdata =2060 bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));1685 amt = sizeof (struct xcoff_section_tdata); 1686 coff_section_data (abfd, csect)->tdata = bfd_zalloc (abfd, amt); 2061 1687 if (coff_section_data (abfd, csect)->tdata == NULL) 2062 1688 goto error_return; … … 2082 1708 && aux.x_csect.x_smclas != XMC_TD) 2083 1709 { 2084 int i; 2085 2086 i = -1; 1710 1711 int i = -1; 1712 2087 1713 if (name[0] == '_') 2088 1714 { 2089 1715 if (strcmp (name, "_text") == 0) 2090 i = 0;1716 i = XCOFF_SPECIAL_SECTION_TEXT; 2091 1717 else if (strcmp (name, "_etext") == 0) 2092 i = 1;1718 i = XCOFF_SPECIAL_SECTION_ETEXT; 2093 1719 else if (strcmp (name, "_data") == 0) 2094 i = 2;1720 i = XCOFF_SPECIAL_SECTION_DATA; 2095 1721 else if (strcmp (name, "_edata") == 0) 2096 i = 3;1722 i = XCOFF_SPECIAL_SECTION_EDATA; 2097 1723 else if (strcmp (name, "_end") == 0) 2098 i = 4;1724 i = XCOFF_SPECIAL_SECTION_END; 2099 1725 } 2100 1726 else if (name[0] == 'e' && strcmp (name, "end") == 0) 2101 i = 5; 1727 { 1728 i = XCOFF_SPECIAL_SECTION_END2; 1729 } 2102 1730 2103 1731 if (i != -1) 2104 xcoff_hash_table (info)->special_sections[i] = csect; 1732 { 1733 xcoff_hash_table (info)->special_sections[i] = csect; 1734 } 2105 1735 } 2106 1736 2107 1737 /* Now we have enough information to add the symbol to the 2108 1738 linker hash table. */ 2109 1739 2110 1740 if (sym.n_sclass == C_EXT) 2111 1741 { 2112 b oolean copy;1742 bfd_boolean copy; 2113 1743 2114 1744 BFD_ASSERT (section != NULL); 2115 1745 2116 1746 /* We must copy the name into memory if we got it from the 2117 1747 syment itself, rather than the string table. */ 2118 1748 copy = default_copy; 2119 1749 if (sym._n._n_n._n_zeroes != 0 2120 1750 || sym._n._n_n._n_offset == 0) 2121 copy = true;1751 copy = TRUE; 2122 1752 2123 1753 /* The AIX linker appears to only detect multiple symbol … … 2146 1776 although this is an easier case to detect. */ 2147 1777 2148 if (info->hash->creator == abfd->xvec)1778 if (info->hash->creator == abfd->xvec) 2149 1779 { 2150 1780 if (! bfd_is_und_section (section)) 2151 *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info), 2152 name, true, copy, false); 1781 { 1782 *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info), 1783 name, TRUE, copy, FALSE); 1784 } 2153 1785 else 2154 *sym_hash = ((struct xcoff_link_hash_entry *) 2155 bfd_wrapped_link_hash_lookup (abfd, info, name, 2156 true, copy, false)); 1786 { 1787 /* Make a copy of the symbol name to prevent problems with 1788 merging symbols. */ 1789 *sym_hash = ((struct xcoff_link_hash_entry *) 1790 bfd_wrapped_link_hash_lookup (abfd, info, name, 1791 TRUE, TRUE, 1792 FALSE)); 1793 } 2157 1794 if (*sym_hash == NULL) 2158 1795 goto error_return; … … 2170 1807 { 2171 1808 /* The new symbol is from a shared library, and 2172 2173 2174 2175 2176 1809 either the existing symbol is not global 1810 linkage code or this symbol is global linkage 1811 code. If the existing symbol is global 1812 linkage code and the new symbol is not, then 1813 we want to use the new symbol. */ 2177 1814 section = bfd_und_section_ptr; 2178 1815 value = 0; … … 2182 1819 { 2183 1820 /* The existing symbol is from a shared library. 2184 1821 Replace it. */ 2185 1822 (*sym_hash)->root.type = bfd_link_hash_undefined; 2186 1823 (*sym_hash)->root.u.undef.abfd = … … 2190 1827 { 2191 1828 /* This is a redefinition in an object contained 2192 2193 1829 in an archive. Just ignore it. See the 1830 comment above. */ 2194 1831 section = bfd_und_section_ptr; 2195 1832 value = 0; … … 2199 1836 { 2200 1837 /* This symbol has been referenced. In this 2201 2202 2203 1838 case, we just continue and permit the 1839 multiple definition error. See the comment 1840 above about the behaviour of the AIX linker. */ 2204 1841 } 2205 1842 else if ((*sym_hash)->smclas == aux.x_csect.x_smclas) 2206 1843 { 2207 1844 /* The symbols are both csects of the same 2208 2209 1845 class. There is at least a chance that this 1846 is a semi-legitimate redefinition. */ 2210 1847 section = bfd_und_section_ptr; 2211 1848 value = 0; … … 2228 1865 if (! ((*info->callbacks->multiple_definition) 2229 1866 (info, (*sym_hash)->root.root.string, 2230 (bfd *) NULL, (asection *) NULL, 0,1867 (bfd *) NULL, (asection *) NULL, (bfd_vma) 0, 2231 1868 (*sym_hash)->root.u.def.section->owner, 2232 1869 (*sym_hash)->root.u.def.section, … … 2252 1889 if (! (_bfd_generic_link_add_one_symbol 2253 1890 (info, abfd, name, flags, section, value, 2254 (const char *) NULL, copy, true,1891 (const char *) NULL, copy, TRUE, 2255 1892 (struct bfd_link_hash_entry **) sym_hash))) 2256 1893 goto error_return; … … 2272 1909 } 2273 1910 2274 if (info->hash->creator == abfd->xvec)1911 if (info->hash->creator == abfd->xvec) 2275 1912 { 2276 1913 int flag; … … 2316 1953 rel = reloc_info[o->target_index].relocs; 2317 1954 rel_csect = reloc_info[o->target_index].csects; 1955 2318 1956 for (i = 0; i < o->reloc_count; i++, rel++, rel_csect++) 2319 1957 { 1958 2320 1959 if (*rel_csect == NULL) 2321 1960 { 2322 1961 (*_bfd_error_handler) 2323 1962 (_("%s: reloc %s:%d not in csect"), 2324 bfd_ get_filename (abfd), o->name, i);1963 bfd_archive_filename (abfd), o->name, i); 2325 1964 bfd_set_error (bfd_error_bad_value); 2326 1965 goto error_return; … … 2330 1969 can create glue code for calls to functions imported 2331 1970 from dynamic objects. */ 2332 if (info->hash->creator == abfd->xvec1971 if (info->hash->creator == abfd->xvec 2333 1972 && *rel_csect != bfd_und_section_ptr 2334 1973 && (rel->r_type == R_BR … … 2341 1980 h->flags |= XCOFF_CALLED; 2342 1981 /* If the symbol name starts with a period, it is 2343 2344 2345 2346 2347 2348 2349 2350 1982 the code of a function. If the symbol is 1983 currently undefined, then add an undefined symbol 1984 for the function descriptor. This should do no 1985 harm, because any regular object that defines the 1986 function should also define the function 1987 descriptor. It helps, because it means that we 1988 will identify the function descriptor with a 1989 dynamic object if a dynamic object defines it. */ 2351 1990 if (h->root.root.string[0] == '.' 2352 1991 && h->descriptor == NULL) 2353 1992 { 2354 1993 struct xcoff_link_hash_entry *hds; 1994 struct bfd_link_hash_entry *bh; 2355 1995 2356 1996 hds = xcoff_link_hash_lookup (xcoff_hash_table (info), 2357 1997 h->root.root.string + 1, 2358 true, false, true);1998 TRUE, FALSE, TRUE); 2359 1999 if (hds == NULL) 2360 2000 goto error_return; 2361 2001 if (hds->root.type == bfd_link_hash_new) 2362 2002 { 2003 bh = &hds->root; 2363 2004 if (! (_bfd_generic_link_add_one_symbol 2364 2005 (info, abfd, hds->root.root.string, 2365 2006 (flagword) 0, bfd_und_section_ptr, 2366 (bfd_vma) 0, (const char *) NULL, false, 2367 true, 2368 (struct bfd_link_hash_entry **) &hds))) 2007 (bfd_vma) 0, (const char *) NULL, FALSE, 2008 TRUE, &bh))) 2369 2009 goto error_return; 2010 hds = (struct xcoff_link_hash_entry *) bh; 2370 2011 } 2371 2012 hds->flags |= XCOFF_DESCRIPTOR; … … 2383 2024 /* Reset SEC_RELOC and the reloc_count, since the reloc 2384 2025 information is now attached to the csects. */ 2385 o->flags &= ~SEC_RELOC;2026 o->flags &=~ SEC_RELOC; 2386 2027 o->reloc_count = 0; 2387 2028 … … 2398 2039 2399 2040 /* Free up the line numbers. FIXME: We could cache these 2400 2041 somewhere for the final link, to avoid reading them again. */ 2401 2042 if (reloc_info[o->target_index].linenos != NULL) 2402 2043 { … … 2410 2051 obj_coff_keep_syms (abfd) = keep_syms; 2411 2052 2412 return true;2053 return TRUE; 2413 2054 2414 2055 error_return: … … 2422 2063 free (reloc_info[o->target_index].linenos); 2423 2064 } 2424 free (reloc_info);2065 free (reloc_info); 2425 2066 } 2426 2067 obj_coff_keep_syms (abfd) = keep_syms; 2427 return false;2068 return FALSE; 2428 2069 } 2429 2070 … … 2434 2075 global symbol table. */ 2435 2076 2436 static b oolean2077 static bfd_boolean 2437 2078 xcoff_link_add_dynamic_symbols (abfd, info) 2438 2079 bfd *abfd; … … 2440 2081 { 2441 2082 asection *lsec; 2442 bfd_byte * buf;2083 bfd_byte *contents; 2443 2084 struct internal_ldhdr ldhdr; 2444 2085 const char *strings; 2445 struct external_ldsym*elsym, *elsymend;2086 bfd_byte *elsym, *elsymend; 2446 2087 struct xcoff_import_file *n; 2447 2088 const char *bname; … … 2453 2094 /* We can only handle a dynamic object if we are generating an XCOFF 2454 2095 output file. */ 2455 if (info->hash->creator != abfd->xvec)2096 if (info->hash->creator != abfd->xvec) 2456 2097 { 2457 2098 (*_bfd_error_handler) … … 2459 2100 bfd_get_filename (abfd)); 2460 2101 bfd_set_error (bfd_error_invalid_operation); 2461 return false;2102 return FALSE; 2462 2103 } 2463 2104 … … 2480 2121 bfd_get_filename (abfd)); 2481 2122 bfd_set_error (bfd_error_no_symbols); 2482 return false; 2483 } 2123 return FALSE; 2124 } 2125 2484 2126 2485 2127 if (! xcoff_get_section_contents (abfd, lsec)) 2486 return false;2487 buf= coff_section_data (abfd, lsec)->contents;2128 return FALSE; 2129 contents = coff_section_data (abfd, lsec)->contents; 2488 2130 2489 2131 /* Remove the sections from this object, so that they do not get 2490 2132 included in the link. */ 2491 abfd->sections = NULL; 2492 2493 xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) buf, &ldhdr); 2494 2495 strings = (char *) buf + ldhdr.l_stoff; 2496 2497 elsym = (struct external_ldsym *) (buf + LDHDRSZ); 2498 elsymend = elsym + ldhdr.l_nsyms; 2499 BFD_ASSERT (sizeof (struct external_ldsym) == LDSYMSZ); 2500 for (; elsym < elsymend; elsym++) 2133 bfd_section_list_clear (abfd); 2134 2135 bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr); 2136 2137 strings = (char *) contents + ldhdr.l_stoff; 2138 2139 elsym = contents + bfd_xcoff_loader_symbol_offset(abfd, &ldhdr); 2140 2141 elsymend = elsym + ldhdr.l_nsyms * bfd_xcoff_ldsymsz(abfd); 2142 2143 for (; elsym < elsymend; elsym += bfd_xcoff_ldsymsz(abfd)) 2501 2144 { 2502 2145 struct internal_ldsym ldsym; … … 2505 2148 struct xcoff_link_hash_entry *h; 2506 2149 2507 xcoff_swap_ldsym_in (abfd, elsym, &ldsym);2150 bfd_xcoff_swap_ldsym_in (abfd, elsym, &ldsym); 2508 2151 2509 2152 /* We are only interested in exported symbols. */ … … 2525 2168 hash table. */ 2526 2169 2527 h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, true,2528 true, true);2170 h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, TRUE, 2171 TRUE, TRUE); 2529 2172 if (h == NULL) 2530 return false;2173 return FALSE; 2531 2174 2532 2175 h->flags |= XCOFF_DEF_DYNAMIC; … … 2554 2197 2555 2198 /* Unless this is an XMC_XO symbol, we don't bother to actually 2556 2557 2558 2199 define it, since we don't have a section to put it in anyhow. 2200 Instead, the relocation routines handle the DEF_DYNAMIC flag 2201 correctly. */ 2559 2202 2560 2203 if (h->smclas == XMC_XO … … 2582 2225 char *dsnm; 2583 2226 2584 dsnm = bfd_malloc ( strlen (name) + 2);2227 dsnm = bfd_malloc ((bfd_size_type) strlen (name) + 2); 2585 2228 if (dsnm == NULL) 2586 return false;2229 return FALSE; 2587 2230 dsnm[0] = '.'; 2588 2231 strcpy (dsnm + 1, name); 2589 2232 hds = xcoff_link_hash_lookup (xcoff_hash_table (info), dsnm, 2590 true, true, true);2233 TRUE, TRUE, TRUE); 2591 2234 free (dsnm); 2592 2235 if (hds == NULL) 2593 return false;2236 return FALSE; 2594 2237 2595 2238 if (hds->root.type == bfd_link_hash_new) … … 2598 2241 hds->root.u.undef.abfd = abfd; 2599 2242 /* We do not want to add this to the undefined 2600 2243 symbol list. */ 2601 2244 } 2602 2245 … … 2624 2267 } 2625 2268 2626 if ( buf!= NULL && ! coff_section_data (abfd, lsec)->keep_contents)2269 if (contents != NULL && ! coff_section_data (abfd, lsec)->keep_contents) 2627 2270 { 2628 2271 free (coff_section_data (abfd, lsec)->contents); … … 2633 2276 2634 2277 n = ((struct xcoff_import_file *) 2635 bfd_alloc (abfd, sizeof (struct xcoff_import_file)));2278 bfd_alloc (abfd, (bfd_size_type) sizeof (struct xcoff_import_file))); 2636 2279 if (n == NULL) 2637 return false;2280 return FALSE; 2638 2281 n->next = NULL; 2639 2282 … … 2668 2311 xcoff_data (abfd)->import_file_id = c; 2669 2312 2670 return true;2313 return TRUE; 2671 2314 } 2672 2315 … … 2678 2321 it is defined. */ 2679 2322 2680 static INLINE b oolean2323 static INLINE bfd_boolean 2681 2324 xcoff_mark_symbol (info, h) 2682 2325 struct bfd_link_info *info; 2683 2326 struct xcoff_link_hash_entry *h; 2684 2327 { 2328 2685 2329 if ((h->flags & XCOFF_MARK) != 0) 2686 return true;2330 return TRUE; 2687 2331 2688 2332 h->flags |= XCOFF_MARK; … … 2697 2341 { 2698 2342 if (! xcoff_mark (info, hsec)) 2699 return false;2343 return FALSE; 2700 2344 } 2701 2345 } … … 2705 2349 { 2706 2350 if (! xcoff_mark (info, h->toc_section)) 2707 return false;2708 } 2709 2710 return true;2351 return FALSE; 2352 } 2353 2354 return TRUE; 2711 2355 } 2712 2356 … … 2717 2361 section. */ 2718 2362 2719 static b oolean2363 static bfd_boolean 2720 2364 xcoff_mark (info, sec) 2721 2365 struct bfd_link_info *info; … … 2724 2368 if (bfd_is_abs_section (sec) 2725 2369 || (sec->flags & SEC_MARK) != 0) 2726 return true;2370 return TRUE; 2727 2371 2728 2372 sec->flags |= SEC_MARK; … … 2750 2394 { 2751 2395 if (! xcoff_mark_symbol (info, h)) 2752 return false;2396 return FALSE; 2753 2397 } 2754 2398 } … … 2759 2403 && sec->reloc_count > 0) 2760 2404 { 2761 rel = xcoff_read_internal_relocs (sec->owner, sec, true,2762 (bfd_byte *) NULL, false,2405 rel = xcoff_read_internal_relocs (sec->owner, sec, TRUE, 2406 (bfd_byte *) NULL, FALSE, 2763 2407 (struct internal_reloc *) NULL); 2764 2408 if (rel == NULL) 2765 return false;2409 return FALSE; 2766 2410 relend = rel + sec->reloc_count; 2767 2411 for (; rel < relend; rel++) … … 2779 2423 { 2780 2424 if (! xcoff_mark_symbol (info, h)) 2781 return false;2425 return FALSE; 2782 2426 } 2783 2427 … … 2787 2431 { 2788 2432 if (! xcoff_mark (info, rsec)) 2789 return false;2433 return FALSE; 2790 2434 } 2791 2435 2792 2436 /* See if this reloc needs to be copied into the .loader 2793 2437 section. */ 2794 2438 switch (rel->r_type) 2795 2439 { … … 2840 2484 } 2841 2485 2842 return true;2486 return TRUE; 2843 2487 } 2844 2488 … … 2861 2505 { 2862 2506 /* Keep all sections from non-XCOFF input files. Keep 2863 2864 2507 special sections. Keep .debug sections for the 2508 moment. */ 2865 2509 if (sub->xvec != info->hash->creator 2866 2510 || o == xcoff_hash_table (info)->debug_section … … 2885 2529 correct csect length. */ 2886 2530 2887 b oolean2531 bfd_boolean 2888 2532 bfd_xcoff_link_record_set (output_bfd, info, harg, size) 2889 2533 bfd *output_bfd; … … 2894 2538 struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg; 2895 2539 struct xcoff_link_size_list *n; 2540 bfd_size_type amt; 2896 2541 2897 2542 if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour) 2898 return true;2543 return TRUE; 2899 2544 2900 2545 /* This will hardly ever be called. I don't want to burn four bytes … … 2902 2547 attached to the hash table. */ 2903 2548 2904 n = ((struct xcoff_link_size_list *)2905 bfd_alloc (output_bfd, sizeof (struct xcoff_link_size_list)));2549 amt = sizeof (struct xcoff_link_size_list); 2550 n = (struct xcoff_link_size_list *) bfd_alloc (output_bfd, amt); 2906 2551 if (n == NULL) 2907 return false;2552 return FALSE; 2908 2553 n->next = xcoff_hash_table (info)->size_list; 2909 2554 n->h = h; … … 2913 2558 h->flags |= XCOFF_HAS_SIZE; 2914 2559 2915 return true;2560 return TRUE; 2916 2561 } 2917 2562 2918 2563 /* Import a symbol. */ 2919 2564 2920 b oolean2565 bfd_boolean 2921 2566 bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile, 2922 impmember )2567 impmember, syscall_flag) 2923 2568 bfd *output_bfd; 2924 2569 struct bfd_link_info *info; … … 2928 2573 const char *impfile; 2929 2574 const char *impmember; 2575 unsigned int syscall_flag; 2930 2576 { 2931 2577 struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg; 2932 2578 2933 2579 if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour) 2934 return true;2580 return TRUE; 2935 2581 2936 2582 /* A symbol name which starts with a period is the code for a … … 2948 2594 hds = xcoff_link_hash_lookup (xcoff_hash_table (info), 2949 2595 h->root.root.string + 1, 2950 true, false, true);2596 TRUE, FALSE, TRUE); 2951 2597 if (hds == NULL) 2952 return false;2598 return FALSE; 2953 2599 if (hds->root.type == bfd_link_hash_new) 2954 2600 { … … 2964 2610 2965 2611 /* Now, if the descriptor is undefined, import the descriptor 2966 2967 2612 rather than the symbol we were told to import. FIXME: Is 2613 this correct in all cases? */ 2968 2614 if (hds->root.type == bfd_link_hash_undefined) 2969 2615 h = hds; 2970 2616 } 2971 2617 2972 h->flags |= XCOFF_IMPORT;2618 h->flags |= (XCOFF_IMPORT | syscall_flag); 2973 2619 2974 2620 if (val != (bfd_vma) -1) … … 2982 2628 h->root.u.def.section, h->root.u.def.value, 2983 2629 output_bfd, bfd_abs_section_ptr, val))) 2984 return false;2630 return FALSE; 2985 2631 } 2986 2632 … … 3002 2648 3003 2649 /* We start c at 1 because the first entry in the import list is 3004 2650 reserved for the library search path. */ 3005 2651 for (pp = &xcoff_hash_table (info)->imports, c = 1; 3006 2652 *pp != NULL; … … 3016 2662 { 3017 2663 struct xcoff_import_file *n; 3018 3019 n = ((struct xcoff_import_file *) 3020 bfd_alloc (output_bfd, sizeof (struct xcoff_import_file)));2664 bfd_size_type amt = sizeof (struct xcoff_import_file); 2665 2666 n = (struct xcoff_import_file *) bfd_alloc (output_bfd, amt); 3021 2667 if (n == NULL) 3022 return false;2668 return FALSE; 3023 2669 n->next = NULL; 3024 2670 n->path = imppath; … … 3031 2677 } 3032 2678 3033 return true;2679 return TRUE; 3034 2680 } 3035 2681 3036 2682 /* Export a symbol. */ 3037 2683 3038 b oolean3039 bfd_xcoff_export_symbol (output_bfd, info, harg , syscall)2684 bfd_boolean 2685 bfd_xcoff_export_symbol (output_bfd, info, harg) 3040 2686 bfd *output_bfd; 3041 2687 struct bfd_link_info *info; 3042 2688 struct bfd_link_hash_entry *harg; 3043 boolean syscall ATTRIBUTE_UNUSED;3044 2689 { 3045 2690 struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg; 3046 2691 3047 2692 if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour) 3048 return true;2693 return TRUE; 3049 2694 3050 2695 h->flags |= XCOFF_EXPORT; … … 3060 2705 char *fnname; 3061 2706 struct xcoff_link_hash_entry *hfn; 3062 3063 fnname = (char *) bfd_malloc (strlen (h->root.root.string) + 2); 2707 bfd_size_type amt = strlen (h->root.root.string) + 2; 2708 2709 fnname = (char *) bfd_malloc (amt); 3064 2710 if (fnname == NULL) 3065 return false;2711 return FALSE; 3066 2712 fnname[0] = '.'; 3067 2713 strcpy (fnname + 1, h->root.root.string); 3068 2714 hfn = xcoff_link_hash_lookup (xcoff_hash_table (info), 3069 fnname, false, false, true);2715 fnname, FALSE, FALSE, TRUE); 3070 2716 free (fnname); 3071 2717 if (hfn != NULL … … 3082 2728 /* Make sure we don't garbage collect this symbol. */ 3083 2729 if (! xcoff_mark_symbol (info, h)) 3084 return false;2730 return FALSE; 3085 2731 3086 2732 /* If this is a function descriptor, make sure we don't garbage … … 3092 2738 { 3093 2739 if (! xcoff_mark_symbol (info, h->descriptor)) 3094 return false;3095 } 3096 3097 return true;2740 return FALSE; 2741 } 2742 2743 return TRUE; 3098 2744 } 3099 2745 … … 3102 2748 and destructors. */ 3103 2749 3104 b oolean2750 bfd_boolean 3105 2751 bfd_xcoff_link_count_reloc (output_bfd, info, name) 3106 2752 bfd *output_bfd; … … 3111 2757 3112 2758 if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour) 3113 return true;2759 return TRUE; 3114 2760 3115 2761 h = ((struct xcoff_link_hash_entry *) 3116 bfd_wrapped_link_hash_lookup (output_bfd, info, name, false, false,3117 false));2762 bfd_wrapped_link_hash_lookup (output_bfd, info, name, FALSE, FALSE, 2763 FALSE)); 3118 2764 if (h == NULL) 3119 2765 { 3120 2766 (*_bfd_error_handler) (_("%s: no such symbol"), name); 3121 2767 bfd_set_error (bfd_error_no_symbols); 3122 return false;2768 return FALSE; 3123 2769 } 3124 2770 … … 3128 2774 /* Mark the symbol to avoid garbage collection. */ 3129 2775 if (! xcoff_mark_symbol (info, h)) 3130 return false;3131 3132 return true;2776 return FALSE; 2777 2778 return TRUE; 3133 2779 } 3134 2780 … … 3136 2782 assigns a value. */ 3137 2783 3138 b oolean2784 bfd_boolean 3139 2785 bfd_xcoff_record_link_assignment (output_bfd, info, name) 3140 2786 bfd *output_bfd; … … 3145 2791 3146 2792 if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour) 3147 return true;3148 3149 h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, true, true,3150 false);2793 return TRUE; 2794 2795 h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, TRUE, TRUE, 2796 FALSE); 3151 2797 if (h == NULL) 3152 return false;2798 return FALSE; 3153 2799 3154 2800 h->flags |= XCOFF_DEF_REGULAR; 3155 2801 3156 return true;2802 return TRUE; 3157 2803 } 3158 3159 /* This structure is used to pass information through3160 xcoff_link_hash_traverse. */3161 3162 struct xcoff_loader_info {3163 /* Set if a problem occurred. */3164 boolean failed;3165 /* Output BFD. */3166 bfd *output_bfd;3167 /* Link information structure. */3168 struct bfd_link_info *info;3169 /* Whether all defined symbols should be exported. */3170 boolean export_defineds;3171 /* Number of ldsym structures. */3172 size_t ldsym_count;3173 /* Size of string table. */3174 size_t string_size;3175 /* String table. */3176 bfd_byte *strings;3177 /* Allocated size of string table. */3178 size_t string_alc;3179 };3180 2804 3181 2805 /* Build the .loader section. This is called by the XCOFF linker … … 3196 2820 magic names like _end. */ 3197 2821 3198 b oolean2822 bfd_boolean 3199 2823 bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, 3200 2824 file_align, maxstack, maxdata, gc, 3201 2825 modtype, textro, export_defineds, 3202 special_sections )2826 special_sections, rtld) 3203 2827 bfd *output_bfd; 3204 2828 struct bfd_link_info *info; … … 3208 2832 unsigned long maxstack; 3209 2833 unsigned long maxdata; 3210 b oolean gc;2834 bfd_boolean gc; 3211 2835 int modtype; 3212 b oolean textro;3213 b oolean export_defineds;2836 bfd_boolean textro; 2837 bfd_boolean export_defineds; 3214 2838 asection **special_sections; 2839 bfd_boolean rtld; 3215 2840 { 3216 2841 struct xcoff_link_hash_entry *hentry; … … 3227 2852 struct bfd_strtab_hash *debug_strtab; 3228 2853 bfd_byte *debug_contents = NULL; 2854 bfd_size_type amt; 3229 2855 3230 2856 if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour) 3231 2857 { 3232 for (i = 0; i < 6; i++)2858 for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++) 3233 2859 special_sections[i] = NULL; 3234 return true;3235 } 3236 3237 ldinfo.failed = false;2860 return TRUE; 2861 } 2862 2863 ldinfo.failed = FALSE; 3238 2864 ldinfo.output_bfd = output_bfd; 3239 2865 ldinfo.info = info; … … 3251 2877 xcoff_hash_table (info)->textro = textro; 3252 2878 3253 if (entry == NULL) 3254 hentry = NULL; 3255 else 2879 hentry = NULL; 2880 if (entry != NULL) 3256 2881 { 3257 2882 hentry = xcoff_link_hash_lookup (xcoff_hash_table (info), entry, 3258 false, false, true);2883 FALSE, FALSE, TRUE); 3259 2884 if (hentry != NULL) 3260 2885 hentry->flags |= XCOFF_ENTRY; 2886 } 2887 2888 /* __rtinit */ 2889 if (info->init_function || info->fini_function || rtld) 2890 { 2891 struct xcoff_link_hash_entry *hsym; 2892 struct internal_ldsym *ldsym; 2893 2894 hsym = xcoff_link_hash_lookup (xcoff_hash_table (info), 2895 "__rtinit", FALSE, FALSE, TRUE); 2896 if (hsym == NULL) 2897 { 2898 (*_bfd_error_handler) 2899 (_("error: undefined symbol __rtinit")); 2900 return FALSE; 2901 } 2902 2903 xcoff_mark_symbol (info, hsym); 2904 hsym->flags |= (XCOFF_DEF_REGULAR | XCOFF_RTINIT); 2905 2906 /* __rtinit initalized */ 2907 amt = sizeof (struct internal_ldsym); 2908 ldsym = (struct internal_ldsym *) bfd_malloc (amt); 2909 2910 ldsym->l_value = 0; /* will be filled in later */ 2911 ldsym->l_scnum = 2; /* data section */ 2912 ldsym->l_smtype = XTY_SD; /* csect section definition */ 2913 ldsym->l_smclas = 5; /* .rw */ 2914 ldsym->l_ifile = 0; /* special system loader symbol */ 2915 ldsym->l_parm = 0; /* NA */ 2916 2917 /* Force __rtinit to be the first symbol in the loader symbol table 2918 See xcoff_build_ldsyms 2919 2920 The first 3 symbol table indices are reserved to indicate the data, 2921 text and bss sections. */ 2922 BFD_ASSERT (0 == ldinfo.ldsym_count); 2923 2924 hsym->ldindx = 3; 2925 ldinfo.ldsym_count = 1; 2926 hsym->ldsym = ldsym; 2927 2928 if (! bfd_xcoff_put_ldsymbol_name (ldinfo.output_bfd, &ldinfo, 2929 hsym->ldsym, hsym->root.root.string)) 2930 return FALSE; 2931 2932 /* This symbol is written out by xcoff_write_global_symbol 2933 Set stuff up so xcoff_write_global_symbol logic works. */ 2934 hsym->flags |= XCOFF_DEF_REGULAR | XCOFF_MARK; 2935 hsym->root.type = bfd_link_hash_defined; 2936 hsym->root.u.def.value = 0; 3261 2937 } 3262 2938 … … 3268 2944 && hentry->root.type != bfd_link_hash_defweak)) 3269 2945 { 3270 gc = false;3271 xcoff_hash_table (info)->gc = false;2946 gc = FALSE; 2947 xcoff_hash_table (info)->gc = FALSE; 3272 2948 3273 2949 /* We still need to call xcoff_mark, in order to set ldrel_count 3274 2950 correctly. */ 3275 2951 for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) 3276 2952 { … … 3292 2968 goto error_return; 3293 2969 xcoff_sweep (info); 3294 xcoff_hash_table (info)->gc = true;2970 xcoff_hash_table (info)->gc = TRUE; 3295 2971 } 3296 2972 3297 2973 /* Return special sections to the caller. */ 3298 for (i = 0; i < 6; i++) 3299 { 3300 asection *sec; 3301 2974 for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++) 2975 { 3302 2976 sec = xcoff_hash_table (info)->special_sections[i]; 2977 3303 2978 if (sec != NULL 3304 2979 && gc 3305 2980 && (sec->flags & SEC_MARK) == 0) 3306 sec = NULL; 2981 { 2982 sec = NULL; 2983 } 3307 2984 special_sections[i] = sec; 3308 2985 } … … 3311 2988 { 3312 2989 /* I'm not sure what to do in this bizarre case. */ 3313 return true;2990 return TRUE; 3314 2991 } 3315 2992 … … 3338 3015 /* Set up the .loader section header. */ 3339 3016 ldhdr = &xcoff_hash_table (info)->ldhdr; 3340 ldhdr->l_version = 1;3017 ldhdr->l_version = bfd_xcoff_ldhdr_version(output_bfd); 3341 3018 ldhdr->l_nsyms = ldinfo.ldsym_count; 3342 3019 ldhdr->l_nreloc = xcoff_hash_table (info)->ldrel_count; 3343 3020 ldhdr->l_istlen = impsize; 3344 3021 ldhdr->l_nimpid = impcount; 3345 ldhdr->l_impoff = ( LDHDRSZ3346 + ldhdr->l_nsyms * LDSYMSZ3347 + ldhdr->l_nreloc * LDRELSZ);3022 ldhdr->l_impoff = (bfd_xcoff_ldhdrsz(output_bfd) 3023 + ldhdr->l_nsyms * bfd_xcoff_ldsymsz(output_bfd) 3024 + ldhdr->l_nreloc * bfd_xcoff_ldrelsz(output_bfd)); 3348 3025 ldhdr->l_stlen = ldinfo.string_size; 3349 3026 stoff = ldhdr->l_impoff + impsize; … … 3352 3029 else 3353 3030 ldhdr->l_stoff = stoff; 3031 3032 /* 64 bit elements to ldhdr 3033 The swap out routine for 32 bit will ignore them. 3034 Nothing fancy, symbols come after the header and relocs come 3035 after symbols. */ 3036 ldhdr->l_symoff = bfd_xcoff_ldhdrsz (output_bfd); 3037 ldhdr->l_rldoff = (bfd_xcoff_ldhdrsz (output_bfd) 3038 + ldhdr->l_nsyms * bfd_xcoff_ldsymsz (output_bfd)); 3354 3039 3355 3040 /* We now know the final size of the .loader section. Allocate … … 3362 3047 3363 3048 /* Set up the header. */ 3364 xcoff_swap_ldhdr_out (output_bfd, ldhdr, 3365 (struct external_ldhdr *) lsec->contents); 3049 bfd_xcoff_swap_ldhdr_out (output_bfd, ldhdr, lsec->contents); 3366 3050 3367 3051 /* Set up the import file names. */ … … 3402 3086 xcoff_write_global_symbol. The .loader relocs are written out 3403 3087 when the corresponding normal relocs are handled in 3404 xcoff_link_input_bfd. */ 3088 xcoff_link_input_bfd. 3089 */ 3405 3090 3406 3091 /* Allocate space for the magic sections. */ … … 3478 3163 csectpp = xcoff_data (sub)->csects; 3479 3164 3480 symesz = bfd_coff_symesz (sub); 3481 esym = (bfd_byte *) obj_coff_external_syms (sub); 3482 esymend = esym + symcount * symesz; 3483 while (esym < esymend) 3484 { 3485 struct internal_syment sym; 3486 3487 bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym); 3488 3489 *debug_index = (unsigned long) -1; 3490 3491 if (sym._n._n_n._n_zeroes == 0 3492 && *csectpp != NULL 3493 && (! gc 3494 || ((*csectpp)->flags & SEC_MARK) != 0 3495 || *csectpp == bfd_abs_section_ptr) 3496 && bfd_coff_symname_in_debug (sub, &sym)) 3497 { 3498 char *name; 3499 bfd_size_type indx; 3500 3501 name = (char *) debug_contents + sym._n._n_n._n_offset; 3502 indx = _bfd_stringtab_add (debug_strtab, name, true, true); 3503 if (indx == (bfd_size_type) -1) 3504 goto error_return; 3505 *debug_index = indx; 3506 } 3507 3508 esym += (sym.n_numaux + 1) * symesz; 3509 csectpp += sym.n_numaux + 1; 3510 debug_index += sym.n_numaux + 1; 3165 /* Dynamic object do not have csectpp's. */ 3166 if (NULL != csectpp) 3167 { 3168 symesz = bfd_coff_symesz (sub); 3169 esym = (bfd_byte *) obj_coff_external_syms (sub); 3170 esymend = esym + symcount * symesz; 3171 3172 while (esym < esymend) 3173 { 3174 struct internal_syment sym; 3175 3176 bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym); 3177 3178 *debug_index = (unsigned long) -1; 3179 3180 if (sym._n._n_n._n_zeroes == 0 3181 && *csectpp != NULL 3182 && (! gc 3183 || ((*csectpp)->flags & SEC_MARK) != 0 3184 || *csectpp == bfd_abs_section_ptr) 3185 && bfd_coff_symname_in_debug (sub, &sym)) 3186 { 3187 char *name; 3188 bfd_size_type indx; 3189 3190 name = (char *) debug_contents + sym._n._n_n._n_offset; 3191 indx = _bfd_stringtab_add (debug_strtab, name, TRUE, TRUE); 3192 if (indx == (bfd_size_type) -1) 3193 goto error_return; 3194 *debug_index = indx; 3195 } 3196 3197 esym += (sym.n_numaux + 1) * symesz; 3198 csectpp += sym.n_numaux + 1; 3199 debug_index += sym.n_numaux + 1; 3200 } 3511 3201 } 3512 3202 … … 3529 3219 _bfd_stringtab_size (debug_strtab); 3530 3220 3531 return true;3221 return TRUE; 3532 3222 3533 3223 error_return: … … 3536 3226 if (debug_contents != NULL) 3537 3227 free (debug_contents); 3538 return false;3228 return FALSE; 3539 3229 } 3540 3230 3231 bfd_boolean 3232 bfd_xcoff_link_generate_rtinit (abfd, init, fini, rtld) 3233 bfd *abfd; 3234 const char *init; 3235 const char *fini; 3236 bfd_boolean rtld; 3237 { 3238 struct bfd_in_memory *bim; 3239 3240 bim = ((struct bfd_in_memory *) 3241 bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory))); 3242 if (bim == NULL) 3243 return FALSE; 3244 3245 bim->size = 0; 3246 bim->buffer = 0; 3247 3248 abfd->link_next = 0; 3249 abfd->format = bfd_object; 3250 abfd->iostream = (PTR) bim; 3251 abfd->flags = BFD_IN_MEMORY; 3252 abfd->direction = write_direction; 3253 abfd->where = 0; 3254 3255 if (! bfd_xcoff_generate_rtinit (abfd, init, fini, rtld)) 3256 return FALSE; 3257 3258 /* need to reset to unknown or it will not be read back in correctly */ 3259 abfd->format = bfd_unknown; 3260 abfd->direction = read_direction; 3261 abfd->where = 0; 3262 3263 return TRUE; 3264 } 3265 3266 3541 3267 /* Add a symbol to the .loader symbols, if necessary. */ 3542 3268 3543 static b oolean3269 static bfd_boolean 3544 3270 xcoff_build_ldsyms (h, p) 3545 3271 struct xcoff_link_hash_entry *h; … … 3547 3273 { 3548 3274 struct xcoff_loader_info *ldinfo = (struct xcoff_loader_info *) p; 3549 size_t len; 3275 bfd_size_type amt; 3276 3277 if (h->root.type == bfd_link_hash_warning) 3278 h = (struct xcoff_link_hash_entry *) h->root.u.i.link; 3279 3280 /* __rtinit, this symbol has special handling. */ 3281 if (h->flags & XCOFF_RTINIT) 3282 return TRUE; 3550 3283 3551 3284 /* If this is a final link, and the symbol was defined as a common … … 3569 3302 && h->root.root.string[0] != '.') 3570 3303 { 3571 b oolean export;3304 bfd_boolean export; 3572 3305 3573 3306 /* We don't export a symbol which is being defined by an object … … 3585 3318 a different approach. Note that the symbols can, of course, 3586 3319 be exported explicitly. */ 3587 export = true;3320 export = TRUE; 3588 3321 if ((h->root.type == bfd_link_hash_defined 3589 3322 || h->root.type == bfd_link_hash_defweak) … … 3599 3332 if ((member->flags & DYNAMIC) != 0) 3600 3333 { 3601 export = false;3334 export = FALSE; 3602 3335 break; 3603 3336 } … … 3645 3378 h->smclas = XMC_GL; 3646 3379 h->flags |= XCOFF_DEF_REGULAR; 3647 sec->_raw_size += XCOFF_GLINK_SIZE;3380 sec->_raw_size += bfd_xcoff_glink_code_size(ldinfo->output_bfd); 3648 3381 3649 3382 /* The global linkage code requires a TOC entry for the 3650 3383 descriptor. */ 3651 3384 hds = h->descriptor; 3652 3385 BFD_ASSERT ((hds->root.type == bfd_link_hash_undefined … … 3656 3389 if (hds->toc_section == NULL) 3657 3390 { 3391 int byte_size; 3392 3393 /* 32 vs 64 3394 xcoff32 uses 4 bytes in the toc. 3395 xcoff64 uses 8 bytes in the toc. */ 3396 if (bfd_xcoff_is_xcoff64 (ldinfo->output_bfd)) 3397 byte_size = 8; 3398 else if (bfd_xcoff_is_xcoff32 (ldinfo->output_bfd)) 3399 byte_size = 4; 3400 else 3401 return FALSE; 3402 3658 3403 hds->toc_section = xcoff_hash_table (ldinfo->info)->toc_section; 3659 3404 hds->u.toc_offset = hds->toc_section->_raw_size; 3660 hds->toc_section->_raw_size += 4;3405 hds->toc_section->_raw_size += byte_size; 3661 3406 ++xcoff_hash_table (ldinfo->info)->ldrel_count; 3662 3407 ++hds->toc_section->reloc_count; … … 3665 3410 3666 3411 /* We need to call xcoff_build_ldsyms recursively here, 3667 3412 because we may already have passed hds on the traversal. */ 3668 3413 xcoff_build_ldsyms (hds, p); 3669 3414 } … … 3686 3431 3687 3432 /* This is an undefined function descriptor associated with 3688 3689 3690 3691 3433 a defined entry point. We can build up a function 3434 descriptor ourselves. Believe it or not, the AIX linker 3435 actually does this, and there are cases where we need to 3436 do it as well. */ 3692 3437 sec = xcoff_hash_table (ldinfo->info)->descriptor_section; 3693 3438 h->root.type = bfd_link_hash_defined; … … 3696 3441 h->smclas = XMC_DS; 3697 3442 h->flags |= XCOFF_DEF_REGULAR; 3698 sec->_raw_size += 12; 3443 3444 /* The size of the function descriptor depends if this is an 3445 xcoff32 (12) or xcoff64 (24). */ 3446 sec->_raw_size += 3447 bfd_xcoff_function_descriptor_size(ldinfo->output_bfd); 3699 3448 3700 3449 /* A function descriptor uses two relocs: one for the 3701 3450 associated code, and one for the TOC address. */ 3702 3451 xcoff_hash_table (ldinfo->info)->ldrel_count += 2; 3703 3452 sec->reloc_count += 2; 3704 3453 3705 3454 /* We handle writing out the contents of the descriptor in 3706 3455 xcoff_write_global_symbol. */ 3707 3456 } 3708 3457 else … … 3712 3461 h->root.root.string); 3713 3462 h->ldsym = NULL; 3714 return true;3463 return TRUE; 3715 3464 } 3716 3465 } … … 3741 3490 { 3742 3491 h->ldsym = NULL; 3743 return true;3492 return TRUE; 3744 3493 } 3745 3494 … … 3750 3499 { 3751 3500 h->ldsym = NULL; 3752 return true;3501 return TRUE; 3753 3502 } 3754 3503 … … 3756 3505 call above. */ 3757 3506 if ((h->flags & XCOFF_BUILT_LDSYM) != 0) 3758 return true;3507 return TRUE; 3759 3508 3760 3509 /* We need to add this symbol to the .loader symbols. */ 3761 3510 3762 3511 BFD_ASSERT (h->ldsym == NULL); 3763 h->ldsym = ((struct internal_ldsym *) 3764 bfd_zalloc (ldinfo->output_bfd, 3765 sizeof (struct internal_ldsym))); 3512 amt = sizeof (struct internal_ldsym); 3513 h->ldsym = (struct internal_ldsym *) bfd_zalloc (ldinfo->output_bfd, amt); 3766 3514 if (h->ldsym == NULL) 3767 3515 { 3768 ldinfo->failed = true;3769 return false;3516 ldinfo->failed = TRUE; 3517 return FALSE; 3770 3518 } 3771 3519 … … 3774 3522 3775 3523 /* The first 3 symbol table indices are reserved to indicate the 3776 sections. */3524 data, text and bss sections. */ 3777 3525 h->ldindx = ldinfo->ldsym_count + 3; 3778 3526 3779 3527 ++ldinfo->ldsym_count; 3780 3528 3781 len = strlen (h->root.root.string); 3782 if (len <= SYMNMLEN) 3783 strncpy (h->ldsym->_l._l_name, h->root.root.string, SYMNMLEN); 3784 else 3785 { 3786 if (ldinfo->string_size + len + 3 > ldinfo->string_alc) 3787 { 3788 size_t newalc; 3789 bfd_byte *newstrings; 3790 3791 newalc = ldinfo->string_alc * 2; 3792 if (newalc == 0) 3793 newalc = 32; 3794 while (ldinfo->string_size + len + 3 > newalc) 3795 newalc *= 2; 3796 3797 newstrings = ((bfd_byte *) 3798 bfd_realloc ((PTR) ldinfo->strings, newalc)); 3799 if (newstrings == NULL) 3800 { 3801 ldinfo->failed = true; 3802 return false; 3803 } 3804 ldinfo->string_alc = newalc; 3805 ldinfo->strings = newstrings; 3806 } 3807 3808 bfd_put_16 (ldinfo->output_bfd, len + 1, 3809 ldinfo->strings + ldinfo->string_size); 3810 strcpy (ldinfo->strings + ldinfo->string_size + 2, h->root.root.string); 3811 h->ldsym->_l._l_l._l_zeroes = 0; 3812 h->ldsym->_l._l_l._l_offset = ldinfo->string_size + 2; 3813 ldinfo->string_size += len + 3; 3529 if (! bfd_xcoff_put_ldsymbol_name (ldinfo->output_bfd, ldinfo, 3530 h->ldsym, h->root.root.string)) 3531 { 3532 return FALSE; 3814 3533 } 3815 3534 3816 3535 h->flags |= XCOFF_BUILT_LDSYM; 3817 3536 3818 return true;3537 return TRUE; 3819 3538 } 3820 3539 … … 3822 3541 /* Do the final link step. */ 3823 3542 3824 b oolean3543 bfd_boolean 3825 3544 _bfd_xcoff_bfd_final_link (abfd, info) 3826 3545 bfd *abfd; … … 3831 3550 asection *o; 3832 3551 struct bfd_link_order *p; 3833 size_tmax_contents_size;3834 size_tmax_sym_count;3835 size_tmax_lineno_count;3836 size_tmax_reloc_count;3837 size_tmax_output_reloc_count;3552 bfd_size_type max_contents_size; 3553 bfd_size_type max_sym_count; 3554 bfd_size_type max_lineno_count; 3555 bfd_size_type max_reloc_count; 3556 bfd_size_type max_output_reloc_count; 3838 3557 file_ptr rel_filepos; 3839 3558 unsigned int relsz; … … 3843 3562 bfd_byte *external_relocs = NULL; 3844 3563 char strbuf[STRING_SIZE_SIZE]; 3564 file_ptr pos; 3565 bfd_size_type amt; 3845 3566 3846 3567 if (info->shared) … … 3862 3583 finfo.external_relocs = NULL; 3863 3584 3864 finfo.ldsym = ((struct external_ldsym *) 3865 (xcoff_hash_table (info)->loader_section->contents 3866 + LDHDRSZ)); 3867 finfo.ldrel = ((struct external_ldrel *) 3868 (xcoff_hash_table (info)->loader_section->contents 3869 + LDHDRSZ 3870 + xcoff_hash_table (info)->ldhdr.l_nsyms * LDSYMSZ)); 3585 finfo.ldsym = (xcoff_hash_table (info)->loader_section->contents 3586 + bfd_xcoff_ldhdrsz (abfd)); 3587 finfo.ldrel = (xcoff_hash_table (info)->loader_section->contents 3588 + bfd_xcoff_ldhdrsz(abfd) 3589 + (xcoff_hash_table (info)->ldhdr.l_nsyms 3590 * bfd_xcoff_ldsymsz(abfd))); 3871 3591 3872 3592 xcoff_data (abfd)->coff.link_info = info; … … 3897 3617 to do this so that we can identify any sections which 3898 3618 the linker has decided to not include. */ 3899 sec->linker_mark = true;3619 sec->linker_mark = TRUE; 3900 3620 3901 3621 if (info->strip == strip_none … … 3937 3657 if (file_align != 0) 3938 3658 { 3939 b oolean saw_contents;3659 bfd_boolean saw_contents; 3940 3660 int indx; 3941 3661 asection **op; … … 3943 3663 3944 3664 /* Insert .pad sections before every section which has 3945 3946 3947 saw_contents = true;3665 contents and is loaded, if it is preceded by some other 3666 section which has contents and is loaded. */ 3667 saw_contents = TRUE; 3948 3668 for (op = &abfd->sections; *op != NULL; op = &(*op)->next) 3949 3669 { 3950 3670 if (strcmp ((*op)->name, ".pad") == 0) 3951 saw_contents = false;3671 saw_contents = FALSE; 3952 3672 else if (((*op)->flags & SEC_HAS_CONTENTS) != 0 3953 3673 && ((*op)->flags & SEC_LOAD) != 0) 3954 3674 { 3955 3675 if (! saw_contents) 3956 saw_contents = true;3676 saw_contents = TRUE; 3957 3677 else 3958 3678 { 3959 asection *n, *hold; 3960 3961 hold = *op; 3962 *op = NULL; 3679 asection *n, **st; 3680 3681 /* Create a pad section and place it before the section 3682 that needs padding. This requires unlinking and 3683 relinking the bfd's section list. */ 3684 3685 st = abfd->section_tail; 3963 3686 n = bfd_make_section_anyway (abfd, ".pad"); 3964 BFD_ASSERT (*op == n);3965 n->next = hold;3966 3687 n->flags = SEC_HAS_CONTENTS; 3967 3688 n->alignment_power = 0; 3968 saw_contents = false; 3689 3690 BFD_ASSERT (*st == n); 3691 bfd_section_list_remove (abfd, st); 3692 bfd_section_list_insert (abfd, op, n); 3693 3694 op = &n->next; 3695 saw_contents = FALSE; 3969 3696 } 3970 3697 } … … 3972 3699 3973 3700 /* Reset the section indices after inserting the new 3974 3701 sections. */ 3975 3702 indx = 0; 3976 3703 for (o = abfd->sections; o != NULL; o = o->next) … … 3982 3709 3983 3710 /* Work out appropriate sizes for the .pad sections to force 3984 3985 3986 3711 each section to land on a page boundary. This bit of 3712 code knows what compute_section_file_positions is going 3713 to do. */ 3987 3714 sofar = bfd_coff_filhsz (abfd); 3988 3715 sofar += bfd_coff_aoutsz (abfd); 3989 3716 sofar += abfd->section_count * bfd_coff_scnhsz (abfd); 3990 3717 for (o = abfd->sections; o != NULL; o = o->next) 3991 if (o->reloc_count >= 0xffff || o->lineno_count >= 0xffff) 3718 if ((bfd_xcoff_is_reloc_count_overflow 3719 (abfd, (bfd_vma) o->reloc_count)) 3720 || (bfd_xcoff_is_lineno_count_overflow 3721 (abfd, (bfd_vma) o->lineno_count))) 3722 /* 64 does not overflow, need to check if 32 does */ 3992 3723 sofar += bfd_coff_scnhsz (abfd); 3993 3724 … … 4026 3757 /* We use section_count + 1, rather than section_count, because 4027 3758 the target_index fields are 1 based. */ 4028 finfo.section_info = 4029 ((struct xcoff_link_section_info *) 4030 bfd_malloc ((abfd->section_count + 1) 4031 * sizeof (struct xcoff_link_section_info))); 3759 amt = abfd->section_count + 1; 3760 amt *= sizeof (struct xcoff_link_section_info); 3761 finfo.section_info = (struct xcoff_link_section_info *) bfd_malloc (amt); 4032 3762 if (finfo.section_info == NULL) 4033 3763 goto error_return; … … 4051 3781 { 4052 3782 /* A stripped file has no relocs. However, we still 4053 4054 3783 allocate the buffers, so that later code doesn't have to 3784 worry about whether we are stripping or not. */ 4055 3785 if (info->strip == strip_all) 4056 3786 o->rel_filepos = 0; … … 4063 3793 4064 3794 /* We don't know the indices of global symbols until we have 4065 4066 4067 4068 4069 4070 4071 3795 written out all the local symbols. For each section in 3796 the output file, we keep an array of pointers to hash 3797 table entries. Each entry in the array corresponds to a 3798 reloc. When we find a reloc against a global symbol, we 3799 set the corresponding entry in this array so that we can 3800 fix up the symbol index after we have written out all the 3801 local symbols. 4072 3802 4073 3803 Because of this problem, we also keep the relocs in … … 4075 3805 We could backpatch the file later, I suppose, although it 4076 3806 would be slow. */ 3807 amt = o->reloc_count; 3808 amt *= sizeof (struct internal_reloc); 4077 3809 finfo.section_info[o->target_index].relocs = 4078 ((struct internal_reloc *) 4079 bfd_malloc (o->reloc_count * sizeof (struct internal_reloc))); 3810 (struct internal_reloc *) bfd_malloc (amt); 3811 3812 amt = o->reloc_count; 3813 amt *= sizeof (struct xcoff_link_hash_entry *); 4080 3814 finfo.section_info[o->target_index].rel_hashes = 4081 ((struct xcoff_link_hash_entry **) 4082 bfd_malloc (o->reloc_count 4083 * sizeof (struct xcoff_link_hash_entry *))); 3815 (struct xcoff_link_hash_entry **) bfd_malloc (amt); 3816 4084 3817 if (finfo.section_info[o->target_index].relocs == NULL 4085 3818 || finfo.section_info[o->target_index].rel_hashes == NULL) … … 4121 3854 for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) 4122 3855 { 4123 size_tsz;4124 4125 sub->output_has_begun = false;3856 bfd_size_type sz; 3857 3858 sub->output_has_begun = FALSE; 4126 3859 sz = obj_raw_syment_count (sub); 4127 3860 if (sz > max_sym_count) … … 4130 3863 4131 3864 /* Allocate some buffers used while linking. */ 4132 finfo.internal_syms = ((struct internal_syment *) 4133 bfd_malloc (max_sym_count 4134 * sizeof (struct internal_syment))); 4135 finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long)); 4136 finfo.outsyms = ((bfd_byte *) 4137 bfd_malloc ((size_t) ((max_sym_count + 1) * symesz))); 4138 finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count 4139 * bfd_coff_linesz (abfd)); 4140 finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size); 4141 finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz); 3865 amt = max_sym_count * sizeof (struct internal_syment); 3866 finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt); 3867 3868 amt = max_sym_count * sizeof (long); 3869 finfo.sym_indices = (long *) bfd_malloc (amt); 3870 3871 amt = (max_sym_count + 1) * symesz; 3872 finfo.outsyms = (bfd_byte *) bfd_malloc (amt); 3873 3874 amt = max_lineno_count * bfd_coff_linesz (abfd); 3875 finfo.linenos = (bfd_byte *) bfd_malloc (amt); 3876 3877 amt = max_contents_size; 3878 finfo.contents = (bfd_byte *) bfd_malloc (amt); 3879 3880 amt = max_reloc_count * relsz; 3881 finfo.external_relocs = (bfd_byte *) bfd_malloc (amt); 3882 4142 3883 if ((finfo.internal_syms == NULL && max_sym_count > 0) 4143 3884 || (finfo.sym_indices == NULL && max_sym_count > 0) … … 4168 3909 if (! xcoff_link_input_bfd (&finfo, sub)) 4169 3910 goto error_return; 4170 sub->output_has_begun = true;3911 sub->output_has_begun = TRUE; 4171 3912 } 4172 3913 } … … 4184 3925 } 4185 3926 } 3927 4186 3928 4187 3929 /* Free up the buffers used by xcoff_link_input_bfd. */ … … 4217 3959 if (finfo.last_file_index != -1) 4218 3960 { 4219 finfo.last_file.n_value = - 1;3961 finfo.last_file.n_value = -(bfd_vma) 1; 4220 3962 bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file, 4221 3963 (PTR) finfo.outsyms); 4222 if (bfd_seek (abfd, 4223 (obj_sym_filepos (abfd) 4224 + finfo.last_file_index * symesz), 4225 SEEK_SET) != 0 4226 || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz) 3964 pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz; 3965 if (bfd_seek (abfd, pos, SEEK_SET) != 0 3966 || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz) 4227 3967 goto error_return; 4228 3968 } … … 4243 3983 symbol indices to use for relocs against them, and we can finally 4244 3984 write out the relocs. */ 4245 external_relocs = (bfd_byte *) bfd_malloc (max_output_reloc_count * relsz); 3985 amt = max_output_reloc_count * relsz; 3986 external_relocs = (bfd_byte *) bfd_malloc (amt); 4246 3987 if (external_relocs == NULL && max_output_reloc_count != 0) 4247 3988 goto error_return; … … 4254 3995 struct xcoff_toc_rel_hash *toc_rel_hash; 4255 3996 bfd_byte *erel; 3997 bfd_size_type rel_size; 4256 3998 4257 3999 /* A stripped file has no relocs. */ … … 4300 4042 4301 4043 /* XCOFF requires that the relocs be sorted by address. We tend 4302 4303 4304 4305 4044 to produce them in the order in which their containing csects 4045 appear in the symbol table, which is not necessarily by 4046 address. So we sort them here. There may be a better way to 4047 do this. */ 4306 4048 qsort ((PTR) finfo.section_info[o->target_index].relocs, 4307 4049 o->reloc_count, sizeof (struct internal_reloc), … … 4314 4056 bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel); 4315 4057 4058 rel_size = relsz * o->reloc_count; 4316 4059 if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0 4317 || bfd_write ((PTR) external_relocs, relsz, o->reloc_count, 4318 abfd) != relsz * o->reloc_count) 4060 || bfd_bwrite ((PTR) external_relocs, rel_size, abfd) != rel_size) 4319 4061 goto error_return; 4320 4062 } … … 4347 4089 + xcoff_hash_table (info)->ldhdr.l_impoff)); 4348 4090 o = xcoff_hash_table (info)->loader_section; 4349 if (! bfd_set_section_contents (abfd, o->output_section, 4350 o->contents, o->output_offset, 4351 o->_raw_size)) 4091 if (! bfd_set_section_contents (abfd, o->output_section, o->contents, 4092 (file_ptr) o->output_offset, o->_raw_size)) 4352 4093 goto error_return; 4353 4094 … … 4356 4097 if (o->_raw_size > 0 4357 4098 && ! bfd_set_section_contents (abfd, o->output_section, o->contents, 4358 o->output_offset, o->_raw_size)) 4099 (file_ptr) o->output_offset, 4100 o->_raw_size)) 4359 4101 goto error_return; 4360 4102 o = xcoff_hash_table (info)->toc_section; 4361 4103 if (o->_raw_size > 0 4362 4104 && ! bfd_set_section_contents (abfd, o->output_section, o->contents, 4363 o->output_offset, o->_raw_size)) 4105 (file_ptr) o->output_offset, 4106 o->_raw_size)) 4364 4107 goto error_return; 4365 4108 o = xcoff_hash_table (info)->descriptor_section; 4366 4109 if (o->_raw_size > 0 4367 4110 && ! bfd_set_section_contents (abfd, o->output_section, o->contents, 4368 o->output_offset, o->_raw_size)) 4111 (file_ptr) o->output_offset, 4112 o->_raw_size)) 4369 4113 goto error_return; 4370 4114 4371 4115 /* Write out the string table. */ 4372 if (bfd_seek (abfd, 4373 (obj_sym_filepos (abfd) 4374 + obj_raw_syment_count (abfd) * symesz), 4375 SEEK_SET) != 0) 4116 pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd) * symesz; 4117 if (bfd_seek (abfd, pos, SEEK_SET) != 0) 4376 4118 goto error_return; 4377 bfd_h_put_32 (abfd, 4378 _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE, 4379 (bfd_byte *) strbuf); 4380 if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE) 4119 H_PUT_32 (abfd, 4120 _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE, 4121 strbuf); 4122 amt = STRING_SIZE_SIZE; 4123 if (bfd_bwrite (strbuf, amt, abfd) != amt) 4381 4124 goto error_return; 4382 4125 if (! _bfd_stringtab_emit (abfd, finfo.strtab)) … … 4394 4137 BFD_ASSERT (o->output_section->_raw_size - o->output_offset 4395 4138 >= _bfd_stringtab_size (debug_strtab)); 4396 if (bfd_seek (abfd, 4397 o->output_section->filepos + o->output_offset, 4398 SEEK_SET) != 0) 4139 pos = o->output_section->filepos + o->output_offset; 4140 if (bfd_seek (abfd, pos, SEEK_SET) != 0) 4399 4141 goto error_return; 4400 4142 if (! _bfd_stringtab_emit (abfd, debug_strtab)) … … 4406 4148 bfd_get_symcount (abfd) = 0; 4407 4149 4408 return true;4150 return TRUE; 4409 4151 4410 4152 error_return: 4411 4153 if (finfo.strtab != NULL) 4412 4154 _bfd_stringtab_free (finfo.strtab); 4155 4413 4156 if (finfo.section_info != NULL) 4414 4157 { … … 4424 4167 free (finfo.section_info); 4425 4168 } 4169 4426 4170 if (finfo.internal_syms != NULL) 4427 4171 free (finfo.internal_syms); … … 4438 4182 if (external_relocs != NULL) 4439 4183 free (external_relocs); 4440 return false;4184 return FALSE; 4441 4185 } 4442 4186 … … 4444 4188 handles all the sections and relocations of the input file at once. */ 4445 4189 4446 static b oolean4190 static bfd_boolean 4447 4191 xcoff_link_input_bfd (finfo, input_bfd) 4448 4192 struct xcoff_final_link_info *finfo; … … 4454 4198 unsigned int n_tmask; 4455 4199 unsigned int n_btshft; 4456 b oolean copy, hash;4200 bfd_boolean copy, hash; 4457 4201 bfd_size_type isymesz; 4458 4202 bfd_size_type osymesz; … … 4469 4213 unsigned int incls; 4470 4214 asection *oline; 4471 b oolean keep_syms;4215 bfd_boolean keep_syms; 4472 4216 asection *o; 4473 4217 … … 4475 4219 if ((input_bfd->flags & DYNAMIC) != 0 4476 4220 && ! finfo->info->static_link) 4477 return true;4221 return TRUE; 4478 4222 4479 4223 /* Move all the symbols to the output file. */ … … 4494 4238 #define N_BTSHFT n_btshft 4495 4239 4496 copy = false;4240 copy = FALSE; 4497 4241 if (! finfo->info->keep_memory) 4498 copy = true;4499 hash = true;4242 copy = TRUE; 4243 hash = TRUE; 4500 4244 if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0) 4501 hash = false;4245 hash = FALSE; 4502 4246 4503 4247 if (! _bfd_coff_get_external_symbols (input_bfd)) 4504 return false;4248 return FALSE; 4505 4249 4506 4250 esym = (bfd_byte *) obj_coff_external_syms (input_bfd); … … 4518 4262 while (esym < esym_end) 4519 4263 { 4264 4520 4265 struct internal_syment isym; 4521 4266 union internal_auxent aux; 4522 4267 int smtyp = 0; 4523 b oolean skip;4524 b oolean require;4268 bfd_boolean skip; 4269 bfd_boolean require; 4525 4270 int add; 4526 4271 … … 4528 4273 4529 4274 /* If this is a C_EXT or C_HIDEXT symbol, we need the csect 4530 4275 information. */ 4531 4276 if (isymp->n_sclass == C_EXT || isymp->n_sclass == C_HIDEXT) 4532 4277 { … … 4537 4282 isymp->n_numaux - 1, isymp->n_numaux, 4538 4283 (PTR) &aux); 4284 4539 4285 smtyp = SMTYP_SMTYP (aux.x_csect.x_smtyp); 4540 4286 } … … 4547 4293 4548 4294 /* If this symbol is in the .loader section, swap out the 4549 4550 4551 4295 .loader symbol information. If this is an external symbol 4296 reference to a defined symbol, though, then wait until we get 4297 to the definition. */ 4552 4298 if (isym.n_sclass == C_EXT 4553 4299 && *sym_hash != NULL … … 4621 4367 4622 4368 BFD_ASSERT (h->ldindx >= 0); 4623 BFD_ASSERT (LDSYMSZ == sizeof (struct external_ldsym)); 4624 xcoff_swap_ldsym_out (finfo->output_bfd, ldsym, 4625 finfo->ldsym + h->ldindx - 3); 4369 bfd_xcoff_swap_ldsym_out (finfo->output_bfd, ldsym, 4370 (finfo->ldsym 4371 + ((h->ldindx - 3) 4372 * bfd_xcoff_ldsymsz (finfo->output_bfd)))); 4626 4373 h->ldsym = NULL; 4627 4374 … … 4630 4377 && (h->root.type == bfd_link_hash_defined 4631 4378 || h->root.type == bfd_link_hash_defweak)) 4632 xcoff_data (output_bfd)->snentry = 4633 h->root.u.def.section->output_section->target_index; 4379 { 4380 xcoff_data (output_bfd)->snentry = 4381 h->root.u.def.section->output_section->target_index; 4382 } 4634 4383 } 4635 4384 4636 4385 *indexp = -1; 4637 4386 4638 skip = false;4639 require = false;4387 skip = FALSE; 4388 require = FALSE; 4640 4389 add = 1 + isym.n_numaux; 4641 4390 4642 4391 /* If we are skipping this csect, we want to skip this symbol. */ 4643 4392 if (*csectpp == NULL) 4644 skip = true;4393 skip = TRUE; 4645 4394 4646 4395 /* If we garbage collected this csect, we want to skip this 4647 4396 symbol. */ 4648 4397 if (! skip 4649 4398 && xcoff_hash_table (finfo->info)->gc 4650 4399 && ((*csectpp)->flags & SEC_MARK) == 0 4651 4400 && *csectpp != bfd_abs_section_ptr) 4652 skip = true;4401 skip = TRUE; 4653 4402 4654 4403 /* An XCOFF linker always skips C_STAT symbols. */ 4655 4404 if (! skip 4656 4405 && isymp->n_sclass == C_STAT) 4657 skip = true;4406 skip = TRUE; 4658 4407 4659 4408 /* We skip all but the first TOC anchor. */ … … 4663 4412 { 4664 4413 if (finfo->toc_symindx != -1) 4665 skip = true;4414 skip = TRUE; 4666 4415 else 4667 4416 { … … 4675 4424 4676 4425 /* We want to find out if tocval is a good value to use 4677 4678 4679 4680 4681 4426 as the TOC anchor--that is, whether we can access all 4427 of the TOC using a 16 bit offset from tocval. This 4428 test assumes that the TOC comes at the end of the 4429 output section, as it does in the default linker 4430 script. */ 4682 4431 tocend = ((*csectpp)->output_section->vma 4683 4432 + (*csectpp)->output_section->_raw_size); … … 4686 4435 inp = inp->link_next) 4687 4436 { 4688 asection *o;4689 4437 4690 4438 for (o = inp->sections; o != NULL; o = o->next) … … 4707 4455 (unsigned long) (tocend - tocval)); 4708 4456 bfd_set_error (bfd_error_file_too_big); 4709 return false;4457 return FALSE; 4710 4458 } 4711 4459 … … 4723 4471 xcoff_data (finfo->output_bfd)->sntoc = 4724 4472 (*csectpp)->output_section->target_index; 4725 require = true; 4473 require = TRUE; 4474 4726 4475 } 4727 4476 } … … 4730 4479 if (! skip 4731 4480 && finfo->info->strip == strip_all) 4732 skip = true;4481 skip = TRUE; 4733 4482 4734 4483 /* We can skip resolved external references. */ … … 4737 4486 && smtyp == XTY_ER 4738 4487 && (*sym_hash)->root.type != bfd_link_hash_undefined) 4739 skip = true;4488 skip = TRUE; 4740 4489 4741 4490 /* We can skip common symbols if they got defined somewhere 4742 4491 else. */ 4743 4492 if (! skip 4744 4493 && isym.n_sclass == C_EXT … … 4748 4497 && ((*sym_hash)->root.type != bfd_link_hash_defined 4749 4498 || (*sym_hash)->root.u.def.section != *csectpp)) 4750 skip = true;4499 skip = TRUE; 4751 4500 4752 4501 /* Skip local symbols if we are discarding them. */ … … 4756 4505 && (isym.n_sclass != C_HIDEXT 4757 4506 || smtyp != XTY_SD)) 4758 skip = true;4507 skip = TRUE; 4759 4508 4760 4509 /* If we stripping debugging symbols, and this is a debugging 4761 4510 symbol, then skip it. */ 4762 4511 if (! skip 4763 4512 && finfo->info->strip == strip_debugger 4764 4513 && isym.n_scnum == N_DEBUG) 4765 skip = true;4514 skip = TRUE; 4766 4515 4767 4516 /* If some symbols are stripped based on the name, work out the … … 4779 4528 4780 4529 name = _bfd_coff_internal_syment_name (input_bfd, &isym, buf); 4530 4781 4531 if (name == NULL) 4782 return false;4532 return FALSE; 4783 4533 4784 4534 if ((finfo->info->strip == strip_some 4785 && (bfd_hash_lookup (finfo->info->keep_hash, name, false,4786 false) == NULL))4535 && (bfd_hash_lookup (finfo->info->keep_hash, name, FALSE, 4536 FALSE) == NULL)) 4787 4537 || (finfo->info->discard == discard_l 4788 4538 && (isym.n_sclass != C_EXT … … 4790 4540 || smtyp != XTY_SD)) 4791 4541 && bfd_is_local_label_name (input_bfd, name))) 4792 skip = true;4542 skip = TRUE; 4793 4543 } 4794 4544 … … 4797 4547 && require 4798 4548 && finfo->info->strip != strip_all) 4799 skip = false;4549 skip = FALSE; 4800 4550 4801 4551 /* We now know whether we are to skip this symbol or not. */ … … 4819 4569 name = _bfd_coff_internal_syment_name (input_bfd, &isym, 4820 4570 (char *) NULL); 4571 4821 4572 if (name == NULL) 4822 return false;4573 return FALSE; 4823 4574 indx = _bfd_stringtab_add (finfo->strtab, name, hash, copy); 4824 4575 if (indx == (bfd_size_type) -1) 4825 return false;4576 return FALSE; 4826 4577 isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx; 4827 4578 } … … 4847 4598 { 4848 4599 if (finfo->last_file_index != -1 4849 && finfo->last_file.n_value != ( long) output_index)4600 && finfo->last_file.n_value != (bfd_vma) output_index) 4850 4601 { 4851 4602 /* We must correct the value of the last C_FILE entry. */ … … 4866 4617 symbol. We need to write it out again. We 4867 4618 borrow *outsym temporarily. */ 4619 file_ptr pos; 4620 4868 4621 bfd_coff_swap_sym_out (output_bfd, 4869 4622 (PTR) &finfo->last_file, 4870 4623 (PTR) outsym); 4871 if (bfd_seek (output_bfd, 4872 (obj_sym_filepos (output_bfd)4873 + finfo->last_file_index * osymesz),4874 4875 || (bfd_ write (outsym, osymesz, 1, output_bfd)4624 4625 pos = obj_sym_filepos (output_bfd); 4626 pos += finfo->last_file_index * osymesz; 4627 if (bfd_seek (output_bfd, pos, SEEK_SET) != 0 4628 || (bfd_bwrite (outsym, osymesz, output_bfd) 4876 4629 != osymesz)) 4877 return false;4630 return FALSE; 4878 4631 } 4879 4632 } … … 4884 4637 4885 4638 /* The value of a C_BINCL or C_EINCL symbol is a file offset 4886 4887 4639 into the line numbers. We update the symbol values when 4640 we handle the line numbers. */ 4888 4641 if (isym.n_sclass == C_BINCL 4889 4642 || isym.n_sclass == C_EINCL) … … 4912 4665 4913 4666 /* If this is a symbol in the TOC which we may have merged 4914 4915 4667 (class XMC_TC), remember the symbol index of the TOC 4668 symbol. */ 4916 4669 if (isym.n_sclass == C_HIDEXT 4917 4670 && aux.x_csect.x_smclas == XMC_TC … … 4964 4717 { 4965 4718 struct internal_syment isym; 4966 unsigned long indx; 4719 4720 bfd_vma indx; 4967 4721 4968 4722 /* The value of a C_BSTAT symbol is the symbol table 4969 4723 index of the containing csect. */ 4970 4724 bfd_coff_swap_sym_in (output_bfd, (PTR) outsym, (PTR) &isym); 4971 4725 indx = isym.n_value; … … 5012 4766 strings = _bfd_coff_read_string_table (input_bfd); 5013 4767 if (strings == NULL) 5014 return false;4768 return FALSE; 5015 4769 } 5016 4770 filename = strings + aux.x_file.x_n.x_offset; … … 5018 4772 hash, copy); 5019 4773 if (indx == (bfd_size_type) -1) 5020 return false;4774 return FALSE; 5021 4775 aux.x_file.x_n.x_offset = STRING_SIZE_SIZE + indx; 5022 4776 } … … 5026 4780 && i + 1 == isymp->n_numaux) 5027 4781 { 4782 5028 4783 /* We don't support type checking. I don't know if 5029 4784 anybody does. */ 5030 4785 aux.x_csect.x_parmhash = 0; 5031 4786 /* I don't think anybody uses these fields, but we'd 5032 4787 better clobber them just in case. */ 5033 4788 aux.x_csect.x_stab = 0; 5034 4789 aux.x_csect.x_snstab = 0; 4790 5035 4791 if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_LD) 5036 4792 { … … 5044 4800 symindx = finfo->sym_indices[indx]; 5045 4801 if (symindx < 0) 5046 aux.x_sym.x_tagndx.l = 0; 4802 { 4803 aux.x_csect.x_scnlen.l = 0; 4804 } 5047 4805 else 5048 aux.x_sym.x_tagndx.l = symindx; 4806 { 4807 aux.x_csect.x_scnlen.l = symindx; 4808 } 5049 4809 } 5050 4810 } … … 5064 4824 { 5065 4825 /* We look forward through the symbol for 5066 5067 5068 4826 the index of the next symbol we are going 4827 to include. I don't know if this is 4828 entirely right. */ 5069 4829 while (finfo->sym_indices[indx] < 0 5070 4830 && indx < obj_raw_syment_count (input_bfd)) … … 5075 4835 indx = finfo->sym_indices[indx]; 5076 4836 aux.x_sym.x_fcnary.x_fcn.x_endndx.l = indx; 4837 5077 4838 } 5078 4839 } … … 5089 4850 aux.x_sym.x_tagndx.l = symindx; 5090 4851 } 4852 5091 4853 } 5092 4854 … … 5108 4870 asection *enclosing; 5109 4871 unsigned int enc_count; 5110 bfd_si ze_typelinoff;4872 bfd_signed_vma linoff; 5111 4873 struct internal_lineno lin; 5112 4874 … … 5116 4878 if (oline != enclosing) 5117 4879 { 5118 if (bfd_seek (input_bfd, 5119 enclosing->line_filepos, 5120 SEEK_SET) != 0 5121 || (bfd_read (finfo->linenos, linesz, 5122 enc_count, input_bfd) 5123 != linesz * enc_count)) 5124 return false; 4880 file_ptr pos = enclosing->line_filepos; 4881 bfd_size_type amt = linesz * enc_count; 4882 if (bfd_seek (input_bfd, pos, SEEK_SET) != 0 4883 || (bfd_bread (finfo->linenos, amt, input_bfd) 4884 != amt)) 4885 return FALSE; 5125 4886 oline = enclosing; 5126 4887 } … … 5179 4940 aux.x_sym.x_fcnary.x_fcn.x_lnnoptr, 5180 4941 SEEK_SET) != 0 5181 || (bfd_ write (finfo->linenos + linoff,5182 linesz ,count, output_bfd)4942 || (bfd_bwrite (finfo->linenos + linoff, 4943 linesz * count, output_bfd) 5183 4944 != linesz * count)) 5184 return false;4945 return FALSE; 5185 4946 5186 4947 o->output_section->lineno_count += count; … … 5194 4955 5195 4956 /* Update any C_BINCL or C_EINCL symbols 5196 5197 4957 that refer to a line number in the 4958 range we just output. */ 5198 4959 iisp = finfo->internal_syms; 5199 4960 iispend = (iisp … … 5207 4968 || iisp->n_sclass == C_EINCL) 5208 4969 && ((bfd_size_type) iisp->n_value 5209 >= enclosing->line_filepos + linoff)4970 >= (bfd_size_type)(enclosing->line_filepos + linoff)) 5210 4971 && ((bfd_size_type) iisp->n_value 5211 4972 < (enclosing->line_filepos … … 5269 5030 if (outsym > finfo->outsyms) 5270 5031 { 5271 if (bfd_seek (output_bfd, 5272 obj_sym_filepos (output_bfd) + syment_base * osymesz, 5273 SEEK_SET) != 0 5274 || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1, 5275 output_bfd) 5276 != (bfd_size_type) (outsym - finfo->outsyms))) 5277 return false; 5032 file_ptr pos = obj_sym_filepos (output_bfd) + syment_base * osymesz; 5033 bfd_size_type amt = outsym - finfo->outsyms; 5034 if (bfd_seek (output_bfd, pos, SEEK_SET) != 0 5035 || bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt) 5036 return FALSE; 5278 5037 5279 5038 BFD_ASSERT ((obj_raw_syment_count (output_bfd) … … 5286 5045 /* Don't let the linker relocation routines discard the symbols. */ 5287 5046 keep_syms = obj_coff_keep_syms (input_bfd); 5288 obj_coff_keep_syms (input_bfd) = true;5047 obj_coff_keep_syms (input_bfd) = TRUE; 5289 5048 5290 5049 /* Relocate the contents of each section. */ 5291 5050 for (o = input_bfd->sections; o != NULL; o = o->next) 5292 5051 { 5052 5293 5053 bfd_byte *contents; 5294 5054 … … 5305 5065 5306 5066 /* We have set filepos correctly for the sections we created to 5307 5067 represent csects, so bfd_get_section_contents should work. */ 5308 5068 if (coff_section_data (input_bfd, o) != NULL 5309 5069 && coff_section_data (input_bfd, o)->contents != NULL) 5310 5070 contents = coff_section_data (input_bfd, o)->contents; 5311 else 5312 { 5313 if (! bfd_get_section_contents (input_bfd, o, finfo->contents, 5314 (file_ptr) 0, o->_raw_size)) 5315 return false; 5316 contents = finfo->contents; 5317 } 5071 else { 5072 if (! bfd_get_section_contents (input_bfd, o, finfo->contents, 5073 (file_ptr) 0, o->_raw_size)) 5074 return FALSE; 5075 contents = finfo->contents; 5076 } 5318 5077 5319 5078 if ((o->flags & SEC_RELOC) != 0) … … 5330 5089 target_index = o->output_section->target_index; 5331 5090 internal_relocs = (xcoff_read_internal_relocs 5332 (input_bfd, o, false, finfo->external_relocs,5333 true,5091 (input_bfd, o, FALSE, finfo->external_relocs, 5092 TRUE, 5334 5093 (finfo->section_info[target_index].relocs 5335 5094 + o->output_section->reloc_count))); 5336 5095 if (internal_relocs == NULL) 5337 return false;5096 return FALSE; 5338 5097 5339 5098 /* Call processor specific code to relocate the section 5340 5099 contents. */ 5341 5100 if (! bfd_coff_relocate_section (output_bfd, finfo->info, 5342 5101 input_bfd, o, … … 5345 5104 finfo->internal_syms, 5346 5105 xcoff_data (input_bfd)->csects)) 5347 return false;5106 return FALSE; 5348 5107 5349 5108 offset = o->output_section->vma + o->output_offset - o->vma; … … 5356 5115 struct xcoff_link_hash_entry *h = NULL; 5357 5116 struct internal_ldrel ldrel; 5358 b oolean quiet;5117 bfd_boolean quiet; 5359 5118 5360 5119 *rel_hash = NULL; … … 5382 5141 { 5383 5142 /* This is a TOC relative reloc with a symbol 5384 5385 5386 5387 5143 attached. The symbol should be the one which 5144 this reloc is for. We want to make this 5145 reloc against the TOC address of the symbol, 5146 not the symbol itself. */ 5388 5147 BFD_ASSERT (h->toc_section != NULL); 5389 5148 BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0); … … 5394 5153 struct xcoff_toc_rel_hash *n; 5395 5154 struct xcoff_link_section_info *si; 5396 5155 bfd_size_type amt; 5156 5157 amt = sizeof (struct xcoff_toc_rel_hash); 5397 5158 n = ((struct xcoff_toc_rel_hash *) 5398 bfd_alloc (finfo->output_bfd, 5399 sizeof (struct xcoff_toc_rel_hash))); 5159 bfd_alloc (finfo->output_bfd, amt)); 5400 5160 if (n == NULL) 5401 return false;5161 return FALSE; 5402 5162 si = finfo->section_info + target_index; 5403 5163 n->next = si->toc_rel_hashes; … … 5464 5224 else 5465 5225 { 5226 5466 5227 struct internal_syment *is; 5228 5467 5229 const char *name; 5468 5230 char buf[SYMNMLEN + 1]; … … 5475 5237 name = (_bfd_coff_internal_syment_name 5476 5238 (input_bfd, is, buf)); 5239 5477 5240 if (name == NULL) 5478 return false;5241 return FALSE; 5479 5242 5480 5243 if (! ((*finfo->info->callbacks->unattached_reloc) 5481 5244 (finfo->info, name, input_bfd, o, 5482 5245 irel->r_vaddr))) 5483 return false;5246 return FALSE; 5484 5247 } 5485 5248 } 5486 5249 } 5487 5250 5488 quiet = false;5251 quiet = FALSE; 5489 5252 switch (irel->r_type) 5490 5253 { … … 5504 5267 ldrel.l_vaddr = irel->r_vaddr; 5505 5268 if (r_symndx == -1) 5506 ldrel.l_symndx = - 1;5269 ldrel.l_symndx = -(bfd_size_type ) 1; 5507 5270 else if (h == NULL 5508 5271 || (h->root.type == bfd_link_hash_defined … … 5530 5293 (*_bfd_error_handler) 5531 5294 (_("%s: loader reloc in unrecognized section `%s'"), 5532 bfd_ get_filename (input_bfd),5295 bfd_archive_filename (input_bfd), 5533 5296 sec->name); 5534 5297 bfd_set_error (bfd_error_nonrepresentable_section); 5535 return false;5298 return FALSE; 5536 5299 } 5537 5300 } … … 5546 5309 _bfd_ppc_xcoff_relocate_section. Don't 5547 5310 issue any more warnings. */ 5548 quiet = true;5311 quiet = TRUE; 5549 5312 } 5550 5313 if (h->ldindx < 0 && ! quiet) … … 5552 5315 (*_bfd_error_handler) 5553 5316 (_("%s: `%s' in loader reloc but not loader sym"), 5554 bfd_ get_filename (input_bfd),5317 bfd_archive_filename (input_bfd), 5555 5318 h->root.root.string); 5556 5319 bfd_set_error (bfd_error_bad_value); 5557 return false;5320 return FALSE; 5558 5321 } 5559 5322 ldrel.l_symndx = h->ldindx; … … 5567 5330 (*_bfd_error_handler) 5568 5331 (_("%s: loader reloc in read-only section %s"), 5569 bfd_ get_filename (input_bfd),5332 bfd_archive_filename (input_bfd), 5570 5333 bfd_get_section_name (finfo->output_bfd, 5571 5334 o->output_section)); 5572 5335 bfd_set_error (bfd_error_invalid_operation); 5573 return false;5336 return FALSE; 5574 5337 } 5575 xcoff_swap_ldrel_out (output_bfd, &ldrel,5576 finfo->ldrel);5577 BFD_ASSERT (sizeof (struct external_ldrel) == LDRELSZ); 5578 ++finfo->ldrel;5338 bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, 5339 finfo->ldrel); 5340 5341 finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd); 5579 5342 break; 5580 5343 … … 5595 5358 /* Write out the modified section contents. */ 5596 5359 if (! bfd_set_section_contents (output_bfd, o->output_section, 5597 contents, o->output_offset,5360 contents, (file_ptr) o->output_offset, 5598 5361 (o->_cooked_size != 0 5599 5362 ? o->_cooked_size 5600 5363 : o->_raw_size))) 5601 return false;5364 return FALSE; 5602 5365 } 5603 5366 … … 5607 5370 { 5608 5371 if (! _bfd_coff_free_symbols (input_bfd)) 5609 return false;5610 } 5611 5612 return true;5372 return FALSE; 5373 } 5374 5375 return TRUE; 5613 5376 } 5614 5377 … … 5618 5381 /* Write out a non-XCOFF global symbol. */ 5619 5382 5620 static boolean 5621 xcoff_write_global_symbol (h, p) 5383 5384 static bfd_boolean 5385 xcoff_write_global_symbol (h, inf) 5622 5386 struct xcoff_link_hash_entry *h; 5623 PTR p;5387 PTR inf; 5624 5388 { 5625 struct xcoff_final_link_info *finfo = (struct xcoff_final_link_info *) p;5389 struct xcoff_final_link_info *finfo = (struct xcoff_final_link_info *) inf; 5626 5390 bfd *output_bfd; 5627 5391 bfd_byte *outsym; 5628 5392 struct internal_syment isym; 5629 5393 union internal_auxent aux; 5394 bfd_boolean result; 5395 file_ptr pos; 5396 bfd_size_type amt; 5630 5397 5631 5398 output_bfd = finfo->output_bfd; 5632 5399 outsym = finfo->outsyms; 5400 5401 if (h->root.type == bfd_link_hash_warning) 5402 { 5403 h = (struct xcoff_link_hash_entry *) h->root.u.i.link; 5404 if (h->root.type == bfd_link_hash_new) 5405 return TRUE; 5406 } 5633 5407 5634 5408 /* If this symbol was garbage collected, just skip it. */ 5635 5409 if (xcoff_hash_table (finfo->info)->gc 5636 5410 && (h->flags & XCOFF_MARK) == 0) 5637 return true;5411 return TRUE; 5638 5412 5639 5413 /* If we need a .loader section entry, write it out. */ … … 5648 5422 || h->root.type == bfd_link_hash_undefweak) 5649 5423 { 5424 5650 5425 ldsym->l_value = 0; 5651 5426 ldsym->l_scnum = N_UNDEF; 5652 5427 ldsym->l_smtype = XTY_ER; 5653 5428 impbfd = h->root.u.undef.abfd; 5429 5654 5430 } 5655 5431 else if (h->root.type == bfd_link_hash_defined 5656 5432 || h->root.type == bfd_link_hash_defweak) 5657 5433 { 5434 5658 5435 asection *sec; 5659 5436 … … 5665 5442 ldsym->l_smtype = XTY_SD; 5666 5443 impbfd = sec->owner; 5444 5667 5445 } 5668 5446 else … … 5672 5450 && (h->flags & XCOFF_DEF_DYNAMIC) != 0) 5673 5451 || (h->flags & XCOFF_IMPORT) != 0) 5674 ldsym->l_smtype |= L_IMPORT; 5452 { 5453 /* Clear l_smtype 5454 Import symbols are defined so the check above will make 5455 the l_smtype XTY_SD. But this is not correct, it should 5456 be cleared. */ 5457 ldsym->l_smtype |= L_IMPORT; 5458 } 5459 5675 5460 if (((h->flags & XCOFF_DEF_REGULAR) != 0 5676 5461 && (h->flags & XCOFF_DEF_DYNAMIC) != 0) 5677 5462 || (h->flags & XCOFF_EXPORT) != 0) 5678 ldsym->l_smtype |= L_EXPORT; 5463 { 5464 ldsym->l_smtype |= L_EXPORT; 5465 } 5466 5679 5467 if ((h->flags & XCOFF_ENTRY) != 0) 5680 ldsym->l_smtype |= L_ENTRY; 5468 { 5469 ldsym->l_smtype |= L_ENTRY; 5470 } 5471 5472 if ((h->flags & XCOFF_RTINIT) != 0) 5473 { 5474 ldsym->l_smtype = XTY_SD; 5475 } 5681 5476 5682 5477 ldsym->l_smclas = h->smclas; 5683 5478 5684 if (ldsym->l_ifile == (bfd_size_type) -1) 5685 ldsym->l_ifile = 0; 5479 if (ldsym->l_smtype & L_IMPORT) 5480 { 5481 if ((h->root.type == bfd_link_hash_defined 5482 || h->root.type == bfd_link_hash_defweak) 5483 && (h->root.u.def.value != 0)) 5484 { 5485 ldsym->l_smclas = XMC_XO; 5486 } 5487 else if ((h->flags & (XCOFF_SYSCALL32 | XCOFF_SYSCALL64)) == 5488 (XCOFF_SYSCALL32 | XCOFF_SYSCALL64)) 5489 { 5490 ldsym->l_smclas = XMC_SV3264; 5491 } 5492 else if (h->flags & XCOFF_SYSCALL32) 5493 { 5494 ldsym->l_smclas = XMC_SV; 5495 } 5496 else if (h->flags & XCOFF_SYSCALL64) 5497 { 5498 ldsym->l_smclas = XMC_SV64; 5499 } 5500 } 5501 5502 if (ldsym->l_ifile == -(bfd_size_type) 1) 5503 { 5504 ldsym->l_ifile = 0; 5505 } 5686 5506 else if (ldsym->l_ifile == 0) 5687 5507 { 5688 5508 if ((ldsym->l_smtype & L_IMPORT) == 0) 5689 ldsym->l_ifile = 0; 5509 { 5510 ldsym->l_ifile = 0; 5511 } 5690 5512 else if (impbfd == NULL) 5691 ldsym->l_ifile = 0; 5513 { 5514 ldsym->l_ifile = 0; 5515 } 5692 5516 else 5693 5517 { … … 5700 5524 5701 5525 BFD_ASSERT (h->ldindx >= 0); 5702 BFD_ASSERT (LDSYMSZ == sizeof (struct external_ldsym)); 5703 xcoff_swap_ldsym_out (output_bfd, ldsym, finfo->ldsym + h->ldindx - 3); 5526 5527 bfd_xcoff_swap_ldsym_out (output_bfd, ldsym, 5528 (finfo->ldsym + 5529 (h->ldindx - 3) 5530 * bfd_xcoff_ldsymsz(finfo->output_bfd))); 5704 5531 h->ldsym = NULL; 5705 5532 } … … 5717 5544 5718 5545 /* The first instruction in the global linkage code loads a 5719 5546 specific TOC element. */ 5720 5547 tocoff = (h->descriptor->toc_section->output_section->vma 5721 5548 + h->descriptor->toc_section->output_offset 5722 5549 - xcoff_data (output_bfd)->toc); 5550 5723 5551 if ((h->descriptor->flags & XCOFF_SET_TOC) != 0) 5724 tocoff += h->descriptor->u.toc_offset; 5725 bfd_put_32 (output_bfd, XCOFF_GLINK_FIRST | (tocoff & 0xffff), p); 5726 for (i = 0, p += 4; 5727 i < sizeof xcoff_glink_code / sizeof xcoff_glink_code[0]; 5728 i++, p += 4) 5729 bfd_put_32 (output_bfd, xcoff_glink_code[i], p); 5552 { 5553 tocoff += h->descriptor->u.toc_offset; 5554 } 5555 5556 5557 /* The first instruction in the glink code needs to be 5558 cooked to to hold the correct offset in the toc. The 5559 rest are just output raw. */ 5560 bfd_put_32 (output_bfd, 5561 bfd_xcoff_glink_code(output_bfd, 0) | (tocoff & 0xffff), p); 5562 5563 /* Start with i == 1 to get past the first instruction done above 5564 The /4 is because the glink code is in bytes and we are going 5565 4 at a pop. */ 5566 for (i = 1; i < bfd_xcoff_glink_code_size(output_bfd) / 4; i++) 5567 { 5568 bfd_put_32 (output_bfd, 5569 (bfd_vma) bfd_xcoff_glink_code(output_bfd, i), 5570 &p[4 * i]); 5571 } 5730 5572 } 5731 5573 … … 5749 5591 + tocsec->output_offset 5750 5592 + h->u.toc_offset); 5593 5594 5751 5595 if (h->indx >= 0) 5752 irel->r_symndx = h->indx; 5596 { 5597 irel->r_symndx = h->indx; 5598 } 5753 5599 else 5754 5600 { … … 5756 5602 irel->r_symndx = obj_raw_syment_count (output_bfd); 5757 5603 } 5604 5605 BFD_ASSERT (h->ldindx >= 0); 5606 5607 /* Initialize the aux union here instead of closer to when it is 5608 written out below because the length of the csect depends on 5609 whether the output is 32 or 64 bit. */ 5610 memset (&iraux, 0, sizeof iraux); 5611 iraux.x_csect.x_smtyp = XTY_SD; 5612 /* iraux.x_csect.x_scnlen.l = 4 or 8, see below */ 5613 iraux.x_csect.x_smclas = XMC_TC; 5614 5615 /* 32 bit uses a 32 bit R_POS to do the relocations 5616 64 bit uses a 64 bit R_POS to do the relocations 5617 5618 Also needs to change the csect size : 4 for 32 bit, 8 for 64 bit 5619 5620 Which one is determined by the backend. */ 5621 if (bfd_xcoff_is_xcoff64 (output_bfd)) 5622 { 5623 irel->r_size = 63; 5624 iraux.x_csect.x_scnlen.l = 8; 5625 } 5626 else if (bfd_xcoff_is_xcoff32 (output_bfd)) 5627 { 5628 irel->r_size = 31; 5629 iraux.x_csect.x_scnlen.l = 4; 5630 } 5631 else 5632 { 5633 return FALSE; 5634 } 5758 5635 irel->r_type = R_POS; 5759 irel->r_size = 31;5760 5636 finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL; 5761 5637 ++osec->reloc_count; 5762 5638 5763 BFD_ASSERT (h->ldindx >= 0);5764 5639 ldrel.l_vaddr = irel->r_vaddr; 5765 5640 ldrel.l_symndx = h->ldindx; 5766 ldrel.l_rtype = ( 31<< 8) | R_POS;5641 ldrel.l_rtype = (irel->r_size << 8) | R_POS; 5767 5642 ldrel.l_rsecnm = oindx; 5768 xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);5769 ++finfo->ldrel;5770 5771 /* We need to emit a symbol to define a csect which holds the5772 5643 bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel); 5644 finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd); 5645 5646 /* We need to emit a symbol to define a csect which holds 5647 the reloc. */ 5773 5648 if (finfo->info->strip != strip_all) 5774 5649 { 5775 if (strlen (h->root.root.string) <= SYMNMLEN) 5776 strncpy (irsym._n._n_name, h->root.root.string, SYMNMLEN); 5777 else 5778 { 5779 boolean hash; 5780 bfd_size_type indx; 5781 5782 hash = true; 5783 if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0) 5784 hash = false; 5785 indx = _bfd_stringtab_add (finfo->strtab, h->root.root.string, 5786 hash, false); 5787 if (indx == (bfd_size_type) -1) 5788 return false; 5789 irsym._n._n_n._n_zeroes = 0; 5790 irsym._n._n_n._n_offset = STRING_SIZE_SIZE + indx; 5791 } 5650 5651 result = bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab, 5652 &irsym, h->root.root.string); 5653 if (!result) 5654 return FALSE; 5792 5655 5793 5656 irsym.n_value = irel->r_vaddr; … … 5800 5663 outsym += bfd_coff_symesz (output_bfd); 5801 5664 5802 memset (&iraux, 0, sizeof iraux); 5803 iraux.x_csect.x_smtyp = XTY_SD; 5804 iraux.x_csect.x_scnlen.l = 4; 5805 iraux.x_csect.x_smclas = XMC_TC; 5806 5665 /* note : iraux is initialized above */ 5807 5666 bfd_coff_swap_aux_out (output_bfd, (PTR) &iraux, T_NULL, C_HIDEXT, 5808 5667 0, 1, (PTR) outsym); … … 5813 5672 /* We aren't going to write out the symbols below, so we 5814 5673 need to write them out now. */ 5815 if (bfd_seek (output_bfd, 5816 (obj_sym_filepos (output_bfd) 5817 + (obj_raw_syment_count (output_bfd) 5818 * bfd_coff_symesz (output_bfd))), 5819 SEEK_SET) != 0 5820 || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1, 5821 output_bfd) 5822 != (bfd_size_type) (outsym - finfo->outsyms))) 5823 return false; 5674 pos = obj_sym_filepos (output_bfd); 5675 pos += (obj_raw_syment_count (output_bfd) 5676 * bfd_coff_symesz (output_bfd)); 5677 amt = outsym - finfo->outsyms; 5678 if (bfd_seek (output_bfd, pos, SEEK_SET) != 0 5679 || bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt) 5680 return FALSE; 5824 5681 obj_raw_syment_count (output_bfd) += 5825 5682 (outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd); … … 5833 5690 it out. The first word is the address of the function code 5834 5691 itself, the second word is the address of the TOC, and the third 5835 word is zero. */ 5692 word is zero. 5693 5694 32 bit vs 64 bit 5695 The addresses for the 32 bit will take 4 bytes and the addresses 5696 for 64 bit will take 8 bytes. Similar for the relocs. This type 5697 of logic was also done above to create a TOC entry in 5698 xcoff_write_global_symbol. */ 5836 5699 if ((h->flags & XCOFF_DESCRIPTOR) != 0 5837 5700 && h->root.type == bfd_link_hash_defined … … 5848 5711 struct internal_ldrel ldrel; 5849 5712 asection *tsec; 5713 unsigned int reloc_size, byte_size; 5714 5715 if (bfd_xcoff_is_xcoff64 (output_bfd)) 5716 { 5717 reloc_size = 63; 5718 byte_size = 8; 5719 } 5720 else if (bfd_xcoff_is_xcoff32 (output_bfd)) 5721 { 5722 reloc_size = 31; 5723 byte_size = 4; 5724 } 5725 else 5726 { 5727 return FALSE; 5728 } 5850 5729 5851 5730 sec = h->root.u.def.section; … … 5859 5738 || hentry->root.type == bfd_link_hash_defweak)); 5860 5739 esec = hentry->root.u.def.section; 5861 bfd_put_32 (output_bfd,5862 (esec->output_section->vma5863 + esec->output_offset5864 + hentry->root.u.def.value),5865 p);5866 5740 5867 5741 irel = finfo->section_info[oindx].relocs + osec->reloc_count; … … 5871 5745 irel->r_symndx = esec->output_section->target_index; 5872 5746 irel->r_type = R_POS; 5873 irel->r_size = 31;5747 irel->r_size = reloc_size; 5874 5748 finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL; 5875 5749 ++osec->reloc_count; … … 5889 5763 esec->output_section->name); 5890 5764 bfd_set_error (bfd_error_nonrepresentable_section); 5891 return false;5892 } 5893 ldrel.l_rtype = ( 31<< 8) | R_POS;5765 return FALSE; 5766 } 5767 ldrel.l_rtype = (reloc_size << 8) | R_POS; 5894 5768 ldrel.l_rsecnm = oindx; 5895 xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel); 5896 ++finfo->ldrel; 5897 5898 bfd_put_32 (output_bfd, xcoff_data (output_bfd)->toc, p + 4); 5769 bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel); 5770 finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd); 5771 5772 /* There are three items to write out, 5773 the address of the code 5774 the address of the toc anchor 5775 the environment pointer. 5776 We are ignoring the environment pointer. So set it to zero. */ 5777 if (bfd_xcoff_is_xcoff64 (output_bfd)) 5778 { 5779 bfd_put_64 (output_bfd, 5780 (esec->output_section->vma + esec->output_offset 5781 + hentry->root.u.def.value), 5782 p); 5783 bfd_put_64 (output_bfd, xcoff_data (output_bfd)->toc, p + 8); 5784 bfd_put_64 (output_bfd, (bfd_vma) 0, p + 16); 5785 } 5786 else 5787 { 5788 /* 32 bit backend 5789 This logic was already called above so the error case where 5790 the backend is neither has already been checked. */ 5791 bfd_put_32 (output_bfd, 5792 (esec->output_section->vma + esec->output_offset 5793 + hentry->root.u.def.value), 5794 p); 5795 bfd_put_32 (output_bfd, xcoff_data (output_bfd)->toc, p + 4); 5796 bfd_put_32 (output_bfd, (bfd_vma) 0, p + 8); 5797 } 5899 5798 5900 5799 tsec = coff_section_from_bfd_index (output_bfd, … … 5905 5804 + sec->output_offset 5906 5805 + h->root.u.def.value 5907 + 4);5806 + byte_size); 5908 5807 irel->r_symndx = tsec->output_section->target_index; 5909 5808 irel->r_type = R_POS; 5910 irel->r_size = 31;5809 irel->r_size = reloc_size; 5911 5810 finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL; 5912 5811 ++osec->reloc_count; … … 5926 5825 tsec->output_section->name); 5927 5826 bfd_set_error (bfd_error_nonrepresentable_section); 5928 return false;5929 } 5930 ldrel.l_rtype = ( 31<< 8) | R_POS;5827 return FALSE; 5828 } 5829 ldrel.l_rtype = (reloc_size << 8) | R_POS; 5931 5830 ldrel.l_rsecnm = oindx; 5932 xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);5933 ++finfo->ldrel;5831 bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel); 5832 finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd); 5934 5833 } 5935 5834 … … 5937 5836 { 5938 5837 BFD_ASSERT (outsym == finfo->outsyms); 5939 return true;5838 return TRUE; 5940 5839 } 5941 5840 … … 5943 5842 && (finfo->info->strip == strip_all 5944 5843 || (finfo->info->strip == strip_some 5945 && (bfd_hash_lookup (finfo->info->keep_hash, 5946 h->root.root.string, false, false) 5947 == NULL)))) 5844 && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string, 5845 FALSE, FALSE) == NULL))) 5948 5846 { 5949 5847 BFD_ASSERT (outsym == finfo->outsyms); 5950 return true;5848 return TRUE; 5951 5849 } 5952 5850 … … 5955 5853 { 5956 5854 BFD_ASSERT (outsym == finfo->outsyms); 5957 return true;5855 return TRUE; 5958 5856 } 5959 5857 … … 5962 5860 h->indx = obj_raw_syment_count (output_bfd); 5963 5861 5964 if (strlen (h->root.root.string) <= SYMNMLEN) 5965 strncpy (isym._n._n_name, h->root.root.string, SYMNMLEN); 5966 else 5967 { 5968 boolean hash; 5969 bfd_size_type indx; 5970 5971 hash = true; 5972 if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0) 5973 hash = false; 5974 indx = _bfd_stringtab_add (finfo->strtab, h->root.root.string, hash, 5975 false); 5976 if (indx == (bfd_size_type) -1) 5977 return false; 5978 isym._n._n_n._n_zeroes = 0; 5979 isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx; 5980 } 5862 result = bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab, &isym, 5863 h->root.root.string); 5864 if (!result) 5865 return FALSE; 5981 5866 5982 5867 if (h->root.type == bfd_link_hash_undefined … … 6006 5891 + h->root.u.def.section->output_offset 6007 5892 + h->root.u.def.value); 6008 isym.n_scnum = h->root.u.def.section->output_section->target_index; 5893 if (bfd_is_abs_section (h->root.u.def.section->output_section)) 5894 isym.n_scnum = N_ABS; 5895 else 5896 isym.n_scnum = h->root.u.def.section->output_section->target_index; 6009 5897 isym.n_sclass = C_HIDEXT; 6010 5898 aux.x_csect.x_smtyp = XTY_SD; … … 6043 5931 6044 5932 aux.x_csect.x_smclas = h->smclas; 6045 6046 5933 bfd_coff_swap_aux_out (output_bfd, (PTR) &aux, T_NULL, isym.n_sclass, 0, 1, 6047 5934 (PTR) outsym); … … 6062 5949 aux.x_csect.x_smtyp = XTY_LD; 6063 5950 aux.x_csect.x_scnlen.l = obj_raw_syment_count (output_bfd); 6064 6065 5951 bfd_coff_swap_aux_out (output_bfd, (PTR) &aux, T_NULL, C_EXT, 0, 1, 6066 5952 (PTR) outsym); … … 6068 5954 } 6069 5955 6070 if (bfd_seek (output_bfd, 6071 (obj_sym_filepos (output_bfd) 6072 + (obj_raw_syment_count (output_bfd) 6073 * bfd_coff_symesz (output_bfd))), 6074 SEEK_SET) != 0 6075 || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1, output_bfd) 6076 != (bfd_size_type) (outsym - finfo->outsyms))) 6077 return false; 5956 pos = obj_sym_filepos (output_bfd); 5957 pos += obj_raw_syment_count (output_bfd) * bfd_coff_symesz (output_bfd); 5958 amt = outsym - finfo->outsyms; 5959 if (bfd_seek (output_bfd, pos, SEEK_SET) != 0 5960 || bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt) 5961 return FALSE; 6078 5962 obj_raw_syment_count (output_bfd) += 6079 5963 (outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd); 6080 5964 6081 return true;5965 return TRUE; 6082 5966 } 6083 5967 6084 5968 /* Handle a link order which is supposed to generate a reloc. */ 6085 5969 6086 static b oolean5970 static bfd_boolean 6087 5971 xcoff_reloc_link_order (output_bfd, finfo, output_section, link_order) 6088 5972 bfd *output_bfd; … … 6103 5987 { 6104 5988 /* We need to somehow locate a symbol in the right section. The 6105 6106 6107 5989 symbol must either have a value of zero, or we must adjust 5990 the addend by the value of the symbol. FIXME: Write this 5991 when we need it. The old linker couldn't handle this anyhow. */ 6108 5992 abort (); 6109 5993 } … … 6113 5997 { 6114 5998 bfd_set_error (bfd_error_bad_value); 6115 return false;5999 return FALSE; 6116 6000 } 6117 6001 … … 6119 6003 bfd_wrapped_link_hash_lookup (output_bfd, finfo->info, 6120 6004 link_order->u.reloc.p->u.name, 6121 false, false, true));6005 FALSE, FALSE, TRUE)); 6122 6006 if (h == NULL) 6123 6007 { … … 6125 6009 (finfo->info, link_order->u.reloc.p->u.name, (bfd *) NULL, 6126 6010 (asection *) NULL, (bfd_vma) 0))) 6127 return false;6128 return true;6011 return FALSE; 6012 return TRUE; 6129 6013 } 6130 6014 … … 6157 6041 bfd_byte *buf; 6158 6042 bfd_reloc_status_type rstat; 6159 b oolean ok;6043 bfd_boolean ok; 6160 6044 6161 6045 size = bfd_get_reloc_size (howto); 6162 6046 buf = (bfd_byte *) bfd_zmalloc (size); 6163 6047 if (buf == NULL) 6164 return false;6048 return FALSE; 6165 6049 6166 6050 rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf); … … 6179 6063 { 6180 6064 free (buf); 6181 return false;6065 return FALSE; 6182 6066 } 6183 6067 break; … … 6187 6071 free (buf); 6188 6072 if (! ok) 6189 return false;6073 return FALSE; 6190 6074 } 6191 6075 … … 6242 6126 bfd_get_filename (output_bfd), secname); 6243 6127 bfd_set_error (bfd_error_nonrepresentable_section); 6244 return false;6128 return FALSE; 6245 6129 } 6246 6130 } … … 6254 6138 h->root.root.string); 6255 6139 bfd_set_error (bfd_error_bad_value); 6256 return false;6140 return FALSE; 6257 6141 } 6258 6142 ldrel.l_symndx = h->ldindx; … … 6261 6145 ldrel.l_rtype = (irel->r_size << 8) | irel->r_type; 6262 6146 ldrel.l_rsecnm = output_section->target_index; 6263 xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);6264 ++finfo->ldrel;6265 6266 return true;6147 bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel); 6148 finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd); 6149 6150 return TRUE; 6267 6151 } 6268 6152 … … 6285 6169 } 6286 6170 6287 /* This is the relocation function for the RS/6000/POWER/PowerPC. 6288 This is currently the only processor which uses XCOFF; I hope that 6289 will never change. */ 6290 6291 boolean 6292 _bfd_ppc_xcoff_relocate_section (output_bfd, info, input_bfd, 6293 input_section, contents, relocs, syms, 6294 sections) 6295 bfd *output_bfd; 6296 struct bfd_link_info *info; 6297 bfd *input_bfd; 6298 asection *input_section; 6299 bfd_byte *contents; 6300 struct internal_reloc *relocs; 6301 struct internal_syment *syms; 6302 asection **sections; 6303 { 6304 struct internal_reloc *rel; 6305 struct internal_reloc *relend; 6306 6307 rel = relocs; 6308 relend = rel + input_section->reloc_count; 6309 for (; rel < relend; rel++) 6310 { 6311 long symndx; 6312 struct xcoff_link_hash_entry *h; 6313 struct internal_syment *sym; 6314 bfd_vma addend; 6315 bfd_vma val; 6316 struct reloc_howto_struct howto; 6317 bfd_reloc_status_type rstat; 6318 6319 /* Relocation type R_REF is a special relocation type which is 6320 merely used to prevent garbage collection from occurring for 6321 the csect including the symbol which it references. */ 6322 if (rel->r_type == R_REF) 6323 continue; 6324 6325 symndx = rel->r_symndx; 6326 6327 if (symndx == -1) 6328 { 6329 h = NULL; 6330 sym = NULL; 6331 addend = 0; 6332 } 6333 else 6334 { 6335 h = obj_xcoff_sym_hashes (input_bfd)[symndx]; 6336 sym = syms + symndx; 6337 addend = - sym->n_value; 6338 } 6339 6340 /* We build the howto information on the fly. */ 6341 6342 howto.type = rel->r_type; 6343 howto.rightshift = 0; 6344 howto.size = 2; 6345 howto.bitsize = (rel->r_size & 0x1f) + 1; 6346 howto.pc_relative = false; 6347 howto.bitpos = 0; 6348 if ((rel->r_size & 0x80) != 0) 6349 howto.complain_on_overflow = complain_overflow_signed; 6350 else 6351 howto.complain_on_overflow = complain_overflow_bitfield; 6352 howto.special_function = NULL; 6353 howto.name = "internal"; 6354 howto.partial_inplace = true; 6355 if (howto.bitsize == 32) 6356 howto.src_mask = howto.dst_mask = 0xffffffff; 6357 else 6358 { 6359 howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1; 6360 if (howto.bitsize == 16) 6361 howto.size = 1; 6362 } 6363 howto.pcrel_offset = false; 6364 6365 val = 0; 6366 6367 if (h == NULL) 6368 { 6369 asection *sec; 6370 6371 if (symndx == -1) 6372 { 6373 sec = bfd_abs_section_ptr; 6374 val = 0; 6375 } 6376 else 6377 { 6378 sec = sections[symndx]; 6379 /* Hack to make sure we use the right TOC anchor value 6380 if this reloc is against the TOC anchor. */ 6381 if (sec->name[3] == '0' 6382 && strcmp (sec->name, ".tc0") == 0) 6383 val = xcoff_data (output_bfd)->toc; 6384 else 6385 val = (sec->output_section->vma 6386 + sec->output_offset 6387 + sym->n_value 6388 - sec->vma); 6389 } 6390 } 6391 else 6392 { 6393 if (h->root.type == bfd_link_hash_defined 6394 || h->root.type == bfd_link_hash_defweak) 6395 { 6396 asection *sec; 6397 6398 sec = h->root.u.def.section; 6399 val = (h->root.u.def.value 6400 + sec->output_section->vma 6401 + sec->output_offset); 6402 } 6403 else if (h->root.type == bfd_link_hash_common) 6404 { 6405 asection *sec; 6406 6407 sec = h->root.u.c.p->section; 6408 val = (sec->output_section->vma 6409 + sec->output_offset); 6410 } 6411 else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0 6412 || (h->flags & XCOFF_IMPORT) != 0) 6413 { 6414 /* Every symbol in a shared object is defined somewhere. */ 6415 val = 0; 6416 } 6417 else if (! info->relocateable) 6418 { 6419 if (! ((*info->callbacks->undefined_symbol) 6420 (info, h->root.root.string, input_bfd, input_section, 6421 rel->r_vaddr - input_section->vma, true))) 6422 return false; 6423 6424 /* Don't try to process the reloc. It can't help, and 6425 it may generate another error. */ 6426 continue; 6427 } 6428 } 6429 6430 /* I took the relocation type definitions from two documents: 6431 the PowerPC AIX Version 4 Application Binary Interface, First 6432 Edition (April 1992), and the PowerOpen ABI, Big-Endian 6433 32-Bit Hardware Implementation (June 30, 1994). Differences 6434 between the documents are noted below. */ 6435 6436 switch (rel->r_type) 6437 { 6438 case R_RTB: 6439 case R_RRTBI: 6440 case R_RRTBA: 6441 /* These relocs are defined by the PowerPC ABI to be 6442 relative branches which use half of the difference 6443 between the symbol and the program counter. I can't 6444 quite figure out when this is useful. These relocs are 6445 not defined by the PowerOpen ABI. */ 6446 default: 6447 (*_bfd_error_handler) 6448 (_("%s: unsupported relocation type 0x%02x"), 6449 bfd_get_filename (input_bfd), (unsigned int) rel->r_type); 6450 bfd_set_error (bfd_error_bad_value); 6451 return false; 6452 case R_POS: 6453 /* Simple positive relocation. */ 6454 break; 6455 case R_NEG: 6456 /* Simple negative relocation. */ 6457 val = - val; 6458 break; 6459 case R_REL: 6460 /* Simple PC relative relocation. */ 6461 howto.pc_relative = true; 6462 break; 6463 case R_TOC: 6464 /* TOC relative relocation. The value in the instruction in 6465 the input file is the offset from the input file TOC to 6466 the desired location. We want the offset from the final 6467 TOC to the desired location. We have: 6468 isym = iTOC + in 6469 iinsn = in + o 6470 osym = oTOC + on 6471 oinsn = on + o 6472 so we must change insn by on - in. 6473 */ 6474 case R_GL: 6475 /* Global linkage relocation. The value of this relocation 6476 is the address of the entry in the TOC section. */ 6477 case R_TCL: 6478 /* Local object TOC address. I can't figure out the 6479 difference between this and case R_GL. */ 6480 case R_TRL: 6481 /* TOC relative relocation. A TOC relative load instruction 6482 which may be changed to a load address instruction. 6483 FIXME: We don't currently implement this optimization. */ 6484 case R_TRLA: 6485 /* TOC relative relocation. This is a TOC relative load 6486 address instruction which may be changed to a load 6487 instruction. FIXME: I don't know if this is the correct 6488 implementation. */ 6489 if (h != NULL && h->smclas != XMC_TD) 6490 { 6491 if (h->toc_section == NULL) 6492 { 6493 (*_bfd_error_handler) 6494 (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"), 6495 bfd_get_filename (input_bfd), rel->r_vaddr, 6496 h->root.root.string); 6497 bfd_set_error (bfd_error_bad_value); 6498 return false; 6499 } 6500 6501 BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0); 6502 val = (h->toc_section->output_section->vma 6503 + h->toc_section->output_offset); 6504 } 6505 6506 val = ((val - xcoff_data (output_bfd)->toc) 6507 - (sym->n_value - xcoff_data (input_bfd)->toc)); 6508 addend = 0; 6509 break; 6510 case R_BA: 6511 /* Absolute branch. We don't want to mess with the lower 6512 two bits of the instruction. */ 6513 case R_CAI: 6514 /* The PowerPC ABI defines this as an absolute call which 6515 may be modified to become a relative call. The PowerOpen 6516 ABI does not define this relocation type. */ 6517 case R_RBA: 6518 /* Absolute branch which may be modified to become a 6519 relative branch. */ 6520 case R_RBAC: 6521 /* The PowerPC ABI defines this as an absolute branch to a 6522 fixed address which may be modified to an absolute branch 6523 to a symbol. The PowerOpen ABI does not define this 6524 relocation type. */ 6525 case R_RBRC: 6526 /* The PowerPC ABI defines this as an absolute branch to a 6527 fixed address which may be modified to a relative branch. 6528 The PowerOpen ABI does not define this relocation type. */ 6529 howto.src_mask &= ~3; 6530 howto.dst_mask = howto.src_mask; 6531 break; 6532 case R_BR: 6533 /* Relative branch. We don't want to mess with the lower 6534 two bits of the instruction. */ 6535 case R_CREL: 6536 /* The PowerPC ABI defines this as a relative call which may 6537 be modified to become an absolute call. The PowerOpen 6538 ABI does not define this relocation type. */ 6539 case R_RBR: 6540 /* A relative branch which may be modified to become an 6541 absolute branch. FIXME: We don't implement this, 6542 although we should for symbols of storage mapping class 6543 XMC_XO. */ 6544 howto.pc_relative = true; 6545 howto.src_mask &= ~3; 6546 howto.dst_mask = howto.src_mask; 6547 break; 6548 case R_RL: 6549 /* The PowerPC AIX ABI describes this as a load which may be 6550 changed to a load address. The PowerOpen ABI says this 6551 is the same as case R_POS. */ 6552 break; 6553 case R_RLA: 6554 /* The PowerPC AIX ABI describes this as a load address 6555 which may be changed to a load. The PowerOpen ABI says 6556 this is the same as R_POS. */ 6557 break; 6558 } 6559 6560 /* If we see an R_BR or R_RBR reloc which is jumping to global 6561 linkage code, and it is followed by an appropriate cror nop 6562 instruction, we replace the cror with lwz r2,20(r1). This 6563 restores the TOC after the glink code. Contrariwise, if the 6564 call is followed by a lwz r2,20(r1), but the call is not 6565 going to global linkage code, we can replace the load with a 6566 cror. */ 6567 if ((rel->r_type == R_BR || rel->r_type == R_RBR) 6568 && h != NULL 6569 && h->root.type == bfd_link_hash_defined 6570 && (rel->r_vaddr - input_section->vma + 8 6571 <= input_section->_cooked_size)) 6572 { 6573 bfd_byte *pnext; 6574 unsigned long next; 6575 6576 pnext = contents + (rel->r_vaddr - input_section->vma) + 4; 6577 next = bfd_get_32 (input_bfd, pnext); 6578 6579 /* The _ptrgl function is magic. It is used by the AIX 6580 compiler to call a function through a pointer. */ 6581 if (h->smclas == XMC_GL 6582 || strcmp (h->root.root.string, "._ptrgl") == 0) 6583 { 6584 if (next == 0x4def7b82 /* cror 15,15,15 */ 6585 || next == 0x4ffffb82 /* cror 31,31,31 */ 6586 || next == 0x60000000) /* ori r0,r0,0 */ 6587 bfd_put_32 (input_bfd, 0x80410014, pnext); /* lwz r1,20(r1) */ 6588 } 6589 else 6590 { 6591 if (next == 0x80410014) /* lwz r1,20(r1) */ 6592 bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */ 6593 } 6594 } 6595 6596 /* A PC relative reloc includes the section address. */ 6597 if (howto.pc_relative) 6598 addend += input_section->vma; 6599 6600 rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section, 6601 contents, 6602 rel->r_vaddr - input_section->vma, 6603 val, addend); 6604 6605 switch (rstat) 6606 { 6607 default: 6608 abort (); 6609 case bfd_reloc_ok: 6610 break; 6611 case bfd_reloc_overflow: 6612 { 6613 const char *name; 6614 char buf[SYMNMLEN + 1]; 6615 char howto_name[10]; 6616 6617 if (symndx == -1) 6618 name = "*ABS*"; 6619 else if (h != NULL) 6620 name = h->root.root.string; 6621 else 6622 { 6623 name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); 6624 if (name == NULL) 6625 return false; 6626 } 6627 sprintf (howto_name, "0x%02x", rel->r_type); 6628 6629 if (! ((*info->callbacks->reloc_overflow) 6630 (info, name, howto_name, (bfd_vma) 0, input_bfd, 6631 input_section, rel->r_vaddr - input_section->vma))) 6632 return false; 6633 } 6634 } 6635 } 6636 6637 return true; 6638 } 6171 6172 6173 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.