reloc16.c (78828) | reloc16.c (89857) |
---|---|
1/* 8 and 16 bit COFF relocation functions, for BFD. | 1/* 8 and 16 bit COFF relocation functions, for BFD. |
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000 | 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001 |
3 Free Software Foundation, Inc. 4 Written by Cygnus Support. 5 6This file is part of BFD, the Binary File Descriptor library. 7 8This program is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 2 of the License, or --- 121 unchanged lines hidden (view full) --- 132 } 133 } 134 } 135 s++; 136 } 137} 138 139boolean | 3 Free Software Foundation, Inc. 4 Written by Cygnus Support. 5 6This file is part of BFD, the Binary File Descriptor library. 7 8This program is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 2 of the License, or --- 121 unchanged lines hidden (view full) --- 132 } 133 } 134 } 135 s++; 136 } 137} 138 139boolean |
140bfd_coff_reloc16_relax_section (abfd, i, link_info, again) | 140bfd_coff_reloc16_relax_section (abfd, input_section, link_info, again) |
141 bfd *abfd; | 141 bfd *abfd; |
142 asection *i; | 142 asection *input_section; |
143 struct bfd_link_info *link_info; 144 boolean *again; 145{ 146 /* Get enough memory to hold the stuff. */ | 143 struct bfd_link_info *link_info; 144 boolean *again; 145{ 146 /* Get enough memory to hold the stuff. */ |
147 bfd *input_bfd = i->owner; 148 asection *input_section = i; 149 int *shrinks; 150 int shrink = 0; | 147 bfd *input_bfd = input_section->owner; 148 unsigned *shrinks; 149 unsigned shrink = 0; |
151 long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); 152 arelent **reloc_vector = NULL; 153 long reloc_count; 154 155 /* We only do global relaxation once. It is not safe to do it multiple 156 times (see discussion of the "shrinks" array below). */ 157 *again = false; 158 159 if (reloc_size < 0) 160 return false; 161 | 150 long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); 151 arelent **reloc_vector = NULL; 152 long reloc_count; 153 154 /* We only do global relaxation once. It is not safe to do it multiple 155 times (see discussion of the "shrinks" array below). */ 156 *again = false; 157 158 if (reloc_size < 0) 159 return false; 160 |
162 reloc_vector = (arelent **) bfd_malloc (reloc_size); | 161 reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size); |
163 if (!reloc_vector && reloc_size > 0) 164 return false; 165 166 /* Get the relocs and think about them. */ 167 reloc_count = 168 bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector, 169 _bfd_generic_link_get_symbols (input_bfd)); 170 if (reloc_count < 0) --- 15 unchanged lines hidden (view full) --- 186 In theory, if we kept the "shrinks" array for each section for the 187 entire link, we could use the generic relaxing code in the linker 188 and get better results, particularly for jsr->bsr and 24->16 bit 189 memory reference relaxations. */ 190 191 if (reloc_count > 0) 192 { 193 int another_pass = 0; | 162 if (!reloc_vector && reloc_size > 0) 163 return false; 164 165 /* Get the relocs and think about them. */ 166 reloc_count = 167 bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector, 168 _bfd_generic_link_get_symbols (input_bfd)); 169 if (reloc_count < 0) --- 15 unchanged lines hidden (view full) --- 185 In theory, if we kept the "shrinks" array for each section for the 186 entire link, we could use the generic relaxing code in the linker 187 and get better results, particularly for jsr->bsr and 24->16 bit 188 memory reference relaxations. */ 189 190 if (reloc_count > 0) 191 { 192 int another_pass = 0; |
193 bfd_size_type amt; |
|
194 195 /* Allocate and initialize the shrinks array for this section. 196 The last element is used as an accumlator of shrinks. */ | 194 195 /* Allocate and initialize the shrinks array for this section. 196 The last element is used as an accumlator of shrinks. */ |
197 shrinks = (int *) bfd_malloc ((reloc_count + 1) * sizeof (int)); 198 memset (shrinks, 0, (reloc_count + 1) * sizeof (int)); | 197 amt = reloc_count + 1; 198 amt *= sizeof (unsigned); 199 shrinks = (unsigned *) bfd_malloc (amt); 200 memset (shrinks, 0, (size_t) amt); |
199 200 /* Loop until nothing changes in this section. */ 201 do { 202 arelent **parent; 203 unsigned int i; 204 long j; 205 206 another_pass = 0; --- 56 unchanged lines hidden (view full) --- 263 link_order, 264 data, relocateable, 265 symbols); 266 267 /* Read in the section. */ 268 if (!bfd_get_section_contents(input_bfd, 269 input_section, 270 data, | 201 202 /* Loop until nothing changes in this section. */ 203 do { 204 arelent **parent; 205 unsigned int i; 206 long j; 207 208 another_pass = 0; --- 56 unchanged lines hidden (view full) --- 265 link_order, 266 data, relocateable, 267 symbols); 268 269 /* Read in the section. */ 270 if (!bfd_get_section_contents(input_bfd, 271 input_section, 272 data, |
271 0, | 273 (bfd_vma) 0, |
272 input_section->_raw_size)) 273 return NULL; 274 | 274 input_section->_raw_size)) 275 return NULL; 276 |
275 reloc_vector = (arelent **) bfd_malloc ((size_t) reloc_size); | 277 reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size); |
276 if (!reloc_vector && reloc_size != 0) 277 return NULL; 278 279 reloc_count = bfd_canonicalize_reloc (input_bfd, 280 input_section, 281 reloc_vector, 282 symbols); 283 if (reloc_count < 0) --- 47 unchanged lines hidden --- | 278 if (!reloc_vector && reloc_size != 0) 279 return NULL; 280 281 reloc_count = bfd_canonicalize_reloc (input_bfd, 282 input_section, 283 reloc_vector, 284 symbols); 285 if (reloc_count < 0) --- 47 unchanged lines hidden --- |