Index: bfd/aix386-core.c =================================================================== RCS file: /cvs/src/src/bfd/aix386-core.c,v retrieving revision 1.11 diff -u -p -r1.11 aix386-core.c --- bfd/aix386-core.c 15 Mar 2004 14:21:42 -0000 1.11 +++ bfd/aix386-core.c 22 Jun 2004 01:34:52 -0000 @@ -122,7 +122,7 @@ aix386_core_file_p (abfd) goto loser; core_regsec (abfd)->flags = SEC_HAS_CONTENTS; - core_regsec (abfd)->_raw_size = sizeof (core->cd_regs); + core_regsec (abfd)->size = sizeof (core->cd_regs); core_regsec (abfd)->vma = (bfd_vma) -1; /* We'll access the regs afresh in the core file, like any section. */ @@ -135,7 +135,7 @@ aix386_core_file_p (abfd) goto loser; core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS; - core_reg2sec (abfd)->_raw_size = sizeof (core->cd_fpregs); + core_reg2sec (abfd)->size = sizeof (core->cd_fpregs); core_reg2sec (abfd)->vma = (bfd_vma) -1; core_reg2sec (abfd)->filepos = (file_ptr) offsetof (struct corehdr, cd_fpregs); @@ -180,7 +180,7 @@ aix386_core_file_p (abfd) goto loser; core_section (abfd, n)->flags = flags; - core_section (abfd, n)->_raw_size = core->cd_segs[i].cs_len; + core_section (abfd, n)->size = core->cd_segs[i].cs_len; core_section (abfd, n)->vma = core->cd_segs[i].cs_address; core_section (abfd, n)->filepos = core->cd_segs[i].cs_offset; core_section (abfd, n)->alignment_power = 2; Index: bfd/aix5ppc-core.c =================================================================== RCS file: /cvs/src/src/bfd/aix5ppc-core.c,v retrieving revision 1.5 diff -u -p -r1.5 aix5ppc-core.c --- bfd/aix5ppc-core.c 24 Nov 2003 18:06:39 -0000 1.5 +++ bfd/aix5ppc-core.c 22 Jun 2004 01:34:53 -0000 @@ -1,5 +1,5 @@ /* IBM RS/6000 "XCOFF" back-end for BFD. - Copyright 2001, 2002 + Copyright 2001, 2002, 2004 Free Software Foundation, Inc. Written by Tom Rix Contributed by Redhat. @@ -125,7 +125,7 @@ xcoff64_core_p (abfd) return return_value; sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; - sec->_raw_size = core.c_size; + sec->size = core.c_size; sec->vma = core.c_stackorg; sec->filepos = core.c_stack; @@ -135,7 +135,7 @@ xcoff64_core_p (abfd) return return_value; sec->flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY; - sec->_raw_size = sizeof (struct __context64); + sec->size = sizeof (struct __context64); sec->vma = 0; sec->filepos = 0; sec->contents = (bfd_byte *)&new_core_hdr->c_flt.r64; @@ -149,7 +149,7 @@ xcoff64_core_p (abfd) return return_value; sec->flags = SEC_HAS_CONTENTS; - sec->_raw_size = core.c_lsize; + sec->size = core.c_lsize; sec->vma = 0; sec->filepos = core.c_loader; @@ -163,7 +163,7 @@ xcoff64_core_p (abfd) return return_value; sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; - sec->_raw_size = core.c_datasize; + sec->size = core.c_datasize; sec->vma = core.c_dataorg; sec->filepos = core.c_data; @@ -186,7 +186,7 @@ xcoff64_core_p (abfd) return return_value; sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; - sec->_raw_size = ldinfo.ldinfo_datasize; + sec->size = ldinfo.ldinfo_datasize; sec->vma = ldinfo.ldinfo_dataorg; sec->filepos = ldinfo.ldinfo_core; } @@ -214,7 +214,7 @@ xcoff64_core_p (abfd) return return_value; sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; - sec->_raw_size = vminfo.vminfo_size; + sec->size = vminfo.vminfo_size; sec->vma = vminfo.vminfo_addr; sec->filepos = vminfo.vminfo_offset; } Index: bfd/aout-adobe.c =================================================================== RCS file: /cvs/src/src/bfd/aout-adobe.c,v retrieving revision 1.18 diff -u -p -r1.18 aout-adobe.c --- bfd/aout-adobe.c 30 Apr 2004 14:23:39 -0000 1.18 +++ bfd/aout-adobe.c 22 Jun 2004 01:34:53 -0000 @@ -1,6 +1,6 @@ /* BFD back-end for a.out.adobe binaries. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, - 2002, 2003, 2004 + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, + 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Cygnus Support. Based on bout.c. @@ -235,10 +235,9 @@ aout_adobe_callback (abfd) /* Now set the section's attributes. */ bfd_set_section_flags (abfd, sect, flags); /* Assumed big-endian. */ - sect->_raw_size = ((ext->e_size[0] << 8) - | ext->e_size[1] << 8 - | ext->e_size[2]); - sect->_cooked_size = sect->_raw_size; + sect->size = ((ext->e_size[0] << 8) + | ext->e_size[1] << 8 + | ext->e_size[2]); sect->vma = H_GET_32 (abfd, ext->e_virtbase); sect->filepos = H_GET_32 (abfd, ext->e_filebase); /* FIXME XXX alignment? */ @@ -324,19 +323,19 @@ aout_adobe_write_object_contents (abfd) { if (sect->flags & SEC_CODE) { - exec_hdr (abfd)->a_text += sect->_raw_size; + exec_hdr (abfd)->a_text += sect->size; exec_hdr (abfd)->a_trsize += sect->reloc_count * sizeof (struct reloc_std_external); } else if (sect->flags & SEC_DATA) { - exec_hdr (abfd)->a_data += sect->_raw_size; + exec_hdr (abfd)->a_data += sect->size; exec_hdr (abfd)->a_drsize += sect->reloc_count * sizeof (struct reloc_std_external); } else if (sect->flags & SEC_ALLOC && !(sect->flags & SEC_LOAD)) { - exec_hdr (abfd)->a_bss += sect->_raw_size; + exec_hdr (abfd)->a_bss += sect->size; } } @@ -435,7 +434,7 @@ aout_adobe_set_section_contents (abfd, s { sect->filepos = section_start; /* FIXME: Round to alignment. */ - section_start += sect->_raw_size; + section_start += sect->size; } } @@ -445,7 +444,7 @@ aout_adobe_set_section_contents (abfd, s { sect->filepos = section_start; /* FIXME: Round to alignment. */ - section_start += sect->_raw_size; + section_start += sect->size; } } @@ -456,7 +455,7 @@ aout_adobe_set_section_contents (abfd, s { sect->filepos = section_start; /* FIXME: Round to alignment. */ - section_start += sect->_raw_size; + section_start += sect->size; } } } Index: bfd/aout-target.h =================================================================== RCS file: /cvs/src/src/bfd/aout-target.h,v retrieving revision 1.24 diff -u -p -r1.24 aout-target.h --- bfd/aout-target.h 17 May 2004 16:40:00 -0000 1.24 +++ bfd/aout-target.h 22 Jun 2004 01:34:53 -0000 @@ -46,7 +46,7 @@ MY(callback) (abfd) unsigned long arch_align; /* Calculate the file positions of the parts of a newly read aout header */ - obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp); + obj_textsec (abfd)->size = N_TXTSIZE(*execp); /* The virtual memory addresses of the sections */ obj_textsec (abfd)->vma = N_TXTADDR(*execp); @@ -110,12 +110,12 @@ MY(callback) (abfd) of the section. */ arch_align_power = bfd_get_arch_info (abfd)->section_align_power; arch_align = 1 << arch_align_power; - if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align) - == obj_textsec (abfd)->_raw_size) - && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align) - == obj_datasec (abfd)->_raw_size) - && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align) - == obj_bsssec (abfd)->_raw_size)) + if ((BFD_ALIGN (obj_textsec (abfd)->size, arch_align) + == obj_textsec (abfd)->size) + && (BFD_ALIGN (obj_datasec (abfd)->size, arch_align) + == obj_datasec (abfd)->size) + && (BFD_ALIGN (obj_bsssec (abfd)->size, arch_align) + == obj_bsssec (abfd)->size)) { obj_textsec (abfd)->alignment_power = arch_align_power; obj_datasec (abfd)->alignment_power = arch_align_power; Index: bfd/aout-tic30.c =================================================================== RCS file: /cvs/src/src/bfd/aout-tic30.c,v retrieving revision 1.23 diff -u -p -r1.23 aout-tic30.c --- bfd/aout-tic30.c 17 May 2004 16:40:00 -0000 1.23 +++ bfd/aout-tic30.c 22 Jun 2004 01:34:54 -0000 @@ -338,7 +338,7 @@ tic30_aout_callback (abfd) unsigned long arch_align; /* Calculate the file positions of the parts of a newly read aout header. */ - obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp); + obj_textsec (abfd)->size = N_TXTSIZE (*execp); /* The virtual memory addresses of the sections. */ obj_textsec (abfd)->vma = N_TXTADDR (*execp); @@ -376,12 +376,12 @@ tic30_aout_callback (abfd) of the section. */ arch_align_power = bfd_get_arch_info (abfd)->section_align_power; arch_align = 1 << arch_align_power; - if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align) - == obj_textsec (abfd)->_raw_size) - && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align) - == obj_datasec (abfd)->_raw_size) - && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align) - == obj_bsssec (abfd)->_raw_size)) + if ((BFD_ALIGN (obj_textsec (abfd)->size, arch_align) + == obj_textsec (abfd)->size) + && (BFD_ALIGN (obj_datasec (abfd)->size, arch_align) + == obj_datasec (abfd)->size) + && (BFD_ALIGN (obj_bsssec (abfd)->size, arch_align) + == obj_bsssec (abfd)->size)) { obj_textsec (abfd)->alignment_power = arch_align_power; obj_datasec (abfd)->alignment_power = arch_align_power; @@ -402,8 +402,10 @@ tic30_aout_final_link_relocate (howto, i bfd_vma addend; { bfd_vma relocation; + bfd_size_type sz; - if (address > input_section->_raw_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (address > sz) return bfd_reloc_outofrange; relocation = value + addend; @@ -757,8 +759,8 @@ MY_bfd_final_link (abfd, info) obj_textsec (abfd)->filepos = pos; obj_textsec (abfd)->vma = vma; obj_textsec (abfd)->user_set_vma = 1; - pos += obj_textsec (abfd)->_raw_size; - vma += obj_textsec (abfd)->_raw_size; + pos += obj_textsec (abfd)->size; + vma += obj_textsec (abfd)->size; /* Data. */ if (abfd->flags & D_PAGED) @@ -780,14 +782,14 @@ MY_bfd_final_link (abfd, info) vma = obj_datasec (abfd)->vma; obj_datasec (abfd)->filepos = vma + adata (abfd).exec_bytes_size; execp->a_text = vma - obj_textsec (abfd)->vma; - obj_textsec (abfd)->_raw_size = execp->a_text; + obj_textsec (abfd)->size = execp->a_text; /* Since BSS follows data immediately, see if it needs alignment. */ - vma += obj_datasec (abfd)->_raw_size; + vma += obj_datasec (abfd)->size; pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma; - obj_datasec (abfd)->_raw_size += pad; - pos += obj_datasec (abfd)->_raw_size; - execp->a_data = obj_datasec (abfd)->_raw_size; + obj_datasec (abfd)->size += pad; + pos += obj_datasec (abfd)->size; + execp->a_data = obj_datasec (abfd)->size; /* BSS. */ obj_bsssec (abfd)->vma = vma; Index: bfd/aoutf1.h =================================================================== RCS file: /cvs/src/src/bfd/aoutf1.h,v retrieving revision 1.11 diff -u -p -r1.11 aoutf1.h --- bfd/aoutf1.h 4 Nov 2003 11:30:54 -0000 1.11 +++ bfd/aoutf1.h 22 Jun 2004 01:34:54 -0000 @@ -1,6 +1,6 @@ /* A.out "format 1" file handling code for BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, - 2001, 2002, 2003 + 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Cygnus Support. @@ -701,10 +701,10 @@ sunos4_core_file_p (abfd) core_regsec (abfd)->flags = SEC_HAS_CONTENTS; core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS; - core_stacksec (abfd)->_raw_size = core->c_ssize; - core_datasec (abfd)->_raw_size = core->c_dsize; - core_regsec (abfd)->_raw_size = core->c_regs_size; - core_reg2sec (abfd)->_raw_size = core->fp_stuff_size; + core_stacksec (abfd)->size = core->c_ssize; + core_datasec (abfd)->size = core->c_dsize; + core_regsec (abfd)->size = core->c_regs_size; + core_reg2sec (abfd)->size = core->fp_stuff_size; core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize); core_datasec (abfd)->vma = core->c_data_addr; Index: bfd/aoutx.h =================================================================== RCS file: /cvs/src/src/bfd/aoutx.h,v retrieving revision 1.45 diff -u -p -r1.45 aoutx.h --- bfd/aoutx.h 24 Nov 2003 18:06:39 -0000 1.45 +++ bfd/aoutx.h 22 Jun 2004 01:35:00 -0000 @@ -1,6 +1,6 @@ /* BFD semi-generic back-end for a.out binaries. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, - 2001, 2002, 2003 + 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Cygnus Support. @@ -541,8 +541,8 @@ NAME(aout,some_aout_object_p) (abfd, exe if (! NAME(aout,make_sections) (abfd)) goto error_ret; - obj_datasec (abfd)->_raw_size = execp->a_data; - obj_bsssec (abfd)->_raw_size = execp->a_bss; + obj_datasec (abfd)->size = execp->a_data; + obj_bsssec (abfd)->size = execp->a_bss; obj_textsec (abfd)->flags = (execp->a_trsize != 0 @@ -568,7 +568,6 @@ NAME(aout,some_aout_object_p) (abfd, exe struct exec *execp = exec_hdr (abfd); obj_textsec (abfd)->size = N_TXTSIZE (*execp); - obj_textsec (abfd)->raw_size = N_TXTSIZE (*execp); /* Data and bss are already filled in since they're so standard. */ /* The virtual memory addresses of the sections. */ @@ -632,7 +631,7 @@ NAME(aout,some_aout_object_p) (abfd, exe if (execp->a_entry != 0 || (execp->a_entry >= obj_textsec (abfd)->vma && execp->a_entry < (obj_textsec (abfd)->vma - + obj_textsec (abfd)->_raw_size))) + + obj_textsec (abfd)->size))) abfd->flags |= EXEC_P; #ifdef STAT_FOR_EXEC else @@ -907,8 +906,8 @@ adjust_o_magic (abfd, execp) else vma = obj_textsec (abfd)->vma; - pos += obj_textsec (abfd)->_raw_size; - vma += obj_textsec (abfd)->_raw_size; + pos += obj_textsec (abfd)->size; + vma += obj_textsec (abfd)->size; /* Data. */ if (!obj_datasec (abfd)->user_set_vma) @@ -916,7 +915,7 @@ adjust_o_magic (abfd, execp) #if 0 /* ?? Does alignment in the file image really matter? */ pad = align_power (vma, obj_datasec (abfd)->alignment_power) - vma; #endif - obj_textsec (abfd)->_raw_size += pad; + obj_textsec (abfd)->size += pad; pos += pad; vma += pad; obj_datasec (abfd)->vma = vma; @@ -924,8 +923,8 @@ adjust_o_magic (abfd, execp) else vma = obj_datasec (abfd)->vma; obj_datasec (abfd)->filepos = pos; - pos += obj_datasec (abfd)->_raw_size; - vma += obj_datasec (abfd)->_raw_size; + pos += obj_datasec (abfd)->size; + vma += obj_datasec (abfd)->size; /* BSS. */ if (!obj_bsssec (abfd)->user_set_vma) @@ -933,7 +932,7 @@ adjust_o_magic (abfd, execp) #if 0 pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma; #endif - obj_datasec (abfd)->_raw_size += pad; + obj_datasec (abfd)->size += pad; pos += pad; vma += pad; obj_bsssec (abfd)->vma = vma; @@ -946,16 +945,16 @@ adjust_o_magic (abfd, execp) pad = obj_bsssec (abfd)->vma - vma; if (pad > 0) { - obj_datasec (abfd)->_raw_size += pad; + obj_datasec (abfd)->size += pad; pos += pad; } } obj_bsssec (abfd)->filepos = pos; /* Fix up the exec header. */ - execp->a_text = obj_textsec (abfd)->_raw_size; - execp->a_data = obj_datasec (abfd)->_raw_size; - execp->a_bss = obj_bsssec (abfd)->_raw_size; + execp->a_text = obj_textsec (abfd)->size; + execp->a_data = obj_datasec (abfd)->size; + execp->a_bss = obj_bsssec (abfd)->size; N_SET_MAGIC (*execp, OMAGIC); } @@ -1005,7 +1004,7 @@ adjust_z_magic (abfd, execp) /* Find start of data. */ if (ztih) { - text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->_raw_size; + text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->size; text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end; } else @@ -1013,18 +1012,18 @@ adjust_z_magic (abfd, execp) /* Note that if page_size == zmagic_disk_block_size, then filepos == page_size, and this case is the same as the ztih case. */ - text_end = obj_textsec (abfd)->_raw_size; + text_end = obj_textsec (abfd)->size; text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end; text_end += obj_textsec (abfd)->filepos; } - obj_textsec (abfd)->_raw_size += text_pad; + obj_textsec (abfd)->size += text_pad; text_end += text_pad; /* Data. */ if (!obj_datasec (abfd)->user_set_vma) { bfd_vma vma; - vma = obj_textsec (abfd)->vma + obj_textsec (abfd)->_raw_size; + vma = obj_textsec (abfd)->vma + obj_textsec (abfd)->size; obj_datasec (abfd)->vma = BFD_ALIGN (vma, adata (abfd).segment_size); } if (abdp && abdp->zmagic_mapped_contiguous) @@ -1032,17 +1031,17 @@ adjust_z_magic (abfd, execp) asection * text = obj_textsec (abfd); asection * data = obj_datasec (abfd); - text_pad = data->vma - (text->vma + text->_raw_size); + text_pad = data->vma - (text->vma + text->size); /* Only pad the text section if the data section is going to be placed after it. */ if (text_pad > 0) - text->_raw_size += text_pad; + text->size += text_pad; } obj_datasec (abfd)->filepos = (obj_textsec (abfd)->filepos - + obj_textsec (abfd)->_raw_size); + + obj_textsec (abfd)->size); /* Fix up exec header while we're at it. */ - execp->a_text = obj_textsec (abfd)->_raw_size; + execp->a_text = obj_textsec (abfd)->size; if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted))) execp->a_text += adata (abfd).exec_bytes_size; if (obj_aout_subformat (abfd) == q_magic_format) @@ -1051,17 +1050,17 @@ adjust_z_magic (abfd, execp) N_SET_MAGIC (*execp, ZMAGIC); /* Spec says data section should be rounded up to page boundary. */ - obj_datasec (abfd)->_raw_size - = align_power (obj_datasec (abfd)->_raw_size, + obj_datasec (abfd)->size + = align_power (obj_datasec (abfd)->size, obj_bsssec (abfd)->alignment_power); - execp->a_data = BFD_ALIGN (obj_datasec (abfd)->_raw_size, + execp->a_data = BFD_ALIGN (obj_datasec (abfd)->size, adata (abfd).page_size); - data_pad = execp->a_data - obj_datasec (abfd)->_raw_size; + data_pad = execp->a_data - obj_datasec (abfd)->size; /* BSS. */ if (!obj_bsssec (abfd)->user_set_vma) obj_bsssec (abfd)->vma = (obj_datasec (abfd)->vma - + obj_datasec (abfd)->_raw_size); + + obj_datasec (abfd)->size); /* If the BSS immediately follows the data section and extra space in the page is left after the data section, fudge data in the header so that the bss section looks smaller by that @@ -1070,11 +1069,11 @@ adjust_z_magic (abfd, execp) could have explicitly set the BSS vma to immediately follow the data section.) */ if (align_power (obj_bsssec (abfd)->vma, obj_bsssec (abfd)->alignment_power) - == obj_datasec (abfd)->vma + obj_datasec (abfd)->_raw_size) - execp->a_bss = (data_pad > obj_bsssec (abfd)->_raw_size - ? 0 : obj_bsssec (abfd)->_raw_size - data_pad); + == obj_datasec (abfd)->vma + obj_datasec (abfd)->size) + execp->a_bss = (data_pad > obj_bsssec (abfd)->size + ? 0 : obj_bsssec (abfd)->size - data_pad); else - execp->a_bss = obj_bsssec (abfd)->_raw_size; + execp->a_bss = obj_bsssec (abfd)->size; } static void @@ -1092,8 +1091,8 @@ adjust_n_magic (abfd, execp) obj_textsec (abfd)->vma = vma; else vma = obj_textsec (abfd)->vma; - pos += obj_textsec (abfd)->_raw_size; - vma += obj_textsec (abfd)->_raw_size; + pos += obj_textsec (abfd)->size; + vma += obj_textsec (abfd)->size; /* Data. */ obj_datasec (abfd)->filepos = pos; @@ -1102,10 +1101,10 @@ adjust_n_magic (abfd, execp) vma = obj_datasec (abfd)->vma; /* Since BSS follows data immediately, see if it needs alignment. */ - vma += obj_datasec (abfd)->_raw_size; + vma += obj_datasec (abfd)->size; pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma; - obj_datasec (abfd)->_raw_size += pad; - pos += obj_datasec (abfd)->_raw_size; + obj_datasec (abfd)->size += pad; + pos += obj_datasec (abfd)->size; /* BSS. */ if (!obj_bsssec (abfd)->user_set_vma) @@ -1114,9 +1113,9 @@ adjust_n_magic (abfd, execp) vma = obj_bsssec (abfd)->vma; /* Fix up exec header. */ - execp->a_text = obj_textsec (abfd)->_raw_size; - execp->a_data = obj_datasec (abfd)->_raw_size; - execp->a_bss = obj_bsssec (abfd)->_raw_size; + execp->a_text = obj_textsec (abfd)->size; + execp->a_data = obj_datasec (abfd)->size; + execp->a_bss = obj_bsssec (abfd)->size; N_SET_MAGIC (*execp, NMAGIC); } @@ -1134,11 +1133,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, if (adata (abfd).magic != undecided_magic) return TRUE; - obj_textsec (abfd)->_raw_size = - align_power (obj_textsec (abfd)->_raw_size, + obj_textsec (abfd)->size = + align_power (obj_textsec (abfd)->size, obj_textsec (abfd)->alignment_power); - *text_size = obj_textsec (abfd)->_raw_size; + *text_size = obj_textsec (abfd)->size; /* Rule (heuristic) for when to pad to a new page. Note that there are (at least) two ways demand-paged (ZMAGIC) files have been handled. Most Berkeley-based systems start the text segment at @@ -1176,11 +1175,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, } str; }), - obj_textsec (abfd)->vma, obj_textsec (abfd)->_raw_size, + obj_textsec (abfd)->vma, obj_textsec (abfd)->size, obj_textsec (abfd)->alignment_power, - obj_datasec (abfd)->vma, obj_datasec (abfd)->_raw_size, + obj_datasec (abfd)->vma, obj_datasec (abfd)->size, obj_datasec (abfd)->alignment_power, - obj_bsssec (abfd)->vma, obj_bsssec (abfd)->_raw_size, + obj_bsssec (abfd)->vma, obj_bsssec (abfd)->size, obj_bsssec (abfd)->alignment_power); #endif #endif @@ -1202,11 +1201,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, #ifdef BFD_AOUT_DEBUG fprintf (stderr, " text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n", - obj_textsec (abfd)->vma, obj_textsec (abfd)->_raw_size, + obj_textsec (abfd)->vma, obj_textsec (abfd)->size, obj_textsec (abfd)->filepos, - obj_datasec (abfd)->vma, obj_datasec (abfd)->_raw_size, + obj_datasec (abfd)->vma, obj_datasec (abfd)->size, obj_datasec (abfd)->filepos, - obj_bsssec (abfd)->vma, obj_bsssec (abfd)->_raw_size); + obj_bsssec (abfd)->vma, obj_bsssec (abfd)->size); #endif return TRUE; @@ -1580,8 +1579,8 @@ translate_from_native_sym_flags (abfd, c reloc->next = section->constructor_chain; section->constructor_chain = reloc; - reloc->relent.address = section->_raw_size; - section->_raw_size += BYTES_IN_WORD; + reloc->relent.address = section->size; + section->size += BYTES_IN_WORD; reloc->relent.howto = CTOR_TABLE_RELOC_HOWTO (abfd); @@ -3784,10 +3783,10 @@ NAME(aout,final_link) (abfd, info, callb if (bfd_get_flavour (sub) == bfd_target_aout_flavour) { - sz = bfd_section_size (sub, obj_textsec (sub)); + sz = obj_textsec (sub)->size; if (sz > max_contents_size) max_contents_size = sz; - sz = bfd_section_size (sub, obj_datasec (sub)); + sz = obj_datasec (sub)->size; if (sz > max_contents_size) max_contents_size = sz; @@ -4742,7 +4741,7 @@ aout_link_input_section (finfo, input_bf PTR relocs; /* Get the section contents. */ - input_size = bfd_section_size (input_bfd, input_section); + input_size = input_section->size; if (! bfd_get_section_contents (input_bfd, input_section, (PTR) finfo->contents, (file_ptr) 0, input_size)) Index: bfd/bfd-in.h =================================================================== RCS file: /cvs/src/src/bfd/bfd-in.h,v retrieving revision 1.82 diff -u -p -r1.82 bfd-in.h --- bfd/bfd-in.h 17 Jun 2004 11:47:17 -0000 1.82 +++ bfd/bfd-in.h 22 Jun 2004 01:35:00 -0000 @@ -308,8 +308,8 @@ typedef struct bfd_section *sec_ptr; #define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0) #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) #define bfd_section_name(bfd, ptr) ((ptr)->name) -#define bfd_section_size(bfd, ptr) ((ptr)->_raw_size) -#define bfd_get_section_size(ptr) ((ptr)->_raw_size) +#define bfd_section_size(bfd, ptr) ((ptr)->size) +#define bfd_get_section_size(ptr) ((ptr)->size) #define bfd_section_vma(bfd, ptr) ((ptr)->vma) #define bfd_section_lma(bfd, ptr) ((ptr)->lma) #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) Index: bfd/binary.c =================================================================== RCS file: /cvs/src/src/bfd/binary.c,v retrieving revision 1.21 diff -u -p -r1.21 binary.c --- bfd/binary.c 30 Apr 2004 14:23:39 -0000 1.21 +++ bfd/binary.c 22 Jun 2004 01:35:00 -0000 @@ -99,7 +99,7 @@ binary_object_p (abfd) return NULL; sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS; sec->vma = 0; - sec->_raw_size = statbuf.st_size; + sec->size = statbuf.st_size; sec->filepos = 0; abfd->tdata.any = (PTR) sec; @@ -200,7 +200,7 @@ binary_canonicalize_symtab (abfd, alocat /* End symbol. */ syms[1].the_bfd = abfd; syms[1].name = mangle_name (abfd, "end"); - syms[1].value = sec->_raw_size; + syms[1].value = sec->size; syms[1].flags = BSF_GLOBAL; syms[1].section = sec; syms[1].udata.p = NULL; @@ -208,7 +208,7 @@ binary_canonicalize_symtab (abfd, alocat /* Size symbol. */ syms[2].the_bfd = abfd; syms[2].name = mangle_name (abfd, "size"); - syms[2].value = sec->_raw_size; + syms[2].value = sec->size; syms[2].flags = BSF_GLOBAL; syms[2].section = bfd_abs_section_ptr; syms[2].udata.p = NULL; @@ -278,7 +278,7 @@ binary_set_section_contents (abfd, sec, if (((s->flags & (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_NEVER_LOAD)) == (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC)) - && (s->_raw_size > 0) + && (s->size > 0) && (! found_low || s->lma < low)) { low = s->lma; @@ -294,7 +294,7 @@ binary_set_section_contents (abfd, sec, if ((s->flags & (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_NEVER_LOAD)) != (SEC_HAS_CONTENTS | SEC_ALLOC) - || (s->_raw_size == 0)) + || (s->size == 0)) continue; /* If attempting to generate a binary file from a bfd with Index: bfd/bout.c =================================================================== RCS file: /cvs/src/src/bfd/bout.c,v retrieving revision 1.20 diff -u -p -r1.20 bout.c --- bfd/bout.c 15 Jun 2004 01:24:22 -0000 1.20 +++ bfd/bout.c 22 Jun 2004 01:35:01 -0000 @@ -200,7 +200,7 @@ b_out_callback (abfd) obj_datasec (abfd)->lma = obj_datasec (abfd)->vma; /* And reload the sizes, since the aout module zaps them. */ - obj_textsec (abfd)->_raw_size = execp->a_text; + obj_textsec (abfd)->size = execp->a_text; bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */ obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign); @@ -294,9 +294,9 @@ b_out_write_object_contents (abfd) exec_hdr (abfd)->a_info = BMAGIC; - exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size; - exec_hdr (abfd)->a_data = obj_datasec (abfd)->_raw_size; - exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_raw_size; + exec_hdr (abfd)->a_text = obj_textsec (abfd)->size; + exec_hdr (abfd)->a_data = obj_datasec (abfd)->size; + exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->size; exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist); exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd); exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) * @@ -995,7 +995,7 @@ b_out_set_section_contents (abfd, sectio obj_textsec (abfd)->filepos = sizeof (struct internal_exec); obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos - + obj_textsec (abfd)->_raw_size; + + obj_textsec (abfd)->size; } /* Regardless, once we know what we're doing, we might as well get going. */ @@ -1285,7 +1285,7 @@ b_out_bfd_relax_section (abfd, i, link_i } } } - input_section->_cooked_size = input_section->_raw_size - shrink; + input_section->size -= shrink; if (reloc_vector != NULL) free (reloc_vector); @@ -1333,7 +1333,7 @@ b_out_bfd_get_relocated_section_contents input_section, data, (bfd_vma) 0, - input_section->_raw_size)); + input_section->size)); reloc_count = bfd_canonicalize_reloc (input_bfd, input_section, @@ -1402,7 +1402,7 @@ b_out_bfd_get_relocated_section_contents case ALIGNDONE: BFD_ASSERT (reloc->addend >= src_address); BFD_ASSERT ((bfd_vma) reloc->addend - <= input_section->_raw_size); + <= input_section->size); src_address = reloc->addend; dst_address = ((dst_address + reloc->howto->size) & ~reloc->howto->size); Index: bfd/cisco-core.c =================================================================== RCS file: /cvs/src/src/bfd/cisco-core.c,v retrieving revision 1.8 diff -u -p -r1.8 cisco-core.c --- bfd/cisco-core.c 30 Nov 2002 08:39:35 -0000 1.8 +++ bfd/cisco-core.c 22 Jun 2004 01:35:01 -0000 @@ -1,5 +1,5 @@ /* BFD back-end for CISCO crash dumps. - Copyright 1994, 1997, 1999, 2000, 2001, 2002 + Copyright 1994, 1997, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -246,7 +246,7 @@ cisco_core_file_validate (abfd, crash_in goto error_return; asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; /* The size of memory is the size of the core file itself. */ - asect->_raw_size = statbuf.st_size; + asect->size = statbuf.st_size; asect->vma = rambase; asect->filepos = 0; @@ -259,7 +259,7 @@ cisco_core_file_validate (abfd, crash_in asect->flags = SEC_HAS_CONTENTS; asect->vma = 0; asect->filepos = crashinfo_offset; - asect->_raw_size = sizeof (crashinfo); + asect->size = sizeof (crashinfo); /* Create a ".reg" section to allow access to the saved registers. */ @@ -274,7 +274,7 @@ cisco_core_file_validate (abfd, crash_in choose a register section size that is either the remaining part of the file, or 1024, whichever is smaller. */ nread = statbuf.st_size - asect->filepos; - asect->_raw_size = (nread < 1024) ? nread : 1024; + asect->size = (nread < 1024) ? nread : 1024; return abfd->xvec; Index: bfd/coff-alpha.c =================================================================== RCS file: /cvs/src/src/bfd/coff-alpha.c,v retrieving revision 1.22 diff -u -p -r1.22 coff-alpha.c --- bfd/coff-alpha.c 15 Jun 2004 01:24:22 -0000 1.22 +++ bfd/coff-alpha.c 22 Jun 2004 01:35:02 -0000 @@ -462,8 +462,8 @@ alpha_ecoff_object_p (abfd) bfd_size_type size; size = sec->line_filepos * 8; - BFD_ASSERT (size == bfd_section_size (abfd, sec) - || size + 8 == bfd_section_size (abfd, sec)); + BFD_ASSERT (size == sec->size + || size + 8 == sec->size); if (! bfd_set_section_size (abfd, sec, size)) return NULL; } @@ -768,6 +768,7 @@ alpha_ecoff_get_relocated_section_conten long reloc_count; bfd *output_bfd = relocatable ? abfd : (bfd *) NULL; bfd_vma gp; + bfd_size_type sz; bfd_boolean gp_undefined; bfd_vma stack[RELOC_STACKSIZE]; int tos = 0; @@ -778,13 +779,10 @@ alpha_ecoff_get_relocated_section_conten if (reloc_vector == NULL && reloc_size != 0) goto error_return; - if (! bfd_get_section_contents (input_bfd, input_section, data, - (file_ptr) 0, input_section->_raw_size)) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (! bfd_get_section_contents (input_bfd, input_section, data, 0, sz)) goto error_return; - /* The section size is not going to change. */ - input_section->_cooked_size = input_section->_raw_size; - reloc_count = bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector, symbols); if (reloc_count < 0) @@ -1469,9 +1467,7 @@ alpha_relocate_section (output_bfd, info bfd_size_type lita_size; lita_vma = lita_sec->output_offset + lita_sec->output_section->vma; - lita_size = lita_sec->_cooked_size; - if (lita_size == 0) - lita_size = lita_sec->_raw_size; + lita_size = lita_sec->size; if (gp == 0 || lita_vma < gp - 0x8000 Index: bfd/coff-arm.c =================================================================== RCS file: /cvs/src/src/bfd/coff-arm.c,v retrieving revision 1.51 diff -u -p -r1.51 coff-arm.c --- bfd/coff-arm.c 9 Jan 2004 13:59:55 -0000 1.51 +++ bfd/coff-arm.c 22 Jun 2004 01:35:04 -0000 @@ -1,6 +1,6 @@ /* BFD back-end for ARM COFF files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003 + 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Cygnus Support. @@ -1635,8 +1635,12 @@ coff_arm_relocate_section (output_bfd, i code. */ bfd_vma address = rel->r_vaddr - input_section->vma; + bfd_size_type sz; - if (address > input_section->_raw_size) + sz = (input_section->rawsize + ? input_section->rawsize + : input_section->size); + if (address > sz) rstat = bfd_reloc_outofrange; else { @@ -1858,7 +1862,7 @@ bfd_arm_allocate_interworking_sections ( memset (foo, test_char, (size_t) globals->arm_glue_size); #endif - s->_raw_size = s->_cooked_size = globals->arm_glue_size; + s->size = globals->arm_glue_size; s->contents = foo; } @@ -1877,7 +1881,7 @@ bfd_arm_allocate_interworking_sections ( memset (foo, test_char, (size_t) globals->thumb_glue_size); #endif - s->_raw_size = s->_cooked_size = globals->thumb_glue_size; + s->size = globals->thumb_glue_size; s->contents = foo; } Index: bfd/coff-h8300.c =================================================================== RCS file: /cvs/src/src/bfd/coff-h8300.c,v retrieving revision 1.30 diff -u -p -r1.30 coff-h8300.c --- bfd/coff-h8300.c 9 Feb 2004 12:15:57 -0000 1.30 +++ bfd/coff-h8300.c 22 Jun 2004 01:35:05 -0000 @@ -1231,7 +1231,7 @@ h8300_reloc16_extra_cases (bfd *abfd, st vectors_sec->output_section, vectors_sec->contents, (file_ptr) vectors_sec->output_offset, - vectors_sec->_raw_size); + vectors_sec->size); break; } @@ -1394,11 +1394,11 @@ h8300_bfd_link_add_symbols (bfd *abfd, s case bfd_mach_h8300: case bfd_mach_h8300hn: case bfd_mach_h8300sn: - htab->vectors_sec->_raw_size += 2; + htab->vectors_sec->size += 2; break; case bfd_mach_h8300h: case bfd_mach_h8300s: - htab->vectors_sec->_raw_size += 4; + htab->vectors_sec->size += 4; break; default: abort (); @@ -1414,14 +1414,14 @@ h8300_bfd_link_add_symbols (bfd *abfd, s /* Now actually allocate some space for the function vector. It's wasteful to do this more than once, but this is easier. */ sec = htab->vectors_sec; - if (sec->_raw_size != 0) + if (sec->size != 0) { /* Free the old contents. */ if (sec->contents) free (sec->contents); /* Allocate new contents. */ - sec->contents = bfd_malloc (sec->_raw_size); + sec->contents = bfd_malloc (sec->size); } return TRUE; Index: bfd/coff-mips.c =================================================================== RCS file: /cvs/src/src/bfd/coff-mips.c,v retrieving revision 1.24 diff -u -p -r1.24 coff-mips.c --- bfd/coff-mips.c 30 Apr 2004 14:23:39 -0000 1.24 +++ bfd/coff-mips.c 22 Jun 2004 01:35:06 -0000 @@ -473,6 +473,7 @@ mips_refhi_reloc (abfd, { bfd_reloc_status_type ret; bfd_vma relocation; + bfd_size_type sz; struct mips_hi *n; /* If we're relocating, and this an external symbol, we don't want @@ -499,7 +500,8 @@ mips_refhi_reloc (abfd, relocation += symbol->section->output_offset; relocation += reloc_entry->addend; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Save the information, and let REFLO do the actual relocation. */ @@ -608,6 +610,7 @@ mips_gprel_reloc (abfd, bfd_boolean relocatable; bfd_vma gp; bfd_vma relocation; + bfd_size_type sz; unsigned long val; unsigned long insn; @@ -697,7 +700,8 @@ mips_gprel_reloc (abfd, relocation += symbol->section->output_section->vma; relocation += symbol->section->output_offset; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); Index: bfd/coff-ppc.c =================================================================== RCS file: /cvs/src/src/bfd/coff-ppc.c,v retrieving revision 1.19 diff -u -p -r1.19 coff-ppc.c --- bfd/coff-ppc.c 24 Nov 2003 18:06:40 -0000 1.19 +++ bfd/coff-ppc.c 22 Jun 2004 01:35:07 -0000 @@ -1,6 +1,6 @@ /* BFD back-end for PowerPC Microsoft Portable Executable files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003 + 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Original version pieced together by Kim Knuttila (krk@cygnus.com) @@ -1330,12 +1330,12 @@ coff_ppc_relocate_section (output_bfd, i /* FIXME: this test is conservative. */ if ((r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN - && (bfd_vma) our_toc_offset > toc_section->_raw_size) + && (bfd_vma) our_toc_offset > toc_section->size) { (*_bfd_error_handler) (_("%s: Relocation exceeds allocated TOC (%lx)"), bfd_archive_filename (input_bfd), - (unsigned long) toc_section->_raw_size); + (unsigned long) toc_section->size); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1690,7 +1690,7 @@ ppc_allocate_toc_section (info) foo = (bfd_byte *) bfd_alloc (bfd_of_toc_owner, amt); memset(foo, test_char, (size_t) global_toc_size); - s->_raw_size = s->_cooked_size = global_toc_size; + s->size = global_toc_size; s->contents = foo; return TRUE; @@ -2328,8 +2328,8 @@ ppc_bfd_coff_final_link (abfd, info) if (info->relocatable) o->reloc_count += sec->reloc_count; - if (sec->_raw_size > max_contents_size) - max_contents_size = sec->_raw_size; + if (sec->size > max_contents_size) + max_contents_size = sec->size; if (sec->lineno_count > max_lineno_count) max_lineno_count = sec->lineno_count; if (sec->reloc_count > max_reloc_count) Index: bfd/coff-rs6000.c =================================================================== RCS file: /cvs/src/src/bfd/coff-rs6000.c,v retrieving revision 1.60 diff -u -p -r1.60 coff-rs6000.c --- bfd/coff-rs6000.c 17 May 2004 16:40:00 -0000 1.60 +++ bfd/coff-rs6000.c 22 Jun 2004 01:35:09 -0000 @@ -2948,8 +2948,7 @@ xcoff_reloc_type_br (input_bfd, input_se cror. */ if (NULL != h && bfd_link_hash_defined == h->root.type - && (rel->r_vaddr - input_section->vma + 8 - <= input_section->_cooked_size)) + && rel->r_vaddr - input_section->vma + 8 <= input_section->size) { bfd_byte *pnext; unsigned long next; @@ -3449,7 +3448,7 @@ xcoff_ppc_relocate_section (output_bfd, address = rel->r_vaddr - input_section->vma; location = contents + address; - if (address > input_section->_raw_size) + if (address > input_section->size) abort (); /* Get the value we are going to relocate. */ Index: bfd/coff-sh.c =================================================================== RCS file: /cvs/src/src/bfd/coff-sh.c,v retrieving revision 1.26 diff -u -p -r1.26 coff-sh.c --- bfd/coff-sh.c 11 Oct 2003 13:08:44 -0000 1.26 +++ bfd/coff-sh.c 22 Jun 2004 01:35:11 -0000 @@ -1,6 +1,6 @@ /* BFD back-end for Renesas Super-H COFF binaries. - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, + 2003, 2004 Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Steve Chamberlain, . Relaxing code written by Ian Lance Taylor, . @@ -698,11 +698,9 @@ sh_relax_section (abfd, sec, link_info, bfd_boolean *again; { struct internal_reloc *internal_relocs; - struct internal_reloc *free_relocs = NULL; bfd_boolean have_code; struct internal_reloc *irel, *irelend; bfd_byte *contents = NULL; - bfd_byte *free_contents = NULL; *again = FALSE; @@ -711,10 +709,13 @@ sh_relax_section (abfd, sec, link_info, || sec->reloc_count == 0) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; + if (coff_section_data (abfd, sec) == NULL) + { + bfd_size_type amt = sizeof (struct coff_section_tdata); + sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); + if (sec->used_by_bfd == NULL) + return FALSE; + } internal_relocs = (_bfd_coff_read_internal_relocs (abfd, sec, link_info->keep_memory, @@ -722,8 +723,6 @@ sh_relax_section (abfd, sec, link_info, (struct internal_reloc *) NULL)); if (internal_relocs == NULL) goto error_return; - if (! link_info->keep_memory) - free_relocs = internal_relocs; have_code = FALSE; @@ -745,18 +744,11 @@ sh_relax_section (abfd, sec, link_info, /* Get the section contents. */ if (contents == NULL) { - if (coff_section_data (abfd, sec) != NULL - && coff_section_data (abfd, sec)->contents != NULL) + if (coff_section_data (abfd, sec)->contents != NULL) contents = coff_section_data (abfd, sec)->contents; else { - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - free_contents = contents; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -768,7 +760,7 @@ sh_relax_section (abfd, sec, link_info, laddr = irel->r_vaddr - sec->vma + 4; /* Careful to sign extend the 32-bit offset. */ laddr += ((irel->r_offset & 0xffffffff) ^ 0x80000000) - 0x80000000; - if (laddr >= sec->_raw_size) + if (laddr >= sec->size) { (*_bfd_error_handler) ("%s: 0x%lx: warning: bad R_SH_USES offset", bfd_archive_filename (abfd), @@ -795,7 +787,7 @@ sh_relax_section (abfd, sec, link_info, paddr = insn & 0xff; paddr *= 4; paddr += (laddr + 4) &~ (bfd_vma) 3; - if (paddr >= sec->_raw_size) + if (paddr >= sec->size) { ((*_bfd_error_handler) ("%s: 0x%lx: warning: bad R_SH_USES load offset", @@ -812,11 +804,12 @@ sh_relax_section (abfd, sec, link_info, #ifdef COFF_WITH_PE && (irelfn->r_type == R_SH_IMM32 || irelfn->r_type == R_SH_IMM32CE - || irelfn->r_type == R_SH_IMAGEBASE)) + || irelfn->r_type == R_SH_IMAGEBASE) #else - && irelfn->r_type == R_SH_IMM32) + && irelfn->r_type == R_SH_IMM32 #endif + ) break; if (irelfn >= irelend) { @@ -894,21 +887,11 @@ sh_relax_section (abfd, sec, link_info, that would be more work, but would require less memory when the linker is run. */ - if (coff_section_data (abfd, sec) == NULL) - { - bfd_size_type amt = sizeof (struct coff_section_tdata); - sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); - if (sec->used_by_bfd == NULL) - goto error_return; - } - coff_section_data (abfd, sec)->relocs = internal_relocs; coff_section_data (abfd, sec)->keep_relocs = TRUE; - free_relocs = NULL; coff_section_data (abfd, sec)->contents = contents; coff_section_data (abfd, sec)->keep_contents = TRUE; - free_contents = NULL; obj_coff_keep_syms (abfd) = TRUE; @@ -1011,18 +994,11 @@ sh_relax_section (abfd, sec, link_info, /* Get the section contents. */ if (contents == NULL) { - if (coff_section_data (abfd, sec) != NULL - && coff_section_data (abfd, sec)->contents != NULL) + if (coff_section_data (abfd, sec)->contents != NULL) contents = coff_section_data (abfd, sec)->contents; else { - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - free_contents = contents; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -1032,58 +1008,42 @@ sh_relax_section (abfd, sec, link_info, if (swapped) { - if (coff_section_data (abfd, sec) == NULL) - { - bfd_size_type amt = sizeof (struct coff_section_tdata); - sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); - if (sec->used_by_bfd == NULL) - goto error_return; - } - coff_section_data (abfd, sec)->relocs = internal_relocs; coff_section_data (abfd, sec)->keep_relocs = TRUE; - free_relocs = NULL; coff_section_data (abfd, sec)->contents = contents; coff_section_data (abfd, sec)->keep_contents = TRUE; - free_contents = NULL; obj_coff_keep_syms (abfd) = TRUE; } } - if (free_relocs != NULL) + if (internal_relocs != NULL + && internal_relocs != coff_section_data (abfd, sec)->relocs) { - free (free_relocs); - free_relocs = NULL; + if (! link_info->keep_memory) + free (internal_relocs); + else + coff_section_data (abfd, sec)->relocs = internal_relocs; } - if (free_contents != NULL) + if (contents != NULL && contents != coff_section_data (abfd, sec)->contents) { if (! link_info->keep_memory) - free (free_contents); + free (contents); else - { - /* Cache the section contents for coff_link_input_bfd. */ - if (coff_section_data (abfd, sec) == NULL) - { - bfd_size_type amt = sizeof (struct coff_section_tdata); - sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); - if (sec->used_by_bfd == NULL) - goto error_return; - coff_section_data (abfd, sec)->relocs = NULL; - } - coff_section_data (abfd, sec)->contents = contents; - } + /* Cache the section contents for coff_link_input_bfd. */ + coff_section_data (abfd, sec)->contents = contents; } return TRUE; error_return: - if (free_relocs != NULL) - free (free_relocs); - if (free_contents != NULL) - free (free_contents); + if (internal_relocs != NULL + && internal_relocs != coff_section_data (abfd, sec)->relocs) + free (internal_relocs); + if (contents != NULL && contents != coff_section_data (abfd, sec)->contents) + free (contents); return FALSE; } @@ -1111,7 +1071,7 @@ sh_relax_delete_bytes (abfd, sec, addr, power larger than the number of bytes we are deleting. */ irelalign = NULL; - toaddr = sec->_cooked_size; + toaddr = sec->size; irel = coff_section_data (abfd, sec)->relocs; irelend = irel + sec->reloc_count; @@ -1131,7 +1091,7 @@ sh_relax_delete_bytes (abfd, sec, addr, memmove (contents + addr, contents + addr + count, (size_t) (toaddr - addr - count)); if (irelalign == NULL) - sec->_cooked_size -= count; + sec->size -= count; else { int i; @@ -1443,17 +1403,12 @@ sh_relax_delete_bytes (abfd, sec, addr, ocontents = coff_section_data (abfd, o)->contents; else { + if (!bfd_malloc_and_get_section (abfd, o, &ocontents)) + return FALSE; /* We always cache the section contents. Perhaps, if info->keep_memory is FALSE, we should free them, if we are permitted to, when we leave sh_coff_relax_section. */ - ocontents = (bfd_byte *) bfd_malloc (o->_raw_size); - if (ocontents == NULL) - return FALSE; - if (! bfd_get_section_contents (abfd, o, ocontents, - (file_ptr) 0, - o->_raw_size)) - return FALSE; coff_section_data (abfd, o)->contents = ocontents; } } @@ -2694,7 +2649,7 @@ sh_align_loads (abfd, sec, internal_relo if (irel < irelend) stop = irel->r_vaddr - sec->vma; else - stop = sec->_cooked_size; + stop = sec->size; if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_swap_insns, (PTR) internal_relocs, &label, @@ -3046,7 +3001,7 @@ sh_coff_get_relocated_section_contents ( symbols); memcpy (data, coff_section_data (input_bfd, input_section)->contents, - (size_t) input_section->_raw_size); + (size_t) input_section->size); if ((input_section->flags & SEC_RELOC) != 0 && input_section->reloc_count > 0) Index: bfd/coff64-rs6000.c =================================================================== RCS file: /cvs/src/src/bfd/coff64-rs6000.c,v retrieving revision 1.52 diff -u -p -r1.52 coff64-rs6000.c --- bfd/coff64-rs6000.c 15 Jun 2004 01:24:22 -0000 1.52 +++ bfd/coff64-rs6000.c 22 Jun 2004 01:35:12 -0000 @@ -845,11 +845,11 @@ xcoff64_write_object_contents (abfd) section.s_vaddr = current->vma; section.s_paddr = current->lma; - section.s_size = current->_raw_size; + section.s_size = current->size; /* If this section has no size or is unloadable then the scnptr will be 0 too. */ - if (current->_raw_size == 0 + if (current->size == 0 || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) { section.s_scnptr = 0; @@ -965,19 +965,19 @@ xcoff64_write_object_contents (abfd) if (text_sec) { - internal_a.tsize = bfd_get_section_size (text_sec); + internal_a.tsize = text_sec->size; internal_a.text_start = internal_a.tsize ? text_sec->vma : 0; } if (data_sec) { - internal_a.dsize = bfd_get_section_size (data_sec); + internal_a.dsize = data_sec->size; internal_a.data_start = internal_a.dsize ? data_sec->vma : 0; } if (bss_sec) { - internal_a.bsize = bfd_get_section_size (bss_sec); + internal_a.bsize = bss_sec->size; if (internal_a.bsize && bss_sec->vma < internal_a.data_start) internal_a.data_start = bss_sec->vma; } @@ -1127,8 +1127,7 @@ xcoff64_reloc_type_br (input_bfd, input_ cror. */ if (NULL != h && bfd_link_hash_defined == h->root.type - && (rel->r_vaddr - input_section->vma + 8 - <= input_section->_cooked_size)) + && rel->r_vaddr - input_section->vma + 8 <= input_section->size) { bfd_byte *pnext; unsigned long next; @@ -1301,7 +1300,7 @@ xcoff64_ppc_relocate_section (output_bfd address = rel->r_vaddr - input_section->vma; location = contents + address; - if (address > input_section->_raw_size) + if (address > input_section->size) abort (); /* Get the value we are going to relocate. */ Index: bfd/coffcode.h =================================================================== RCS file: /cvs/src/src/bfd/coffcode.h,v retrieving revision 1.107 diff -u -p -r1.107 coffcode.h --- bfd/coffcode.h 21 Jun 2004 14:40:41 -0000 1.107 +++ bfd/coffcode.h 22 Jun 2004 01:35:15 -0000 @@ -3023,7 +3023,7 @@ coff_compute_section_file_positions (abf dsec = bfd_make_section_old_way (abfd, DOT_DEBUG); if (dsec == NULL) abort (); - dsec->_raw_size = sz; + dsec->size = sz; dsec->flags |= SEC_HAS_CONTENTS; } } @@ -3122,7 +3122,7 @@ coff_compute_section_file_positions (abf a zero size and having real contents are different concepts: .bss has no contents, but (usually) non-zero size. */ - if (current->_raw_size == 0) + if (current->size == 0) { /* Discard. However, it still might have (valid) symbols in it, so arbitrarily set it to section 1 (indexing is @@ -3173,7 +3173,7 @@ coff_compute_section_file_positions (abf return FALSE; } if (pei_section_data (abfd, current)->virt_size == 0) - pei_section_data (abfd, current)->virt_size = current->_raw_size; + pei_section_data (abfd, current)->virt_size = current->size; #endif /* Only deal with sections which have contents. */ @@ -3182,7 +3182,7 @@ coff_compute_section_file_positions (abf #ifdef COFF_IMAGE_WITH_PE /* Make sure we skip empty sections in a PE image. */ - if (current->_raw_size == 0) + if (current->size == 0) continue; #endif @@ -3230,7 +3230,7 @@ coff_compute_section_file_positions (abf } #endif if (previous != (asection *) NULL) - previous->_raw_size += sofar - old_sofar; + previous->size += sofar - old_sofar; } #endif @@ -3246,10 +3246,10 @@ coff_compute_section_file_positions (abf #ifdef COFF_IMAGE_WITH_PE /* Set the padded size. */ - current->_raw_size = (current->_raw_size + page_size -1) & -page_size; + current->size = (current->size + page_size -1) & -page_size; #endif - sofar += current->_raw_size; + sofar += current->size; #ifdef ALIGN_SECTIONS_IN_FILE /* Make sure that this section is of the right size too. */ @@ -3257,26 +3257,26 @@ coff_compute_section_file_positions (abf { bfd_size_type old_size; - old_size = current->_raw_size; - current->_raw_size = BFD_ALIGN (current->_raw_size, - 1 << current->alignment_power); - align_adjust = current->_raw_size != old_size; - sofar += current->_raw_size - old_size; + old_size = current->size; + current->size = BFD_ALIGN (current->size, + 1 << current->alignment_power); + align_adjust = current->size != old_size; + sofar += current->size - old_size; } else { old_sofar = sofar; sofar = BFD_ALIGN (sofar, 1 << current->alignment_power); align_adjust = sofar != old_sofar; - current->_raw_size += sofar - old_sofar; + current->size += sofar - old_sofar; } #endif #ifdef COFF_IMAGE_WITH_PE /* For PE we need to make sure we pad out to the aligned - _raw_size, in case the caller only writes out data to the - unaligned _raw_size. */ - if (pei_section_data (abfd, current)->virt_size < current->_raw_size) + size, in case the caller only writes out data to the + unaligned size. */ + if (pei_section_data (abfd, current)->virt_size < current->size) align_adjust = TRUE; #endif @@ -3648,7 +3648,7 @@ coff_write_object_contents (abfd) #endif section.s_vaddr = current->vma; section.s_paddr = current->lma; - section.s_size = current->_raw_size; + section.s_size = current->size; #ifdef coff_get_section_load_page section.s_page = coff_get_section_load_page (current); #endif @@ -3667,8 +3667,8 @@ coff_write_object_contents (abfd) /* If this section has no size or is unloadable then the scnptr will be 0 too. */ - if (current->_raw_size == 0 || - (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) + if (current->size == 0 + || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) section.s_scnptr = 0; else section.s_scnptr = current->filepos; @@ -4140,17 +4140,17 @@ coff_write_object_contents (abfd) if (text_sec) { - internal_a.tsize = bfd_get_section_size (text_sec); + internal_a.tsize = text_sec->size; internal_a.text_start = internal_a.tsize ? text_sec->vma : 0; } if (data_sec) { - internal_a.dsize = bfd_get_section_size (data_sec); + internal_a.dsize = data_sec->size; internal_a.data_start = internal_a.dsize ? data_sec->vma : 0; } if (bss_sec) { - internal_a.bsize = bfd_get_section_size (bss_sec); + internal_a.bsize = bss_sec->size; if (internal_a.bsize && bss_sec->vma < internal_a.data_start) internal_a.data_start = bss_sec->vma; } Index: bfd/coffgen.c =================================================================== RCS file: /cvs/src/src/bfd/coffgen.c,v retrieving revision 1.42 diff -u -p -r1.42 coffgen.c --- bfd/coffgen.c 15 Jun 2004 01:24:22 -0000 1.42 +++ bfd/coffgen.c 22 Jun 2004 01:35:16 -0000 @@ -131,7 +131,7 @@ make_a_section_from_file (abfd, hdr, tar return_section->vma = hdr->s_vaddr; return_section->lma = hdr->s_paddr; - return_section->_raw_size = hdr->s_size; + return_section->size = hdr->s_size; return_section->filepos = hdr->s_scnptr; return_section->rel_filepos = hdr->s_relptr; return_section->reloc_count = hdr->s_nreloc; @@ -1344,7 +1344,7 @@ coff_write_symbols (abfd) || (debug_string_section != (asection *) NULL && (BFD_ALIGN (debug_string_size, 1 << debug_string_section->alignment_power) - == bfd_section_size (abfd, debug_string_section)))); + == debug_string_section->size))); return TRUE; } @@ -1455,7 +1455,7 @@ coff_section_symbol (abfd, name) csym[0].u.syment.n_sclass = C_STAT; csym[0].u.syment.n_numaux = 1; /* SF_SET_STATICS (sym); @@ ??? */ - csym[1].u.auxent.x_scn.x_scnlen = sec->_raw_size; + csym[1].u.auxent.x_scn.x_scnlen = sec->size; csym[1].u.auxent.x_scn.x_nreloc = sec->reloc_count; csym[1].u.auxent.x_scn.x_nlinno = sec->lineno_count; @@ -1537,7 +1537,7 @@ build_debug_section (abfd) return NULL; } - sec_size = bfd_get_section_size (sect); + sec_size = sect->size; debug_section = (PTR) bfd_alloc (abfd, sec_size); if (debug_section == NULL) return NULL; Index: bfd/cofflink.c =================================================================== RCS file: /cvs/src/src/bfd/cofflink.c,v retrieving revision 1.43 diff -u -p -r1.43 cofflink.c --- bfd/cofflink.c 24 Nov 2003 18:06:40 -0000 1.43 +++ bfd/cofflink.c 22 Jun 2004 01:35:18 -0000 @@ -1,6 +1,6 @@ /* COFF specific linker code. - Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, + 2004 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -551,8 +551,8 @@ coff_link_add_symbols (bfd *abfd, For example, it won't help objdump. This needs to be done when we swap in the section header. */ BFD_ASSERT ((*sym_hash)->numaux == 1); - if (section->_raw_size == 0) - section->_raw_size = (*sym_hash)->aux[0].x_scn.x_scnlen; + if (section->size == 0) + section->size = (*sym_hash)->aux[0].x_scn.x_scnlen; /* FIXME: We could test whether the section sizes matches the size in the aux entry, but apparently @@ -714,8 +714,10 @@ _bfd_coff_final_link (bfd *abfd, if (info->relocatable) o->reloc_count += sec->reloc_count; - if (sec->_raw_size > max_contents_size) - max_contents_size = sec->_raw_size; + if (sec->rawsize > max_contents_size) + max_contents_size = sec->rawsize; + if (sec->size > max_contents_size) + max_contents_size = sec->size; if (sec->lineno_count > max_lineno_count) max_lineno_count = sec->lineno_count; if (sec->reloc_count > max_reloc_count) @@ -1208,21 +1210,18 @@ process_embedded_commands (bfd *output_b asection *sec = bfd_get_section_by_name (abfd, ".drectve"); char *s; char *e; - char *copy; + bfd_byte *copy; if (!sec) return 1; - copy = bfd_malloc (sec->_raw_size); - if (!copy) - return 0; - - if (! bfd_get_section_contents (abfd, sec, copy, (bfd_vma) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, ©)) { - free (copy); + if (copy != NULL) + free (copy); return 0; } - e = copy + sec->_raw_size; + e = copy + sec->size; for (s = copy; s < e ; ) { @@ -2284,7 +2283,7 @@ _bfd_coff_link_input_bfd (struct coff_fi continue; if ((o->flags & SEC_HAS_CONTENTS) == 0 - || (o->_raw_size == 0 && (o->flags & SEC_RELOC) == 0)) + || (o->size == 0 && (o->flags & SEC_RELOC) == 0)) { if ((o->flags & SEC_RELOC) != 0 && o->reloc_count != 0) @@ -2305,8 +2304,8 @@ _bfd_coff_link_input_bfd (struct coff_fi contents = secdata->contents; else { - if (! bfd_get_section_contents (input_bfd, o, finfo->contents, - (file_ptr) 0, o->_raw_size)) + bfd_size_type x = o->rawsize ? o->rawsize : o->size; + if (! bfd_get_section_contents (input_bfd, o, finfo->contents, 0, x)) return FALSE; contents = finfo->contents; } @@ -2431,10 +2430,8 @@ _bfd_coff_link_input_bfd (struct coff_fi if (secdata == NULL || secdata->stab_info == NULL) { file_ptr loc = o->output_offset * bfd_octets_per_byte (output_bfd); - bfd_size_type amt = (o->_cooked_size != 0 - ? o->_cooked_size : o->_raw_size); if (! bfd_set_section_contents (output_bfd, o->output_section, - contents, loc, amt)) + contents, loc, o->size)) return FALSE; } else @@ -2616,9 +2613,7 @@ _bfd_coff_write_global_sym (struct coff_ sec = h->root.u.def.section->output_section; if (sec != NULL) { - auxp->x_scn.x_scnlen = (sec->_cooked_size != 0 - ? sec->_cooked_size - : sec->_raw_size); + auxp->x_scn.x_scnlen = sec->size; /* For PE, an overflow on the final link reportedly does not matter. FIXME: Why not? */ Index: bfd/cpu-arm.c =================================================================== RCS file: /cvs/src/src/bfd/cpu-arm.c,v retrieving revision 1.12 diff -u -p -r1.12 cpu-arm.c --- bfd/cpu-arm.c 24 Nov 2003 18:06:40 -0000 1.12 +++ bfd/cpu-arm.c 22 Jun 2004 01:35:22 -0000 @@ -1,5 +1,6 @@ /* BFD support for the ARM processor - Copyright 1994, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright 1994, 1997, 1999, 2000, 2002, 2003, 2004 + Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) This file is part of BFD, the Binary File Descriptor library. @@ -286,7 +287,7 @@ bfd_arm_update_notes (abfd, note_section { asection * arm_arch_section; bfd_size_type buffer_size; - char * buffer; + bfd_byte * buffer; char * arch_string; char * expected; @@ -298,16 +299,11 @@ bfd_arm_update_notes (abfd, note_section if (arm_arch_section == NULL) return TRUE; - buffer_size = arm_arch_section->_raw_size; + buffer_size = arm_arch_section->size; if (buffer_size == 0) return FALSE; - buffer = bfd_malloc (buffer_size); - if (buffer == NULL) - return FALSE; - - if (! bfd_get_section_contents (abfd, arm_arch_section, buffer, - (file_ptr) 0, buffer_size)) + if (!bfd_malloc_and_get_section (abfd, arm_arch_section, &buffer)) goto FAIL; /* Parse the note. */ @@ -351,7 +347,8 @@ bfd_arm_update_notes (abfd, note_section return TRUE; FAIL: - free (buffer); + if (buffer != NULL) + free (buffer); return FALSE; } @@ -385,7 +382,7 @@ bfd_arm_get_mach_from_notes (abfd, note_ { asection * arm_arch_section; bfd_size_type buffer_size; - char * buffer; + bfd_byte * buffer; char * arch_string; int i; @@ -397,16 +394,11 @@ bfd_arm_get_mach_from_notes (abfd, note_ if (arm_arch_section == NULL) return bfd_mach_arm_unknown; - buffer_size = arm_arch_section->_raw_size; + buffer_size = arm_arch_section->size; if (buffer_size == 0) return bfd_mach_arm_unknown; - buffer = bfd_malloc (buffer_size); - if (buffer == NULL) - return bfd_mach_arm_unknown; - - if (! bfd_get_section_contents (abfd, arm_arch_section, buffer, - (file_ptr) 0, buffer_size)) + if (!bfd_malloc_and_get_section (abfd, arm_arch_section, &buffer)) goto FAIL; /* Parse the note. */ @@ -422,6 +414,7 @@ bfd_arm_get_mach_from_notes (abfd, note_ } FAIL: - free (buffer); + if (buffer != NULL) + free (buffer); return bfd_mach_arm_unknown; } Index: bfd/cpu-ns32k.c =================================================================== RCS file: /cvs/src/src/bfd/cpu-ns32k.c,v retrieving revision 1.13 diff -u -p -r1.13 cpu-ns32k.c --- bfd/cpu-ns32k.c 24 Nov 2003 18:06:40 -0000 1.13 +++ bfd/cpu-ns32k.c 22 Jun 2004 01:35:22 -0000 @@ -1,5 +1,5 @@ /* BFD support for the ns32k architecture. - Copyright 1990, 1991, 1994, 1995, 1998, 2000, 2001, 2002, 2003 + Copyright 1990, 1991, 1994, 1995, 1998, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Almost totally rewritten by Ian Dall from initial work by Andrew Cagney. @@ -170,6 +170,7 @@ do_ns32k_reloc (abfd, reloc_entry, symbo bfd_vma relocation; bfd_reloc_status_type flag = bfd_reloc_ok; bfd_size_type addr = reloc_entry->address; + bfd_size_type sz; bfd_vma output_base = 0; reloc_howto_type *howto = reloc_entry->howto; asection *reloc_target_output_section; @@ -191,7 +192,8 @@ do_ns32k_reloc (abfd, reloc_entry, symbo flag = bfd_reloc_undefined; /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Work out which section the relocation is targeted at and the @@ -802,9 +804,11 @@ _bfd_ns32k_final_link_relocate (howto, i bfd_vma addend; { bfd_vma relocation; + bfd_size_type sz; /* Sanity check the address. */ - if (address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (address > sz) return bfd_reloc_outofrange; /* This function assumes that we are dealing with a basic relocation Index: bfd/dwarf1.c =================================================================== RCS file: /cvs/src/src/bfd/dwarf1.c,v retrieving revision 1.12 diff -u -p -r1.12 dwarf1.c --- bfd/dwarf1.c 15 Jun 2004 01:24:22 -0000 1.12 +++ bfd/dwarf1.c 22 Jun 2004 01:35:22 -0000 @@ -285,14 +285,14 @@ parse_line_table (stash, aUnit) if (! msec) return FALSE; - size = bfd_get_section_size (msec); + size = msec->rawsize ? msec->rawsize : msec->size; stash->line_section = (char *) bfd_alloc (stash->abfd, size); if (! stash->line_section) return FALSE; if (! bfd_get_section_contents (stash->abfd, msec, stash->line_section, - (bfd_vma) 0, size)) + 0, size)) { stash->line_section = 0; return FALSE; @@ -502,14 +502,14 @@ _bfd_dwarf1_find_nearest_line (abfd, sec return FALSE; } - size = bfd_get_section_size (msec); + size = msec->rawsize ? msec->rawsize : msec->size; stash->debug_section = (char *) bfd_alloc (abfd, size); if (! stash->debug_section) return FALSE; if (! bfd_get_section_contents (abfd, msec, stash->debug_section, - (bfd_vma) 0, size)) + 0, size)) { stash->debug_section = 0; return FALSE; Index: bfd/dwarf2.c =================================================================== RCS file: /cvs/src/src/bfd/dwarf2.c,v retrieving revision 1.56 diff -u -p -r1.56 dwarf2.c --- bfd/dwarf2.c 21 May 2004 01:58:03 -0000 1.56 +++ bfd/dwarf2.c 22 Jun 2004 01:35:24 -0000 @@ -281,6 +281,7 @@ read_indirect_string (struct comp_unit* { asection *msec; bfd *abfd = unit->abfd; + bfd_size_type sz; msec = bfd_get_section_by_name (abfd, ".debug_str"); if (! msec) @@ -291,13 +292,14 @@ read_indirect_string (struct comp_unit* return NULL; } - stash->dwarf_str_size = msec->_raw_size; - stash->dwarf_str_buffer = bfd_alloc (abfd, msec->_raw_size); + sz = msec->rawsize ? msec->rawsize : msec->size; + stash->dwarf_str_size = sz; + stash->dwarf_str_buffer = bfd_alloc (abfd, sz); if (! stash->dwarf_abbrev_buffer) return NULL; if (! bfd_get_section_contents (abfd, msec, stash->dwarf_str_buffer, - 0, msec->_raw_size)) + 0, sz)) return NULL; } @@ -443,7 +445,7 @@ read_abbrevs (bfd *abfd, bfd_uint64_t of return 0; } - stash->dwarf_abbrev_size = msec->_raw_size; + stash->dwarf_abbrev_size = msec->size; stash->dwarf_abbrev_buffer = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, stash->syms); @@ -921,7 +923,7 @@ decode_line_info (struct comp_unit *unit return 0; } - stash->dwarf_line_size = msec->_raw_size; + stash->dwarf_line_size = msec->size; stash->dwarf_line_buffer = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, stash->syms); @@ -1744,7 +1746,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd In the second pass we read in the section's contents. The allows us to avoid reallocing the data as we add sections to the stash. */ for (total_size = 0; msec; msec = find_debug_info (abfd, msec)) - total_size += msec->_raw_size; + total_size += msec->size; stash->info_ptr = bfd_alloc (abfd, total_size); if (stash->info_ptr == NULL) @@ -1759,7 +1761,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd bfd_size_type size; bfd_size_type start; - size = msec->_raw_size; + size = msec->size; if (size == 0) continue; @@ -1833,7 +1835,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd stash->info_ptr += length; if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr) - == stash->sec->_raw_size) + == stash->sec->size) { stash->sec = find_debug_info (abfd, stash->sec); stash->sec_info_ptr = stash->info_ptr; Index: bfd/ecoff.c =================================================================== RCS file: /cvs/src/src/bfd/ecoff.c,v retrieving revision 1.34 diff -u -p -r1.34 ecoff.c --- bfd/ecoff.c 15 Jun 2004 01:24:22 -0000 1.34 +++ bfd/ecoff.c 22 Jun 2004 01:35:26 -0000 @@ -74,19 +74,18 @@ static unsigned int ecoff_armap_hash PARAMS ((const char *, unsigned int *, unsigned int, unsigned int)); /* This stuff is somewhat copied from coffcode.h. */ - static asection bfd_debug_section = { - /* name, id, index, next, flags, user_set_vma, */ - "*DEBUG*", 0, 0, NULL, 0, 0, + /* name, id, index, next, flags, user_set_vma, */ + "*DEBUG*", 0, 0, NULL, 0, 0, /* linker_mark, linker_has_input, gc_mark, segment_mark, */ 0, 0, 0, 0, /* sec_info_type, use_rela_p, has_tls_reloc, has_gp_reloc, */ 0, 0, 0, 0, /* need_finalize_relax, reloc_done, */ 0, 0, - /* vma, lma, _cooked_size, _raw_size, */ - 0, 0, 0, 0, + /* vma, lma, size, rawsize, */ + 0, 0, 0, 0, /* output_offset, output_section, alignment_power, */ 0, NULL, 0, /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ @@ -906,7 +905,7 @@ ecoff_set_symbol_info (abfd, ecoff_sym, return FALSE; reloc_chain->relent.sym_ptr_ptr = bfd_get_section (asym)->symbol_ptr_ptr; - reloc_chain->relent.address = section->_raw_size; + reloc_chain->relent.address = section->size; reloc_chain->relent.addend = asym->value; reloc_chain->relent.howto = ecoff_backend (abfd)->constructor_reloc; @@ -926,7 +925,7 @@ ecoff_set_symbol_info (abfd, ecoff_sym, reloc_chain->next = section->constructor_chain; section->constructor_chain = reloc_chain; - section->_raw_size += bitsize / 8; + section->size += bitsize / 8; #endif /* 0 */ @@ -2116,7 +2115,7 @@ ecoff_compute_section_file_positions (ab really in the section. Each entry is 8 bytes. We store this away in line_filepos before increasing the section size. */ if (strcmp (current->name, _PDATA) == 0) - current->line_filepos = current->_raw_size / 8; + current->line_filepos = current->size / 8; alignment_power = current->alignment_power; @@ -2177,16 +2176,16 @@ ecoff_compute_section_file_positions (ab if ((current->flags & (SEC_HAS_CONTENTS | SEC_LOAD)) != 0) current->filepos = file_sofar; - sofar += current->_raw_size; + sofar += current->size; if ((current->flags & SEC_HAS_CONTENTS) != 0) - file_sofar += current->_raw_size; + file_sofar += current->size; /* Make sure that this section is of the right size too. */ old_sofar = sofar; sofar = BFD_ALIGN (sofar, 1 << alignment_power); if ((current->flags & SEC_HAS_CONTENTS) != 0) file_sofar = BFD_ALIGN (file_sofar, 1 << alignment_power); - current->_raw_size += sofar - old_sofar; + current->size += sofar - old_sofar; } free (sorted_hdrs); @@ -2548,7 +2547,7 @@ _bfd_ecoff_write_object_contents (abfd) section.s_vaddr = vma; section.s_paddr = current->lma; - section.s_size = bfd_get_section_size (current); + section.s_size = current->size; /* If this section is unloadable then the scnptr will be 0. */ if ((current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) @@ -2599,7 +2598,7 @@ _bfd_ecoff_write_object_contents (abfd) || (section.s_flags & STYP_ECOFF_FINI) != 0 || section.s_flags == STYP_RCONST) { - text_size += bfd_get_section_size (current); + text_size += current->size; if (! set_text_start || text_start > vma) { text_start = vma; @@ -2615,7 +2614,7 @@ _bfd_ecoff_write_object_contents (abfd) || section.s_flags == STYP_XDATA || (section.s_flags & STYP_GOT) != 0) { - data_size += bfd_get_section_size (current); + data_size += current->size; if (! set_data_start || data_start > vma) { data_start = vma; @@ -2624,7 +2623,7 @@ _bfd_ecoff_write_object_contents (abfd) } else if ((section.s_flags & STYP_BSS) != 0 || (section.s_flags & STYP_SBSS) != 0) - bss_size += bfd_get_section_size (current); + bss_size += current->size; else if (section.s_flags == 0 || (section.s_flags & STYP_ECOFF_LIB) != 0 || section.s_flags == STYP_COMMENT) @@ -4524,13 +4523,10 @@ ecoff_indirect_link_order (output_bfd, i { asection *input_section; bfd *input_bfd; - bfd_size_type raw_size; - bfd_size_type cooked_size; bfd_byte *contents = NULL; bfd_size_type external_reloc_size; bfd_size_type external_relocs_size; PTR external_relocs = NULL; - bfd_size_type amt; BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0); @@ -4540,25 +4536,12 @@ ecoff_indirect_link_order (output_bfd, i input_section = link_order->u.indirect.section; input_bfd = input_section->owner; - raw_size = input_section->_raw_size; - cooked_size = input_section->_cooked_size; - if (cooked_size == 0) - cooked_size = raw_size; - BFD_ASSERT (input_section->output_section == output_section); BFD_ASSERT (input_section->output_offset == link_order->offset); - BFD_ASSERT (cooked_size == link_order->size); - - /* Get the section contents. We allocate memory for the larger of - the size before relocating and the size after relocating. */ - amt = raw_size >= cooked_size ? raw_size : cooked_size; - contents = (bfd_byte *) bfd_malloc (amt); - if (contents == NULL && amt != 0) - goto error_return; + BFD_ASSERT (input_section->size == link_order->size); - if (! bfd_get_section_contents (input_bfd, input_section, - (PTR) contents, - (file_ptr) 0, raw_size)) + /* Get the section contents. */ + if (!bfd_malloc_and_get_section (input_bfd, input_section, &contents)) goto error_return; /* Get the relocs. If we are relaxing MIPS code, they will already @@ -4584,9 +4567,9 @@ ecoff_indirect_link_order (output_bfd, i /* Write out the relocated section. */ if (! bfd_set_section_contents (output_bfd, output_section, - (PTR) contents, - (file_ptr) input_section->output_offset, - cooked_size)) + contents, + input_section->output_offset, + input_section->size)) goto error_return; /* If we are producing relocatable output, the relocs were Index: bfd/elf-eh-frame.c =================================================================== RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v retrieving revision 1.30 diff -u -p -r1.30 elf-eh-frame.c --- bfd/elf-eh-frame.c 13 May 2004 15:16:00 -0000 1.30 +++ bfd/elf-eh-frame.c 22 Jun 2004 01:35:27 -0000 @@ -224,7 +224,7 @@ _bfd_elf_discard_section_eh_frame bfd_size_type new_size; unsigned int ptr_size; - if (sec->_raw_size == 0) + if (sec->size == 0) { /* This file does not contain .eh_frame information. */ return FALSE; @@ -243,14 +243,10 @@ _bfd_elf_discard_section_eh_frame /* Read the frame unwind information from abfd. */ - ehbuf = bfd_malloc (sec->_raw_size); - if (ehbuf == NULL) + if (!bfd_malloc_and_get_section (abfd, sec, &ehbuf)) goto free_no_table; - if (! bfd_get_section_contents (abfd, sec, ehbuf, 0, sec->_raw_size)) - goto free_no_table; - - if (sec->_raw_size >= 4 + if (sec->size >= 4 && bfd_get_32 (abfd, ehbuf) == 0 && cookie->rel == cookie->relend) { @@ -261,7 +257,7 @@ _bfd_elf_discard_section_eh_frame /* If .eh_frame section size doesn't fit into int, we cannot handle it (it would need to use 64-bit .eh_frame format anyway). */ - if (sec->_raw_size != (unsigned int) sec->_raw_size) + if (sec->size != (unsigned int) sec->size) goto free_no_table; ptr_size = (elf_elfheader (abfd)->e_ident[EI_CLASS] @@ -271,13 +267,14 @@ _bfd_elf_discard_section_eh_frame last_cie_ndx = 0; memset (&cie, 0, sizeof (cie)); cie_usage_count = 0; - new_size = sec->_raw_size; + new_size = sec->size; make_relative = hdr_info->last_cie.make_relative; make_lsda_relative = hdr_info->last_cie.make_lsda_relative; sec_info = bfd_zmalloc (sizeof (struct eh_frame_sec_info) + 99 * sizeof (struct eh_cie_fde)); if (sec_info == NULL) goto free_no_table; + sec_info->alloced = 100; #define ENSURE_NO_RELOCS(buf) \ @@ -320,11 +317,11 @@ _bfd_elf_discard_section_eh_frame last_fde = buf; /* If we are at the end of the section, we still need to decide on whether to output or discard last encountered CIE (if any). */ - if ((bfd_size_type) (buf - ehbuf) == sec->_raw_size) + if ((bfd_size_type) (buf - ehbuf) == sec->size) hdr.id = (unsigned int) -1; else { - if ((bfd_size_type) (buf + 4 - ehbuf) > sec->_raw_size) + if ((bfd_size_type) (buf + 4 - ehbuf) > sec->size) /* No space for CIE/FDE header length. */ goto free_no_table; @@ -333,7 +330,7 @@ _bfd_elf_discard_section_eh_frame /* 64-bit .eh_frame is not supported. */ goto free_no_table; buf += 4; - if ((bfd_size_type) (buf - ehbuf) + hdr.length > sec->_raw_size) + if ((bfd_size_type) (buf - ehbuf) + hdr.length > sec->size) /* CIE/FDE not contained fully in this .eh_frame input section. */ goto free_no_table; @@ -343,7 +340,7 @@ _bfd_elf_discard_section_eh_frame if (hdr.length == 0) { /* CIE with length 0 must be only the last in the section. */ - if ((bfd_size_type) (buf - ehbuf) < sec->_raw_size) + if ((bfd_size_type) (buf - ehbuf) < sec->size) goto free_no_table; ENSURE_NO_RELOCS (buf); sec_info->count++; @@ -640,18 +637,14 @@ _bfd_elf_discard_section_eh_frame hdr_info->last_cie_offset = sec_info->entry[last_cie_ndx].new_offset; } - /* FIXME: Currently it is not possible to shrink sections to zero size at - this point, so build a fake minimal CIE. */ - if (new_size == 0) - new_size = 16; - /* Shrink the sec as needed. */ - sec->_cooked_size = new_size; - if (sec->_cooked_size == 0) + sec->rawsize = sec->size; + sec->size = new_size; + if (sec->size == 0) sec->flags |= SEC_EXCLUDE; free (ehbuf); - return new_size != sec->_raw_size; + return new_size != sec->rawsize; free_no_table: if (ehbuf) @@ -680,9 +673,9 @@ _bfd_elf_discard_section_eh_frame_hdr (b if (sec == NULL) return FALSE; - sec->_cooked_size = EH_FRAME_HDR_SIZE; + sec->size = EH_FRAME_HDR_SIZE; if (hdr_info->table) - sec->_cooked_size += 4 + hdr_info->fde_count * 8; + sec->size += 4 + hdr_info->fde_count * 8; /* Request program headers to be recalculated. */ elf_tdata (abfd)->program_header_size = 0; @@ -721,7 +714,7 @@ _bfd_elf_maybe_strip_eh_frame_hdr (struc /* Count only sections which have at least a single CIE or FDE. There cannot be any CIE or FDE <= 8 bytes. */ o = bfd_get_section_by_name (abfd, ".eh_frame"); - if (o && o->_raw_size > 8 && !bfd_is_abs_section (o->output_section)) + if (o && o->size > 8 && !bfd_is_abs_section (o->output_section)) break; } @@ -753,8 +746,8 @@ _bfd_elf_eh_frame_section_offset (bfd *o return offset; sec_info = elf_section_data (sec)->sec_info; - if (offset >= sec->_raw_size) - return offset - (sec->_cooked_size - sec->_raw_size); + if (offset >= sec->rawsize) + return offset - sec->rawsize + sec->size; lo = 0; hi = sec_info->count; @@ -819,7 +812,7 @@ _bfd_elf_write_section_eh_frame (bfd *ab if (sec->sec_info_type != ELF_INFO_TYPE_EH_FRAME) return bfd_set_section_contents (abfd, sec->output_section, contents, - sec->output_offset, sec->_raw_size); + sec->output_offset, sec->size); sec_info = elf_section_data (sec)->sec_info; htab = elf_hash_table (info); hdr_info = &htab->eh_info; @@ -1022,27 +1015,15 @@ _bfd_elf_write_section_eh_frame (bfd *ab p += sec_info->entry[i].size; } - /* FIXME: Once _bfd_elf_discard_section_eh_frame will be able to - shrink sections to zero size, this won't be needed any more. */ - if (p == contents && sec->_cooked_size == 16) - { - bfd_put_32 (abfd, 12, p); /* Fake CIE length */ - bfd_put_32 (abfd, 0, p + 4); /* Fake CIE id */ - p[8] = 1; /* Fake CIE version */ - memset (p + 9, 0, 7); /* Fake CIE augmentation, 3xleb128 - and 3xDW_CFA_nop as pad */ - p += 16; - } - else { unsigned int alignment = 1 << sec->alignment_power; - unsigned int pad = sec->_cooked_size % alignment; + unsigned int pad = sec->size % alignment; /* Don't pad beyond the raw size of the output section. It can happen at the last input section. */ if (pad - && ((sec->output_offset + sec->_cooked_size + pad) - <= sec->output_section->_raw_size)) + && ((sec->output_offset + sec->size + pad) + <= sec->output_section->size)) { /* Find the last CIE/FDE. */ for (i = sec_info->count - 1; i > 0; i--) @@ -1066,15 +1047,15 @@ _bfd_elf_write_section_eh_frame (bfd *ab memset (p, 0, pad); p += pad; - sec->_cooked_size += pad; + sec->size += pad; } } - BFD_ASSERT ((bfd_size_type) (p - contents) == sec->_cooked_size); + BFD_ASSERT ((bfd_size_type) (p - contents) == sec->size); return bfd_set_section_contents (abfd, sec->output_section, contents, (file_ptr) sec->output_offset, - sec->_cooked_size); + sec->size); } /* Helper function used to sort .eh_frame_hdr search table by increasing @@ -1185,7 +1166,7 @@ _bfd_elf_write_section_eh_frame_hdr (bfd retval = bfd_set_section_contents (abfd, sec->output_section, contents, (file_ptr) sec->output_offset, - sec->_cooked_size); + sec->size); free (contents); return retval; } Index: bfd/elf-hppa.h =================================================================== RCS file: /cvs/src/src/bfd/elf-hppa.h,v retrieving revision 1.72 diff -u -p -r1.72 elf-hppa.h --- bfd/elf-hppa.h 27 Mar 2004 10:58:05 -0000 1.72 +++ bfd/elf-hppa.h 22 Jun 2004 01:35:27 -0000 @@ -1042,16 +1042,12 @@ static bfd_boolean elf_hppa_sort_unwind if (s != NULL) { bfd_size_type size; - char *contents; + bfd_byte *contents; - size = s->_raw_size; - contents = bfd_malloc (size); - if (contents == NULL) - return FALSE; - - if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size)) + if (!bfd_malloc_and_get_section (abfd, s, &contents)) return FALSE; + size = s->size; qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare); if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size)) Index: bfd/elf-m10200.c =================================================================== RCS file: /cvs/src/src/bfd/elf-m10200.c,v retrieving revision 1.26 diff -u -p -r1.26 elf-m10200.c --- bfd/elf-m10200.c 22 Mar 2004 02:28:15 -0000 1.26 +++ bfd/elf-m10200.c 22 Jun 2004 01:35:28 -0000 @@ -505,11 +505,6 @@ mn10200_elf_relax_section (abfd, sec, li || (sec->flags & SEC_CODE) == 0) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; /* Get a copy of the native relocations. */ @@ -541,12 +536,7 @@ mn10200_elf_relax_section (abfd, sec, li else { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -737,7 +727,7 @@ mn10200_elf_relax_section (abfd, sec, li value += irel->r_addend; /* Do nothing if this reloc is the last byte in the section. */ - if (irel->r_offset == sec->_cooked_size) + if (irel->r_offset == sec->size) continue; /* See if the next instruction is an unconditional pc-relative @@ -1189,7 +1179,7 @@ mn10200_elf_relax_delete_bytes (abfd, se power larger than the number of bytes we are deleting. */ irelalign = NULL; - toaddr = sec->_cooked_size; + toaddr = sec->size; irel = elf_section_data (sec)->relocs; irelend = irel + sec->reloc_count; @@ -1197,7 +1187,7 @@ mn10200_elf_relax_delete_bytes (abfd, se /* Actually delete the bytes. */ memmove (contents + addr, contents + addr + count, (size_t) (toaddr - addr - count)); - sec->_cooked_size -= count; + sec->size -= count; /* Adjust all the relocs. */ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++) @@ -1316,7 +1306,7 @@ mn10200_elf_get_relocated_section_conten symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; memcpy (data, elf_section_data (input_section)->this_hdr.contents, - (size_t) input_section->_raw_size); + (size_t) input_section->size); if ((input_section->flags & SEC_RELOC) != 0 && input_section->reloc_count > 0) Index: bfd/elf-m10300.c =================================================================== RCS file: /cvs/src/src/bfd/elf-m10300.c,v retrieving revision 1.53 diff -u -p -r1.53 elf-m10300.c --- bfd/elf-m10300.c 9 Jun 2004 08:31:28 -0000 1.53 +++ bfd/elf-m10300.c 22 Jun 2004 01:35:30 -0000 @@ -656,7 +656,7 @@ _bfd_mn10300_elf_create_got_section (abf elf_hash_table (info)->hgot = h; /* The first bit of the global offset table is the header. */ - s->_raw_size += bed->got_header_size + bed->got_symbol_offset; + s->size += bed->got_header_size + bed->got_symbol_offset; return TRUE; } @@ -817,7 +817,7 @@ mn10300_elf_check_relocs (abfd, info, se /* We have already allocated space in the .got. */ break; - h->got.offset = sgot->_raw_size; + h->got.offset = sgot->size; /* Make sure this symbol is output as a dynamic symbol. */ if (h->dynindx == -1) @@ -826,7 +826,7 @@ mn10300_elf_check_relocs (abfd, info, se return FALSE; } - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } else { @@ -852,16 +852,16 @@ mn10300_elf_check_relocs (abfd, info, se /* We have already allocated space in the .got. */ break; - local_got_offsets[r_symndx] = sgot->_raw_size; + local_got_offsets[r_symndx] = sgot->size; if (info->shared) /* If we are generating a shared object, we need to output a R_MN10300_RELATIVE reloc so that the dynamic linker can adjust this GOT entry. */ - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } - sgot->_raw_size += 4; + sgot->size += 4; break; @@ -954,7 +954,7 @@ mn10300_elf_check_relocs (abfd, info, se } } - sreloc->_raw_size += sizeof (Elf32_External_Rela); + sreloc->size += sizeof (Elf32_External_Rela); /* If we are linking with -Bsymbolic, and this is a global symbol, we count the number of PC relative @@ -1056,7 +1056,7 @@ mn10300_elf_final_link_relocate (howto, bfd_vma addend; struct elf_link_hash_entry * h; unsigned long symndx; - struct bfd_link_info *info ATTRIBUTE_UNUSED; + struct bfd_link_info *info; asection *sym_sec ATTRIBUTE_UNUSED; int is_local ATTRIBUTE_UNUSED; { @@ -1112,22 +1112,10 @@ mn10300_elf_final_link_relocate (howto, skip = FALSE; - if (elf_section_data (input_section)->sec_info == NULL - || (input_section->sec_info_type != ELF_INFO_TYPE_STABS)) - outrel.r_offset = offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, & elf_hash_table (info)->stab_info, - input_section, - & elf_section_data (input_section)->sec_info, - offset)); - if (off == (bfd_vma) -1) - skip = TRUE; - outrel.r_offset = off; - } + outrel.r_offset = _bfd_elf_section_offset (input_bfd, info, + input_section, offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = TRUE; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); @@ -1265,23 +1253,10 @@ mn10300_elf_final_link_relocate (howto, } skip = FALSE; - - if (elf_section_data (input_section)->sec_info == NULL - || (input_section->sec_info_type != ELF_INFO_TYPE_STABS)) - outrel.r_offset = offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, & elf_hash_table (info)->stab_info, - input_section, - & elf_section_data (input_section)->sec_info, - offset)); - if (off == (bfd_vma) -1) - skip = TRUE; - outrel.r_offset = off; - } + outrel.r_offset = _bfd_elf_section_offset (input_bfd, info, + input_section, offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = TRUE; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); @@ -1868,16 +1843,11 @@ mn10300_elf_relax_section (abfd, sec, li /* Get cached copy of section contents if it exists. */ if (elf_section_data (section)->this_hdr.contents != NULL) contents = elf_section_data (section)->this_hdr.contents; - else if (section->_raw_size != 0) + else if (section->size != 0) { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (section->_raw_size); - if (contents == NULL) - goto error_return; - - if (!bfd_get_section_contents (input_bfd, section, - contents, (file_ptr) 0, - section->_raw_size)) + if (!bfd_malloc_and_get_section (input_bfd, section, + &contents)) goto error_return; } else @@ -2168,7 +2138,7 @@ mn10300_elf_relax_section (abfd, sec, li unsigned int symcount; /* Skip non-code sections and empty sections. */ - if ((section->flags & SEC_CODE) == 0 || section->_raw_size == 0) + if ((section->flags & SEC_CODE) == 0 || section->size == 0) continue; if (section->reloc_count != 0) @@ -2188,13 +2158,8 @@ mn10300_elf_relax_section (abfd, sec, li else { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (section->_raw_size); - if (contents == NULL) - goto error_return; - - if (!bfd_get_section_contents (input_bfd, section, - contents, (file_ptr) 0, - section->_raw_size)) + if (!bfd_malloc_and_get_section (input_bfd, section, + &contents)) goto error_return; } @@ -2396,11 +2361,6 @@ mn10300_elf_relax_section (abfd, sec, li || (sec->flags & SEC_CODE) == 0) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; /* Get a copy of the native relocations. */ @@ -2433,12 +2393,7 @@ mn10300_elf_relax_section (abfd, sec, li else { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -2792,7 +2747,7 @@ mn10300_elf_relax_section (abfd, sec, li value += irel->r_addend; /* Do nothing if this reloc is the last byte in the section. */ - if (irel->r_offset == sec->_cooked_size) + if (irel->r_offset == sec->size) continue; /* See if the next instruction is an unconditional pc-relative @@ -3625,7 +3580,7 @@ mn10300_elf_relax_delete_bytes (abfd, se power larger than the number of bytes we are deleting. */ irelalign = NULL; - toaddr = sec->_cooked_size; + toaddr = sec->size; irel = elf_section_data (sec)->relocs; irelend = irel + sec->reloc_count; @@ -3633,7 +3588,7 @@ mn10300_elf_relax_delete_bytes (abfd, se /* Actually delete the bytes. */ memmove (contents + addr, contents + addr + count, (size_t) (toaddr - addr - count)); - sec->_cooked_size -= count; + sec->size -= count; /* Adjust all the relocs. */ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++) @@ -3752,7 +3707,7 @@ mn10300_elf_get_relocated_section_conten symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; memcpy (data, elf_section_data (input_section)->this_hdr.contents, - (size_t) input_section->_raw_size); + (size_t) input_section->size); if ((input_section->flags & SEC_RELOC) != 0 && input_section->reloc_count > 0) @@ -4231,8 +4186,8 @@ _bfd_mn10300_elf_adjust_dynamic_symbol ( /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += elf_mn10300_sizeof_plt0 (info); + if (s->size == 0) + s->size += elf_mn10300_sizeof_plt0 (info); /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -4243,26 +4198,26 @@ _bfd_mn10300_elf_adjust_dynamic_symbol ( && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) { h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; } - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* Make room for this entry. */ - s->_raw_size += elf_mn10300_sizeof_plt (info); + s->size += elf_mn10300_sizeof_plt (info); /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ s = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += 4; + s->size += 4; /* We also need to make an entry in the .rela.plt section. */ s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += sizeof (Elf32_External_Rela); + s->size += sizeof (Elf32_External_Rela); return TRUE; } @@ -4317,7 +4272,7 @@ _bfd_mn10300_elf_adjust_dynamic_symbol ( srel = bfd_get_section_by_name (dynobj, ".rela.bss"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -4328,8 +4283,7 @@ _bfd_mn10300_elf_adjust_dynamic_symbol ( power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (! bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -4338,10 +4292,10 @@ _bfd_mn10300_elf_adjust_dynamic_symbol ( /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -4368,7 +4322,7 @@ _bfd_mn10300_elf_discard_copies (h, info || info->symbolic)) { for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) - s->section->_raw_size -= s->count * sizeof (Elf32_External_Rel); + s->section->size -= s->count * sizeof (Elf32_External_Rel); } return TRUE; @@ -4397,7 +4351,7 @@ _bfd_mn10300_elf_size_dynamic_sections ( { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -4410,7 +4364,7 @@ _bfd_mn10300_elf_size_dynamic_sections ( below. */ s = bfd_get_section_by_name (dynobj, ".rela.got"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; } /* If this is a -Bsymbolic shared link, then we need to discard all @@ -4444,7 +4398,7 @@ _bfd_mn10300_elf_size_dynamic_sections ( if (strcmp (name, ".plt") == 0) { - if (s->_raw_size == 0) + if (s->size == 0) /* Strip this section if we don't need it; see the comment below. */ strip = TRUE; @@ -4454,7 +4408,7 @@ _bfd_mn10300_elf_size_dynamic_sections ( } else if (strncmp (name, ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -4513,8 +4467,8 @@ _bfd_mn10300_elf_size_dynamic_sections ( section's contents are written out. This should not happen, but this way if it does, we get a R_MN10300_NONE reloc instead of garbage. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -4761,7 +4715,7 @@ _bfd_mn10300_elf_finish_dynamic_sections BFD_ASSERT (sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { @@ -4792,10 +4746,7 @@ _bfd_mn10300_elf_finish_dynamic_sections case DT_PLTRELSZ: s = bfd_get_section_by_name (output_bfd, ".rela.plt"); BFD_ASSERT (s != NULL); - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -4811,12 +4762,7 @@ _bfd_mn10300_elf_finish_dynamic_sections about changing the DT_RELA entry. */ s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s != NULL) - { - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; - } + dyn.d_un.d_val -= s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; } @@ -4824,7 +4770,7 @@ _bfd_mn10300_elf_finish_dynamic_sections /* Fill in the first entry in the procedure linkage table. */ splt = bfd_get_section_by_name (dynobj, ".plt"); - if (splt && splt->_raw_size > 0) + if (splt && splt->size > 0) { if (info->shared) { @@ -4849,7 +4795,7 @@ _bfd_mn10300_elf_finish_dynamic_sections } /* Fill in the first three entries in the global offset table. */ - if (sgot->_raw_size > 0) + if (sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); Index: bfd/elf.c =================================================================== RCS file: /cvs/src/src/bfd/elf.c,v retrieving revision 1.230 diff -u -p -r1.230 elf.c --- bfd/elf.c 27 May 2004 05:53:35 -0000 1.230 +++ bfd/elf.c 22 Jun 2004 01:35:35 -0000 @@ -1030,10 +1030,7 @@ _bfd_elf_print_private_bfd_data (bfd *ab fprintf (f, _("\nDynamic Section:\n")); - dynbuf = bfd_malloc (s->_raw_size); - if (dynbuf == NULL) - goto error_return; - if (! bfd_get_section_contents (abfd, s, dynbuf, 0, s->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, s, &dynbuf)) goto error_return; elfsec = _bfd_elf_section_from_bfd_section (abfd, s); @@ -1045,7 +1042,7 @@ _bfd_elf_print_private_bfd_data (bfd *ab swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in; extdyn = dynbuf; - extdynend = extdyn + s->_raw_size; + extdynend = extdyn + s->size; for (; extdyn < extdynend; extdyn += extdynsize) { Elf_Internal_Dyn dyn; @@ -1584,14 +1581,10 @@ bfd_elf_get_bfd_needed_list (bfd *abfd, return TRUE; s = bfd_get_section_by_name (abfd, ".dynamic"); - if (s == NULL || s->_raw_size == 0) + if (s == NULL || s->size == 0) return TRUE; - dynbuf = bfd_malloc (s->_raw_size); - if (dynbuf == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, s, dynbuf, 0, s->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, s, &dynbuf)) goto error_return; elfsec = _bfd_elf_section_from_bfd_section (abfd, s); @@ -1604,7 +1597,7 @@ bfd_elf_get_bfd_needed_list (bfd *abfd, swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in; extdyn = dynbuf; - extdynend = extdyn + s->_raw_size; + extdynend = extdyn + s->size; for (; extdyn < extdynend; extdyn += extdynsize) { Elf_Internal_Dyn dyn; @@ -2236,7 +2229,7 @@ _bfd_elf_make_section_from_phdr (bfd *ab return FALSE; newsect->vma = hdr->p_vaddr; newsect->lma = hdr->p_paddr; - newsect->_raw_size = hdr->p_filesz; + newsect->size = hdr->p_filesz; newsect->filepos = hdr->p_offset; newsect->flags |= SEC_HAS_CONTENTS; newsect->alignment_power = bfd_log2 (hdr->p_align); @@ -2269,7 +2262,7 @@ _bfd_elf_make_section_from_phdr (bfd *ab return FALSE; newsect->vma = hdr->p_vaddr + hdr->p_filesz; newsect->lma = hdr->p_paddr + hdr->p_filesz; - newsect->_raw_size = hdr->p_memsz - hdr->p_filesz; + newsect->size = hdr->p_memsz - hdr->p_filesz; if (hdr->p_type == PT_LOAD) { newsect->flags |= SEC_ALLOC; @@ -2407,7 +2400,7 @@ elf_fake_sections (bfd *abfd, asection * this_hdr->sh_addr = 0; this_hdr->sh_offset = 0; - this_hdr->sh_size = asect->_raw_size; + this_hdr->sh_size = asect->size; this_hdr->sh_link = 0; this_hdr->sh_addralign = 1 << asect->alignment_power; /* The sh_entsize and sh_info fields may have been set already by @@ -2539,7 +2532,7 @@ elf_fake_sections (bfd *abfd, asection * if ((asect->flags & SEC_THREAD_LOCAL) != 0) { this_hdr->sh_flags |= SHF_TLS; - if (asect->_raw_size == 0 && (asect->flags & SEC_HAS_CONTENTS) == 0) + if (asect->size == 0 && (asect->flags & SEC_HAS_CONTENTS) == 0) { struct bfd_link_order *o; @@ -2605,7 +2598,7 @@ bfd_elf_set_group_contents (bfd *abfd, a if (sec->contents == NULL) { gas = FALSE; - sec->contents = bfd_alloc (abfd, sec->_raw_size); + sec->contents = bfd_alloc (abfd, sec->size); /* Arrange for the section to be written out. */ elf_section_data (sec)->this_hdr.contents = sec->contents; @@ -2616,7 +2609,7 @@ bfd_elf_set_group_contents (bfd *abfd, a } } - loc = sec->contents + sec->_raw_size; + loc = sec->contents + sec->size; /* Get the pointer to the first section in the group that gas squirreled away here. objcopy arranges for this to be set to the @@ -3423,7 +3416,7 @@ map_sections_to_segments (bfd *abfd) last_hdr = hdr; /* .tbss sections effectively have zero size. */ if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) != SEC_THREAD_LOCAL) - last_size = hdr->_raw_size; + last_size = hdr->size; else last_size = 0; continue; @@ -3447,7 +3440,7 @@ map_sections_to_segments (bfd *abfd) last_hdr = hdr; /* .tbss sections effectively have zero size. */ if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) != SEC_THREAD_LOCAL) - last_size = hdr->_raw_size; + last_size = hdr->size; else last_size = 0; phdr_index = i; @@ -3646,8 +3639,8 @@ elf_sort_sections (const void *arg1, con /* Sort by size, to put zero sized sections before others at the same address. */ - size1 = (sec1->flags & SEC_LOAD) ? sec1->_raw_size : 0; - size2 = (sec2->flags & SEC_LOAD) ? sec2->_raw_size : 0; + size1 = (sec1->flags & SEC_LOAD) ? sec1->size : 0; + size2 = (sec2->flags & SEC_LOAD) ? sec2->size : 0; if (size1 < size2) return -1; @@ -4027,12 +4020,12 @@ Error: First section in segment (%s) sta contents. */ if ((flags & SEC_LOAD) != 0 || (flags & SEC_HAS_CONTENTS) != 0) - off += sec->_raw_size; + off += sec->size; if ((flags & SEC_ALLOC) != 0 && ((flags & SEC_LOAD) != 0 || (flags & SEC_THREAD_LOCAL) == 0)) - voff += sec->_raw_size; + voff += sec->size; } if (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core) @@ -4042,15 +4035,15 @@ Error: First section in segment (%s) sta if (i == 0) { sec->filepos = off; - p->p_filesz = sec->_raw_size; - off += sec->_raw_size; + p->p_filesz = sec->size; + off += sec->size; voff = off; } else { /* Fake sections -- don't need to be written. */ sec->filepos = 0; - sec->_raw_size = 0; + sec->size = 0; flags = sec->flags = 0; } p->p_memsz = 0; @@ -4061,13 +4054,13 @@ Error: First section in segment (%s) sta if ((sec->flags & SEC_LOAD) != 0 || (sec->flags & SEC_THREAD_LOCAL) == 0 || p->p_type == PT_TLS) - p->p_memsz += sec->_raw_size; + p->p_memsz += sec->size; if ((flags & SEC_LOAD) != 0) - p->p_filesz += sec->_raw_size; + p->p_filesz += sec->size; if (p->p_type == PT_TLS - && sec->_raw_size == 0 + && sec->size == 0 && (sec->flags & SEC_HAS_CONTENTS) == 0) { struct bfd_link_order *o; @@ -4737,7 +4730,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *o #define SECTION_SIZE(section, segment) \ (((section->flags & (SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) \ != SEC_THREAD_LOCAL || segment->p_type == PT_TLS) \ - ? section->_raw_size : 0) + ? section->size : 0) /* Returns TRUE if the given section is contained within the given segment. VMA addresses are compared. */ @@ -4759,7 +4752,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *o && bfd_get_format (ibfd) == bfd_core \ && s->vma == 0 && s->lma == 0 \ && (bfd_vma) s->filepos >= p->p_offset \ - && ((bfd_vma) s->filepos + s->_raw_size \ + && ((bfd_vma) s->filepos + s->size \ <= p->p_offset + p->p_filesz)) /* The complicated case when p_vaddr is 0 is to handle the Solaris @@ -4771,9 +4764,9 @@ copy_private_bfd_data (bfd *ibfd, bfd *o && p->p_memsz == 0 \ && p->p_filesz > 0 \ && (s->flags & SEC_HAS_CONTENTS) != 0 \ - && s->_raw_size > 0 \ + && s->size > 0 \ && (bfd_vma) s->filepos >= p->p_offset \ - && ((bfd_vma) s->filepos + s->_raw_size \ + && ((bfd_vma) s->filepos + s->size \ <= p->p_offset + p->p_filesz)) /* Decide if the given section should be included in the given segment. @@ -5171,10 +5164,10 @@ copy_private_bfd_data (bfd *ibfd, bfd *o /* If the gap between the end of the previous section and the start of this section is more than maxpagesize then we need to start a new segment. */ - if ((BFD_ALIGN (prev_sec->lma + prev_sec->_raw_size, + if ((BFD_ALIGN (prev_sec->lma + prev_sec->size, maxpagesize) < BFD_ALIGN (output_section->lma, maxpagesize)) - || ((prev_sec->lma + prev_sec->_raw_size) + || ((prev_sec->lma + prev_sec->size) > output_section->lma)) { if (suggested_lma == 0) @@ -5810,7 +5803,7 @@ _bfd_elf_get_dynamic_reloc_upper_bound ( if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd) && (elf_section_data (s)->this_hdr.sh_type == SHT_REL || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)) - ret += ((s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize) + ret += ((s->size / elf_section_data (s)->this_hdr.sh_entsize) * sizeof (arelent *)); return ret; @@ -5853,7 +5846,7 @@ _bfd_elf_canonicalize_dynamic_reloc (bfd if (! (*slurp_relocs) (abfd, s, syms, TRUE)) return -1; - count = s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize; + count = s->size / elf_section_data (s)->this_hdr.sh_entsize; p = s->relocation; for (i = 0; i < count; i++) *storage++ = p++; @@ -6455,7 +6448,7 @@ elfcore_maybe_make_sect (bfd *abfd, char if (sect2 == NULL) return FALSE; - sect2->_raw_size = sect->_raw_size; + sect2->size = sect->size; sect2->filepos = sect->filepos; sect2->flags = sect->flags; sect2->alignment_power = sect->alignment_power; @@ -6492,7 +6485,7 @@ _bfd_elfcore_make_pseudosection (bfd *ab sect = bfd_make_section_anyway (abfd, threaded_name); if (sect == NULL) return FALSE; - sect->_raw_size = size; + sect->size = size; sect->filepos = filepos; sect->flags = SEC_HAS_CONTENTS; sect->alignment_power = 2; @@ -6511,14 +6504,14 @@ _bfd_elfcore_make_pseudosection (bfd *ab static bfd_boolean elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { - size_t raw_size; + size_t size; int offset; if (note->descsz == sizeof (prstatus_t)) { prstatus_t prstat; - raw_size = sizeof (prstat.pr_reg); + size = sizeof (prstat.pr_reg); offset = offsetof (prstatus_t, pr_reg); memcpy (&prstat, note->descdata, sizeof (prstat)); @@ -6544,7 +6537,7 @@ elfcore_grok_prstatus (bfd *abfd, Elf_In /* 64-bit host, 32-bit corefile */ prstatus32_t prstat; - raw_size = sizeof (prstat.pr_reg); + size = sizeof (prstat.pr_reg); offset = offsetof (prstatus32_t, pr_reg); memcpy (&prstat, note->descdata, sizeof (prstat)); @@ -6574,7 +6567,7 @@ elfcore_grok_prstatus (bfd *abfd, Elf_In /* Make a ".reg/999" section and a ".reg" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } #endif /* defined (HAVE_PRSTATUS_T) */ @@ -6778,13 +6771,13 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_I return FALSE; #if defined (HAVE_LWPSTATUS_T_PR_CONTEXT) - sect->_raw_size = sizeof (lwpstat.pr_context.uc_mcontext.gregs); + sect->size = sizeof (lwpstat.pr_context.uc_mcontext.gregs); sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_context.uc_mcontext.gregs); #endif #if defined (HAVE_LWPSTATUS_T_PR_REG) - sect->_raw_size = sizeof (lwpstat.pr_reg); + sect->size = sizeof (lwpstat.pr_reg); sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_reg); #endif @@ -6808,13 +6801,13 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_I return FALSE; #if defined (HAVE_LWPSTATUS_T_PR_CONTEXT) - sect->_raw_size = sizeof (lwpstat.pr_context.uc_mcontext.fpregs); + sect->size = sizeof (lwpstat.pr_context.uc_mcontext.fpregs); sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_context.uc_mcontext.fpregs); #endif #if defined (HAVE_LWPSTATUS_T_PR_FPREG) - sect->_raw_size = sizeof (lwpstat.pr_fpreg); + sect->size = sizeof (lwpstat.pr_fpreg); sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_fpreg); #endif @@ -6863,7 +6856,7 @@ elfcore_grok_win32pstatus (bfd *abfd, El if (sect == NULL) return FALSE; - sect->_raw_size = sizeof (pstatus.data.thread_info.thread_context); + sect->size = sizeof (pstatus.data.thread_info.thread_context); sect->filepos = (note->descpos + offsetof (struct win32_pstatus, data.thread_info.thread_context)); @@ -6891,7 +6884,7 @@ elfcore_grok_win32pstatus (bfd *abfd, El if (sect == NULL) return FALSE; - sect->_raw_size = note->descsz; + sect->size = note->descsz; sect->filepos = note->descpos; sect->flags = SEC_HAS_CONTENTS; sect->alignment_power = 2; @@ -6967,7 +6960,7 @@ elfcore_grok_note (bfd *abfd, Elf_Intern if (sect == NULL) return FALSE; - sect->_raw_size = note->descsz; + sect->size = note->descsz; sect->filepos = note->descpos; sect->flags = SEC_HAS_CONTENTS; sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32; @@ -7120,7 +7113,7 @@ elfcore_grok_nto_status (bfd *abfd, Elf_ if (sect == NULL) return FALSE; - sect->_raw_size = note->descsz; + sect->size = note->descsz; sect->filepos = note->descpos; sect->flags = SEC_HAS_CONTENTS; sect->alignment_power = 2; @@ -7147,7 +7140,7 @@ elfcore_grok_nto_gregs (bfd *abfd, Elf_I if (sect == NULL) return FALSE; - sect->_raw_size = note->descsz; + sect->size = note->descsz; sect->filepos = note->descpos; sect->flags = SEC_HAS_CONTENTS; sect->alignment_power = 2; @@ -7594,19 +7587,15 @@ _bfd_elf_rel_local_sym (bfd *abfd, bfd_vma _bfd_elf_section_offset (bfd *abfd, - struct bfd_link_info *info, + struct bfd_link_info *info ATTRIBUTE_UNUSED, asection *sec, bfd_vma offset) { - struct bfd_elf_section_data *sec_data; - - sec_data = elf_section_data (sec); switch (sec->sec_info_type) { case ELF_INFO_TYPE_STABS: - return _bfd_stab_section_offset (abfd, - &elf_hash_table (info)->merge_info, - sec, &sec_data->sec_info, offset); + return _bfd_stab_section_offset (sec, elf_section_data (sec)->sec_info, + offset); case ELF_INFO_TYPE_EH_FRAME: return _bfd_elf_eh_frame_section_offset (abfd, sec, offset); default: @@ -7677,7 +7666,7 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd if (! (*slurp_relocs) (abfd, relplt, dynsyms, TRUE)) return -1; - count = relplt->_raw_size / hdr->sh_entsize; + count = relplt->size / hdr->sh_entsize; size = count * sizeof (asymbol); p = relplt->relocation; for (i = 0; i < count; i++, s++, p++) Index: bfd/elf32-arm.h =================================================================== RCS file: /cvs/src/src/bfd/elf32-arm.h,v retrieving revision 1.132 diff -u -p -r1.132 elf32-arm.h --- bfd/elf32-arm.h 6 May 2004 23:43:40 -0000 1.132 +++ bfd/elf32-arm.h 22 Jun 2004 01:35:37 -0000 @@ -589,7 +589,7 @@ bfd_elf32_arm_allocate_interworking_sect foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner, globals->arm_glue_size); - s->_raw_size = s->_cooked_size = globals->arm_glue_size; + s->size = globals->arm_glue_size; s->contents = foo; } @@ -605,7 +605,7 @@ bfd_elf32_arm_allocate_interworking_sect foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner, globals->thumb_glue_size); - s->_raw_size = s->_cooked_size = globals->thumb_glue_size; + s->size = globals->thumb_glue_size; s->contents = foo; } @@ -916,12 +916,7 @@ bfd_elf32_arm_process_before_allocation else { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (!bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -3331,7 +3326,7 @@ elf32_arm_adjust_dynamic_symbol (info, h srel = bfd_get_section_by_name (dynobj, ".rel.bss"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rel); + srel->size += sizeof (Elf32_External_Rel); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -3342,8 +3337,7 @@ elf32_arm_adjust_dynamic_symbol (info, h power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (! bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -3352,10 +3346,10 @@ elf32_arm_adjust_dynamic_symbol (info, h /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -3404,10 +3398,10 @@ allocate_dynrelocs (h, inf) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_HEADER_SIZE; + if (s->size == 0) + s->size += PLT_HEADER_SIZE; - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -3422,14 +3416,14 @@ allocate_dynrelocs (h, inf) } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->_raw_size += 4; + htab->sgotplt->size += 4; /* We also need to make an entry in the .rel.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf32_External_Rel); + htab->srelplt->size += sizeof (Elf32_External_Rel); } else { @@ -3458,14 +3452,14 @@ allocate_dynrelocs (h, inf) } s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += 4; + h->got.offset = s->size; + s->size += 4; dyn = htab->root.dynamic_sections_created; if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) && (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rel); + htab->srelgot->size += sizeof (Elf32_External_Rel); } else h->got.offset = (bfd_vma) -1; @@ -3525,7 +3519,7 @@ allocate_dynrelocs (h, inf) for (p = eh->relocs_copied; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->section)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf32_External_Rel); + sreloc->size += p->count * sizeof (Elf32_External_Rel); } return TRUE; @@ -3556,7 +3550,7 @@ elf32_arm_size_dynamic_sections (output_ { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -3595,7 +3589,7 @@ elf32_arm_size_dynamic_sections (output_ else if (p->count != 0) { srel = elf_section_data (p->section)->sreloc; - srel->_raw_size += p->count * sizeof (Elf32_External_Rel); + srel->size += p->count * sizeof (Elf32_External_Rel); if ((p->section->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -3615,10 +3609,10 @@ elf32_arm_size_dynamic_sections (output_ { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += 4; + *local_got = s->size; + s->size += 4; if (info->shared) - srel->_raw_size += sizeof (Elf32_External_Rel); + srel->size += sizeof (Elf32_External_Rel); } else *local_got = (bfd_vma) -1; @@ -3650,7 +3644,7 @@ elf32_arm_size_dynamic_sections (output_ if (strcmp (name, ".plt") == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* Strip this section if we don't need it; see the comment below. */ @@ -3664,7 +3658,7 @@ elf32_arm_size_dynamic_sections (output_ } else if (strncmp (name, ".rel", 4) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rel.bss and @@ -3702,8 +3696,8 @@ elf32_arm_size_dynamic_sections (output_ } /* Allocate memory for the section contents. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -3947,7 +3941,7 @@ elf32_arm_finish_dynamic_sections (outpu BFD_ASSERT (splt != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { @@ -3977,10 +3971,7 @@ elf32_arm_finish_dynamic_sections (outpu case DT_PLTRELSZ: s = bfd_get_section_by_name (output_bfd, ".rel.plt"); BFD_ASSERT (s != NULL); - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -3996,12 +3987,7 @@ elf32_arm_finish_dynamic_sections (outpu about changing the DT_REL entry. */ s = bfd_get_section_by_name (output_bfd, ".rel.plt"); if (s != NULL) - { - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; - } + dyn.d_un.d_val -= s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -4033,7 +4019,7 @@ elf32_arm_finish_dynamic_sections (outpu } /* Fill in the first entry in the procedure linkage table. */ - if (splt->_raw_size > 0) + if (splt->size > 0) { bfd_vma got_displacement; @@ -4063,7 +4049,7 @@ elf32_arm_finish_dynamic_sections (outpu } /* Fill in the first three entries in the global offset table. */ - if (sgot->_raw_size > 0) + if (sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); @@ -4243,7 +4229,7 @@ elf32_arm_write_section (bfd *output_bfd for (i = 0; i < mapcount; i++) { if (i == mapcount - 1) - end = bfd_section_size (output_bfd, sec); + end = sec->size; else end = map[i + 1].vma - offset; Index: bfd/elf32-cris.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-cris.c,v retrieving revision 1.51 diff -u -p -r1.51 elf32-cris.c --- bfd/elf32-cris.c 27 Mar 2004 10:58:05 -0000 1.51 +++ bfd/elf32-cris.c 22 Jun 2004 01:35:38 -0000 @@ -475,7 +475,7 @@ cris_elf_grok_prstatus (abfd, note) Elf_Internal_Note *note; { int offset; - size_t raw_size; + size_t size; switch (note->descsz) { @@ -491,14 +491,14 @@ cris_elf_grok_prstatus (abfd, note) /* pr_reg */ offset = 70; - raw_size = 140; + size = 140; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean @@ -1645,7 +1645,7 @@ elf_cris_finish_dynamic_sections (output BFD_ASSERT (splt != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -1677,10 +1677,8 @@ elf_cris_finish_dynamic_sections (output s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s == NULL) dyn.d_un.d_val = 0; - else if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -1694,19 +1692,14 @@ elf_cris_finish_dynamic_sections (output about changing the DT_RELA entry. */ s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s != NULL) - { - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; - } + dyn.d_un.d_val -= s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; } } /* Fill in the first entry in the procedure linkage table. */ - if (splt->_raw_size > 0) + if (splt->size > 0) { if (info->shared) memcpy (splt->contents, elf_cris_pic_plt0_entry, PLT_ENTRY_SIZE); @@ -1727,7 +1720,7 @@ elf_cris_finish_dynamic_sections (output } /* Fill in the first three entries in the global offset table. */ - if (sgot->_raw_size > 0) + if (sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); @@ -1832,8 +1825,8 @@ cris_elf_gc_sweep_hook (abfd, info, sec, if (h->got.refcount == 0) { /* We don't need the .got entry any more. */ - sgot->_raw_size -= 4; - srelgot->_raw_size -= sizeof (Elf32_External_Rela); + sgot->size -= 4; + srelgot->size -= sizeof (Elf32_External_Rela); } } break; @@ -1848,9 +1841,9 @@ cris_elf_gc_sweep_hook (abfd, info, sec, if (local_got_refcounts[r_symndx] == 0) { /* We don't need the .got entry any more. */ - sgot->_raw_size -= 4; + sgot->size -= 4; if (info->shared) - srelgot->_raw_size -= sizeof (Elf32_External_Rela); + srelgot->size -= sizeof (Elf32_External_Rela); } } } @@ -1939,10 +1932,10 @@ elf_cris_adjust_gotplt_to_got (h, p) BFD_ASSERT (sgot != NULL && srelgot != NULL); /* Allocate space in the .got section. */ - sgot->_raw_size += 4; + sgot->size += 4; /* Allocate relocation space. */ - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } return TRUE; @@ -2104,8 +2097,8 @@ elf_cris_adjust_dynamic_symbol (info, h) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_ENTRY_SIZE; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -2114,7 +2107,7 @@ elf_cris_adjust_dynamic_symbol (info, h) && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) { h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; } /* If there's already a GOT entry, use that, not a .got.plt. A @@ -2130,10 +2123,10 @@ elf_cris_adjust_dynamic_symbol (info, h) /* Mark the PLT offset to use the GOT entry by setting the low bit in the plt offset; it is always a multiple of pointer-size. */ - BFD_ASSERT ((s->_raw_size & 3) == 0); + BFD_ASSERT ((s->size & 3) == 0); /* Change the PLT refcount to an offset. */ - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* By not setting gotplt_offset (i.e. it remains at 0), we signal that the got entry should be used instead. */ @@ -2141,16 +2134,16 @@ elf_cris_adjust_dynamic_symbol (info, h) h)->gotplt_offset == 0); /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; return TRUE; } /* No GOT reference for this symbol; prepare for an ordinary PLT. */ - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ @@ -2160,13 +2153,13 @@ elf_cris_adjust_dynamic_symbol (info, h) s = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += 4; + s->size += 4; /* We also need to make an entry in the .rela.plt section. */ s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += sizeof (Elf32_External_Rela); + s->size += sizeof (Elf32_External_Rela); return TRUE; } @@ -2225,7 +2218,7 @@ elf_cris_adjust_dynamic_symbol (info, h) srel = bfd_get_section_by_name (dynobj, ".rela.bss"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -2239,8 +2232,7 @@ elf_cris_adjust_dynamic_symbol (info, h) power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (!bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -2249,10 +2241,10 @@ elf_cris_adjust_dynamic_symbol (info, h) /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -2427,9 +2419,9 @@ cris_elf_check_relocs (abfd, info, sec, } /* Allocate space in the .got section. */ - sgot->_raw_size += 4; + sgot->size += 4; /* Allocate relocation space. */ - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } h->got.refcount++; } @@ -2438,13 +2430,13 @@ cris_elf_check_relocs (abfd, info, sec, /* This is a global offset table entry for a local symbol. */ if (local_got_refcounts[r_symndx] == 0) { - sgot->_raw_size += 4; + sgot->size += 4; if (info->shared) { /* If we are generating a shared object, we need to output a R_CRIS_RELATIVE reloc so that the dynamic linker can adjust this GOT entry. */ - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } } local_got_refcounts[r_symndx]++; @@ -2599,7 +2591,7 @@ cris_elf_check_relocs (abfd, info, sec, info->flags |= DF_TEXTREL; } - sreloc->_raw_size += sizeof (Elf32_External_Rela); + sreloc->size += sizeof (Elf32_External_Rela); /* If we are linking with -Bsymbolic, we count the number of PC relative relocations we have entered for this symbol, so that @@ -2682,7 +2674,7 @@ elf_cris_size_dynamic_sections (output_b { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -2700,7 +2692,7 @@ elf_cris_size_dynamic_sections (output_b below. */ s = bfd_get_section_by_name (dynobj, ".rela.got"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; } /* If this is a -Bsymbolic shared link, then we need to discard all PC @@ -2740,7 +2732,7 @@ elf_cris_size_dynamic_sections (output_b if (strcmp (name, ".plt") == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* Strip this section if we don't need it; see the comment below. */ @@ -2754,7 +2746,7 @@ elf_cris_size_dynamic_sections (output_b } else if (strncmp (name, ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -2796,8 +2788,8 @@ elf_cris_size_dynamic_sections (output_b contents are written out. This should not happen, but this way if it does, we will not write out garbage. For reloc sections, this will make entries have the type R_CRIS_NONE. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -2874,7 +2866,7 @@ elf_cris_discard_excess_dso_dynamics (h, || info->symbolic)) { for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) - s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela); + s->section->size -= s->count * sizeof (Elf32_External_Rela); } return TRUE; @@ -2917,7 +2909,7 @@ elf_cris_discard_excess_program_dynamics BFD_ASSERT (srelgot != NULL); - srelgot->_raw_size -= sizeof (Elf32_External_Rela); + srelgot->size -= sizeof (Elf32_External_Rela); } /* If the locally-defined symbol isn't used by a DSO, then we don't Index: bfd/elf32-d30v.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-d30v.c,v retrieving revision 1.12 diff -u -p -r1.12 elf32-d30v.c --- bfd/elf32-d30v.c 27 Nov 2003 18:49:37 -0000 1.12 +++ bfd/elf32-d30v.c 22 Jun 2004 01:35:39 -0000 @@ -1,5 +1,5 @@ /* D30V-specific support for 32-bit ELF - Copyright 1997, 1998, 1999, 2000, 2001, 2002 + Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. Contributed by Martin Hunt (hunt@cygnus.com). @@ -266,6 +266,7 @@ bfd_elf_d30v_reloc (abfd, reloc_entry, s bfd_reloc_status_type r; asection *reloc_target_output_section; bfd_size_type addr = reloc_entry->address; + bfd_size_type sz; bfd_reloc_status_type flag = bfd_reloc_ok; bfd_vma output_base = 0; reloc_howto_type *howto = reloc_entry->howto; @@ -290,7 +291,8 @@ bfd_elf_d30v_reloc (abfd, reloc_entry, s flag = bfd_reloc_undefined; /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Work out which section the relocation is targeted at and the @@ -375,6 +377,7 @@ bfd_elf_d30v_reloc_21 (abfd, reloc_entry bfd_reloc_status_type r; asection *reloc_target_output_section; bfd_size_type addr = reloc_entry->address; + bfd_size_type sz; bfd_reloc_status_type flag = bfd_reloc_ok; bfd_vma output_base = 0; reloc_howto_type *howto = reloc_entry->howto; @@ -399,7 +402,8 @@ bfd_elf_d30v_reloc_21 (abfd, reloc_entry flag = bfd_reloc_undefined; /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Work out which section the relocation is targeted at and the Index: bfd/elf32-dlx.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-dlx.c,v retrieving revision 1.8 diff -u -p -r1.8 elf32-dlx.c --- bfd/elf32-dlx.c 27 Mar 2004 10:58:05 -0000 1.8 +++ bfd/elf32-dlx.c 22 Jun 2004 01:35:39 -0000 @@ -1,5 +1,5 @@ /* DLX specific support for 32-bit ELF - Copyright 2002, 2003 Free Software Foundation, Inc. + Copyright 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -257,6 +257,7 @@ _bfd_dlx_elf_hi16_reloc (abfd, reloc_ent { bfd_reloc_status_type ret; bfd_vma relocation; + bfd_size_type sz; /* If the skip flag is set then we simply do the generic relocating, this is more of a hack for dlx gas/gld, so we do not need to do the %hi/%lo @@ -307,7 +308,8 @@ _bfd_dlx_elf_hi16_reloc (abfd, reloc_ent relocation += reloc_entry->addend; relocation += bfd_get_16 (abfd, (bfd_byte *)data + reloc_entry->address); - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; #if 0 Index: bfd/elf32-frv.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-frv.c,v retrieving revision 1.25 diff -u -p -r1.25 elf32-frv.c --- bfd/elf32-frv.c 21 Jun 2004 14:45:41 -0000 1.25 +++ bfd/elf32-frv.c 22 Jun 2004 01:35:41 -0000 @@ -934,7 +934,7 @@ _frvfdpic_add_dyn_reloc (bfd *output_bfd outrel.r_addend = addend; reloc_offset = sreloc->reloc_count * sizeof (Elf32_External_Rel); - BFD_ASSERT (reloc_offset < sreloc->_raw_size); + BFD_ASSERT (reloc_offset < sreloc->size); bfd_elf32_swap_reloc_out (output_bfd, &outrel, sreloc->contents + reloc_offset); sreloc->reloc_count++; @@ -969,7 +969,7 @@ _frvfdpic_add_rofixup (bfd *output_bfd, fixup_offset = rofixup->reloc_count * 4; if (rofixup->contents) { - BFD_ASSERT (fixup_offset < rofixup->_raw_size); + BFD_ASSERT (fixup_offset < rofixup->size); bfd_put_32 (output_bfd, offset, rofixup->contents + fixup_offset); } rofixup->reloc_count++; @@ -2778,7 +2778,7 @@ _frv_create_got_section (bfd *abfd, stru } /* The first bit of the global offset table is the header. */ - s->_raw_size += bed->got_header_size + bed->got_symbol_offset; + s->size += bed->got_header_size + bed->got_symbol_offset; /* This is the machine-specific part. Create and initialize section data for the got. */ @@ -3354,7 +3354,7 @@ _frvfdpic_assign_plt_entries (void **ent /* We use the section's raw size to mark the location of the next PLT entry. */ - entry->plt_entry = frvfdpic_plt_section (dinfo->g.info)->_raw_size; + entry->plt_entry = frvfdpic_plt_section (dinfo->g.info)->size; /* Figure out the length of this PLT entry based on the addressing mode we need to reach the function descriptor. */ @@ -3368,7 +3368,7 @@ _frvfdpic_assign_plt_entries (void **ent else size = 16; - frvfdpic_plt_section (dinfo->g.info)->_raw_size += size; + frvfdpic_plt_section (dinfo->g.info)->size += size; } if (entry->lazyplt) @@ -3463,7 +3463,7 @@ elf32_frvfdpic_size_dynamic_sections (bf { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER; } } @@ -3530,24 +3530,24 @@ elf32_frvfdpic_size_dynamic_sections (bf htab_traverse (frvfdpic_relocs_info (info), _frvfdpic_assign_got_entries, &gpinfo); - frvfdpic_got_section (info)->_raw_size = gpinfo.gothilo.max + frvfdpic_got_section (info)->size = gpinfo.gothilo.max - gpinfo.gothilo.min /* If an odd word is the last word of the GOT, we don't need this word to be part of the GOT. */ - (odd + 4 == gpinfo.gothilo.max ? 4 : 0); - if (frvfdpic_got_section (info)->_raw_size == 0) + if (frvfdpic_got_section (info)->size == 0) frvfdpic_got_section (info)->flags |= SEC_EXCLUDE; - else if (frvfdpic_got_section (info)->_raw_size == 12 + else if (frvfdpic_got_section (info)->size == 12 && ! elf_hash_table (info)->dynamic_sections_created) { frvfdpic_got_section (info)->flags |= SEC_EXCLUDE; - frvfdpic_got_section (info)->_raw_size = 0; + frvfdpic_got_section (info)->size = 0; } else { frvfdpic_got_section (info)->contents = (bfd_byte *) bfd_zalloc (dynobj, - frvfdpic_got_section (info)->_raw_size); + frvfdpic_got_section (info)->size); if (frvfdpic_got_section (info)->contents == NULL) return FALSE; } @@ -3555,46 +3555,45 @@ elf32_frvfdpic_size_dynamic_sections (bf if (elf_hash_table (info)->dynamic_sections_created) /* Subtract the number of lzplt entries, since those will generate relocations in the pltrel section. */ - frvfdpic_gotrel_section (info)->_raw_size = + frvfdpic_gotrel_section (info)->size = (gpinfo.g.relocs - gpinfo.g.lzplt / 8) * get_elf_backend_data (output_bfd)->s->sizeof_rel; else BFD_ASSERT (gpinfo.g.relocs == 0); - if (frvfdpic_gotrel_section (info)->_raw_size == 0) + if (frvfdpic_gotrel_section (info)->size == 0) frvfdpic_gotrel_section (info)->flags |= SEC_EXCLUDE; else { frvfdpic_gotrel_section (info)->contents = (bfd_byte *) bfd_zalloc (dynobj, - frvfdpic_gotrel_section (info)->_raw_size); + frvfdpic_gotrel_section (info)->size); if (frvfdpic_gotrel_section (info)->contents == NULL) return FALSE; } - frvfdpic_gotfixup_section (info)->_raw_size = (gpinfo.g.fixups + 1) * 4; - if (frvfdpic_gotfixup_section (info)->_raw_size == 0) + frvfdpic_gotfixup_section (info)->size = (gpinfo.g.fixups + 1) * 4; + if (frvfdpic_gotfixup_section (info)->size == 0) frvfdpic_gotfixup_section (info)->flags |= SEC_EXCLUDE; else { frvfdpic_gotfixup_section (info)->contents = (bfd_byte *) bfd_zalloc (dynobj, - frvfdpic_gotfixup_section (info)->_raw_size); + frvfdpic_gotfixup_section (info)->size); if (frvfdpic_gotfixup_section (info)->contents == NULL) return FALSE; } if (elf_hash_table (info)->dynamic_sections_created) { - frvfdpic_pltrel_section (info)->_raw_size = + frvfdpic_pltrel_section (info)->size = gpinfo.g.lzplt / 8 * get_elf_backend_data (output_bfd)->s->sizeof_rel; - if (frvfdpic_pltrel_section (info)->_raw_size == 0) + if (frvfdpic_pltrel_section (info)->size == 0) frvfdpic_pltrel_section (info)->flags |= SEC_EXCLUDE; else { frvfdpic_pltrel_section (info)->contents = (bfd_byte *) bfd_zalloc (dynobj, - frvfdpic_pltrel_section (info) - ->_raw_size); + frvfdpic_pltrel_section (info)->size); if (frvfdpic_pltrel_section (info)->contents == NULL) return FALSE; } @@ -3607,7 +3606,7 @@ elf32_frvfdpic_size_dynamic_sections (bf block size. */ if (elf_hash_table (info)->dynamic_sections_created) { - frvfdpic_plt_section (info)->_raw_size = gpinfo.g.lzplt + frvfdpic_plt_section (info)->size = gpinfo.g.lzplt + ((gpinfo.g.lzplt + (FRVFDPIC_LZPLT_BLOCK_SIZE - 4) - 8) / (FRVFDPIC_LZPLT_BLOCK_SIZE - 4) * 4); } @@ -3626,7 +3625,7 @@ elf32_frvfdpic_size_dynamic_sections (bf if (elf_hash_table (info)->dynamic_sections_created) frvfdpic_plt_initial_offset (info) = - frvfdpic_plt_section (info)->_raw_size; + frvfdpic_plt_section (info)->size; htab_traverse (frvfdpic_relocs_info (info), _frvfdpic_assign_plt_entries, &gpinfo); @@ -3636,13 +3635,13 @@ elf32_frvfdpic_size_dynamic_sections (bf non-lazy PLT entries. */ if (elf_hash_table (info)->dynamic_sections_created) { - if (frvfdpic_plt_section (info)->_raw_size == 0) + if (frvfdpic_plt_section (info)->size == 0) frvfdpic_plt_section (info)->flags |= SEC_EXCLUDE; else { frvfdpic_plt_section (info)->contents = (bfd_byte *) bfd_zalloc (dynobj, - frvfdpic_plt_section (info)->_raw_size); + frvfdpic_plt_section (info)->size); if (frvfdpic_plt_section (info)->contents == NULL) return FALSE; } @@ -3650,17 +3649,17 @@ elf32_frvfdpic_size_dynamic_sections (bf if (elf_hash_table (info)->dynamic_sections_created) { - if (frvfdpic_got_section (info)->_raw_size) + if (frvfdpic_got_section (info)->size) if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0)) return FALSE; - if (frvfdpic_pltrel_section (info)->_raw_size) + if (frvfdpic_pltrel_section (info)->size) if (!_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0) || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_REL) || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0)) return FALSE; - if (frvfdpic_gotrel_section (info)->_raw_size) + if (frvfdpic_gotrel_section (info)->size) if (!_bfd_elf_add_dynamic_entry (info, DT_REL, 0) || !_bfd_elf_add_dynamic_entry (info, DT_RELSZ, 0) || !_bfd_elf_add_dynamic_entry (info, DT_RELENT, @@ -3749,9 +3748,9 @@ elf32_frvfdpic_modify_segment_map (bfd * /* Set the section size from the symbol value. We intentionally ignore the symbol section. */ if (h->root.type == bfd_link_hash_defined) - sec->_raw_size = h->root.u.def.value; + sec->size = h->root.u.def.value; else - sec->_raw_size = DEFAULT_STACK_SIZE; + sec->size = DEFAULT_STACK_SIZE; /* Add the stack section to the PT_GNU_STACK segment, such that its size and alignment requirements make it @@ -3785,7 +3784,7 @@ elf32_frvfdpic_finish_dynamic_sections ( if (frvfdpic_got_section (info)) { - BFD_ASSERT (frvfdpic_gotrel_section (info)->_raw_size + BFD_ASSERT (frvfdpic_gotrel_section (info)->size == (frvfdpic_gotrel_section (info)->reloc_count * sizeof (Elf32_External_Rel))); @@ -3799,7 +3798,7 @@ elf32_frvfdpic_finish_dynamic_sections ( _frvfdpic_add_rofixup (output_bfd, frvfdpic_gotfixup_section (info), got_value, 0); - if (frvfdpic_gotfixup_section (info)->_raw_size + if (frvfdpic_gotfixup_section (info)->size != (frvfdpic_gotfixup_section (info)->reloc_count * 4)) { (*_bfd_error_handler) @@ -3810,7 +3809,7 @@ elf32_frvfdpic_finish_dynamic_sections ( } if (elf_hash_table (info)->dynamic_sections_created) { - BFD_ASSERT (frvfdpic_pltrel_section (info)->_raw_size + BFD_ASSERT (frvfdpic_pltrel_section (info)->size == (frvfdpic_pltrel_section (info)->reloc_count * sizeof (Elf32_External_Rel))); } @@ -3825,7 +3824,7 @@ elf32_frvfdpic_finish_dynamic_sections ( BFD_ASSERT (sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { @@ -3853,10 +3852,7 @@ elf32_frvfdpic_finish_dynamic_sections ( break; case DT_PLTRELSZ: - if (frvfdpic_pltrel_section (info)->_cooked_size != 0) - dyn.d_un.d_val = frvfdpic_pltrel_section (info)->_cooked_size; - else - dyn.d_un.d_val = frvfdpic_pltrel_section (info)->_raw_size; + dyn.d_un.d_val = frvfdpic_pltrel_section (info)->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; } Index: bfd/elf32-h8300.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-h8300.c,v retrieving revision 1.44 diff -u -p -r1.44 elf32-h8300.c --- bfd/elf32-h8300.c 27 Mar 2004 10:58:06 -0000 1.44 +++ bfd/elf32-h8300.c 22 Jun 2004 01:35:42 -0000 @@ -679,11 +679,6 @@ elf32_h8_relax_section (bfd *abfd, asect || (sec->flags & SEC_CODE) == 0) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; /* Get a copy of the native relocations. */ @@ -725,12 +720,7 @@ elf32_h8_relax_section (bfd *abfd, asect else { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -1297,7 +1287,7 @@ elf32_h8_relax_delete_bytes (bfd *abfd, power larger than the number of bytes we are deleting. */ irelalign = NULL; - toaddr = sec->_cooked_size; + toaddr = sec->size; irel = elf_section_data (sec)->relocs; irelend = irel + sec->reloc_count; @@ -1305,7 +1295,7 @@ elf32_h8_relax_delete_bytes (bfd *abfd, /* Actually delete the bytes. */ memmove (contents + addr, contents + addr + count, (size_t) (toaddr - addr - count)); - sec->_cooked_size -= count; + sec->size -= count; /* Adjust all the relocs. */ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++) @@ -1422,7 +1412,7 @@ elf32_h8_get_relocated_section_contents symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; memcpy (data, elf_section_data (input_section)->this_hdr.contents, - (size_t) input_section->_raw_size); + (size_t) input_section->size); if ((input_section->flags & SEC_RELOC) != 0 && input_section->reloc_count > 0) Index: bfd/elf32-hppa.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-hppa.c,v retrieving revision 1.116 diff -u -p -r1.116 elf32-hppa.c --- bfd/elf32-hppa.c 27 Mar 2004 10:58:06 -0000 1.116 +++ bfd/elf32-hppa.c 22 Jun 2004 01:35:44 -0000 @@ -672,7 +672,7 @@ hppa_build_one_stub (struct bfd_hash_ent stub_sec = stub_entry->stub_sec; /* Make a note of the offset within the stubs for this entry. */ - stub_entry->stub_offset = stub_sec->_raw_size; + stub_entry->stub_offset = stub_sec->size; loc = stub_sec->contents + stub_entry->stub_offset; stub_bfd = stub_sec->owner; @@ -816,7 +816,7 @@ hppa_build_one_stub (struct bfd_hash_ent /* Point the function symbol at the stub. */ stub_entry->h->elf.root.u.def.section = stub_sec; - stub_entry->h->elf.root.u.def.value = stub_sec->_raw_size; + stub_entry->h->elf.root.u.def.value = stub_sec->size; size = 24; break; @@ -826,7 +826,7 @@ hppa_build_one_stub (struct bfd_hash_ent return FALSE; } - stub_sec->_raw_size += size; + stub_sec->size += size; return TRUE; } @@ -879,7 +879,7 @@ hppa_size_one_stub (struct bfd_hash_entr size = 16; } - stub_entry->stub_sec->_raw_size += size; + stub_entry->stub_sec->size += size; return TRUE; } @@ -1732,7 +1732,7 @@ elf32_hppa_adjust_dynamic_symbol (struct runtime process image. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { - htab->srelbss->_raw_size += sizeof (Elf32_External_Rela); + htab->srelbss->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1745,8 +1745,7 @@ elf32_hppa_adjust_dynamic_symbol (struct /* Apply the required alignment. */ s = htab->sdynbss; - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) { if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) @@ -1755,10 +1754,10 @@ elf32_hppa_adjust_dynamic_symbol (struct /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1807,8 +1806,8 @@ allocate_plt_static (struct elf_link_has /* Make an entry in the .plt section for plabel references that won't have a .plt entry for other reasons. */ s = htab->splt; - h->plt.offset = s->_raw_size; - s->_raw_size += PLT_ENTRY_SIZE; + h->plt.offset = s->size; + s->size += PLT_ENTRY_SIZE; } else { @@ -1852,11 +1851,11 @@ allocate_dynrelocs (struct elf_link_hash { /* Make an entry in the .plt section. */ s = htab->splt; - h->plt.offset = s->_raw_size; - s->_raw_size += PLT_ENTRY_SIZE; + h->plt.offset = s->size; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .rela.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf32_External_Rela); + htab->srelplt->size += sizeof (Elf32_External_Rela); htab->need_plt_stub = 1; } @@ -1873,14 +1872,14 @@ allocate_dynrelocs (struct elf_link_hash } s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += GOT_ENTRY_SIZE; + h->got.offset = s->size; + s->size += GOT_ENTRY_SIZE; if (htab->elf.dynamic_sections_created && (info->shared || (h->dynindx != -1 && h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)) { - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); } } else @@ -1959,7 +1958,7 @@ allocate_dynrelocs (struct elf_link_hash for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela); + sreloc->size += p->count * sizeof (Elf32_External_Rela); } return TRUE; @@ -2041,7 +2040,7 @@ elf32_hppa_size_dynamic_sections (bfd *o s = bfd_get_section_by_name (dynobj, ".interp"); if (s == NULL) abort (); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } @@ -2086,7 +2085,7 @@ elf32_hppa_size_dynamic_sections (bfd *o else if (p->count != 0) { srel = elf_section_data (p->sec)->sreloc; - srel->_raw_size += p->count * sizeof (Elf32_External_Rela); + srel->size += p->count * sizeof (Elf32_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -2106,10 +2105,10 @@ elf32_hppa_size_dynamic_sections (bfd *o { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += GOT_ENTRY_SIZE; + *local_got = s->size; + s->size += GOT_ENTRY_SIZE; if (info->shared) - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); } else *local_got = (bfd_vma) -1; @@ -2131,10 +2130,10 @@ elf32_hppa_size_dynamic_sections (bfd *o { if (*local_plt > 0) { - *local_plt = s->_raw_size; - s->_raw_size += PLT_ENTRY_SIZE; + *local_plt = s->size; + s->size += PLT_ENTRY_SIZE; if (info->shared) - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); } else *local_plt = (bfd_vma) -1; @@ -2174,14 +2173,14 @@ elf32_hppa_size_dynamic_sections (bfd *o if (gotalign > pltalign) bfd_set_section_alignment (dynobj, s, gotalign); mask = ((bfd_size_type) 1 << gotalign) - 1; - s->_raw_size = (s->_raw_size + sizeof (plt_stub) + mask) & ~mask; + s->size = (s->size + sizeof (plt_stub) + mask) & ~mask; } } else if (s == htab->sgot) ; else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->_raw_size != 0) + if (s->size != 0) { /* Remember whether there are any reloc sections other than .rela.plt. */ @@ -2199,7 +2198,7 @@ elf32_hppa_size_dynamic_sections (bfd *o continue; } - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -2216,8 +2215,8 @@ elf32_hppa_size_dynamic_sections (bfd *o /* Allocate memory for the section contents. Zero it, because we may not fill in all the reloc sections. */ - s->contents = bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -2244,7 +2243,7 @@ elf32_hppa_size_dynamic_sections (bfd *o return FALSE; } - if (htab->srelplt->_raw_size != 0) + if (htab->srelplt->size != 0) { if (!add_dynamic_entry (DT_PLTRELSZ, 0) || !add_dynamic_entry (DT_PLTREL, DT_RELA) @@ -2401,10 +2400,7 @@ group_sections (struct elf32_hppa_link_h bfd_boolean big_sec; curr = tail; - if (tail->_cooked_size) - total = tail->_cooked_size; - else - total = tail->_raw_size; + total = tail->size; big_sec = total >= stub_group_size; while ((prev = PREV_SEC (curr)) != NULL @@ -2852,10 +2848,7 @@ elf32_hppa_size_stubs for (stub_sec = htab->stub_bfd->sections; stub_sec != NULL; stub_sec = stub_sec->next) - { - stub_sec->_raw_size = 0; - stub_sec->_cooked_size = 0; - } + stub_sec->size = 0; bfd_hash_traverse (&htab->stub_hash_table, hppa_size_one_stub, htab); @@ -2909,8 +2902,8 @@ elf32_hppa_set_gp (bfd *abfd, struct bfd sec = splt; if (sec != NULL) { - gp_val = sec->_raw_size; - if (gp_val > 0x2000 || (sgot && sgot->_raw_size > 0x2000)) + gp_val = sec->size; + if (gp_val > 0x2000 || (sgot && sgot->size > 0x2000)) { gp_val = 0x2000; } @@ -2922,7 +2915,7 @@ elf32_hppa_set_gp (bfd *abfd, struct bfd { /* We know we don't have a .plt. If .got is large, offset our LTP. */ - if (sec->_raw_size > 0x2000) + if (sec->size > 0x2000) gp_val = 0x2000; } else @@ -2972,11 +2965,11 @@ elf32_hppa_build_stubs (struct bfd_link_ bfd_size_type size; /* Allocate memory to hold the linker stubs. */ - size = stub_sec->_raw_size; + size = stub_sec->size; stub_sec->contents = bfd_zalloc (htab->stub_bfd, size); if (stub_sec->contents == NULL && size != 0) return FALSE; - stub_sec->_raw_size = 0; + stub_sec->size = 0; } /* Build the stubs as directed by the stub hash table. */ @@ -4010,7 +4003,7 @@ elf32_hppa_finish_dynamic_sections (bfd abort (); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -4035,7 +4028,7 @@ elf32_hppa_finish_dynamic_sections (bfd case DT_PLTRELSZ: s = htab->srelplt; - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; break; case DT_RELASZ: @@ -4044,7 +4037,7 @@ elf32_hppa_finish_dynamic_sections (bfd s = htab->srelplt; if (s == NULL) continue; - dyn.d_un.d_val -= s->_raw_size; + dyn.d_un.d_val -= s->size; break; case DT_RELA: @@ -4056,7 +4049,7 @@ elf32_hppa_finish_dynamic_sections (bfd continue; if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset) continue; - dyn.d_un.d_ptr += s->_raw_size; + dyn.d_un.d_ptr += s->size; break; } @@ -4064,7 +4057,7 @@ elf32_hppa_finish_dynamic_sections (bfd } } - if (htab->sgot != NULL && htab->sgot->_raw_size != 0) + if (htab->sgot != NULL && htab->sgot->size != 0) { /* Fill in the first entry in the global offset table. We use it to point to our dynamic section, if we have one. */ @@ -4080,7 +4073,7 @@ elf32_hppa_finish_dynamic_sections (bfd ->this_hdr.sh_entsize = GOT_ENTRY_SIZE; } - if (htab->splt != NULL && htab->splt->_raw_size != 0) + if (htab->splt != NULL && htab->splt->size != 0) { /* Set plt entry size. */ elf_section_data (htab->splt->output_section) @@ -4090,12 +4083,12 @@ elf32_hppa_finish_dynamic_sections (bfd { /* Set up the .plt stub. */ memcpy (htab->splt->contents - + htab->splt->_raw_size - sizeof (plt_stub), + + htab->splt->size - sizeof (plt_stub), plt_stub, sizeof (plt_stub)); if ((htab->splt->output_offset + htab->splt->output_section->vma - + htab->splt->_raw_size) + + htab->splt->size) != (htab->sgot->output_offset + htab->sgot->output_section->vma)) { Index: bfd/elf32-i370.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-i370.c,v retrieving revision 1.35 diff -u -p -r1.35 elf32-i370.c --- bfd/elf32-i370.c 26 Mar 2004 06:13:39 -0000 1.35 +++ bfd/elf32-i370.c 22 Jun 2004 01:35:45 -0000 @@ -511,7 +511,7 @@ i370_elf_adjust_dynamic_symbol (info, h) s = bfd_get_section_by_name (dynobj, ".rela.text"); BFD_ASSERT (s != NULL); - s->_raw_size += sizeof (Elf32_External_Rela); + s->size += sizeof (Elf32_External_Rela); /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the @@ -568,7 +568,7 @@ i370_elf_adjust_dynamic_symbol (info, h) else srel = bfd_get_section_by_name (dynobj, ".rela.bss"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -579,8 +579,7 @@ i370_elf_adjust_dynamic_symbol (info, h) power_of_two = 4; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (! bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -589,10 +588,10 @@ i370_elf_adjust_dynamic_symbol (info, h) /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -657,7 +656,7 @@ i370_elf_size_dynamic_sections (output_b { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -677,7 +676,7 @@ i370_elf_size_dynamic_sections (output_b { s = bfd_get_section_by_name (dynobj, *p); if (s != NULL) - s->_raw_size = 0; + s->size = 0; } } @@ -702,7 +701,7 @@ i370_elf_size_dynamic_sections (output_b if (strcmp (name, ".plt") == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* Strip this section if we don't need it; see the comment below. */ @@ -716,7 +715,7 @@ i370_elf_size_dynamic_sections (output_b } else if (strncmp (name, ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -778,8 +777,8 @@ i370_elf_size_dynamic_sections (output_b continue; } /* Allocate memory for the section contents. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -955,7 +954,7 @@ i370_elf_check_relocs (abfd, info, sec, } } - sreloc->_raw_size += sizeof (Elf32_External_Rela); + sreloc->size += sizeof (Elf32_External_Rela); /* FIXME: We should here do what the m68k and i386 backends do: if the reloc is pc-relative, record it @@ -999,7 +998,7 @@ i370_elf_finish_dynamic_sections (output BFD_ASSERT (splt != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -1028,12 +1027,7 @@ i370_elf_finish_dynamic_sections (output if (! size) dyn.d_un.d_ptr = s->vma; else - { - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; - } + dyn.d_un.d_val = s->size; } bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); } Index: bfd/elf32-i386.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-i386.c,v retrieving revision 1.122 diff -u -p -r1.122 elf32-i386.c --- bfd/elf32-i386.c 11 May 2004 17:08:37 -0000 1.122 +++ bfd/elf32-i386.c 22 Jun 2004 01:35:47 -0000 @@ -351,7 +351,7 @@ static bfd_boolean elf_i386_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; - size_t raw_size; + size_t size; if (note->namesz == 8 && strcmp (note->namedata, "FreeBSD") == 0) { @@ -368,7 +368,7 @@ elf_i386_grok_prstatus (bfd *abfd, Elf_I /* pr_reg */ offset = 28; - raw_size = bfd_get_32 (abfd, note->descdata + 8); + size = bfd_get_32 (abfd, note->descdata + 8); } else { @@ -386,7 +386,7 @@ elf_i386_grok_prstatus (bfd *abfd, Elf_I /* pr_reg */ offset = 72; - raw_size = 68; + size = 68; break; } @@ -394,7 +394,7 @@ elf_i386_grok_prstatus (bfd *abfd, Elf_I /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean @@ -1429,7 +1429,7 @@ elf_i386_adjust_dynamic_symbol (struct b runtime process image. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { - htab->srelbss->_raw_size += sizeof (Elf32_External_Rel); + htab->srelbss->size += sizeof (Elf32_External_Rel); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1441,7 +1441,7 @@ elf_i386_adjust_dynamic_symbol (struct b /* Apply the required alignment. */ s = htab->sdynbss; - s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) { if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) @@ -1450,10 +1450,10 @@ elf_i386_adjust_dynamic_symbol (struct b /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1500,10 +1500,10 @@ allocate_dynrelocs (struct elf_link_hash /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_ENTRY_SIZE; - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -1518,14 +1518,14 @@ allocate_dynrelocs (struct elf_link_hash } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->_raw_size += 4; + htab->sgotplt->size += 4; /* We also need to make an entry in the .rel.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf32_External_Rel); + htab->srelplt->size += sizeof (Elf32_External_Rel); } else { @@ -1562,11 +1562,11 @@ allocate_dynrelocs (struct elf_link_hash } s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += 4; + h->got.offset = s->size; + s->size += 4; /* R_386_TLS_GD needs 2 consecutive GOT slots. */ if (tls_type == GOT_TLS_GD || tls_type == GOT_TLS_IE_BOTH) - s->_raw_size += 4; + s->size += 4; dyn = htab->elf.dynamic_sections_created; /* R_386_TLS_IE_32 needs one dynamic relocation, R_386_TLS_IE resp. R_386_TLS_GOTIE needs one dynamic relocation, @@ -1574,17 +1574,17 @@ allocate_dynrelocs (struct elf_link_hash need two), R_386_TLS_GD needs one if local symbol and two if global. */ if (tls_type == GOT_TLS_IE_BOTH) - htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rel); + htab->srelgot->size += 2 * sizeof (Elf32_External_Rel); else if ((tls_type == GOT_TLS_GD && h->dynindx == -1) || (tls_type & GOT_TLS_IE)) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rel); + htab->srelgot->size += sizeof (Elf32_External_Rel); else if (tls_type == GOT_TLS_GD) - htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rel); + htab->srelgot->size += 2 * sizeof (Elf32_External_Rel); else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) && (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rel); + htab->srelgot->size += sizeof (Elf32_External_Rel); } else h->got.offset = (bfd_vma) -1; @@ -1665,7 +1665,7 @@ allocate_dynrelocs (struct elf_link_hash for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf32_External_Rel); + sreloc->size += p->count * sizeof (Elf32_External_Rel); } return TRUE; @@ -1725,7 +1725,7 @@ elf_i386_size_dynamic_sections (bfd *out s = bfd_get_section_by_name (dynobj, ".interp"); if (s == NULL) abort (); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -1764,7 +1764,7 @@ elf_i386_size_dynamic_sections (bfd *out else if (p->count != 0) { srel = elf_section_data (p->sec)->sreloc; - srel->_raw_size += p->count * sizeof (Elf32_External_Rel); + srel->size += p->count * sizeof (Elf32_External_Rel); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -1785,19 +1785,19 @@ elf_i386_size_dynamic_sections (bfd *out { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += 4; + *local_got = s->size; + s->size += 4; if (*local_tls_type == GOT_TLS_GD || *local_tls_type == GOT_TLS_IE_BOTH) - s->_raw_size += 4; + s->size += 4; if (info->shared || *local_tls_type == GOT_TLS_GD || (*local_tls_type & GOT_TLS_IE)) { if (*local_tls_type == GOT_TLS_IE_BOTH) - srel->_raw_size += 2 * sizeof (Elf32_External_Rel); + srel->size += 2 * sizeof (Elf32_External_Rel); else - srel->_raw_size += sizeof (Elf32_External_Rel); + srel->size += sizeof (Elf32_External_Rel); } } else @@ -1809,9 +1809,9 @@ elf_i386_size_dynamic_sections (bfd *out { /* Allocate 2 got entries and 1 dynamic reloc for R_386_TLS_LDM relocs. */ - htab->tls_ldm_got.offset = htab->sgot->_raw_size; - htab->sgot->_raw_size += 8; - htab->srelgot->_raw_size += sizeof (Elf32_External_Rel); + htab->tls_ldm_got.offset = htab->sgot->size; + htab->sgot->size += 8; + htab->srelgot->size += sizeof (Elf32_External_Rel); } else htab->tls_ldm_got.offset = -1; @@ -1837,7 +1837,7 @@ elf_i386_size_dynamic_sections (bfd *out } else if (strncmp (bfd_get_section_name (dynobj, s), ".rel", 4) == 0) { - if (s->_raw_size != 0 && s != htab->srelplt) + if (s->size != 0 && s != htab->srelplt) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -1850,7 +1850,7 @@ elf_i386_size_dynamic_sections (bfd *out continue; } - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rel.bss and @@ -1871,7 +1871,7 @@ elf_i386_size_dynamic_sections (bfd *out section's contents are written out. This should not happen, but this way if it does, we get a R_386_NONE reloc instead of garbage. */ - s->contents = bfd_zalloc (dynobj, s->_raw_size); + s->contents = bfd_zalloc (dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -1892,7 +1892,7 @@ elf_i386_size_dynamic_sections (bfd *out return FALSE; } - if (htab->splt->_raw_size != 0) + if (htab->splt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -2449,7 +2449,7 @@ elf_i386_relocate_section (bfd *output_b BFD_ASSERT (rel->r_offset >= 2); type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2); BFD_ASSERT (type == 0x8d || type == 0x04); - BFD_ASSERT (rel->r_offset + 9 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 9 <= input_section->size); BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 4) == 0xe8); @@ -2475,7 +2475,7 @@ elf_i386_relocate_section (bfd *output_b else { BFD_ASSERT ((val & 0xf8) == 0x80 && (val & 7) != 4); - if (rel->r_offset + 10 <= input_section->_raw_size + if (rel->r_offset + 10 <= input_section->size && bfd_get_8 (input_bfd, contents + rel->r_offset + 9) == 0x90) { @@ -2518,7 +2518,7 @@ elf_i386_relocate_section (bfd *output_b addl $foo, %reg. */ BFD_ASSERT (rel->r_offset >= 1); val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); - BFD_ASSERT (rel->r_offset + 4 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 4 <= input_section->size); if (val == 0xa1) { /* movl foo, %eax. */ @@ -2575,7 +2575,7 @@ elf_i386_relocate_section (bfd *output_b BFD_ASSERT (rel->r_offset >= 2); type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2); val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); - BFD_ASSERT (rel->r_offset + 4 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 4 <= input_section->size); BFD_ASSERT ((val & 0xc0) == 0x80 && (val & 7) != 4); if (type == 0x8b) { @@ -2724,7 +2724,7 @@ elf_i386_relocate_section (bfd *output_b BFD_ASSERT (rel->r_offset >= 2); type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2); BFD_ASSERT (type == 0x8d || type == 0x04); - BFD_ASSERT (rel->r_offset + 9 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 9 <= input_section->size); BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 4) == 0xe8); BFD_ASSERT (rel + 1 < relend); @@ -2748,7 +2748,7 @@ elf_i386_relocate_section (bfd *output_b /* leal foo(%reg), %eax; call ___tls_get_addr; nop Change it into: movl %gs:0, %eax; subl $foo@gottpoff(%reg), %eax. */ - BFD_ASSERT (rel->r_offset + 10 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 10 <= input_section->size); BFD_ASSERT ((val & 0xf8) == 0x80 && (val & 7) != 4); BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 9) @@ -2796,7 +2796,7 @@ elf_i386_relocate_section (bfd *output_b == 0x8d); val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); BFD_ASSERT ((val & 0xf8) == 0x80 && (val & 7) != 4); - BFD_ASSERT (rel->r_offset + 9 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 9 <= input_section->size); BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 4) == 0xe8); BFD_ASSERT (rel + 1 < relend); @@ -3160,7 +3160,7 @@ elf_i386_finish_dynamic_sections (bfd *o abort (); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -3185,7 +3185,7 @@ elf_i386_finish_dynamic_sections (bfd *o case DT_PLTRELSZ: s = htab->srelplt; - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; break; case DT_RELSZ: @@ -3198,7 +3198,7 @@ elf_i386_finish_dynamic_sections (bfd *o s = htab->srelplt; if (s == NULL) continue; - dyn.d_un.d_val -= s->_raw_size; + dyn.d_un.d_val -= s->size; break; case DT_REL: @@ -3210,7 +3210,7 @@ elf_i386_finish_dynamic_sections (bfd *o continue; if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset) continue; - dyn.d_un.d_ptr += s->_raw_size; + dyn.d_un.d_ptr += s->size; break; } @@ -3218,7 +3218,7 @@ elf_i386_finish_dynamic_sections (bfd *o } /* Fill in the first entry in the procedure linkage table. */ - if (htab->splt && htab->splt->_raw_size > 0) + if (htab->splt && htab->splt->size > 0) { if (info->shared) memcpy (htab->splt->contents, @@ -3249,7 +3249,7 @@ elf_i386_finish_dynamic_sections (bfd *o if (htab->sgotplt) { /* Fill in the first three entries in the global offset table. */ - if (htab->sgotplt->_raw_size > 0) + if (htab->sgotplt->size > 0) { bfd_put_32 (output_bfd, (sdyn == NULL ? 0 @@ -3262,7 +3262,7 @@ elf_i386_finish_dynamic_sections (bfd *o elf_section_data (htab->sgotplt->output_section)->this_hdr.sh_entsize = 4; } - if (htab->sgot && htab->sgot->_raw_size > 0) + if (htab->sgot && htab->sgot->size > 0) elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4; return TRUE; Index: bfd/elf32-i860.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-i860.c,v retrieving revision 1.30 diff -u -p -r1.30 elf32-i860.c --- bfd/elf32-i860.c 22 Mar 2004 02:28:16 -0000 1.30 +++ bfd/elf32-i860.c 22 Jun 2004 01:35:48 -0000 @@ -38,6 +38,7 @@ i860_howto_pc26_reloc (bfd *abfd ATTRIBU { bfd_vma insn; bfd_vma relocation; + bfd_size_type sz; bfd_byte *addr; if (output_bfd != NULL @@ -63,7 +64,8 @@ i860_howto_pc26_reloc (bfd *abfd ATTRIBU relocation += symbol->section->output_offset; relocation += reloc_entry->addend; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Adjust for PC-relative relocation. */ @@ -101,6 +103,7 @@ i860_howto_pc16_reloc (bfd *abfd, { bfd_vma insn; bfd_vma relocation; + bfd_size_type sz; bfd_byte *addr; if (output_bfd != NULL @@ -126,7 +129,8 @@ i860_howto_pc16_reloc (bfd *abfd, relocation += symbol->section->output_offset; relocation += reloc_entry->addend; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Adjust for PC-relative relocation. */ @@ -165,6 +169,7 @@ i860_howto_highadj_reloc (bfd *abfd, { bfd_vma insn; bfd_vma relocation; + bfd_size_type sz; bfd_byte *addr; if (output_bfd != NULL @@ -191,7 +196,8 @@ i860_howto_highadj_reloc (bfd *abfd, relocation += reloc_entry->addend; relocation += 0x8000; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; addr = (bfd_byte *) data + reloc_entry->address; @@ -218,6 +224,7 @@ i860_howto_splitn_reloc (bfd *abfd, { bfd_vma insn; bfd_vma relocation; + bfd_size_type sz; bfd_byte *addr; if (output_bfd != NULL @@ -243,7 +250,8 @@ i860_howto_splitn_reloc (bfd *abfd, relocation += symbol->section->output_offset; relocation += reloc_entry->addend; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; addr = (bfd_byte *) data + reloc_entry->address; Index: bfd/elf32-ip2k.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-ip2k.c,v retrieving revision 1.12 diff -u -p -r1.12 elf32-ip2k.c --- bfd/elf32-ip2k.c 22 Mar 2004 02:28:16 -0000 1.12 +++ bfd/elf32-ip2k.c 22 Jun 2004 01:35:48 -0000 @@ -503,7 +503,7 @@ ip2k_is_switch_table_128 (abfd, sec, add int index = 0; /* Check current page-jmp. */ - if (addr + 4 > sec->_cooked_size) + if (addr + 4 > sec->size) return -1; ip2k_get_mem (abfd, contents + addr, 4, code); @@ -550,7 +550,7 @@ ip2k_relax_switch_table_128 (abfd, sec, addr = irel->r_offset; while (1) { - if (addr + 4 > sec->_cooked_size) + if (addr + 4 > sec->size) break; ip2k_get_mem (abfd, misc->contents + addr, 4, code); @@ -656,7 +656,7 @@ ip2k_is_switch_table_256 (abfd, sec, add int index = 0; /* Check current page-jmp. */ - if (addr + 4 > sec->_cooked_size) + if (addr + 4 > sec->size) return -1; ip2k_get_mem (abfd, contents + addr, 4, code); @@ -718,7 +718,7 @@ ip2k_relax_switch_table_256 (abfd, sec, while (1) { - if (addr + 4 > sec->_cooked_size) + if (addr + 4 > sec->size) break; ip2k_get_mem (abfd, misc->contents + addr, 4, code); @@ -840,11 +840,6 @@ ip2k_elf_relax_section (abfd, sec, link_ || (sec->flags & SEC_CODE) == 0) return TRUE; - /* If this is the first time we have been called - for this section, initialise the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, @@ -875,12 +870,7 @@ ip2k_elf_relax_section (abfd, sec, link_ else { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -917,8 +907,8 @@ ip2k_elf_relax_section (abfd, sec, link_ search_addr = 0xFFFFFFFF; } - if ((BASEADDR (sec) + sec->_cooked_size < search_addr) - && (BASEADDR (sec) + sec->_cooked_size > page_end)) + if ((BASEADDR (sec) + sec->size < search_addr) + && (BASEADDR (sec) + sec->size > page_end)) { if (BASEADDR (sec) <= page_end) search_addr = page_end + 1; @@ -940,7 +930,7 @@ ip2k_elf_relax_section (abfd, sec, link_ } /* Only process sections in range. */ - if ((BASEADDR (sec) + sec->_cooked_size >= page_start) + if ((BASEADDR (sec) + sec->size >= page_start) && (BASEADDR (sec) <= page_end)) { if (!ip2k_elf_relax_section_page (abfd, sec, &changed, &misc, page_start, page_end)) @@ -1137,6 +1127,7 @@ adjust_all_relocations (abfd, sec, addr, if (stab) { bfd_byte *stabcontents, *stabend, *stabp; + bfd_size_type stab_size = stab->rawsize ? stab->rawsize : stab->size; irelbase = elf_section_data (stab)->relocs; irelend = irelbase + stab->reloc_count; @@ -1146,19 +1137,18 @@ adjust_all_relocations (abfd, sec, addr, stabcontents = elf_section_data (stab)->this_hdr.contents; else { - stabcontents = (bfd_byte *) bfd_alloc (abfd, stab->_raw_size); - if (stabcontents == NULL) - return; - - if (! bfd_get_section_contents (abfd, stab, stabcontents, - (file_ptr) 0, stab->_raw_size)) - return; + if (!bfd_malloc_and_get_section (abfd, stab, &stabcontents)) + { + if (stabcontents != NULL) + free (stabcontents); + return; + } /* We need to remember this. */ elf_section_data (stab)->this_hdr.contents = stabcontents; } - stabend = stabcontents + stab->_raw_size; + stabend = stabcontents + stab_size; for (irel = irelbase; irel < irelend; irel++) { @@ -1308,13 +1298,13 @@ ip2k_elf_relax_delete_bytes (abfd, sec, int count; { bfd_byte *contents = elf_section_data (sec)->this_hdr.contents; - bfd_vma endaddr = sec->_cooked_size; + bfd_vma endaddr = sec->size; /* Actually delete the bytes. */ memmove (contents + addr, contents + addr + count, endaddr - addr - count); - sec->_cooked_size -= count; + sec->size -= count; adjust_all_relocations (abfd, sec, addr + count, endaddr, -count, 0); return TRUE; Index: bfd/elf32-m32r.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-m32r.c,v retrieving revision 1.44 diff -u -p -r1.44 elf32-m32r.c --- bfd/elf32-m32r.c 27 Mar 2004 10:58:06 -0000 1.44 +++ bfd/elf32-m32r.c 22 Jun 2004 01:35:51 -0000 @@ -859,11 +859,13 @@ m32r_elf_do_10_pcrel_reloc (abfd, howto, bfd_vma addend; { bfd_signed_vma relocation; + bfd_size_type sz; unsigned long x; bfd_reloc_status_type status; /* Sanity check the address (offset in section). */ - if (offset > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (offset > sz) return bfd_reloc_outofrange; relocation = symbol_value + addend; @@ -928,6 +930,7 @@ m32r_elf_hi16_reloc (abfd, reloc_entry, { bfd_reloc_status_type ret; bfd_vma relocation; + bfd_size_type sz; struct m32r_hi16 *n; /* This part is from bfd_elf_generic_reloc. @@ -942,7 +945,8 @@ m32r_elf_hi16_reloc (abfd, reloc_entry, } /* Sanity check the address (offset in section). */ - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; ret = bfd_reloc_ok; @@ -1095,6 +1099,7 @@ m32r_elf_generic_reloc (input_bfd, reloc { bfd_reloc_status_type ret; bfd_vma relocation; + bfd_size_type sz; bfd_byte *inplace_address; /* This part is from bfd_elf_generic_reloc. @@ -1115,7 +1120,8 @@ m32r_elf_generic_reloc (input_bfd, reloc a section relative addend which is wrong. */ /* Sanity check the address (offset in section). */ - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; ret = bfd_reloc_ok; @@ -2020,7 +2026,7 @@ printf("m32r_elf_adjust_dynamic_symbol() srel = htab->srelbss; BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -2031,8 +2037,7 @@ printf("m32r_elf_adjust_dynamic_symbol() power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (! bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -2041,10 +2046,10 @@ printf("m32r_elf_adjust_dynamic_symbol() /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -2104,10 +2109,10 @@ allocate_dynrelocs (h, inf) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_ENTRY_SIZE; - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -2122,14 +2127,14 @@ allocate_dynrelocs (h, inf) } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->_raw_size += 4; + htab->sgotplt->size += 4; /* We also need to make an entry in the .rel.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf32_External_Rela); + htab->srelplt->size += sizeof (Elf32_External_Rela); } else { @@ -2159,11 +2164,11 @@ allocate_dynrelocs (h, inf) s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += 4; + h->got.offset = s->size; + s->size += 4; dyn = htab->root.dynamic_sections_created; if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); } else h->got.offset = (bfd_vma) -1; @@ -2232,7 +2237,7 @@ allocate_dynrelocs (h, inf) for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela); + sreloc->size += p->count * sizeof (Elf32_External_Rela); } return TRUE; @@ -2296,7 +2301,7 @@ printf("m32r_elf_size_dynamic_sections() { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -2334,7 +2339,7 @@ printf("m32r_elf_size_dynamic_sections() else if (p->count != 0) { srel = elf_section_data (p->sec)->sreloc; - srel->_raw_size += p->count * sizeof (Elf32_External_Rela); + srel->size += p->count * sizeof (Elf32_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -2354,10 +2359,10 @@ printf("m32r_elf_size_dynamic_sections() { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += 4; + *local_got = s->size; + s->size += 4; if (info->shared) - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); } else *local_got = (bfd_vma) -1; @@ -2385,7 +2390,7 @@ printf("m32r_elf_size_dynamic_sections() } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->_raw_size != 0 && s != htab->srelplt) + if (s->size != 0 && s != htab->srelplt) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -2398,7 +2403,7 @@ printf("m32r_elf_size_dynamic_sections() continue; } - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -2418,7 +2423,7 @@ printf("m32r_elf_size_dynamic_sections() section's contents are written out. This should not happen, but this way if it does, we get a R_M32R_NONE reloc instead of garbage. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -2439,7 +2444,7 @@ printf("m32r_elf_size_dynamic_sections() return FALSE; } - if (htab->splt->_raw_size != 0) + if (htab->splt->size != 0) { if (! add_dynamic_entry (DT_PLTGOT, 0) || ! add_dynamic_entry (DT_PLTRELSZ, 0) @@ -2645,6 +2650,7 @@ m32r_elf_relocate_section (output_bfd, i else { bfd_vma relocation; + bfd_size_type sz; /* This is a final link. */ sym = NULL; @@ -2779,7 +2785,10 @@ m32r_elf_relocate_section (output_bfd, i } /* Sanity check the address. */ - if (offset > input_section->_raw_size) + sz = (input_section->rawsize + ? input_section->rawsize + : input_section->size); + if (offset > input_section->size) { r = bfd_reloc_outofrange; goto check_reloc; @@ -3450,7 +3459,7 @@ printf("m32r_elf_finish_dynamic_sections BFD_ASSERT (sgot != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { @@ -3481,10 +3490,7 @@ printf("m32r_elf_finish_dynamic_sections case DT_PLTRELSZ: s = htab->srelplt->output_section; BFD_ASSERT (s != NULL); - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -3501,10 +3507,7 @@ printf("m32r_elf_finish_dynamic_sections if (htab->srelplt != NULL) { s = htab->srelplt->output_section; - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; + dyn.d_un.d_val -= s->size; } bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -3513,7 +3516,7 @@ printf("m32r_elf_finish_dynamic_sections /* Fill in the first entry in the procedure linkage table. */ splt = htab->splt; - if (splt && splt->_raw_size > 0) + if (splt && splt->size > 0) { if (info->shared) { @@ -3545,7 +3548,7 @@ printf("m32r_elf_finish_dynamic_sections } /* Fill in the first three entries in the global offset table. */ - if (sgot && sgot->_raw_size > 0) + if (sgot && sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); @@ -3615,11 +3618,6 @@ m32r_elf_relax_section (abfd, sec, link_ || 0 /* FIXME: check SHF_M32R_CAN_RELAX */) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; /* Get a copy of the native relocations. */ @@ -3649,12 +3647,7 @@ m32r_elf_relax_section (abfd, sec, link_ else { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -3734,7 +3727,7 @@ m32r_elf_relax_section (abfd, sec, link_ /* Do nothing if no room in the section for this to be what we're looking for. */ - if (irel->r_offset > sec->_cooked_size - 8) + if (irel->r_offset > sec->size - 8) continue; /* Make sure the next relocation applies to the next @@ -3776,7 +3769,7 @@ m32r_elf_relax_section (abfd, sec, link_ if (pcrel_value >= -(1 << 25) && pcrel_value < (1 << 25) + 4 /* Do nothing if no room in the section for this to be what we're looking for. */ - && (irel->r_offset <= sec->_cooked_size - 12) + && (irel->r_offset <= sec->size - 12) /* Ensure the next insn is "jl rN". */ && ((code = bfd_get_16 (abfd, contents + irel->r_offset + 8)), code != (0x1ec0 | reg))) @@ -3943,14 +3936,14 @@ m32r_elf_relax_delete_bytes (abfd, sec, power larger than the number of bytes we are deleting. */ irelalign = NULL; - toaddr = sec->_cooked_size; + toaddr = sec->size; irel = elf_section_data (sec)->relocs; irelend = irel + sec->reloc_count; /* Actually delete the bytes. */ memmove (contents + addr, contents + addr + count, toaddr - addr - count); - sec->_cooked_size -= count; + sec->size -= count; /* Adjust all the relocs. */ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++) @@ -4027,7 +4020,7 @@ m32r_elf_get_relocated_section_contents symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; memcpy (data, elf_section_data (input_section)->this_hdr.contents, - input_section->_raw_size); + input_section->size); if ((input_section->flags & SEC_RELOC) != 0 && input_section->reloc_count > 0) Index: bfd/elf32-m68hc11.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-m68hc11.c,v retrieving revision 1.25 diff -u -p -r1.25 elf32-m68hc11.c --- bfd/elf32-m68hc11.c 27 Nov 2003 18:49:37 -0000 1.25 +++ bfd/elf32-m68hc11.c 22 Jun 2004 01:35:52 -0000 @@ -1,5 +1,6 @@ /* Motorola 68HC11-specific support for 32-bit ELF - Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. Contributed by Stephane Carrez (stcarrez@nerim.fr) (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com)) @@ -394,8 +395,8 @@ m68hc11_elf_build_one_stub (struct bfd_h stub_sec = stub_entry->stub_sec; /* Make a note of the offset within the stubs for this entry. */ - stub_entry->stub_offset = stub_sec->_raw_size; - stub_sec->_raw_size += 10; + stub_entry->stub_offset = stub_sec->size; + stub_sec->size += 10; loc = stub_sec->contents + stub_entry->stub_offset; stub_bfd = stub_sec->owner; @@ -445,7 +446,7 @@ m68hc11_elf_size_one_stub (struct bfd_ha /* Massage our args to the form they really have. */ stub_entry = (struct elf32_m68hc11_stub_hash_entry *) gen_entry; - stub_entry->stub_sec->_raw_size += 10; + stub_entry->stub_sec->size += 10; return TRUE; } @@ -679,11 +680,6 @@ m68hc11_elf_relax_section (bfd *abfd, as || (sec->flags & SEC_CODE) == 0) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; @@ -731,13 +727,7 @@ m68hc11_elf_relax_section (bfd *abfd, as else { /* Go get them off disk. */ - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - free_contents = contents; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -763,7 +753,7 @@ m68hc11_elf_relax_section (bfd *abfd, as prev_insn_group = 0; /* Do nothing if this reloc is the last byte in the section. */ - if (irel->r_offset + 2 >= sec->_cooked_size) + if (irel->r_offset + 2 >= sec->size) continue; /* See if the next instruction is an unconditional pc-relative @@ -849,7 +839,7 @@ m68hc11_elf_relax_section (bfd *abfd, as prev_insn_group = 0; /* Do nothing if this reloc is the last byte in the section. */ - if (irel->r_offset == sec->_cooked_size) + if (irel->r_offset == sec->size) continue; prev_insn_group = irel; @@ -952,7 +942,7 @@ m68hc11_elf_relax_section (bfd *abfd, as if (prev_insn_group) { - unsigned long old_sec_size = sec->_cooked_size; + unsigned long old_sec_size = sec->size; /* Note that we've changed the relocation contents, etc. */ elf_section_data (sec)->relocs = internal_relocs; @@ -971,7 +961,7 @@ m68hc11_elf_relax_section (bfd *abfd, as prev_insn_group = 0; irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_M68HC11_NONE); - if (sec->_cooked_size != old_sec_size) + if (sec->size != old_sec_size) *again = TRUE; continue; } @@ -1124,7 +1114,7 @@ m68hc11_elf_relax_delete_bytes (bfd *abf contents = elf_section_data (sec)->this_hdr.contents; - toaddr = sec->_cooked_size; + toaddr = sec->size; irel = elf_section_data (sec)->relocs; irelend = irel + sec->reloc_count; @@ -1133,7 +1123,7 @@ m68hc11_elf_relax_delete_bytes (bfd *abf memmove (contents + addr, contents + addr + count, (size_t) (toaddr - addr - count)); - sec->_cooked_size -= count; + sec->size -= count; /* Adjust all the relocs. */ for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++) Index: bfd/elf32-m68hc12.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-m68hc12.c,v retrieving revision 1.17 diff -u -p -r1.17 elf32-m68hc12.c --- bfd/elf32-m68hc12.c 4 Oct 2003 21:02:53 -0000 1.17 +++ bfd/elf32-m68hc12.c 22 Jun 2004 01:35:52 -0000 @@ -1,5 +1,5 @@ /* Motorola 68HC12-specific support for 32-bit ELF - Copyright 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by Stephane Carrez (stcarrez@nerim.fr) (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com)) @@ -443,8 +443,8 @@ m68hc12_elf_build_one_stub (struct bfd_h stub_sec = stub_entry->stub_sec; /* Make a note of the offset within the stubs for this entry. */ - stub_entry->stub_offset = stub_sec->_raw_size; - stub_sec->_raw_size += 7; + stub_entry->stub_offset = stub_sec->size; + stub_sec->size += 7; loc = stub_sec->contents + stub_entry->stub_offset; stub_bfd = stub_sec->owner; @@ -486,7 +486,7 @@ m68hc12_elf_size_one_stub (struct bfd_ha /* Massage our args to the form they really have. */ stub_entry = (struct elf32_m68hc11_stub_hash_entry *) gen_entry; - stub_entry->stub_sec->_raw_size += 7; + stub_entry->stub_sec->size += 7; return TRUE; } Index: bfd/elf32-m68hc1x.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v retrieving revision 1.13 diff -u -p -r1.13 elf32-m68hc1x.c --- bfd/elf32-m68hc1x.c 27 Mar 2004 10:58:06 -0000 1.13 +++ bfd/elf32-m68hc1x.c 22 Jun 2004 01:35:55 -0000 @@ -534,8 +534,7 @@ elf32_m68hc11_size_stubs (bfd *output_bf stub_sec != NULL; stub_sec = stub_sec->next) { - stub_sec->_raw_size = 0; - stub_sec->_cooked_size = 0; + stub_sec->size = 0; } bfd_hash_traverse (htab->stub_hash_table, htab->size_one_stub, htab); @@ -629,11 +628,11 @@ elf32_m68hc11_build_stubs (bfd *abfd, st bfd_size_type size; /* Allocate memory to hold the linker stubs. */ - size = stub_sec->_raw_size; + size = stub_sec->size; stub_sec->contents = (unsigned char *) bfd_zalloc (htab->stub_bfd, size); if (stub_sec->contents == NULL && size != 0) return FALSE; - stub_sec->_raw_size = 0; + stub_sec->size = 0; } /* Build the stubs as directed by the stub hash table. */ @@ -791,6 +790,8 @@ m68hc11_elf_special_reloc (bfd *abfd ATT bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED) { + bfd_size_type sz; + if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0 && (! reloc_entry->howto->partial_inplace @@ -803,7 +804,8 @@ m68hc11_elf_special_reloc (bfd *abfd ATT if (output_bfd != NULL) return bfd_reloc_continue; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; abort(); Index: bfd/elf32-m68k.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-m68k.c,v retrieving revision 1.64 diff -u -p -r1.64 elf32-m68k.c --- bfd/elf32-m68k.c 27 Mar 2004 10:58:06 -0000 1.64 +++ bfd/elf32-m68k.c 22 Jun 2004 01:35:56 -0000 @@ -513,9 +513,9 @@ elf_m68k_check_relocs (abfd, info, sec, } /* Allocate space in the .got section. */ - sgot->_raw_size += 4; + sgot->size += 4; /* Allocate relocation space. */ - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } h->got.refcount++; } @@ -536,13 +536,13 @@ elf_m68k_check_relocs (abfd, info, sec, } if (local_got_refcounts[r_symndx] == 0) { - sgot->_raw_size += 4; + sgot->size += 4; if (info->shared) { /* If we are generating a shared object, we need to output a R_68K_RELATIVE reloc so that the dynamic linker can adjust this GOT entry. */ - srelgot->_raw_size += sizeof (Elf32_External_Rela); + srelgot->size += sizeof (Elf32_External_Rela); } } local_got_refcounts[r_symndx]++; @@ -684,7 +684,7 @@ elf_m68k_check_relocs (abfd, info, sec, || ELF32_R_TYPE (rel->r_info) == R_68K_PC32)) info->flags |= DF_TEXTREL; - sreloc->_raw_size += sizeof (Elf32_External_Rela); + sreloc->size += sizeof (Elf32_External_Rela); /* We count the number of PC relative relocations we have entered for this symbol, so that we can discard them @@ -856,8 +856,8 @@ elf_m68k_gc_sweep_hook (abfd, info, sec, if (h->got.refcount == 0) { /* We don't need the .got entry any more. */ - sgot->_raw_size -= 4; - srelgot->_raw_size -= sizeof (Elf32_External_Rela); + sgot->size -= 4; + srelgot->size -= sizeof (Elf32_External_Rela); } } } @@ -869,9 +869,9 @@ elf_m68k_gc_sweep_hook (abfd, info, sec, if (local_got_refcounts[r_symndx] == 0) { /* We don't need the .got entry any more. */ - sgot->_raw_size -= 4; + sgot->size -= 4; if (info->shared) - srelgot->_raw_size -= sizeof (Elf32_External_Rela); + srelgot->size -= sizeof (Elf32_External_Rela); } } } @@ -979,12 +979,12 @@ elf_m68k_adjust_dynamic_symbol (info, h) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) + if (s->size == 0) { if (CPU32_FLAG (dynobj)) - s->_raw_size += PLT_CPU32_ENTRY_SIZE; + s->size += PLT_CPU32_ENTRY_SIZE; else - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; } /* If this symbol is not defined in a regular file, and we are @@ -996,27 +996,27 @@ elf_m68k_adjust_dynamic_symbol (info, h) && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) { h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; } - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* Make room for this entry. */ if (CPU32_FLAG (dynobj)) - s->_raw_size += PLT_CPU32_ENTRY_SIZE; + s->size += PLT_CPU32_ENTRY_SIZE; else - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ s = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += 4; + s->size += 4; /* We also need to make an entry in the .rela.plt section. */ s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += sizeof (Elf32_External_Rela); + s->size += sizeof (Elf32_External_Rela); return TRUE; } @@ -1070,7 +1070,7 @@ elf_m68k_adjust_dynamic_symbol (info, h) srel = bfd_get_section_by_name (dynobj, ".rela.bss"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1081,8 +1081,7 @@ elf_m68k_adjust_dynamic_symbol (info, h) power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (!bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -1091,10 +1090,10 @@ elf_m68k_adjust_dynamic_symbol (info, h) /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1121,7 +1120,7 @@ elf_m68k_size_dynamic_sections (output_b { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -1134,7 +1133,7 @@ elf_m68k_size_dynamic_sections (output_b below. */ s = bfd_get_section_by_name (dynobj, ".rela.got"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; } /* If this is a -Bsymbolic shared link, then we need to discard all @@ -1169,7 +1168,7 @@ elf_m68k_size_dynamic_sections (output_b if (strcmp (name, ".plt") == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* Strip this section if we don't need it; see the comment below. */ @@ -1183,7 +1182,7 @@ elf_m68k_size_dynamic_sections (output_b } else if (strncmp (name, ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -1223,8 +1222,8 @@ elf_m68k_size_dynamic_sections (output_b are written out, but at the moment this does not happen. Thus in order to prevent writing out garbage, we initialise the section's contents to zero. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -1319,7 +1318,7 @@ elf_m68k_discard_copies (h, inf) for (s = elf_m68k_hash_entry (h)->pcrel_relocs_copied; s != NULL; s = s->next) - s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela); + s->section->size -= s->count * sizeof (Elf32_External_Rela); return TRUE; } @@ -1970,7 +1969,7 @@ elf_m68k_finish_dynamic_sections (output BFD_ASSERT (splt != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -1999,10 +1998,7 @@ elf_m68k_finish_dynamic_sections (output case DT_PLTRELSZ: s = bfd_get_section_by_name (output_bfd, ".rela.plt"); BFD_ASSERT (s != NULL); - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -2016,19 +2012,14 @@ elf_m68k_finish_dynamic_sections (output about changing the DT_RELA entry. */ s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s != NULL) - { - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; - } + dyn.d_un.d_val -= s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; } } /* Fill in the first entry in the procedure linkage table. */ - if (splt->_raw_size > 0) + if (splt->size > 0) { if (!CPU32_FLAG (output_bfd)) { @@ -2066,7 +2057,7 @@ elf_m68k_finish_dynamic_sections (output } /* Fill in the first three entries in the global offset table. */ - if (sgot->_raw_size > 0) + if (sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); Index: bfd/elf32-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-mips.c,v retrieving revision 1.176 diff -u -p -r1.176 elf32-mips.c --- bfd/elf32-mips.c 14 Jun 2004 18:25:09 -0000 1.176 +++ bfd/elf32-mips.c 22 Jun 2004 01:35:56 -0000 @@ -1,6 +1,6 @@ /* MIPS-specific support for 32-bit ELF Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003 Free Software Foundation, Inc. + 2003, 2004 Free Software Foundation, Inc. Most of the information added by Ian Lance Taylor, Cygnus Support, . @@ -824,6 +824,7 @@ gprel32_with_gp (bfd *abfd, asymbol *sym { bfd_vma relocation; bfd_vma val; + bfd_size_type sz; if (bfd_is_com_section (symbol->section)) relocation = 0; @@ -833,7 +834,8 @@ gprel32_with_gp (bfd *abfd, asymbol *sym relocation += symbol->section->output_section->vma; relocation += symbol->section->output_offset; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Set val to the offset into the section or symbol. */ @@ -941,6 +943,7 @@ mips16_gprel_reloc (bfd *abfd, arelent * unsigned short insn = 0; bfd_signed_vma val; bfd_vma relocation; + bfd_size_type sz; /* If we're relocating, and this is an external symbol, we don't want to change anything. */ @@ -965,7 +968,8 @@ mips16_gprel_reloc (bfd *abfd, arelent * if (ret != bfd_reloc_ok) return ret; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; if (bfd_is_com_section (symbol->section)) @@ -1209,7 +1213,7 @@ static bfd_boolean elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; - unsigned int raw_size; + unsigned int size; switch (note->descsz) { @@ -1225,14 +1229,14 @@ elf32_mips_grok_prstatus (bfd *abfd, Elf /* pr_reg */ offset = 72; - raw_size = 180; + size = 180; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean Index: bfd/elf32-or32.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-or32.c,v retrieving revision 1.5 diff -u -p -r1.5 elf32-or32.c --- bfd/elf32-or32.c 30 Nov 2002 08:39:38 -0000 1.5 +++ bfd/elf32-or32.c 22 Jun 2004 01:35:56 -0000 @@ -1,5 +1,5 @@ /* OR32-specific support for 32-bit ELF - Copyright 2002 Free Software Foundation, Inc. + Copyright 2002, 2004 Free Software Foundation, Inc. Contributed by Ivan Guzvinec This file is part of BFD, the Binary File Descriptor library. @@ -400,6 +400,7 @@ or32_elf_consth_reloc (abfd, reloc_entry { bfd_reloc_status_type ret; bfd_vma relocation; + bfd_size_type sz; struct or32_consth *n; ret = bfd_reloc_ok; @@ -417,7 +418,8 @@ or32_elf_consth_reloc (abfd, reloc_entry relocation += symbol->section->output_offset; relocation += reloc_entry->addend; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Save the information, and let LO16 do the actual relocation. */ Index: bfd/elf32-ppc.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-ppc.c,v retrieving revision 1.120 diff -u -p -r1.120 elf32-ppc.c --- bfd/elf32-ppc.c 17 Jun 2004 02:27:12 -0000 1.120 +++ bfd/elf32-ppc.c 22 Jun 2004 01:35:57 -0000 @@ -1679,11 +1679,7 @@ ppc_elf_relax_section (bfd *abfd, if ((isec->flags & SEC_RELOC) == 0 || isec->reloc_count == 0) return TRUE; - /* If needed, initialize this section's cooked size. */ - if (isec->_cooked_size == 0) - isec->_cooked_size = isec->_raw_size; - - trampoff = (isec->_cooked_size + 3) & (bfd_vma) -4; + trampoff = (isec->size + 3) & (bfd_vma) -4; /* Space for a branch around any trampolines. */ trampoff += 4; @@ -1698,21 +1694,6 @@ ppc_elf_relax_section (bfd *abfd, ppc_info = ppc_elf_hash_table (link_info); irelend = internal_relocs + isec->reloc_count; - /* Get the section contents. */ - /* Get cached copy if it exists. */ - if (elf_section_data (isec)->this_hdr.contents != NULL) - contents = elf_section_data (isec)->this_hdr.contents; - else - { - /* Go get them off disk. */ - contents = bfd_malloc (isec->_raw_size); - if (contents == NULL) - goto error_return; - - if (!bfd_get_section_contents (abfd, isec, contents, 0, isec->_raw_size)) - goto error_return; - } - for (irel = internal_relocs; irel < irelend; irel++) { unsigned long r_type = ELF32_R_TYPE (irel->r_info); @@ -1877,6 +1858,20 @@ ppc_elf_relax_section (bfd *abfd, irel->r_info = ELF32_R_INFO (0, R_PPC_NONE); } + /* Get the section contents. */ + if (contents == NULL) + { + /* Get cached copy if it exists. */ + if (elf_section_data (isec)->this_hdr.contents != NULL) + contents = elf_section_data (isec)->this_hdr.contents; + else + { + /* Go get them off disk. */ + if (!bfd_malloc_and_get_section (abfd, isec, &contents)) + goto error_return; + } + } + /* Fix up the existing branch to hit the trampoline. */ hit_addr = contents + roff; switch (r_type) @@ -1922,11 +1917,11 @@ ppc_elf_relax_section (bfd *abfd, if (contents == NULL) goto error_return; - isec->_cooked_size = (isec->_cooked_size + 3) & (bfd_vma) -4; + isec->size = (isec->size + 3) & (bfd_vma) -4; /* Branch around the trampolines. */ - val = trampoff - isec->_cooked_size + 0x48000000; - dest = contents + isec->_cooked_size; - isec->_cooked_size = trampoff; + val = trampoff - isec->size + 0x48000000; + dest = contents + isec->size; + isec->size = trampoff; bfd_put_32 (abfd, val, dest); dest += 4; @@ -2128,6 +2123,7 @@ ppc_elf_addr16_ha_reloc (bfd *abfd ATTRI char **error_message ATTRIBUTE_UNUSED) { bfd_vma relocation; + bfd_size_type sz; if (output_bfd != NULL) { @@ -2135,7 +2131,8 @@ ppc_elf_addr16_ha_reloc (bfd *abfd ATTRI return bfd_reloc_ok; } - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; if (bfd_is_com_section (symbol->section)) @@ -2397,7 +2394,7 @@ elf_create_pointer_linker_section (bfd * } if (lsect->rel_section) - lsect->rel_section->_raw_size += sizeof (Elf32_External_Rela); + lsect->rel_section->size += sizeof (Elf32_External_Rela); } else { @@ -2433,7 +2430,7 @@ elf_create_pointer_linker_section (bfd * output a R__RELATIVE reloc so that the dynamic linker can adjust this GOT entry. */ BFD_ASSERT (lsect->rel_section != NULL); - lsect->rel_section->_raw_size += sizeof (Elf32_External_Rela); + lsect->rel_section->size += sizeof (Elf32_External_Rela); } } @@ -2452,14 +2449,14 @@ elf_create_pointer_linker_section (bfd * linker_section_ptr->written_address_p = FALSE; *ptr_linker_section_ptr = linker_section_ptr; - linker_section_ptr->offset = lsect->section->_raw_size; - lsect->section->_raw_size += 4; + linker_section_ptr->offset = lsect->section->size; + lsect->section->size += 4; #ifdef DEBUG fprintf (stderr, "Create pointer in linker section %s, offset = %ld, section size = %ld\n", lsect->name, (long) linker_section_ptr->offset, - (long) lsect->section->_raw_size); + (long) lsect->section->size); #endif return TRUE; @@ -2658,11 +2655,11 @@ ppc_elf_create_linker_section (bfd *abfd && !bfd_set_section_alignment (htab->elf.dynobj, s, 2)) return NULL; - s->_raw_size = align_power (s->_raw_size, 2); + s->size = align_power (s->size, 2); #ifdef DEBUG fprintf (stderr, "Creating section %s, current size = %ld\n", - name, (long) s->_raw_size); + name, (long) s->size); #endif if (sym_name) @@ -2722,11 +2719,11 @@ ppc_elf_additional_program_headers (bfd ++ret; s = bfd_get_section_by_name (abfd, ".sbss2"); - if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0) + if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->size > 0) ++ret; s = bfd_get_section_by_name (abfd, ".PPC.EMB.sbss0"); - if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0) + if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->size > 0) ++ret; return ret; @@ -2966,7 +2963,7 @@ ppc_elf_adjust_dynamic_symbol (struct bf else srel = htab->relbss; BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -2977,8 +2974,7 @@ ppc_elf_adjust_dynamic_symbol (struct bf power_of_two = 4; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) { if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) @@ -2987,10 +2983,10 @@ ppc_elf_adjust_dynamic_symbol (struct bf /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -3044,15 +3040,15 @@ allocate_dynrelocs (struct elf_link_hash /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_INITIAL_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_INITIAL_ENTRY_SIZE; /* The PowerPC PLT is actually composed of two parts, the first part is 2 words (for a load and a jump), and then there is a remaining word available at the end. */ h->plt.offset = (PLT_INITIAL_ENTRY_SIZE + (PLT_SLOT_SIZE - * ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) + * ((s->size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE))); /* If this symbol is not defined in a regular file, and we @@ -3069,13 +3065,13 @@ allocate_dynrelocs (struct elf_link_hash /* Make room for this entry. After the 8192nd entry, room for two entries is allocated. */ - s->_raw_size += PLT_ENTRY_SIZE; - if ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE + s->size += PLT_ENTRY_SIZE; + if ((s->size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE > PLT_NUM_SINGLE_ENTRIES) - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .rela.plt section. */ - htab->relplt->_raw_size += sizeof (Elf32_External_Rela); + htab->relplt->size += sizeof (Elf32_External_Rela); } else { @@ -3107,20 +3103,20 @@ allocate_dynrelocs (struct elf_link_hash else { bfd_boolean dyn; - eh->elf.got.offset = htab->got->_raw_size; + eh->elf.got.offset = htab->got->size; if ((eh->tls_mask & TLS_TLS) != 0) { if ((eh->tls_mask & TLS_LD) != 0) - htab->got->_raw_size += 8; + htab->got->size += 8; if ((eh->tls_mask & TLS_GD) != 0) - htab->got->_raw_size += 8; + htab->got->size += 8; if ((eh->tls_mask & (TLS_TPREL | TLS_TPRELGD)) != 0) - htab->got->_raw_size += 4; + htab->got->size += 4; if ((eh->tls_mask & TLS_DTPREL) != 0) - htab->got->_raw_size += 4; + htab->got->size += 4; } else - htab->got->_raw_size += 4; + htab->got->size += 4; dyn = htab->elf.dynamic_sections_created; if ((info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, &eh->elf)) @@ -3128,12 +3124,12 @@ allocate_dynrelocs (struct elf_link_hash || eh->elf.root.type != bfd_link_hash_undefweak)) { /* All the entries we allocated need relocs. */ - htab->relgot->_raw_size - += ((htab->got->_raw_size - eh->elf.got.offset) / 4 + htab->relgot->size + += ((htab->got->size - eh->elf.got.offset) / 4 * sizeof (Elf32_External_Rela)); /* Except LD only needs one. */ if ((eh->tls_mask & TLS_LD) != 0) - htab->relgot->_raw_size -= sizeof (Elf32_External_Rela); + htab->relgot->size -= sizeof (Elf32_External_Rela); } } } @@ -3224,7 +3220,7 @@ allocate_dynrelocs (struct elf_link_hash for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela); + sreloc->size += p->count * sizeof (Elf32_External_Rela); } return TRUE; @@ -3285,17 +3281,17 @@ ppc_elf_size_dynamic_sections (bfd *outp { s = bfd_get_section_by_name (htab->elf.dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } if (htab->tlsld_got.refcount > 0) { - htab->tlsld_got.offset = htab->got->_raw_size; - htab->got->_raw_size += 8; + htab->tlsld_got.offset = htab->got->size; + htab->got->size += 8; if (info->shared) - htab->relgot->_raw_size += sizeof (Elf32_External_Rela); + htab->relgot->size += sizeof (Elf32_External_Rela); } else htab->tlsld_got.offset = (bfd_vma) -1; @@ -3333,7 +3329,7 @@ ppc_elf_size_dynamic_sections (bfd *outp } else if (p->count != 0) { - elf_section_data (p->sec)->sreloc->_raw_size + elf_section_data (p->sec)->sreloc->size += p->count * sizeof (Elf32_External_Rela); if ((p->sec->output_section->flags & (SEC_READONLY | SEC_ALLOC)) @@ -3362,30 +3358,30 @@ ppc_elf_size_dynamic_sections (bfd *outp htab->tlsld_got.offset. */ if (htab->tlsld_got.offset == (bfd_vma) -1) { - htab->tlsld_got.offset = s->_raw_size; - s->_raw_size += 8; + htab->tlsld_got.offset = s->size; + s->size += 8; if (info->shared) - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); } *local_got = (bfd_vma) -1; } else { - *local_got = s->_raw_size; + *local_got = s->size; if ((*lgot_masks & TLS_TLS) != 0) { if ((*lgot_masks & TLS_GD) != 0) - s->_raw_size += 8; + s->size += 8; if ((*lgot_masks & (TLS_TPREL | TLS_TPRELGD)) != 0) - s->_raw_size += 4; + s->size += 4; if ((*lgot_masks & TLS_DTPREL) != 0) - s->_raw_size += 4; + s->size += 4; } else - s->_raw_size += 4; + s->size += 4; if (info->shared) - srel->_raw_size += ((s->_raw_size - *local_got) / 4 - * sizeof (Elf32_External_Rela)); + srel->size += ((s->size - *local_got) / 4 + * sizeof (Elf32_External_Rela)); } } else @@ -3413,7 +3409,7 @@ ppc_elf_size_dynamic_sections (bfd *outp } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -3441,14 +3437,14 @@ ppc_elf_size_dynamic_sections (bfd *outp continue; } - if (s->_raw_size == 0) + if (s->size == 0) { _bfd_strip_section_from_output (info, s); continue; } /* Allocate memory for the section contents. */ - s->contents = bfd_zalloc (htab->elf.dynobj, s->_raw_size); + s->contents = bfd_zalloc (htab->elf.dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -3469,7 +3465,7 @@ ppc_elf_size_dynamic_sections (bfd *outp return FALSE; } - if (htab->plt != NULL && htab->plt->_raw_size != 0) + if (htab->plt != NULL && htab->plt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -4533,7 +4529,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou BFD_ASSERT (htab->plt != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -4549,7 +4545,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou break; case DT_PLTRELSZ: - dyn.d_un.d_val = htab->relplt->_raw_size; + dyn.d_un.d_val = htab->relplt->size; break; case DT_JMPREL: @@ -5791,7 +5787,7 @@ static bfd_boolean ppc_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; - unsigned int raw_size; + unsigned int size; switch (note->descsz) { @@ -5807,14 +5803,14 @@ ppc_elf_grok_prstatus (bfd *abfd, Elf_In /* pr_reg */ offset = 72; - raw_size = 192; + size = 192; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean @@ -5960,7 +5956,7 @@ ppc_elf_begin_write_processing (bfd *abf if (asec) { ++ num_input_sections; - output_section_size += asec->_raw_size; + output_section_size += asec->size; } } @@ -5992,7 +5988,7 @@ ppc_elf_begin_write_processing (bfd *abf if (asec == NULL) continue; - length = asec->_raw_size; + length = asec->size; if (length < 24) { error_message = _("corrupt or empty %s section in %s"); @@ -6093,7 +6089,7 @@ ppc_elf_final_write_processing (bfd *abf if (apuinfo_list_length () == 0) return; - length = asec->_raw_size; + length = asec->size; if (length < 20) return; @@ -6119,7 +6115,7 @@ ppc_elf_final_write_processing (bfd *abf length += 4; } - if (length != asec->_raw_size) + if (length != asec->size) (*_bfd_error_handler) (_("failed to compute new APUinfo section.")); if (! bfd_set_section_contents (abfd, asec, buffer, (file_ptr) 0, length)) Index: bfd/elf32-s390.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-s390.c,v retrieving revision 1.61 diff -u -p -r1.61 elf32-s390.c --- bfd/elf32-s390.c 22 Apr 2004 14:45:31 -0000 1.61 +++ bfd/elf32-s390.c 22 Jun 2004 01:35:59 -0000 @@ -398,6 +398,7 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, reloc_howto_type *howto = reloc_entry->howto; bfd_vma relocation; bfd_vma insn; + bfd_size_type sz; if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0 @@ -411,7 +412,8 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, if (output_bfd != NULL) return bfd_reloc_continue; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; relocation = (symbol->value @@ -1687,7 +1689,7 @@ elf_s390_adjust_dynamic_symbol (info, h) runtime process image. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { - htab->srelbss->_raw_size += sizeof (Elf32_External_Rela); + htab->srelbss->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1699,7 +1701,7 @@ elf_s390_adjust_dynamic_symbol (info, h) /* Apply the required alignment. */ s = htab->sdynbss; - s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) { if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) @@ -1708,10 +1710,10 @@ elf_s390_adjust_dynamic_symbol (info, h) /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1762,10 +1764,10 @@ allocate_dynrelocs (h, inf) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_FIRST_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_FIRST_ENTRY_SIZE; - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -1780,14 +1782,14 @@ allocate_dynrelocs (h, inf) } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->_raw_size += GOT_ENTRY_SIZE; + htab->sgotplt->size += GOT_ENTRY_SIZE; /* We also need to make an entry in the .rela.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf32_External_Rela); + htab->srelplt->size += sizeof (Elf32_External_Rela); } else { @@ -1817,8 +1819,8 @@ allocate_dynrelocs (h, inf) to be stored somewhere. The immediate value in the instruction is not bit enough so the value is stored in the got. */ { - h->got.offset = htab->sgot->_raw_size; - htab->sgot->_raw_size += GOT_ENTRY_SIZE; + h->got.offset = htab->sgot->size; + htab->sgot->size += GOT_ENTRY_SIZE; } else h->got.offset = (bfd_vma) -1; @@ -1839,24 +1841,24 @@ allocate_dynrelocs (h, inf) } s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += GOT_ENTRY_SIZE; + h->got.offset = s->size; + s->size += GOT_ENTRY_SIZE; /* R_390_TLS_GD32 needs 2 consecutive GOT slots. */ if (tls_type == GOT_TLS_GD) - s->_raw_size += GOT_ENTRY_SIZE; + s->size += GOT_ENTRY_SIZE; dyn = htab->elf.dynamic_sections_created; /* R_390_TLS_IE32 needs one dynamic relocation, R_390_TLS_GD32 needs one if local symbol and two if global. */ if ((tls_type == GOT_TLS_GD && h->dynindx == -1) || tls_type >= GOT_TLS_IE) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); else if (tls_type == GOT_TLS_GD) - htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rela); + htab->srelgot->size += 2 * sizeof (Elf32_External_Rela); else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) && (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); } else h->got.offset = (bfd_vma) -1; @@ -1932,7 +1934,7 @@ allocate_dynrelocs (h, inf) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela); + sreloc->size += p->count * sizeof (Elf32_External_Rela); } return TRUE; @@ -1995,7 +1997,7 @@ elf_s390_size_dynamic_sections (output_b s = bfd_get_section_by_name (dynobj, ".interp"); if (s == NULL) abort (); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -2034,7 +2036,7 @@ elf_s390_size_dynamic_sections (output_b else if (p->count != 0) { srela = elf_section_data (p->sec)->sreloc; - srela->_raw_size += p->count * sizeof (Elf32_External_Rela); + srela->size += p->count * sizeof (Elf32_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -2055,12 +2057,12 @@ elf_s390_size_dynamic_sections (output_b { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += GOT_ENTRY_SIZE; + *local_got = s->size; + s->size += GOT_ENTRY_SIZE; if (*local_tls_type == GOT_TLS_GD) - s->_raw_size += GOT_ENTRY_SIZE; + s->size += GOT_ENTRY_SIZE; if (info->shared) - srela->_raw_size += sizeof (Elf32_External_Rela); + srela->size += sizeof (Elf32_External_Rela); } else *local_got = (bfd_vma) -1; @@ -2071,9 +2073,9 @@ elf_s390_size_dynamic_sections (output_b { /* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM32 relocs. */ - htab->tls_ldm_got.offset = htab->sgot->_raw_size; - htab->sgot->_raw_size += 2 * GOT_ENTRY_SIZE; - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->tls_ldm_got.offset = htab->sgot->size; + htab->sgot->size += 2 * GOT_ENTRY_SIZE; + htab->srelgot->size += sizeof (Elf32_External_Rela); } else htab->tls_ldm_got.offset = -1; @@ -2099,7 +2101,7 @@ elf_s390_size_dynamic_sections (output_b } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->_raw_size != 0) + if (s->size != 0) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -2112,7 +2114,7 @@ elf_s390_size_dynamic_sections (output_b continue; } - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is to handle .rela.bss and @@ -2133,7 +2135,7 @@ elf_s390_size_dynamic_sections (output_b section's contents are written out. This should not happen, but this way if it does, we get a R_390_NONE reloc instead of garbage. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -2154,7 +2156,7 @@ elf_s390_size_dynamic_sections (output_b return FALSE; } - if (htab->splt->_raw_size != 0) + if (htab->splt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -3330,7 +3332,7 @@ elf_s390_finish_dynamic_sections (output abort (); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -3353,10 +3355,7 @@ elf_s390_finish_dynamic_sections (output case DT_PLTRELSZ: s = htab->srelplt->output_section; - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; break; } @@ -3364,7 +3363,7 @@ elf_s390_finish_dynamic_sections (output } /* Fill in the special first entry in the procedure linkage table. */ - if (htab->splt && htab->splt->_raw_size > 0) + if (htab->splt && htab->splt->size > 0) { memset (htab->splt->contents, 0, PLT_FIRST_ENTRY_SIZE); if (info->shared) @@ -3408,7 +3407,7 @@ elf_s390_finish_dynamic_sections (output if (htab->sgotplt) { /* Fill in the first three entries in the global offset table. */ - if (htab->sgotplt->_raw_size > 0) + if (htab->sgotplt->size > 0) { bfd_put_32 (output_bfd, (sdyn == NULL ? (bfd_vma) 0 @@ -3432,7 +3431,7 @@ elf_s390_grok_prstatus (abfd, note) Elf_Internal_Note * note; { int offset; - unsigned int raw_size; + unsigned int size; switch (note->descsz) { @@ -3448,13 +3447,13 @@ elf_s390_grok_prstatus (abfd, note) /* pr_reg */ offset = 72; - raw_size = 144; + size = 144; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } /* Return address for Ith PLT stub in section PLT, for relocation REL Index: bfd/elf32-sh.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-sh.c,v retrieving revision 1.106 diff -u -p -r1.106 elf32-sh.c --- bfd/elf32-sh.c 28 May 2004 12:32:01 -0000 1.106 +++ bfd/elf32-sh.c 22 Jun 2004 01:36:03 -0000 @@ -1843,10 +1843,12 @@ sh_elf_reloc_loop (int r_type ATTRIBUTE_ bfd_byte *start_ptr, *ptr, *last_ptr; int diff, cum_diff; bfd_signed_vma x; + bfd_size_type sz; int insn; /* Sanity check the address. */ - if (addr > input_section->_raw_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (addr > sz) return bfd_reloc_outofrange; /* We require the start and end relocations to be processed consecutively - @@ -1871,14 +1873,11 @@ sh_elf_reloc_loop (int r_type ATTRIBUTE_ contents = elf_section_data (symbol_section)->this_hdr.contents; else { - contents = (bfd_byte *) bfd_malloc (symbol_section->_raw_size); - if (contents == NULL) - return bfd_reloc_outofrange; - if (! bfd_get_section_contents (input_bfd, symbol_section, contents, - (file_ptr) 0, - symbol_section->_raw_size)) + if (!bfd_malloc_and_get_section (input_bfd, symbol_section, + &contents)) { - free (contents); + if (contents != NULL) + free (contents); return bfd_reloc_outofrange; } } @@ -2197,11 +2196,6 @@ sh_elf_relax_section (bfd *abfd, asectio } #endif - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; internal_relocs = (_bfd_elf_link_read_relocs @@ -2233,12 +2227,7 @@ sh_elf_relax_section (bfd *abfd, asectio contents = elf_section_data (sec)->this_hdr.contents; else { - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -2248,7 +2237,7 @@ sh_elf_relax_section (bfd *abfd, asectio computed as though it were a jump offset, which are based from 4 bytes after the jump instruction. */ laddr = irel->r_offset + 4 + irel->r_addend; - if (laddr >= sec->_raw_size) + if (laddr >= sec->size) { (*_bfd_error_handler) (_("%s: 0x%lx: warning: bad R_SH_USES offset"), bfd_archive_filename (abfd), @@ -2276,7 +2265,7 @@ sh_elf_relax_section (bfd *abfd, asectio paddr = insn & 0xff; paddr *= 4; paddr += (laddr + 4) &~ (bfd_vma) 3; - if (paddr >= sec->_raw_size) + if (paddr >= sec->size) { ((*_bfd_error_handler) (_("%s: 0x%lx: warning: bad R_SH_USES load offset"), @@ -2490,12 +2479,7 @@ sh_elf_relax_section (bfd *abfd, asectio contents = elf_section_data (sec)->this_hdr.contents; else { - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -2587,7 +2571,7 @@ sh_elf_relax_delete_bytes (bfd *abfd, as power larger than the number of bytes we are deleting. */ irelalign = NULL; - toaddr = sec->_cooked_size; + toaddr = sec->size; irel = elf_section_data (sec)->relocs; irelend = irel + sec->reloc_count; @@ -2607,7 +2591,7 @@ sh_elf_relax_delete_bytes (bfd *abfd, as memmove (contents + addr, contents + addr + count, (size_t) (toaddr - addr - count)); if (irelalign == NULL) - sec->_cooked_size -= count; + sec->size -= count; else { int i; @@ -2908,13 +2892,13 @@ sh_elf_relax_delete_bytes (bfd *abfd, as Perhaps, if info->keep_memory is FALSE, we should free them, if we are permitted to, when we leave sh_coff_relax_section. */ - ocontents = (bfd_byte *) bfd_malloc (o->_raw_size); - if (ocontents == NULL) - return FALSE; - if (! bfd_get_section_contents (abfd, o, ocontents, - (file_ptr) 0, - o->_raw_size)) - return FALSE; + if (!bfd_malloc_and_get_section (abfd, o, &ocontents)) + { + if (ocontents != NULL) + free (ocontents); + return FALSE; + } + elf_section_data (o)->this_hdr.contents = ocontents; } } @@ -2966,13 +2950,13 @@ sh_elf_relax_delete_bytes (bfd *abfd, as Perhaps, if info->keep_memory is FALSE, we should free them, if we are permitted to, when we leave sh_coff_relax_section. */ - ocontents = (bfd_byte *) bfd_malloc (o->_raw_size); - if (ocontents == NULL) - return FALSE; - if (! bfd_get_section_contents (abfd, o, ocontents, - (file_ptr) 0, - o->_raw_size)) - return FALSE; + if (!bfd_malloc_and_get_section (abfd, o, &ocontents)) + { + if (ocontents != NULL) + free (ocontents); + return FALSE; + } + elf_section_data (o)->this_hdr.contents = ocontents; } } @@ -3089,7 +3073,7 @@ sh_elf_align_loads (bfd *abfd ATTRIBUTE_ if (irel < irelend) stop = irel->r_offset; else - stop = sec->_cooked_size; + stop = sec->size; if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_elf_swap_insns, internal_relocs, &label, @@ -4140,7 +4124,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd srel = htab->srelbss; BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -4151,7 +4135,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (htab->root.dynobj, s)) { if (! bfd_set_section_alignment (htab->root.dynobj, s, power_of_two)) @@ -4160,10 +4144,10 @@ sh_elf_adjust_dynamic_symbol (struct bfd /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -4224,10 +4208,10 @@ allocate_dynrelocs (struct elf_link_hash /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_ENTRY_SIZE; - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -4242,14 +4226,14 @@ allocate_dynrelocs (struct elf_link_hash } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->_raw_size += 4; + htab->sgotplt->size += 4; /* We also need to make an entry in the .rel.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf32_External_Rela); + htab->srelplt->size += sizeof (Elf32_External_Rela); } else { @@ -4279,24 +4263,24 @@ allocate_dynrelocs (struct elf_link_hash } s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += 4; + h->got.offset = s->size; + s->size += 4; /* R_SH_TLS_GD needs 2 consecutive GOT slots. */ if (tls_type == GOT_TLS_GD) - s->_raw_size += 4; + s->size += 4; dyn = htab->root.dynamic_sections_created; /* R_SH_TLS_IE_32 needs one dynamic relocation if dynamic, R_SH_TLS_GD needs one if local symbol and two if global. */ if ((tls_type == GOT_TLS_GD && h->dynindx == -1) || (tls_type == GOT_TLS_IE && dyn)) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); else if (tls_type == GOT_TLS_GD) - htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rela); + htab->srelgot->size += 2 * sizeof (Elf32_External_Rela); else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) && (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); } else h->got.offset = (bfd_vma) -1; @@ -4317,11 +4301,11 @@ allocate_dynrelocs (struct elf_link_hash } s = htab->sgot; - eh->datalabel_got.offset = s->_raw_size; - s->_raw_size += 4; + eh->datalabel_got.offset = s->size; + s->size += 4; dyn = htab->root.dynamic_sections_created; if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); } else eh->datalabel_got.offset = (bfd_vma) -1; @@ -4396,7 +4380,7 @@ allocate_dynrelocs (struct elf_link_hash for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela); + sreloc->size += p->count * sizeof (Elf32_External_Rela); } return TRUE; @@ -4454,7 +4438,7 @@ sh_elf_size_dynamic_sections (bfd *outpu { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -4493,7 +4477,7 @@ sh_elf_size_dynamic_sections (bfd *outpu else if (p->count != 0) { srel = elf_section_data (p->sec)->sreloc; - srel->_raw_size += p->count * sizeof (Elf32_External_Rela); + srel->size += p->count * sizeof (Elf32_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -4518,12 +4502,12 @@ sh_elf_size_dynamic_sections (bfd *outpu { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += 4; + *local_got = s->size; + s->size += 4; if (*local_tls_type == GOT_TLS_GD) - s->_raw_size += 4; + s->size += 4; if (info->shared) - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); } else *local_got = (bfd_vma) -1; @@ -4535,9 +4519,9 @@ sh_elf_size_dynamic_sections (bfd *outpu { /* Allocate 2 got entries and 1 dynamic reloc for R_SH_TLS_LD_32 relocs. */ - htab->tls_ldm_got.offset = htab->sgot->_raw_size; - htab->sgot->_raw_size += 8; - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->tls_ldm_got.offset = htab->sgot->size; + htab->sgot->size += 8; + htab->srelgot->size += sizeof (Elf32_External_Rela); } else htab->tls_ldm_got.offset = -1; @@ -4563,7 +4547,7 @@ sh_elf_size_dynamic_sections (bfd *outpu } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->_raw_size != 0 && s != htab->srelplt) + if (s->size != 0 && s != htab->srelplt) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -4576,7 +4560,7 @@ sh_elf_size_dynamic_sections (bfd *outpu continue; } - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -4597,7 +4581,7 @@ sh_elf_size_dynamic_sections (bfd *outpu section's contents are written out. This should not happen, but this way if it does, we get a R_SH_NONE reloc instead of garbage. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -4618,7 +4602,7 @@ sh_elf_size_dynamic_sections (bfd *outpu return FALSE; } - if (htab->splt->_raw_size != 0) + if (htab->splt->size != 0) { if (! add_dynamic_entry (DT_PLTGOT, 0) || ! add_dynamic_entry (DT_PLTRELSZ, 0) @@ -5925,7 +5909,7 @@ sh_elf_get_relocated_section_contents (b symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; memcpy (data, elf_section_data (input_section)->this_hdr.contents, - (size_t) input_section->_raw_size); + (size_t) input_section->size); if ((input_section->flags & SEC_RELOC) != 0 && input_section->reloc_count > 0) @@ -7242,7 +7226,7 @@ sh_elf_finish_dynamic_sections (bfd *out BFD_ASSERT (sgot != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -7296,10 +7280,7 @@ sh_elf_finish_dynamic_sections (bfd *out case DT_PLTRELSZ: s = htab->srelplt->output_section; BFD_ASSERT (s != NULL); - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -7316,10 +7297,7 @@ sh_elf_finish_dynamic_sections (bfd *out if (htab->srelplt != NULL) { s = htab->srelplt->output_section; - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; + dyn.d_un.d_val -= s->size; } bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -7328,7 +7306,7 @@ sh_elf_finish_dynamic_sections (bfd *out /* Fill in the first entry in the procedure linkage table. */ splt = htab->splt; - if (splt && splt->_raw_size > 0) + if (splt && splt->size > 0) { if (info->shared) { @@ -7373,7 +7351,7 @@ sh_elf_finish_dynamic_sections (bfd *out } /* Fill in the first three entries in the global offset table. */ - if (sgot && sgot->_raw_size > 0) + if (sgot && sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); @@ -7411,7 +7389,7 @@ static bfd_boolean elf32_shlin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; - unsigned int raw_size; + unsigned int size; switch (note->descsz) { @@ -7427,14 +7405,14 @@ elf32_shlin_grok_prstatus (bfd *abfd, El /* pr_reg */ offset = 72; - raw_size = 92; + size = 92; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean Index: bfd/elf32-sh64-com.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-sh64-com.c,v retrieving revision 1.7 diff -u -p -r1.7 elf32-sh64-com.c --- bfd/elf32-sh64-com.c 25 Jul 2003 06:19:20 -0000 1.7 +++ bfd/elf32-sh64-com.c 22 Jun 2004 01:36:03 -0000 @@ -1,5 +1,5 @@ /* SuperH SH64-specific support for 32-bit ELF - Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -99,7 +99,7 @@ sh64_address_in_cranges (asection *crang { bfd_byte *cranges_contents; bfd_byte *found_rangep; - bfd_size_type cranges_size = bfd_section_size (cranges->owner, cranges); + bfd_size_type cranges_size = cranges->size; /* If the size is not a multiple of the cranges entry size, then something is badly wrong. */ @@ -117,15 +117,8 @@ sh64_address_in_cranges (asection *crang cranges_contents = cranges->contents; else { - cranges_contents - = bfd_malloc (cranges->_cooked_size != 0 - ? cranges->_cooked_size : cranges->_raw_size); - if (cranges_contents == NULL) - return FALSE; - - if (! bfd_get_section_contents (cranges->owner, cranges, - cranges_contents, (file_ptr) 0, - cranges_size)) + if (!bfd_malloc_and_get_section (cranges->owner, cranges, + &cranges_contents)) goto error_return; /* Is it sorted? */ @@ -182,7 +175,8 @@ sh64_address_in_cranges (asection *crang return FALSE; error_return: - free (cranges_contents); + if (cranges_contents != NULL) + free (cranges_contents); return FALSE; } @@ -199,7 +193,7 @@ sh64_get_contents_type (asection *sec, b && elf_elfheader (sec->owner)->e_type == ET_EXEC) { rangep->cr_addr = bfd_get_section_vma (sec->owner, sec); - rangep->cr_size = bfd_section_size (sec->owner, sec); + rangep->cr_size = sec->size; rangep->cr_type = CRT_NONE; } else Index: bfd/elf32-sh64.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-sh64.c,v retrieving revision 1.25 diff -u -p -r1.25 elf32-sh64.c --- bfd/elf32-sh64.c 15 Jun 2004 01:24:22 -0000 1.25 +++ bfd/elf32-sh64.c 22 Jun 2004 01:36:03 -0000 @@ -605,6 +605,7 @@ sh64_find_section_for_address (bfd *abfd { bfd_vma vma; bfd_size_type size; + struct sh64_find_section_vma_data *fsec_datap = (struct sh64_find_section_vma_data *) data; @@ -620,9 +621,7 @@ sh64_find_section_for_address (bfd *abfd if (fsec_datap->addr < vma) return; - size - = section->_cooked_size ? section->_cooked_size : section->_raw_size; - + size = section->size; if (fsec_datap->addr >= vma + size) return; @@ -653,9 +652,7 @@ sh64_elf_final_write_processing (bfd *ab = sh64_elf_section_data (cranges)->sh64_info->cranges_growth) != 0) { bfd_vma incoming_cranges_size - = ((cranges->_cooked_size != 0 - ? cranges->_cooked_size : cranges->_raw_size) - - ld_generated_cranges_size); + = cranges->size - ld_generated_cranges_size; if (! bfd_set_section_contents (abfd, cranges, cranges->contents @@ -698,9 +695,7 @@ sh64_elf_final_write_processing (bfd *ab /* If we have a .cranges section, sort the entries. */ if (cranges != NULL) { - bfd_size_type cranges_size - = (cranges->_cooked_size != 0 - ? cranges->_cooked_size : cranges->_raw_size); + bfd_size_type cranges_size = cranges->size; /* We know we always have these in memory at this time. */ BFD_ASSERT (cranges->contents != NULL); Index: bfd/elf32-sparc.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-sparc.c,v retrieving revision 1.68 diff -u -p -r1.68 elf32-sparc.c --- bfd/elf32-sparc.c 22 Apr 2004 14:45:31 -0000 1.68 +++ bfd/elf32-sparc.c 22 Jun 2004 01:36:05 -0000 @@ -374,6 +374,7 @@ sparc_elf_wdisp16_reloc (abfd, { bfd_vma relocation; bfd_vma x; + bfd_size_type sz; if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0 @@ -387,7 +388,8 @@ sparc_elf_wdisp16_reloc (abfd, if (output_bfd != NULL) return bfd_reloc_continue; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; relocation = (symbol->value @@ -430,6 +432,7 @@ sparc_elf_hix22_reloc (abfd, { bfd_vma relocation; bfd_vma insn; + bfd_size_type sz; if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0) @@ -441,7 +444,8 @@ sparc_elf_hix22_reloc (abfd, if (output_bfd != NULL) return bfd_reloc_continue; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; relocation = (symbol->value @@ -476,6 +480,7 @@ sparc_elf_lox10_reloc (abfd, { bfd_vma relocation; bfd_vma insn; + bfd_size_type sz; if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0) @@ -487,7 +492,8 @@ sparc_elf_lox10_reloc (abfd, if (output_bfd != NULL) return bfd_reloc_continue; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; relocation = (symbol->value @@ -1562,7 +1568,7 @@ elf32_sparc_adjust_dynamic_symbol (info, .rel.bss section we are going to use. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { - htab->srelbss->_raw_size += sizeof (Elf32_External_Rela); + htab->srelbss->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1574,8 +1580,7 @@ elf32_sparc_adjust_dynamic_symbol (info, /* Apply the required alignment. */ s = htab->sdynbss; - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (! bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -1584,10 +1589,10 @@ elf32_sparc_adjust_dynamic_symbol (info, /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1634,17 +1639,17 @@ allocate_dynrelocs (h, inf) asection *s = htab->splt; /* The first four entries in .plt are reserved. */ - if (s->_raw_size == 0) - s->_raw_size = 4 * PLT_ENTRY_SIZE; + if (s->size == 0) + s->size = 4 * PLT_ENTRY_SIZE; /* The procedure linkage table has a maximum size. */ - if (s->_raw_size >= 0x400000) + if (s->size >= 0x400000) { bfd_set_error (bfd_error_bad_value); return FALSE; } - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -1659,10 +1664,10 @@ allocate_dynrelocs (h, inf) } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .rela.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf32_External_Rela); + htab->srelplt->size += sizeof (Elf32_External_Rela); } else { @@ -1699,22 +1704,22 @@ allocate_dynrelocs (h, inf) } s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += 4; + h->got.offset = s->size; + s->size += 4; /* R_SPARC_TLS_GD_HI{22,LO10} needs 2 consecutive GOT slots. */ if (tls_type == GOT_TLS_GD) - s->_raw_size += 4; + s->size += 4; dyn = htab->elf.dynamic_sections_created; /* R_SPARC_TLS_IE_{HI22,LO10} needs one dynamic relocation, R_SPARC_TLS_GD_{HI22,LO10} needs one if local symbol and two if global. */ if ((tls_type == GOT_TLS_GD && h->dynindx == -1) || tls_type == GOT_TLS_IE) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); else if (tls_type == GOT_TLS_GD) - htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rela); + htab->srelgot->size += 2 * sizeof (Elf32_External_Rela); else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)) - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->srelgot->size += sizeof (Elf32_External_Rela); } else h->got.offset = (bfd_vma) -1; @@ -1785,7 +1790,7 @@ allocate_dynrelocs (h, inf) for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela); + sreloc->size += p->count * sizeof (Elf32_External_Rela); } return TRUE; @@ -1845,7 +1850,7 @@ elf32_sparc_size_dynamic_sections (outpu { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -1884,7 +1889,7 @@ elf32_sparc_size_dynamic_sections (outpu else if (p->count != 0) { srel = elf_section_data (p->sec)->sreloc; - srel->_raw_size += p->count * sizeof (Elf32_External_Rela); + srel->size += p->count * sizeof (Elf32_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -1905,14 +1910,14 @@ elf32_sparc_size_dynamic_sections (outpu { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += 4; + *local_got = s->size; + s->size += 4; if (*local_tls_type == GOT_TLS_GD) - s->_raw_size += 4; + s->size += 4; if (info->shared || *local_tls_type == GOT_TLS_GD || *local_tls_type == GOT_TLS_IE) - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); } else *local_got = (bfd_vma) -1; @@ -1923,9 +1928,9 @@ elf32_sparc_size_dynamic_sections (outpu { /* Allocate 2 got entries and 1 dynamic reloc for R_SPARC_TLS_LDM_{HI22,LO10} relocs. */ - htab->tls_ldm_got.offset = htab->sgot->_raw_size; - htab->sgot->_raw_size += 8; - htab->srelgot->_raw_size += sizeof (Elf32_External_Rela); + htab->tls_ldm_got.offset = htab->sgot->size; + htab->sgot->size += 8; + htab->srelgot->size += sizeof (Elf32_External_Rela); } else htab->tls_ldm_got.offset = -1; @@ -1937,13 +1942,13 @@ elf32_sparc_size_dynamic_sections (outpu if (elf_hash_table (info)->dynamic_sections_created) { /* Make space for the trailing nop in .plt. */ - if (htab->splt->_raw_size > 0) - htab->splt->_raw_size += 4; + if (htab->splt->size > 0) + htab->splt->size += 4; /* If the .got section is more than 0x1000 bytes, we add 0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13 bit relocations have a greater chance of working. */ - if (htab->sgot->_raw_size >= 0x1000 + if (htab->sgot->size >= 0x1000 && elf_hash_table (info)->hgot->root.u.def.value == 0) elf_hash_table (info)->hgot->root.u.def.value = 0x1000; } @@ -1965,7 +1970,7 @@ elf32_sparc_size_dynamic_sections (outpu if (strncmp (name, ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is to handle .rela.bss and @@ -2003,8 +2008,8 @@ elf32_sparc_size_dynamic_sections (outpu are written out, but at the moment this does not happen. Thus in order to prevent writing out garbage, we initialise the section's contents to zero. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -2024,7 +2029,7 @@ elf32_sparc_size_dynamic_sections (outpu return FALSE; } - if (htab->srelplt->_raw_size != 0) + if (htab->srelplt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -2921,7 +2926,7 @@ elf32_sparc_relocate_section (output_bfd } else if ((r_type == R_SPARC_WDISP30 || r_type == R_SPARC_WPLT30) && sec_do_relax (input_section) - && rel->r_offset + 4 < input_section->_raw_size) + && rel->r_offset + 4 < input_section->size) { #define G0 0 #define O7 15 @@ -3223,7 +3228,7 @@ elf32_sparc_finish_dynamic_sections (out BFD_ASSERT (splt != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -3252,12 +3257,7 @@ elf32_sparc_finish_dynamic_sections (out if (! size) dyn.d_un.d_ptr = s->vma; else - { - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; - } + dyn.d_un.d_val = s->size; } bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); } @@ -3265,11 +3265,11 @@ elf32_sparc_finish_dynamic_sections (out /* Clear the first four entries in the procedure linkage table, and put a nop in the last four bytes. */ - if (splt->_raw_size > 0) + if (splt->size > 0) { memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE); bfd_put_32 (output_bfd, (bfd_vma) SPARC_NOP, - splt->contents + splt->_raw_size - 4); + splt->contents + splt->size - 4); } elf_section_data (splt->output_section)->this_hdr.sh_entsize = 0; @@ -3277,7 +3277,7 @@ elf32_sparc_finish_dynamic_sections (out /* Set the first entry in the global offset table to the address of the dynamic section. */ - if (htab->sgot && htab->sgot->_raw_size > 0) + if (htab->sgot && htab->sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgot->contents); Index: bfd/elf32-v850.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-v850.c,v retrieving revision 1.43 diff -u -p -r1.43 elf32-v850.c --- bfd/elf32-v850.c 27 Mar 2004 10:58:07 -0000 1.43 +++ bfd/elf32-v850.c 22 Jun 2004 01:36:07 -0000 @@ -1334,6 +1334,7 @@ v850_elf_reloc (abfd, reloc, symbol, dat bfd *obfd; char **err ATTRIBUTE_UNUSED; { + bfd_size_type sz; long relocation; /* If there is an output BFD, @@ -1359,7 +1360,8 @@ v850_elf_reloc (abfd, reloc, symbol, dat /* We handle final linking of some relocs ourselves. */ /* Is the address of the relocation really within the section? */ - if (reloc->address > isection->_cooked_size) + sz = isection->rawsize ? isection->rawsize : isection->size; + if (reloc->address > sz) return bfd_reloc_outofrange; /* Work out which section the relocation is targeted at and the @@ -2515,11 +2517,6 @@ v850_elf_relax_section (abfd, sec, link_ || sec->reloc_count == 0) return TRUE; - /* If this is the first time we have been called - for this section, initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = & elf_tdata (abfd)->symtab_hdr; internal_relocs = (_bfd_elf_link_read_relocs @@ -2530,9 +2527,9 @@ v850_elf_relax_section (abfd, sec, link_ irelend = internal_relocs + sec->reloc_count; - while (addr < sec->_cooked_size) + while (addr < sec->size) { - toaddr = sec->_cooked_size; + toaddr = sec->size; for (irel = internal_relocs; irel < irelend; irel ++) if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_ALIGN @@ -2606,12 +2603,7 @@ v850_elf_relax_section (abfd, sec, link_ contents = elf_section_data (sec)->this_hdr.contents; else { - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } } @@ -2633,7 +2625,7 @@ v850_elf_relax_section (abfd, sec, link_ if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGCALL) { /* Check code for -mlong-calls output. */ - if (laddr + 16 <= (bfd_vma) sec->_raw_size) + if (laddr + 16 <= (bfd_vma) sec->size) { insn[0] = bfd_get_16 (abfd, contents + laddr); insn[1] = bfd_get_16 (abfd, contents + laddr + 4); @@ -2862,7 +2854,7 @@ v850_elf_relax_section (abfd, sec, link_ else if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGJUMP) { /* Check code for -mlong-jumps output. */ - if (laddr + 10 <= (bfd_vma) sec->_raw_size) + if (laddr + 10 <= (bfd_vma) sec->size) { insn[0] = bfd_get_16 (abfd, contents + laddr); insn[1] = bfd_get_16 (abfd, contents + laddr + 4); @@ -3104,10 +3096,10 @@ v850_elf_relax_section (abfd, sec, link_ #ifdef DEBUG_RELAX fprintf (stderr, "relax pad %d shorten %d -> %d\n", align_pad_size, - sec->_cooked_size, - sec->_cooked_size - align_pad_size); + sec->size, + sec->size - align_pad_size); #endif - sec->_cooked_size -= align_pad_size; + sec->size -= align_pad_size; } finish: Index: bfd/elf32-vax.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-vax.c,v retrieving revision 1.21 diff -u -p -r1.21 elf32-vax.c --- bfd/elf32-vax.c 27 Mar 2004 10:58:07 -0000 1.21 +++ bfd/elf32-vax.c 22 Jun 2004 01:36:08 -0000 @@ -777,7 +777,7 @@ elf_vax_check_relocs (abfd, info, sec, r info->flags |= DF_TEXTREL; } - sreloc->_raw_size += sizeof (Elf32_External_Rela); + sreloc->size += sizeof (Elf32_External_Rela); /* If we are linking with -Bsymbolic, we count the number of PC relative relocations we have entered for this symbol, @@ -1015,9 +1015,9 @@ elf_vax_adjust_dynamic_symbol (info, h) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) + if (s->size == 0) { - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; } /* If this symbol is not defined in a regular file, and we are @@ -1029,26 +1029,26 @@ elf_vax_adjust_dynamic_symbol (info, h) && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) { h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; } - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ s = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += 4; + s->size += 4; /* We also need to make an entry in the .rela.plt section. */ s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += sizeof (Elf32_External_Rela); + s->size += sizeof (Elf32_External_Rela); return TRUE; } @@ -1102,7 +1102,7 @@ elf_vax_adjust_dynamic_symbol (info, h) srel = bfd_get_section_by_name (dynobj, ".rela.bss"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1113,8 +1113,7 @@ elf_vax_adjust_dynamic_symbol (info, h) power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (!bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -1123,10 +1122,10 @@ elf_vax_adjust_dynamic_symbol (info, h) /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1154,7 +1153,7 @@ elf_vax_size_dynamic_sections (output_bf { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -1167,13 +1166,13 @@ elf_vax_size_dynamic_sections (output_bf file below. */ s = bfd_get_section_by_name (dynobj, ".rela.got"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; s = bfd_get_section_by_name (dynobj, ".got.plt"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; s = bfd_get_section_by_name (dynobj, ".got"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; } /* If this is a -Bsymbolic shared link, then we need to discard all PC @@ -1214,7 +1213,7 @@ elf_vax_size_dynamic_sections (output_bf if (strcmp (name, ".plt") == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* Strip this section if we don't need it; see the comment below. */ @@ -1228,7 +1227,7 @@ elf_vax_size_dynamic_sections (output_bf } else if (strncmp (name, ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -1284,8 +1283,8 @@ elf_vax_size_dynamic_sections (output_bf } /* Allocate memory for the section contents. */ - s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_alloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -1354,7 +1353,7 @@ elf_vax_discard_copies (h, ignore) return TRUE; for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) - s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela); + s->section->size -= s->count * sizeof (Elf32_External_Rela); return TRUE; } @@ -1405,8 +1404,8 @@ elf_vax_instantiate_got_entries (h, info } /* Allocate space in the .got and .rela.got sections. */ - sgot->_raw_size += 4; - srelgot->_raw_size += sizeof (Elf32_External_Rela); + sgot->size += 4; + srelgot->size += sizeof (Elf32_External_Rela); } return TRUE; @@ -1555,7 +1554,7 @@ elf_vax_relocate_section (output_bfd, in BFD_ASSERT (h != NULL); off = h->got.offset; BFD_ASSERT (off != (bfd_vma) -1); - BFD_ASSERT (off < sgot->_raw_size); + BFD_ASSERT (off < sgot->size); if (info->shared && h->dynindx == -1 @@ -2030,7 +2029,7 @@ elf_vax_finish_dynamic_sections (output_ BFD_ASSERT (splt != NULL && sdyn != NULL); dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -2059,10 +2058,7 @@ elf_vax_finish_dynamic_sections (output_ case DT_PLTRELSZ: s = bfd_get_section_by_name (output_bfd, ".rela.plt"); BFD_ASSERT (s != NULL); - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -2076,19 +2072,14 @@ elf_vax_finish_dynamic_sections (output_ about changing the DT_RELA entry. */ s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s != NULL) - { - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; - } + dyn.d_un.d_val -= s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; } } /* Fill in the first entry in the procedure linkage table. */ - if (splt->_raw_size > 0) + if (splt->size > 0) { memcpy (splt->contents, elf_vax_plt0_entry, PLT_ENTRY_SIZE); bfd_put_32 (output_bfd, @@ -2107,7 +2098,7 @@ elf_vax_finish_dynamic_sections (output_ } /* Fill in the first three entries in the global offset table. */ - if (sgot->_raw_size > 0) + if (sgot->size > 0) { if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); Index: bfd/elf32-xstormy16.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-xstormy16.c,v retrieving revision 1.26 diff -u -p -r1.26 elf32-xstormy16.c --- bfd/elf32-xstormy16.c 27 Mar 2004 10:58:07 -0000 1.26 +++ bfd/elf32-xstormy16.c 22 Jun 2004 01:36:08 -0000 @@ -372,6 +372,7 @@ xstormy16_elf_24_reloc (abfd, reloc_entr char **error_message ATTRIBUTE_UNUSED; { bfd_vma relocation, x; + bfd_size_type sz; if (output_bfd != NULL) { @@ -379,7 +380,8 @@ xstormy16_elf_24_reloc (abfd, reloc_entr return bfd_reloc_ok; } - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; if (bfd_is_com_section (symbol->section)) @@ -508,8 +510,8 @@ xstormy16_elf_check_relocs (abfd, info, if (*offset == (bfd_vma) -1) { - *offset = splt->_raw_size; - splt->_raw_size += 4; + *offset = splt->size; + splt->size += 4; } break; @@ -566,7 +568,7 @@ xstormy16_relax_plt_check (h, xdata) if (address <= 0xffff) { h->plt.offset = -1; - data->splt->_cooked_size -= 4; + data->splt->size -= 4; *data->again = TRUE; } } @@ -618,14 +620,9 @@ xstormy16_elf_relax_section (dynobj, spl return TRUE; /* Quick check for an empty plt. */ - if (splt->_raw_size == 0) + if (splt->size == 0) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (splt->_cooked_size == 0) - splt->_cooked_size = splt->_raw_size; - /* Map across all global symbols; see which ones happen to fall in the low 64k. */ relax_plt_data.splt = splt; @@ -682,7 +679,7 @@ xstormy16_elf_relax_section (dynobj, spl if (address <= 0xffff) { local_plt_offsets[idx] = -1; - splt->_cooked_size -= 4; + splt->size -= 4; *again = TRUE; } } @@ -702,7 +699,7 @@ xstormy16_elf_relax_section (dynobj, spl /* If we changed anything, walk the symbols again to reallocate .plt entry addresses. */ - if (*again && splt->_cooked_size > 0) + if (*again && splt->size > 0) { bfd_vma entry = 0; @@ -727,7 +724,6 @@ xstormy16_elf_relax_section (dynobj, spl } } - splt->_raw_size = splt->_cooked_size; return TRUE; } @@ -749,7 +745,7 @@ xstormy16_elf_always_size_sections (outp splt = bfd_get_section_by_name (dynobj, ".plt"); BFD_ASSERT (splt != NULL); - splt->contents = (bfd_byte *) bfd_zalloc (dynobj, splt->_raw_size); + splt->contents = (bfd_byte *) bfd_zalloc (dynobj, splt->size); if (splt->contents == NULL) return FALSE; @@ -996,7 +992,7 @@ xstormy16_elf_finish_dynamic_sections (a && (splt = bfd_get_section_by_name (dynobj, ".plt")) != NULL) { bfd_byte *contents = splt->contents; - unsigned int i, size = splt->_raw_size; + unsigned int i, size = splt->size; for (i = 0; i < size; i += 4) { unsigned int x = bfd_get_32 (dynobj, contents + i); Index: bfd/elf32-xtensa.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v retrieving revision 1.27 diff -u -p -r1.27 elf32-xtensa.c --- bfd/elf32-xtensa.c 17 May 2004 20:33:33 -0000 1.27 +++ bfd/elf32-xtensa.c 22 Jun 2004 01:36:11 -0000 @@ -504,8 +504,7 @@ xtensa_read_table_entries (abfd, section table_section = bfd_get_section_by_name (abfd, table_section_name); free (table_section_name); if (table_section != NULL) - table_size = (table_section->_cooked_size - ? table_section->_cooked_size : table_section->_raw_size); + table_size = table_section->size; if (table_size == 0) { @@ -562,7 +561,7 @@ xtensa_read_table_entries (abfd, section bfd_vma address = bfd_get_32 (abfd, table_data + off); if (address >= section_addr - && address < ( section_addr + section->_raw_size)) + && address < section_addr + section->size) { blocks[block_count].address = address; blocks[block_count].size = @@ -1056,7 +1055,7 @@ elf_xtensa_allocate_plt_size (h, arg) h = (struct elf_link_hash_entry *) h->root.u.i.link; if (h->plt.refcount > 0) - srelplt->_raw_size += (h->plt.refcount * sizeof (Elf32_External_Rela)); + srelplt->size += (h->plt.refcount * sizeof (Elf32_External_Rela)); return TRUE; } @@ -1073,7 +1072,7 @@ elf_xtensa_allocate_got_size (h, arg) h = (struct elf_link_hash_entry *) h->root.u.i.link; if (h->got.refcount > 0) - srelgot->_raw_size += (h->got.refcount * sizeof (Elf32_External_Rela)); + srelgot->size += (h->got.refcount * sizeof (Elf32_External_Rela)); return TRUE; } @@ -1102,8 +1101,8 @@ elf_xtensa_allocate_local_got_size (info for (j = 0; j < cnt; ++j) { if (local_got_refcounts[j] > 0) - srelgot->_raw_size += (local_got_refcounts[j] - * sizeof (Elf32_External_Rela)); + srelgot->size += (local_got_refcounts[j] + * sizeof (Elf32_External_Rela)); } } } @@ -1137,7 +1136,7 @@ elf_xtensa_size_dynamic_sections (output s = bfd_get_section_by_name (dynobj, ".interp"); if (s == NULL) abort (); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } @@ -1145,7 +1144,7 @@ elf_xtensa_size_dynamic_sections (output s = bfd_get_section_by_name (dynobj, ".got"); if (s == NULL) abort (); - s->_raw_size = 4; + s->size = 4; /* Adjust refcounts for symbols that we now know are not "dynamic". */ elf_link_hash_traverse (elf_hash_table (info), @@ -1184,7 +1183,7 @@ elf_xtensa_size_dynamic_sections (output if (spltlittbl == NULL) abort (); - plt_entries = srelplt->_raw_size / sizeof (Elf32_External_Rela); + plt_entries = srelplt->size / sizeof (Elf32_External_Rela); plt_chunks = (plt_entries + PLT_ENTRIES_PER_CHUNK - 1) / PLT_ENTRIES_PER_CHUNK; @@ -1210,15 +1209,15 @@ elf_xtensa_size_dynamic_sections (output if (chunk_entries != 0) { - sgotplt->_raw_size = 4 * (chunk_entries + 2); - splt->_raw_size = PLT_ENTRY_SIZE * chunk_entries; - srelgot->_raw_size += 2 * sizeof (Elf32_External_Rela); - spltlittbl->_raw_size += 8; + sgotplt->size = 4 * (chunk_entries + 2); + splt->size = PLT_ENTRY_SIZE * chunk_entries; + srelgot->size += 2 * sizeof (Elf32_External_Rela); + spltlittbl->size += 8; } else { - sgotplt->_raw_size = 0; - splt->_raw_size = 0; + sgotplt->size = 0; + splt->size = 0; } } @@ -1227,7 +1226,7 @@ elf_xtensa_size_dynamic_sections (output sgotloc = bfd_get_section_by_name (dynobj, ".got.loc"); if (sgotloc == NULL) abort (); - sgotloc->_raw_size = spltlittbl->_raw_size; + sgotloc->size = spltlittbl->size; for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next) { if (abfd->flags & DYNAMIC) @@ -1237,7 +1236,7 @@ elf_xtensa_size_dynamic_sections (output if (! elf_discarded_section (s) && xtensa_is_littable_section (s) && s != spltlittbl) - sgotloc->_raw_size += s->_raw_size; + sgotloc->size += s->size; } } } @@ -1273,7 +1272,7 @@ elf_xtensa_size_dynamic_sections (output else if (strncmp (name, ".plt.", 5) == 0 || strncmp (name, ".got.plt.", 9) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. We must create the ".plt*" and ".got.plt*" @@ -1302,8 +1301,8 @@ elf_xtensa_size_dynamic_sections (output else { /* Allocate memory for the section contents. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } } @@ -1439,7 +1438,7 @@ elf_xtensa_do_reloc (howto, abfd, input_ /* Check for windowed CALL across a 1GB boundary. */ xtensa_opcode opcode = get_expanded_call_opcode (contents + address, - input_section->_raw_size - address); + input_section->size - address); if (is_windowed_call_opcode (opcode)) { self_address = (input_section->output_section->vma @@ -1460,8 +1459,7 @@ elf_xtensa_do_reloc (howto, abfd, input_ { /* Convert the L32R/CALLX to CALL. */ bfd_reloc_status_type retval = - elf_xtensa_do_asm_simplify (contents, address, - input_section->_raw_size); + elf_xtensa_do_asm_simplify (contents, address, input_section->size); if (retval != bfd_reloc_ok) return retval; @@ -1652,6 +1650,7 @@ bfd_elf_xtensa_reloc (abfd, reloc_entry, bfd_vma relocation; bfd_reloc_status_type flag; bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); + bfd_size_type sz; bfd_vma output_base = 0; reloc_howto_type *howto = reloc_entry->howto; asection *reloc_target_output_section; @@ -1676,8 +1675,8 @@ bfd_elf_xtensa_reloc (abfd, reloc_entry, } /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > (input_section->_cooked_size - / bfd_octets_per_byte (abfd))) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz / bfd_octets_per_byte (abfd)) return bfd_reloc_outofrange; /* Work out which section the relocation is targeted at and the @@ -1895,7 +1894,7 @@ elf_xtensa_relocate_section (output_bfd, { /* Convert ASM_SIMPLIFY into the simpler relocation so that they never escape a relaxing link. */ - contract_asm_expansion (contents, input_section->_raw_size, rel); + contract_asm_expansion (contents, input_section->size, rel); r_type = ELF32_R_TYPE (rel->r_info); } @@ -1991,7 +1990,7 @@ elf_xtensa_relocate_section (output_bfd, } /* Sanity check the address. */ - if (rel->r_offset >= input_section->_raw_size + if (rel->r_offset >= input_section->size && ELF32_R_TYPE (rel->r_info) != R_XTENSA_NONE) { bfd_set_error (bfd_error_bad_value); @@ -2095,7 +2094,7 @@ elf_xtensa_relocate_section (output_bfd, + srel->reloc_count++ * sizeof (Elf32_External_Rela)); bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); BFD_ASSERT (sizeof (Elf32_External_Rela) * srel->reloc_count - <= srel->_cooked_size); + <= srel->size); } } @@ -2201,13 +2200,11 @@ elf_xtensa_combine_prop_entries (output_ bfd_vma offset; int n, m, num; - section_size = (sxtlit->_cooked_size != 0 - ? sxtlit->_cooked_size : sxtlit->_raw_size); + section_size = sxtlit->size; BFD_ASSERT (section_size % 8 == 0); num = section_size / 8; - sgotloc_size = (sgotloc->_cooked_size != 0 - ? sgotloc->_cooked_size : sgotloc->_raw_size); + sgotloc_size = sgotloc->size; if (sgotloc_size != section_size) { (*_bfd_error_handler) @@ -2215,20 +2212,22 @@ elf_xtensa_combine_prop_entries (output_ return -1; } - contents = (bfd_byte *) bfd_malloc (section_size); - table = (property_table_entry *) - bfd_malloc (num * sizeof (property_table_entry)); - if (contents == 0 || table == 0) + table = bfd_malloc (num * sizeof (property_table_entry)); + if (table == 0) return -1; /* The ".xt.lit.plt" section has the SEC_IN_MEMORY flag set and this propagates to the output section, where it doesn't really apply and - where it breaks the following call to bfd_get_section_contents. */ + where it breaks the following call to bfd_malloc_and_get_section. */ sxtlit->flags &= ~SEC_IN_MEMORY; - if (! bfd_get_section_contents (output_bfd, sxtlit, contents, 0, - section_size)) - return -1; + if (!bfd_malloc_and_get_section (output_bfd, sxtlit, &contents)) + { + if (contents != 0) + free (contents); + free (table); + return -1; + } /* There should never be any relocations left at this point, so this is quite a bit easier than what is done during relaxation. */ @@ -2282,7 +2281,7 @@ elf_xtensa_combine_prop_entries (output_ if ((bfd_size_type) (num * 8) < section_size) { memset (&contents[num * 8], 0, section_size - num * 8); - sxtlit->_cooked_size = num * 8; + sxtlit->size = num * 8; } if (! bfd_set_section_contents (output_bfd, sxtlit, contents, 0, @@ -2322,7 +2321,7 @@ elf_xtensa_finish_dynamic_sections (outp sgot = bfd_get_section_by_name (dynobj, ".got"); if (sgot) { - BFD_ASSERT (sgot->_raw_size == 4); + BFD_ASSERT (sgot->size == 4); if (sdyn == NULL) bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); else @@ -2332,7 +2331,7 @@ elf_xtensa_finish_dynamic_sections (outp } srelplt = bfd_get_section_by_name (dynobj, ".rela.plt"); - if (srelplt != NULL && srelplt->_raw_size != 0) + if (srelplt != NULL && srelplt->size != 0) { asection *sgotplt, *srelgot, *spltlittbl; int chunk, plt_chunks, plt_entries; @@ -2357,7 +2356,7 @@ elf_xtensa_finish_dynamic_sections (outp } BFD_ASSERT (rtld_reloc < srelgot->reloc_count); - plt_entries = (srelplt->_raw_size / sizeof (Elf32_External_Rela)); + plt_entries = srelplt->size / sizeof (Elf32_External_Rela); plt_chunks = (plt_entries + PLT_ENTRIES_PER_CHUNK - 1) / PLT_ENTRIES_PER_CHUNK; @@ -2399,7 +2398,7 @@ elf_xtensa_finish_dynamic_sections (outp else chunk_entries = plt_entries - (chunk * PLT_ENTRIES_PER_CHUNK); - BFD_ASSERT ((unsigned) (chunk + 1) * 8 <= spltlittbl->_cooked_size); + BFD_ASSERT ((unsigned) (chunk + 1) * 8 <= spltlittbl->size); bfd_put_32 (output_bfd, sgotplt->output_section->vma + sgotplt->output_offset, spltlittbl->contents + (chunk * 8) + 0); @@ -2410,10 +2409,10 @@ elf_xtensa_finish_dynamic_sections (outp /* All the dynamic relocations have been emitted at this point. Make sure the relocation sections are the correct size. */ - if (srelgot->_cooked_size != (sizeof (Elf32_External_Rela) - * srelgot->reloc_count) - || srelplt->_cooked_size != (sizeof (Elf32_External_Rela) - * srelplt->reloc_count)) + if (srelgot->size != (sizeof (Elf32_External_Rela) + * srelgot->reloc_count) + || srelplt->size != (sizeof (Elf32_External_Rela) + * srelplt->reloc_count)) abort (); /* The .xt.lit.plt section has just been modified. This must @@ -2424,7 +2423,7 @@ elf_xtensa_finish_dynamic_sections (outp spltlittbl->output_section, spltlittbl->contents, spltlittbl->output_offset, - spltlittbl->_raw_size)) + spltlittbl->size)) return FALSE; /* Clear SEC_HAS_CONTENTS so the contents won't be output again. */ spltlittbl->flags &= ~SEC_HAS_CONTENTS; @@ -2441,7 +2440,7 @@ elf_xtensa_finish_dynamic_sections (outp return FALSE; dyncon = (Elf32_External_Dyn *) sdyn->contents; - dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -2476,7 +2475,7 @@ elf_xtensa_finish_dynamic_sections (outp case DT_PLTRELSZ: s = bfd_get_section_by_name (output_bfd, ".rela.plt"); BFD_ASSERT (s); - dyn.d_un.d_val = (s->_cooked_size ? s->_cooked_size : s->_raw_size); + dyn.d_un.d_val = s->size; break; case DT_RELASZ: @@ -2488,10 +2487,7 @@ elf_xtensa_finish_dynamic_sections (outp don't have to worry about changing the DT_RELA entry. */ s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s) - { - dyn.d_un.d_val -= - (s->_cooked_size ? s->_cooked_size : s->_raw_size); - } + dyn.d_un.d_val -= s->size; break; } @@ -2687,7 +2683,7 @@ elf_xtensa_discard_info_for_section (abf bfd_vma offset, actual_offset; size_t removed_bytes = 0; - section_size = (sec->_cooked_size ? sec->_cooked_size : sec->_raw_size); + section_size = sec->size; if (section_size == 0 || section_size % 8 != 0) return FALSE; @@ -2775,9 +2771,8 @@ elf_xtensa_discard_info_for_section (abf pin_contents (sec, contents); pin_internal_relocs (sec, cookie->rels); - sec->_cooked_size = section_size - removed_bytes; - /* Also shrink _raw_size. See comments in relax_property_section. */ - sec->_raw_size = sec->_cooked_size; + /* Shrink size. */ + sec->size = section_size - removed_bytes; if (xtensa_is_littable_section (sec)) { @@ -2787,13 +2782,7 @@ elf_xtensa_discard_info_for_section (abf asection *sgotloc = bfd_get_section_by_name (dynobj, ".got.loc"); if (sgotloc) - { - bfd_size_type sgotloc_size = - (sgotloc->_cooked_size ? sgotloc->_cooked_size - : sgotloc->_raw_size); - sgotloc->_cooked_size = sgotloc_size - removed_bytes; - sgotloc->_raw_size = sgotloc_size - removed_bytes; - } + sgotloc->size -= removed_bytes; } } } @@ -2845,7 +2834,7 @@ elf_xtensa_grok_prstatus (abfd, note) Elf_Internal_Note *note; { int offset; - unsigned int raw_size; + unsigned int size; /* The size for Xtensa is variable, so don't try to recognize the format based on the size. Just assume this is GNU/Linux. */ @@ -2858,11 +2847,11 @@ elf_xtensa_grok_prstatus (abfd, note) /* pr_reg */ offset = 72; - raw_size = note->descsz - offset - 4; + size = note->descsz - offset - 4; /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } @@ -3024,7 +3013,7 @@ get_relocation_opcode (sec, contents, ir if (contents == NULL) return XTENSA_UNDEFINED; - if (sec->_raw_size <= irel->r_offset) + if (sec->size <= irel->r_offset) return XTENSA_UNDEFINED; if (ibuff == NULL) @@ -3958,20 +3947,16 @@ retrieve_contents (abfd, sec, keep_memor contents = elf_section_data (sec)->this_hdr.contents; - if (contents == NULL && sec->_raw_size != 0) + if (contents == NULL && sec->size != 0) { - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents != NULL) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) { - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) - { - free (contents); - return NULL; - } - if (keep_memory) - elf_section_data (sec)->this_hdr.contents = contents; + if (contents != NULL) + free (contents); + return NULL; } + if (keep_memory) + elf_section_data (sec)->this_hdr.contents = contents; } return contents; } @@ -4197,7 +4182,7 @@ find_relaxable_sections (abfd, sec, link return ok; contents = retrieve_contents (abfd, sec, link_info->keep_memory); - if (contents == NULL && sec->_raw_size != 0) + if (contents == NULL && sec->size != 0) { ok = FALSE; goto error_return; @@ -4258,7 +4243,7 @@ collect_source_relocs (abfd, sec, link_i return ok; contents = retrieve_contents (abfd, sec, link_info->keep_memory); - if (contents == NULL && sec->_raw_size != 0) + if (contents == NULL && sec->size != 0) { ok = FALSE; goto error_return; @@ -4406,7 +4391,7 @@ is_resolvable_asm_expansion (abfd, sec, return FALSE; opcode = get_expanded_call_opcode (contents + irel->r_offset, - sec->_raw_size - irel->r_offset); + sec->size - irel->r_offset); direct_call_opcode = swap_callx_for_call_opcode (opcode); if (direct_call_opcode == XTENSA_UNDEFINED) @@ -4509,7 +4494,7 @@ remove_literals (abfd, sec, link_info, v link_info->keep_memory); contents = retrieve_contents (abfd, sec, link_info->keep_memory); - if (contents == NULL && sec->_raw_size != 0) + if (contents == NULL && sec->size != 0) { ok = FALSE; goto error_return; @@ -4567,7 +4552,7 @@ remove_literals (abfd, sec, link_info, v /* Find the literal value. */ r_reloc_init (&val.r_rel, abfd, irel); - BFD_ASSERT (rel->r_rel.target_offset < sec->_raw_size); + BFD_ASSERT (rel->r_rel.target_offset < sec->size); val.value = bfd_get_32 (abfd, contents + rel->r_rel.target_offset); /* Check if we've seen another literal with the same value. */ @@ -4723,7 +4708,7 @@ relax_section (abfd, sec, link_info) internal_relocs = retrieve_internal_relocs (abfd, sec, link_info->keep_memory); contents = retrieve_contents (abfd, sec, link_info->keep_memory); - if (contents == NULL && sec->_raw_size != 0) + if (contents == NULL && sec->size != 0) { ok = FALSE; goto error_return; @@ -4802,13 +4787,13 @@ relax_section (abfd, sec, link_info) /* Walk through the contents and delete literals that are not needed anymore. */ - unsigned long size = sec->_cooked_size; + unsigned long size = sec->size; unsigned long removed = 0; removed_literal *reloc = relax_info->removed_list.head; for (; reloc; reloc = reloc->next) { - unsigned long upper = sec->_raw_size; + unsigned long upper = sec->size; bfd_vma start = reloc->from.target_offset + 4; if (reloc->next) upper = reloc->next->from.target_offset; @@ -4825,13 +4810,7 @@ relax_section (abfd, sec, link_info) } /* Change the section size. */ - sec->_cooked_size = size; - /* Also shrink _raw_size. (The code in relocate_section that - checks that relocations are within the section must use - _raw_size because of the way the stabs sections are relaxed; - shrinking _raw_size means that these checks will not be - unnecessarily lax.) */ - sec->_raw_size = size; + sec->size = size; } error_return: @@ -4957,13 +4936,8 @@ shrink_dynamic_reloc_sections (info, abf /* Reduce size of the .rela.* section by one reloc. */ srel = bfd_get_section_by_name (dynobj, srel_name); BFD_ASSERT (srel != NULL); - BFD_ASSERT (srel->_cooked_size >= sizeof (Elf32_External_Rela)); - srel->_cooked_size -= sizeof (Elf32_External_Rela); - - /* Also shrink _raw_size. (This seems wrong but other bfd code seems - to assume that linker-created sections will never be relaxed and - hence _raw_size must always equal _cooked_size.) */ - srel->_raw_size = srel->_cooked_size; + BFD_ASSERT (srel->size >= sizeof (Elf32_External_Rela)); + srel->size -= sizeof (Elf32_External_Rela); if (is_plt) { @@ -4976,7 +4950,7 @@ shrink_dynamic_reloc_sections (info, abf = size - 1" since the index starts at zero, but in this context, the size has just been decremented so there's no need to subtract one. */ - reloc_index = srel->_cooked_size / sizeof (Elf32_External_Rela); + reloc_index = srel->size / sizeof (Elf32_External_Rela); chunk = reloc_index / PLT_ENTRIES_PER_CHUNK; splt = elf_xtensa_get_plt_section (dynobj, chunk); @@ -4990,27 +4964,20 @@ shrink_dynamic_reloc_sections (info, abf srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); BFD_ASSERT (srelgot != NULL); srelgot->reloc_count -= 2; - srelgot->_cooked_size -= 2 * sizeof (Elf32_External_Rela); - /* Shrink _raw_size (see comment above). */ - srelgot->_raw_size = srelgot->_cooked_size; - - sgotplt->_cooked_size -= 8; + srelgot->size -= 2 * sizeof (Elf32_External_Rela); + sgotplt->size -= 8; /* There should be only one entry left (and it will be removed below). */ - BFD_ASSERT (sgotplt->_cooked_size == 4); - BFD_ASSERT (splt->_cooked_size == PLT_ENTRY_SIZE); + BFD_ASSERT (sgotplt->size == 4); + BFD_ASSERT (splt->size == PLT_ENTRY_SIZE); } - BFD_ASSERT (sgotplt->_cooked_size >= 4); - BFD_ASSERT (splt->_cooked_size >= PLT_ENTRY_SIZE); - - sgotplt->_cooked_size -= 4; - splt->_cooked_size -= PLT_ENTRY_SIZE; + BFD_ASSERT (sgotplt->size >= 4); + BFD_ASSERT (splt->size >= PLT_ENTRY_SIZE); - /* Shrink _raw_sizes (see comment above). */ - sgotplt->_raw_size = sgotplt->_cooked_size; - splt->_raw_size = splt->_cooked_size; + sgotplt->size -= 4; + splt->size -= PLT_ENTRY_SIZE; } } } @@ -5035,7 +5002,7 @@ relax_property_section (abfd, sec, link_ internal_relocs = retrieve_internal_relocs (abfd, sec, link_info->keep_memory); contents = retrieve_contents (abfd, sec, link_info->keep_memory); - if (contents == NULL && sec->_raw_size != 0) + if (contents == NULL && sec->size != 0) { ok = FALSE; goto error_return; @@ -5126,7 +5093,7 @@ relax_property_section (abfd, sec, link_ pin_contents (sec, contents); last_irel_offset = (bfd_vma) -1; - section_size = (sec->_cooked_size ? sec->_cooked_size : sec->_raw_size); + section_size = sec->size; BFD_ASSERT (section_size % 8 == 0); for (offset = 0; offset < section_size; offset += 8) @@ -5258,13 +5225,7 @@ relax_property_section (abfd, sec, link_ /* Clear the removed bytes. */ memset (&contents[section_size - removed_bytes], 0, removed_bytes); - sec->_cooked_size = section_size - removed_bytes; - /* Also shrink _raw_size. (The code in relocate_section that - checks that relocations are within the section must use - _raw_size because of the way the stabs sections are - relaxed; shrinking _raw_size means that these checks will - not be unnecessarily lax.) */ - sec->_raw_size = sec->_cooked_size; + sec->size = section_size - removed_bytes; if (xtensa_is_littable_section (sec)) { @@ -5274,13 +5235,7 @@ relax_property_section (abfd, sec, link_ asection *sgotloc = bfd_get_section_by_name (dynobj, ".got.loc"); if (sgotloc) - { - bfd_size_type sgotloc_size = - (sgotloc->_cooked_size ? sgotloc->_cooked_size - : sgotloc->_raw_size); - sgotloc->_cooked_size = sgotloc_size - removed_bytes; - sgotloc->_raw_size = sgotloc_size - removed_bytes; - } + sgotloc->size -= removed_bytes; } } } @@ -5739,7 +5694,7 @@ xtensa_callback_required_dependence (abf /* Assume worst-case offsets: L32R at the very end of the ".plt" section referencing a literal at the very beginning of ".got.plt". This is very close to the real dependence, anyway. */ - (*callback) (sec, sec->_raw_size, sgotplt, 0, closure); + (*callback) (sec, sec->size, sgotplt, 0, closure); } internal_relocs = retrieve_internal_relocs (abfd, sec, @@ -5750,7 +5705,7 @@ xtensa_callback_required_dependence (abf /* Cache the contents for the duration of this scan. */ contents = retrieve_contents (abfd, sec, link_info->keep_memory); - if (contents == NULL && sec->_raw_size != 0) + if (contents == NULL && sec->size != 0) { ok = FALSE; goto error_return; Index: bfd/elf64-alpha.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-alpha.c,v retrieving revision 1.119 diff -u -p -r1.119 elf64-alpha.c --- bfd/elf64-alpha.c 22 May 2004 01:56:30 -0000 1.119 +++ bfd/elf64-alpha.c 22 Jun 2004 01:36:14 -0000 @@ -1036,6 +1036,7 @@ elf64_alpha_reloc_gpdisp (abfd, reloc_en { bfd_reloc_status_type ret; bfd_vma gp, relocation; + bfd_size_type sz; bfd_byte *p_ldah, *p_lda; /* Don't do anything if we're not doing a final link. */ @@ -1045,8 +1046,9 @@ elf64_alpha_reloc_gpdisp (abfd, reloc_en return bfd_reloc_ok; } - if (reloc_entry->address > input_section->_cooked_size || - reloc_entry->address + reloc_entry->addend > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz + || reloc_entry->address + reloc_entry->addend > sz) return bfd_reloc_outofrange; /* The gp used in the portion of the output object to which this @@ -1973,11 +1975,6 @@ elf64_alpha_relax_section (abfd, sec, li || sec->reloc_count == 0) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; local_got_entries = alpha_elf_tdata(abfd)->local_got_entries; @@ -2012,12 +2009,7 @@ elf64_alpha_relax_section (abfd, sec, li info.contents = elf_section_data (sec)->this_hdr.contents; else { - info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (info.contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, info.contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &info.contents)) goto error_return; } @@ -3204,7 +3196,7 @@ elf64_alpha_check_relocs (abfd, info, se { /* If this is a shared library, and the section is to be loaded into memory, we need a RELATIVE reloc. */ - sreloc->_raw_size += sizeof (Elf64_External_Rela); + sreloc->size += sizeof (Elf64_External_Rela); if ((sec->flags & (SEC_READONLY | SEC_ALLOC)) == (SEC_READONLY | SEC_ALLOC)) info->flags |= DF_TEXTREL; @@ -3255,11 +3247,11 @@ elf64_alpha_adjust_dynamic_symbol (info, return FALSE; /* The first bit of the .plt is reserved. */ - if (s->_raw_size == 0) - s->_raw_size = PLT_HEADER_SIZE; + if (s->size == 0) + s->size = PLT_HEADER_SIZE; - h->plt.offset = s->_raw_size; - s->_raw_size += PLT_ENTRY_SIZE; + h->plt.offset = s->size; + s->size += PLT_ENTRY_SIZE; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to the location @@ -3278,7 +3270,7 @@ elf64_alpha_adjust_dynamic_symbol (info, /* We also need a JMP_SLOT entry in the .rela.plt section. */ s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += sizeof (Elf64_External_Rela); + s->size += sizeof (Elf64_External_Rela); return TRUE; } @@ -3566,7 +3558,7 @@ elf64_alpha_calc_got_offsets_for_symbol result = FALSE; continue; } - plge = &td->got->_raw_size; + plge = &td->got->size; gotent->got_offset = *plge; *plge += alpha_got_entry_size (gotent->reloc_type); } @@ -3583,7 +3575,7 @@ elf64_alpha_calc_got_offsets (info) /* First, zero out the .got sizes, as we may be recalculating the .got after optimizing it. */ for (i = got_list; i ; i = alpha_elf_tdata(i)->got_link_next) - alpha_elf_tdata(i)->got->_raw_size = 0; + alpha_elf_tdata(i)->got->size = 0; /* Next, fill in the offsets for all the global entries. */ alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), @@ -3593,7 +3585,7 @@ elf64_alpha_calc_got_offsets (info) /* Finally, fill in the offsets for the local entries. */ for (i = got_list; i ; i = alpha_elf_tdata(i)->got_link_next) { - bfd_size_type got_offset = alpha_elf_tdata(i)->got->_raw_size; + bfd_size_type got_offset = alpha_elf_tdata(i)->got->size; bfd *j; for (j = i; j ; j = alpha_elf_tdata(j)->in_got_link_next) @@ -3614,8 +3606,7 @@ elf64_alpha_calc_got_offsets (info) } } - alpha_elf_tdata(i)->got->_raw_size = got_offset; - alpha_elf_tdata(i)->got->_cooked_size = got_offset; + alpha_elf_tdata(i)->got->size = got_offset; } } @@ -3712,21 +3703,18 @@ elf64_alpha_size_plt_section (info) if (splt == NULL) return TRUE; - splt->_raw_size = 0; + splt->size = 0; alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), elf64_alpha_size_plt_section_1, splt); - splt->_cooked_size = splt->_raw_size; - /* Every plt entry requires a JMP_SLOT relocation. */ spltrel = bfd_get_section_by_name (dynobj, ".rela.plt"); - if (splt->_raw_size) - entries = (splt->_raw_size - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE; + if (splt->size) + entries = (splt->size - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE; else entries = 0; - spltrel->_raw_size = entries * sizeof (Elf64_External_Rela); - spltrel->_cooked_size = spltrel->_raw_size; + spltrel->size = entries * sizeof (Elf64_External_Rela); return TRUE; } @@ -3753,10 +3741,10 @@ elf64_alpha_size_plt_section_1 (h, data) a need for the PLT entry. */ if (gotent) { - if (splt->_raw_size == 0) - splt->_raw_size = PLT_HEADER_SIZE; - h->root.plt.offset = splt->_raw_size; - splt->_raw_size += PLT_ENTRY_SIZE; + if (splt->size == 0) + splt->size = PLT_HEADER_SIZE; + h->root.plt.offset = splt->size; + splt->size += PLT_ENTRY_SIZE; } else { @@ -3798,9 +3786,9 @@ elf64_alpha_always_size_sections (output for ( ; i ; i = alpha_elf_tdata(i)->got_link_next) { asection *s = alpha_elf_tdata(i)->got; - if (s->_raw_size > 0) + if (s->size > 0) { - s->contents = (bfd_byte *) bfd_zalloc (i, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (i, s->size); if (s->contents == NULL) return FALSE; } @@ -3884,7 +3872,7 @@ elf64_alpha_calc_dynrel_sizes (h, info) info->shared); if (entries) { - relent->srel->_raw_size += + relent->srel->size += entries * sizeof (Elf64_External_Rela) * relent->count; if (relent->reltext) info->flags |= DT_TEXTREL; @@ -3938,14 +3926,12 @@ elf64_alpha_size_rela_got_section (info) BFD_ASSERT (entries == 0); return TRUE; } - srel->_raw_size = sizeof (Elf64_External_Rela) * entries; + srel->size = sizeof (Elf64_External_Rela) * entries; /* Now do the non-local symbols. */ alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), elf64_alpha_size_rela_got_1, info); - srel->_cooked_size = srel->_raw_size; - return TRUE; } @@ -3986,7 +3972,7 @@ elf64_alpha_size_rela_got_1 (h, info) bfd *dynobj = elf_hash_table(info)->dynobj; asection *srel = bfd_get_section_by_name (dynobj, ".rela.got"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf64_External_Rela) * entries; + srel->size += sizeof (Elf64_External_Rela) * entries; } return TRUE; @@ -4013,7 +3999,7 @@ elf64_alpha_size_dynamic_sections (outpu { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } @@ -4056,7 +4042,7 @@ elf64_alpha_size_dynamic_sections (outpu if (strncmp (name, ".rela", 5) == 0) { - strip = (s->_raw_size == 0); + strip = (s->size == 0); if (!strip) { @@ -4079,8 +4065,8 @@ elf64_alpha_size_dynamic_sections (outpu else { /* Allocate memory for the section contents. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } } @@ -4154,8 +4140,7 @@ elf64_alpha_emit_dynrel (abfd, info, sec loc = srel->contents; loc += srel->reloc_count++ * sizeof (Elf64_External_Rela); bfd_elf64_swap_reloca_out (abfd, &outrel, loc); - BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count - <= srel->_cooked_size); + BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count <= srel->size); } /* Relocate an Alpha ELF section for a relocatable link. @@ -5032,7 +5017,7 @@ elf64_alpha_finish_dynamic_sections (out BFD_ASSERT (splt != NULL && sdyn != NULL); dyncon = (Elf64_External_Dyn *) sdyn->contents; - dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -5061,10 +5046,7 @@ elf64_alpha_finish_dynamic_sections (out out who is right. */ s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s) - { - dyn.d_un.d_val -= - (s->_cooked_size ? s->_cooked_size : s->_raw_size); - } + dyn.d_un.d_val -= s->size; break; get_vma: @@ -5074,8 +5056,7 @@ elf64_alpha_finish_dynamic_sections (out get_size: s = bfd_get_section_by_name (output_bfd, name); - dyn.d_un.d_val = - (s->_cooked_size ? s->_cooked_size : s->_raw_size); + dyn.d_un.d_val = s->size; break; } @@ -5083,7 +5064,7 @@ elf64_alpha_finish_dynamic_sections (out } /* Initialize the PLT0 entry. */ - if (splt->_raw_size > 0) + if (splt->size > 0) { bfd_put_32 (output_bfd, PLT_HEADER_WORD1, splt->contents); bfd_put_32 (output_bfd, PLT_HEADER_WORD2, splt->contents + 4); @@ -5194,7 +5175,7 @@ elf64_alpha_final_link (abfd, info) if (s != NULL) { esym.asym.value = s->vma; - last = s->vma + s->_raw_size; + last = s->vma + s->size; } else esym.asym.value = last; @@ -5239,7 +5220,7 @@ elf64_alpha_final_link (abfd, info) input_swap = (get_elf_backend_data (input_bfd) ->elf_backend_ecoff_debug_swap); - BFD_ASSERT (p->size == input_section->_raw_size); + BFD_ASSERT (p->size == input_section->size); /* The ECOFF linking code expects that we have already read in the debugging information and set up an @@ -5322,7 +5303,7 @@ elf64_alpha_final_link (abfd, info) return FALSE; /* Set the size of the .mdebug section. */ - o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap); + o->size = bfd_ecoff_debug_size (abfd, &debug, swap); /* Skip this section later on (I don't think this currently matters, but someday it might). */ @@ -5355,7 +5336,7 @@ elf64_alpha_final_link (abfd, info) if (! bfd_set_section_contents (abfd, sgot->output_section, sgot->contents, (file_ptr) sgot->output_offset, - sgot->_raw_size)) + sgot->size)) return FALSE; } } Index: bfd/elf64-hppa.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-hppa.c,v retrieving revision 1.48 diff -u -p -r1.48 elf64-hppa.c --- bfd/elf64-hppa.c 27 Mar 2004 10:58:07 -0000 1.48 +++ bfd/elf64-hppa.c 22 Jun 2004 01:36:15 -0000 @@ -1503,7 +1503,7 @@ allocate_dynrel_entries (dyn_h, data) if (!shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd) continue; - hppa_info->other_rel_sec->_raw_size += sizeof (Elf64_External_Rela); + hppa_info->other_rel_sec->size += sizeof (Elf64_External_Rela); /* Make sure this symbol gets into the dynamic symbol table if it is not already recorded. ?!? This should not be in the loop since @@ -1518,13 +1518,13 @@ allocate_dynrel_entries (dyn_h, data) /* Take care of the GOT and PLT relocations. */ if ((dynamic_symbol || shared) && dyn_h->want_dlt) - hppa_info->dlt_rel_sec->_raw_size += sizeof (Elf64_External_Rela); + hppa_info->dlt_rel_sec->size += sizeof (Elf64_External_Rela); /* If we are building a shared library, then every symbol that has an opd entry will need an EPLT relocation to relocate the symbol's address and __gp value based on the runtime load address. */ if (shared && dyn_h->want_opd) - hppa_info->opd_rel_sec->_raw_size += sizeof (Elf64_External_Rela); + hppa_info->opd_rel_sec->size += sizeof (Elf64_External_Rela); if (dyn_h->want_plt && dynamic_symbol) { @@ -1538,7 +1538,7 @@ allocate_dynrel_entries (dyn_h, data) else if (shared) t = 2 * sizeof (Elf64_External_Rela); - hppa_info->plt_rel_sec->_raw_size += t; + hppa_info->plt_rel_sec->size += t; } return TRUE; @@ -1648,7 +1648,7 @@ elf64_hppa_size_dynamic_sections (output { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -1661,7 +1661,7 @@ elf64_hppa_size_dynamic_sections (output below. */ s = bfd_get_section_by_name (dynobj, ".rela.dlt"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; } /* Allocate the GOT entries. */ @@ -1672,17 +1672,17 @@ elf64_hppa_size_dynamic_sections (output data.ofs = 0x0; elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, allocate_global_data_dlt, &data); - hppa_info->dlt_sec->_raw_size = data.ofs; + hppa_info->dlt_sec->size = data.ofs; data.ofs = 0x0; elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, allocate_global_data_plt, &data); - hppa_info->plt_sec->_raw_size = data.ofs; + hppa_info->plt_sec->size = data.ofs; data.ofs = 0x0; elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, allocate_global_data_stub, &data); - hppa_info->stub_sec->_raw_size = data.ofs; + hppa_info->stub_sec->size = data.ofs; } /* Allocate space for entries in the .opd section. */ @@ -1691,7 +1691,7 @@ elf64_hppa_size_dynamic_sections (output data.ofs = 0; elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, allocate_global_data_opd, &data); - hppa_info->opd_sec->_raw_size = data.ofs; + hppa_info->opd_sec->size = data.ofs; } /* Now allocate space for dynamic relocations, if necessary. */ @@ -1720,7 +1720,7 @@ elf64_hppa_size_dynamic_sections (output if (strcmp (name, ".plt") == 0) { /* Strip this section if we don't need it; see the comment below. */ - if (s->_raw_size == 0) + if (s->size == 0) { strip = TRUE; } @@ -1733,7 +1733,7 @@ elf64_hppa_size_dynamic_sections (output else if (strcmp (name, ".dlt") == 0) { /* Strip this section if we don't need it; see the comment below. */ - if (s->_raw_size == 0) + if (s->size == 0) { strip = TRUE; } @@ -1741,7 +1741,7 @@ elf64_hppa_size_dynamic_sections (output else if (strcmp (name, ".opd") == 0) { /* Strip this section if we don't need it; see the comment below. */ - if (s->_raw_size == 0) + if (s->size == 0) { strip = TRUE; } @@ -1755,7 +1755,7 @@ elf64_hppa_size_dynamic_sections (output sections. The linker does that before adjust_dynamic_symbol is called, and it is that function which decides whether anything needs to go into these sections. */ - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -1821,8 +1821,8 @@ elf64_hppa_size_dynamic_sections (output garbage. */ if (s->contents == NULL) { - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } } @@ -2498,7 +2498,7 @@ elf64_hppa_finish_dynamic_sections (outp BFD_ASSERT (sdyn != NULL); dyncon = (Elf64_External_Dyn *) sdyn->contents; - dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -2537,15 +2537,15 @@ elf64_hppa_finish_dynamic_sections (outp case DT_PLTRELSZ: s = hppa_info->plt_rel_sec; - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); break; case DT_RELA: s = hppa_info->other_rel_sec; - if (! s || ! s->_raw_size) + if (! s || ! s->size) s = hppa_info->dlt_rel_sec; - if (! s || ! s->_raw_size) + if (! s || ! s->size) s = hppa_info->opd_rel_sec; dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); @@ -2553,16 +2553,16 @@ elf64_hppa_finish_dynamic_sections (outp case DT_RELASZ: s = hppa_info->other_rel_sec; - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; s = hppa_info->dlt_rel_sec; - dyn.d_un.d_val += s->_raw_size; + dyn.d_un.d_val += s->size; s = hppa_info->opd_rel_sec; - dyn.d_un.d_val += s->_raw_size; + dyn.d_un.d_val += s->size; /* There is some question about whether or not the size of the PLT relocs should be included here. HP's tools do it, so we'll emulate them. */ s = hppa_info->plt_rel_sec; - dyn.d_un.d_val += s->_raw_size; + dyn.d_un.d_val += s->size; bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); break; Index: bfd/elf64-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-mips.c,v retrieving revision 1.59 diff -u -p -r1.59 elf64-mips.c --- bfd/elf64-mips.c 14 Jan 2004 03:06:00 -0000 1.59 +++ bfd/elf64-mips.c 22 Jun 2004 01:36:16 -0000 @@ -1,5 +1,5 @@ /* MIPS-specific support for 64-bit ELF - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Ian Lance Taylor, Cygnus Support Linker support added by Mark Mitchell, CodeSourcery, LLC. @@ -1588,6 +1588,7 @@ mips_elf64_gprel32_reloc (bfd *abfd, are bfd_vma gp; bfd_vma relocation; bfd_vma val; + bfd_size_type sz; /* If we're relocating, and this is an external symbol, we don't want to change anything. */ @@ -1621,7 +1622,8 @@ mips_elf64_gprel32_reloc (bfd *abfd, are relocation += symbol->section->output_section->vma; relocation += symbol->section->output_offset; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Set val to the offset into the section or symbol. */ @@ -1712,6 +1714,7 @@ mips16_gprel_reloc (bfd *abfd, arelent * unsigned short insn = 0; bfd_signed_vma val; bfd_vma relocation; + bfd_size_type sz; /* If we're relocating, and this is an external symbol with no addend, we don't want to change anything. */ @@ -1736,7 +1739,8 @@ mips16_gprel_reloc (bfd *abfd, arelent * if (ret != bfd_reloc_ok) return ret; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; if (bfd_is_com_section (symbol->section)) @@ -1984,7 +1988,7 @@ mips_elf64_canonicalize_dynamic_reloc (b if (! (*slurp_relocs) (abfd, s, syms, TRUE)) return -1; - count = s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize * 3; + count = s->size / elf_section_data (s)->this_hdr.sh_entsize * 3; p = s->relocation; for (i = 0; i < count; i++) *storage++ = p++; @@ -2210,7 +2214,7 @@ mips_elf64_slurp_reloc_table (bfd *abfd, case because relocations against this section may use the dynamic symbol table, and in that case bfd_section_from_shdr in elf.c does not update the RELOC_COUNT. */ - if (asect->_raw_size == 0) + if (asect->size == 0) return TRUE; rel_hdr = &d->this_hdr; @@ -2539,7 +2543,7 @@ static bfd_boolean elf64_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; - unsigned int raw_size; + unsigned int size; switch (note->descsz) { @@ -2555,14 +2559,14 @@ elf64_mips_grok_prstatus (bfd *abfd, Elf /* pr_reg */ offset = 112; - raw_size = 360; + size = 360; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean Index: bfd/elf64-mmix.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-mmix.c,v retrieving revision 1.35 diff -u -p -r1.35 elf64-mmix.c --- bfd/elf64-mmix.c 15 Jun 2004 01:24:22 -0000 1.35 +++ bfd/elf64-mmix.c 22 Jun 2004 01:36:18 -0000 @@ -991,10 +991,10 @@ mmix_elf_perform_relocation (isec, howto goto pcrel_mmix_reloc_fits; else { - bfd_size_type raw_size - = (isec->_raw_size - - mmix_elf_section_data (isec)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE); + bfd_size_type size + = (isec->size + - (mmix_elf_section_data (isec)->pjs.n_pushj_relocs + * MAX_PUSHJ_STUB_SIZE)); /* We have the bytes at the PUSHJ insn and need to get the position for the stub. There's supposed to be room allocated @@ -1002,7 +1002,7 @@ mmix_elf_perform_relocation (isec, howto bfd_byte *stubcontents = ((char *) datap - (addr - (isec->output_section->vma + isec->output_offset)) - + raw_size + + size + mmix_elf_section_data (isec)->pjs.stub_offset); bfd_vma stubaddr; @@ -1015,7 +1015,7 @@ mmix_elf_perform_relocation (isec, howto addr, isec->output_section->vma + isec->output_offset - + raw_size + + size + (mmix_elf_section_data (isec) ->pjs.stub_offset) - addr); @@ -1025,7 +1025,7 @@ mmix_elf_perform_relocation (isec, howto stubaddr = (isec->output_section->vma + isec->output_offset - + raw_size + + size + mmix_elf_section_data (isec)->pjs.stub_offset); /* We generate a simple JMP if that suffices, else the whole 5 @@ -1045,9 +1045,8 @@ mmix_elf_perform_relocation (isec, howto value + addr - stubaddr); mmix_elf_section_data (isec)->pjs.stub_offset += 4; - if (raw_size - + mmix_elf_section_data (isec)->pjs.stub_offset - > isec->_cooked_size) + if (size + mmix_elf_section_data (isec)->pjs.stub_offset + > isec->size) abort (); return r; @@ -1262,6 +1261,7 @@ mmix_elf_reloc (abfd, reloc_entry, symbo bfd_reloc_status_type flag = bfd_reloc_ok; bfd_vma output_base = 0; bfd_vma addr; + bfd_size_type sz; r = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message); @@ -1277,7 +1277,8 @@ mmix_elf_reloc (abfd, reloc_entry, symbo return bfd_reloc_undefined; /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Work out which section the relocation is targeted at and the @@ -1342,10 +1343,10 @@ mmix_elf_relocate_section (output_bfd, i struct elf_link_hash_entry **sym_hashes; Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; - bfd_size_type raw_size - = (input_section->_raw_size - - mmix_elf_section_data (input_section)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE); + bfd_size_type size + = (input_section->size + - (mmix_elf_section_data (input_section)->pjs.n_pushj_relocs + * MAX_PUSHJ_STUB_SIZE)); size_t pjsno = 0; symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; @@ -1421,7 +1422,7 @@ mmix_elf_relocate_section (output_bfd, i input_section ->output_section->vma + input_section->output_offset - + raw_size + + size + mmix_elf_section_data (input_section) ->pjs.stub_offset, NULL, NULL) != bfd_reloc_ok) @@ -1431,7 +1432,7 @@ mmix_elf_relocate_section (output_bfd, i R_MMIX_JMP reloc. */ bfd_put_32 (output_bfd, JMP_INSN_BYTE << 24, contents - + raw_size + + size + mmix_elf_section_data (input_section) ->pjs.stub_offset); @@ -1439,7 +1440,7 @@ mmix_elf_relocate_section (output_bfd, i R_MMIX_JMP reloc. */ rel->r_info = ELF64_R_INFO (r_symndx, R_MMIX_JMP); rel->r_offset - = (raw_size + = (size + mmix_elf_section_data (input_section) ->pjs.stub_offset); @@ -2287,21 +2288,14 @@ mmix_elf_final_link (abfd, info) greg_section->output_section, greg_section->contents, (file_ptr) greg_section->output_offset, - greg_section->_cooked_size)) + greg_section->size)) return FALSE; } return TRUE; } /* We need to include the maximum size of PUSHJ-stubs in the initial - section size. This is expected to shrink during linker relaxation. - - You might think that we should set *only* _cooked_size, but that - won't work: section contents allocation will be using _raw_size in - mixed format linking and not enough storage will be allocated. - FIXME: That's a major bug. The relaxation functions set _cooked - size. Relaxation happens before relocation. All functions - *after relaxation* should be using _cooked size. */ + section size. This is expected to shrink during linker relaxation. */ static void mmix_set_relaxable_size (abfd, sec, ptr) @@ -2316,11 +2310,8 @@ mmix_set_relaxable_size (abfd, sec, ptr) if (mmix_elf_section_data (sec)->pjs.n_pushj_relocs == 0) return; - sec->_cooked_size - = (sec->_raw_size - + mmix_elf_section_data (sec)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE); - sec->_raw_size = sec->_cooked_size; + sec->size += (mmix_elf_section_data (sec)->pjs.n_pushj_relocs + * MAX_PUSHJ_STUB_SIZE); /* For use in relocatable link, we start with a max stubs size. See mmix_elf_relax_section. */ @@ -2450,11 +2441,8 @@ _bfd_mmix_after_linker_allocation (abfd, n_gregs = gregdata->n_allocated_bpo_gregs; - /* We need to have a _raw_size contents even though there's only - _cooked_size worth of data, since the generic relocation machinery - will allocate and copy that much temporarily. */ bpo_gregs_section->contents - = contents = bfd_alloc (bpo_greg_owner, bpo_gregs_section->_raw_size); + = contents = bfd_alloc (bpo_greg_owner, bpo_gregs_section->size); if (contents == NULL) return FALSE; @@ -2601,21 +2589,15 @@ mmix_elf_relax_section (abfd, sec, link_ size_t pjsno = 0; bfd *bpo_greg_owner; Elf_Internal_Sym *isymbuf = NULL; - bfd_size_type raw_size - = (sec->_raw_size - - mmix_elf_section_data (sec)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE); + bfd_size_type size = (sec->size + - (mmix_elf_section_data (sec)->pjs.n_pushj_relocs + * MAX_PUSHJ_STUB_SIZE)); mmix_elf_section_data (sec)->pjs.stubs_size_sum = 0; /* Assume nothing changes. */ *again = FALSE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0 && sec->_raw_size != 0) - abort (); - /* We don't have to do anything if this section does not have relocs, or if this is not a code section. */ if ((sec->flags & SEC_RELOC) == 0 @@ -2687,7 +2669,7 @@ mmix_elf_relax_section (abfd, sec, link_ 0, bfd_arch_bits_per_address (abfd), /* Output-stub location. */ - sec->output_section->_cooked_size + sec->output_section->size + (mmix_elf_section_data (sec ->output_section) ->pjs.stubs_size_sum) @@ -2780,7 +2762,7 @@ mmix_elf_relax_section (abfd, sec, link_ bfd_vma stubaddr = (sec->output_section->vma + sec->output_offset - + raw_size + + size + mmix_elf_section_data (sec)->pjs.stubs_size_sum); if ((value & 3) == 0 @@ -2891,7 +2873,7 @@ mmix_elf_relax_section (abfd, sec, link_ *again = TRUE; } - bpo_gregs_section->_cooked_size = (regindex + 1) * 8; + bpo_gregs_section->size = (regindex + 1) * 8; } if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents) @@ -2909,15 +2891,12 @@ mmix_elf_relax_section (abfd, sec, link_ && elf_section_data (sec)->relocs != internal_relocs) free (internal_relocs); - if (sec->_cooked_size - < raw_size + mmix_elf_section_data (sec)->pjs.stubs_size_sum) + if (sec->size < size + mmix_elf_section_data (sec)->pjs.stubs_size_sum) abort (); - if (sec->_cooked_size - > raw_size + mmix_elf_section_data (sec)->pjs.stubs_size_sum) + if (sec->size > size + mmix_elf_section_data (sec)->pjs.stubs_size_sum) { - sec->_cooked_size - = raw_size + mmix_elf_section_data (sec)->pjs.stubs_size_sum; + sec->size = size + mmix_elf_section_data (sec)->pjs.stubs_size_sum; *again = TRUE; } @@ -2932,9 +2911,9 @@ mmix_elf_relax_section (abfd, sec, link_ return FALSE; } -/* Because we set _raw_size to include the max size of pushj stubs, +/* Because we set size to include the max size of pushj stubs, i.e. larger than the actual section input size (see - mmix_set_relaxable_raw_size), we have to take care of that when reading + mmix_set_relaxablesize), we have to take care of that when reading the section. */ static bfd_boolean @@ -2945,32 +2924,31 @@ mmix_elf_get_section_contents (abfd, sec file_ptr offset; bfd_size_type count; { - bfd_size_type raw_size - = (section->_raw_size - - mmix_elf_section_data (section)->pjs.n_pushj_relocs - * MAX_PUSHJ_STUB_SIZE); + bfd_size_type size = (section->size + - (mmix_elf_section_data (section)->pjs.n_pushj_relocs + * MAX_PUSHJ_STUB_SIZE)); - if (offset + count > section->_raw_size) + if (offset + count > section->size) { abort(); bfd_set_error (bfd_error_invalid_operation); return FALSE; } - /* Check bounds against the faked raw_size. */ - if (offset + count > raw_size) + /* Check bounds against the faked size. */ + if (offset + count > size) { /* Clear the part in the faked area. */ - memset (location + raw_size - offset, 0, count - (raw_size - offset)); + memset (location + size - offset, 0, count - (size - offset)); /* If there's no initial part within the "real" contents, we're done. */ - if ((bfd_size_type) offset >= raw_size) + if ((bfd_size_type) offset >= size) return TRUE; /* Else adjust the count and fall through to call the generic function. */ - count = raw_size - offset; + count = size - offset; } return Index: bfd/elf64-ppc.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-ppc.c,v retrieving revision 1.147 diff -u -p -r1.147 elf64-ppc.c --- bfd/elf64-ppc.c 27 Mar 2004 10:58:07 -0000 1.147 +++ bfd/elf64-ppc.c 22 Jun 2004 01:36:22 -0000 @@ -2382,7 +2382,7 @@ ppc64_elf_object_p (bfd *abfd) static bfd_boolean ppc64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { - size_t offset, raw_size; + size_t offset, size; if (note->descsz != 504) return FALSE; @@ -2395,11 +2395,11 @@ ppc64_elf_grok_prstatus (bfd *abfd, Elf_ /* pr_reg */ offset = 112; - raw_size = 384; + size = 384; /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean @@ -3644,7 +3644,7 @@ ppc64_elf_check_relocs (bfd *abfd, struc }; bfd_size_type amt; - amt = sec->_raw_size * sizeof (union opd_info) / 24; + amt = sec->size * sizeof (union opd_info) / 24; opd_sym_map = bfd_zalloc (abfd, amt); if (opd_sym_map == NULL) return FALSE; @@ -3888,7 +3888,7 @@ ppc64_elf_check_relocs (bfd *abfd, struc if (ppc64_elf_section_data (sec)->t_symndx == NULL) { /* One extra to simplify get_tls_mask. */ - bfd_size_type amt = sec->_raw_size * sizeof (unsigned) / 8 + 1; + bfd_size_type amt = sec->size * sizeof (unsigned) / 8 + 1; ppc64_elf_section_data (sec)->t_symndx = bfd_zalloc (abfd, amt); if (ppc64_elf_section_data (sec)->t_symndx == NULL) return FALSE; @@ -4508,10 +4508,10 @@ ppc64_elf_func_desc_adjust (bfd *obfd AT elf_link_hash_traverse (&htab->elf, func_desc_adjust, info); - htab->sfpr->_raw_size = ((MAX_SAVE_FPR + 2 - lowest_savef) * 4 - + (MAX_SAVE_FPR + 2 - lowest_restf) * 4); + htab->sfpr->size = ((MAX_SAVE_FPR + 2 - lowest_savef) * 4 + + (MAX_SAVE_FPR + 2 - lowest_restf) * 4); - if (htab->sfpr->_raw_size == 0) + if (htab->sfpr->size == 0) { if (!htab->have_undefweak) { @@ -4519,10 +4519,10 @@ ppc64_elf_func_desc_adjust (bfd *obfd AT return TRUE; } - htab->sfpr->_raw_size = 4; + htab->sfpr->size = 4; } - p = bfd_alloc (htab->elf.dynobj, htab->sfpr->_raw_size); + p = bfd_alloc (htab->elf.dynobj, htab->sfpr->size); if (p == NULL) return FALSE; htab->sfpr->contents = p; @@ -4548,7 +4548,7 @@ ppc64_elf_func_desc_adjust (bfd *obfd AT p += 4; } if (lowest_restf <= MAX_SAVE_FPR - || htab->sfpr->_raw_size == 4) + || htab->sfpr->size == 4) { bfd_put_32 (htab->elf.dynobj, BLR, p); } @@ -4677,7 +4677,7 @@ ppc64_elf_adjust_dynamic_symbol (struct .rela.bss section we are going to use. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { - htab->relbss->_raw_size += sizeof (Elf64_External_Rela); + htab->relbss->size += sizeof (Elf64_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -4689,7 +4689,7 @@ ppc64_elf_adjust_dynamic_symbol (struct /* Apply the required alignment. */ s = htab->dynbss; - s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) { if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) @@ -4698,10 +4698,10 @@ ppc64_elf_adjust_dynamic_symbol (struct /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -4970,7 +4970,7 @@ ppc64_elf_edit_opd (bfd *obfd, struct bf if (sec == NULL) continue; - amt = sec->_raw_size * sizeof (long) / 24; + amt = sec->size * sizeof (long) / 24; adjust = ppc64_elf_section_data (sec)->opd.adjust; if (adjust == NULL) { @@ -5092,11 +5092,11 @@ ppc64_elf_edit_opd (bfd *obfd, struct bf the third word of .opd entries. */ if ((sec->flags & SEC_IN_MEMORY) == 0) { - bfd_byte *loc = bfd_alloc (ibfd, sec->_raw_size); - if (loc == NULL - || !bfd_get_section_contents (ibfd, sec, loc, 0, - sec->_raw_size)) + bfd_byte *loc; + if (!bfd_malloc_and_get_section (ibfd, sec, &loc)) { + if (loc != NULL) + free (loc); error_ret: if (local_syms != NULL && symtab_hdr->contents != (unsigned char *) local_syms) @@ -5222,7 +5222,7 @@ ppc64_elf_edit_opd (bfd *obfd, struct bf } } - sec->_cooked_size = wptr - sec->contents; + sec->size = wptr - sec->contents; sec->reloc_count = write_rel - relstart; /* Fudge the size too, as this is used later in elf_bfd_final_link if we are emitting relocs. */ @@ -5610,26 +5610,26 @@ allocate_dynrelocs (struct elf_link_hash /* If this is the first .plt entry, make room for the special first entry. */ s = htab->plt; - if (s->_raw_size == 0) - s->_raw_size += PLT_INITIAL_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_INITIAL_ENTRY_SIZE; - pent->plt.offset = s->_raw_size; + pent->plt.offset = s->size; /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* Make room for the .glink code. */ s = htab->glink; - if (s->_raw_size == 0) - s->_raw_size += GLINK_CALL_STUB_SIZE; + if (s->size == 0) + s->size += GLINK_CALL_STUB_SIZE; /* We need bigger stubs past index 32767. */ - if (s->_raw_size >= GLINK_CALL_STUB_SIZE + 32768*2*4) - s->_raw_size += 4; - s->_raw_size += 2*4; + if (s->size >= GLINK_CALL_STUB_SIZE + 32768*2*4) + s->size += 4; + s->size += 2*4; /* We also need to make an entry in the .rela.plt section. */ s = htab->relplt; - s->_raw_size += sizeof (Elf64_External_Rela); + s->size += sizeof (Elf64_External_Rela); doneone = TRUE; } else @@ -5695,15 +5695,15 @@ allocate_dynrelocs (struct elf_link_hash } s = ppc64_elf_tdata (gent->owner)->got; - gent->got.offset = s->_raw_size; - s->_raw_size + gent->got.offset = s->size; + s->size += (gent->tls_type & eh->tls_mask & (TLS_GD | TLS_LD)) ? 16 : 8; dyn = htab->elf.dynamic_sections_created; if ((info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)) && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak)) - ppc64_elf_tdata (gent->owner)->relgot->_raw_size + ppc64_elf_tdata (gent->owner)->relgot->size += (gent->tls_type & eh->tls_mask & TLS_GD ? 2 * sizeof (Elf64_External_Rela) : sizeof (Elf64_External_Rela)); @@ -5783,7 +5783,7 @@ allocate_dynrelocs (struct elf_link_hash for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela); + sreloc->size += p->count * sizeof (Elf64_External_Rela); } return TRUE; @@ -5843,7 +5843,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou s = bfd_get_section_by_name (dynobj, ".interp"); if (s == NULL) abort (); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -5865,12 +5865,12 @@ ppc64_elf_size_dynamic_sections (bfd *ou if (ppc64_tlsld_got (ibfd)->refcount > 0) { s = ppc64_elf_tdata (ibfd)->got; - ppc64_tlsld_got (ibfd)->offset = s->_raw_size; - s->_raw_size += 16; + ppc64_tlsld_got (ibfd)->offset = s->size; + s->size += 16; if (info->shared) { srel = ppc64_elf_tdata (ibfd)->relgot; - srel->_raw_size += sizeof (Elf64_External_Rela); + srel->size += sizeof (Elf64_External_Rela); } } else @@ -5896,7 +5896,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou else if (p->count != 0) { srel = elf_section_data (p->sec)->sreloc; - srel->_raw_size += p->count * sizeof (Elf64_External_Rela); + srel->size += p->count * sizeof (Elf64_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -5924,27 +5924,27 @@ ppc64_elf_size_dynamic_sections (bfd *ou { if (ppc64_tlsld_got (ibfd)->offset == (bfd_vma) -1) { - ppc64_tlsld_got (ibfd)->offset = s->_raw_size; - s->_raw_size += 16; + ppc64_tlsld_got (ibfd)->offset = s->size; + s->size += 16; if (info->shared) - srel->_raw_size += sizeof (Elf64_External_Rela); + srel->size += sizeof (Elf64_External_Rela); } ent->got.offset = ppc64_tlsld_got (ibfd)->offset; } else { - ent->got.offset = s->_raw_size; + ent->got.offset = s->size; if ((ent->tls_type & *lgot_masks & TLS_GD) != 0) { - s->_raw_size += 16; + s->size += 16; if (info->shared) - srel->_raw_size += 2 * sizeof (Elf64_External_Rela); + srel->size += 2 * sizeof (Elf64_External_Rela); } else { - s->_raw_size += 8; + s->size += 8; if (info->shared) - srel->_raw_size += sizeof (Elf64_External_Rela); + srel->size += sizeof (Elf64_External_Rela); } } } @@ -5965,10 +5965,6 @@ ppc64_elf_size_dynamic_sections (bfd *ou if ((s->flags & SEC_LINKER_CREATED) == 0) continue; - /* Reset _cooked_size since prelim layout will set it wrongly, - and a non-zero _cooked_size sticks. */ - s->_cooked_size = 0; - if (s == htab->brlt || s == htab->relbrlt) /* These haven't been allocated yet; don't strip. */ continue; @@ -5981,7 +5977,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -6009,7 +6005,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou continue; } - if (s->_raw_size == 0) + if (s->size == 0) { _bfd_strip_section_from_output (info, s); continue; @@ -6026,7 +6022,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou sections instead of garbage. We also rely on the section contents being zero when writing the GOT. */ - s->contents = bfd_zalloc (dynobj, s->_raw_size); + s->contents = bfd_zalloc (dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -6036,12 +6032,11 @@ ppc64_elf_size_dynamic_sections (bfd *ou s = ppc64_elf_tdata (ibfd)->got; if (s != NULL && s != htab->got) { - s->_cooked_size = 0; - if (s->_raw_size == 0) + if (s->size == 0) _bfd_strip_section_from_output (info, s); else { - s->contents = bfd_zalloc (ibfd, s->_raw_size); + s->contents = bfd_zalloc (ibfd, s->size); if (s->contents == NULL) return FALSE; } @@ -6049,12 +6044,11 @@ ppc64_elf_size_dynamic_sections (bfd *ou s = ppc64_elf_tdata (ibfd)->relgot; if (s != NULL) { - s->_cooked_size = 0; - if (s->_raw_size == 0) + if (s->size == 0) _bfd_strip_section_from_output (info, s); else { - s->contents = bfd_zalloc (ibfd, s->_raw_size); + s->contents = bfd_zalloc (ibfd, s->size); if (s->contents == NULL) return FALSE; relocs = TRUE; @@ -6079,7 +6073,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou return FALSE; } - if (htab->plt != NULL && htab->plt->_raw_size != 0) + if (htab->plt != NULL && htab->plt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -6222,7 +6216,7 @@ ppc_build_one_stub (struct bfd_hash_entr htab = ppc_hash_table (info); /* Make a note of the offset within the stubs for this entry. */ - stub_entry->stub_offset = stub_entry->stub_sec->_cooked_size; + stub_entry->stub_offset = stub_entry->stub_sec->size; loc = stub_entry->stub_sec->contents + stub_entry->stub_offset; htab->stub_count[stub_entry->stub_type - 1] += 1; @@ -6399,7 +6393,7 @@ ppc_build_one_stub (struct bfd_hash_entr return FALSE; } - stub_entry->stub_sec->_cooked_size += size; + stub_entry->stub_sec->size += size; if (htab->emit_stub_syms && !(stub_entry->stub_type == ppc_stub_plt_call @@ -6474,7 +6468,7 @@ ppc_size_one_stub (struct bfd_hash_entry off = (stub_entry->target_value + stub_entry->target_section->output_offset + stub_entry->target_section->output_section->vma); - off -= (stub_entry->stub_sec->_raw_size + off -= (stub_entry->stub_sec->size + stub_entry->stub_sec->output_offset + stub_entry->stub_sec->output_section->vma); @@ -6509,11 +6503,11 @@ ppc_size_one_stub (struct bfd_hash_entry if (br_entry->iter != htab->stub_iteration) { br_entry->iter = htab->stub_iteration; - br_entry->offset = htab->brlt->_raw_size; - htab->brlt->_raw_size += 8; + br_entry->offset = htab->brlt->size; + htab->brlt->size += 8; if (info->shared) - htab->relbrlt->_raw_size += sizeof (Elf64_External_Rela); + htab->relbrlt->size += sizeof (Elf64_External_Rela); } stub_entry->stub_type += ppc_stub_plt_branch - ppc_stub_long_branch; @@ -6523,7 +6517,7 @@ ppc_size_one_stub (struct bfd_hash_entry } } - stub_entry->stub_sec->_raw_size += size; + stub_entry->stub_sec->size += size; return TRUE; } @@ -6605,7 +6599,7 @@ ppc64_elf_next_toc_section (struct bfd_l { bfd_vma addr = isec->output_offset + isec->output_section->vma; bfd_vma off = addr - htab->toc_curr; - if (off + isec->_raw_size > 0x10000) + if (off + isec->size > 0x10000) { htab->toc_curr = addr; htab->multi_toc_needed = 1; @@ -6646,7 +6640,7 @@ toc_adjusting_stub_needed (struct bfd_li if ((isec->flags & SEC_LINKER_CREATED) != 0) return 0; - if (isec->_raw_size == 0) + if (isec->size == 0) return 0; /* Hack for linux kernel. .fixup contains branches, but only back to @@ -6656,13 +6650,10 @@ toc_adjusting_stub_needed (struct bfd_li contents = elf_section_data (isec)->this_hdr.contents; if (contents == NULL) { - contents = bfd_malloc (isec->_raw_size); - if (contents == NULL) - return -1; - if (! bfd_get_section_contents (isec->owner, isec, contents, - 0, isec->_raw_size)) + if (!bfd_malloc_and_get_section (isec->owner, isec, &contents)) { - free (contents); + if (contents != NULL) + free (contents); return -1; } if (info->keep_memory) @@ -6672,7 +6663,7 @@ toc_adjusting_stub_needed (struct bfd_li /* Code scan, because we don't necessarily have relocs on calls to static functions. */ ret = 0; - for (i = 0; i < isec->_raw_size; i += 4) + for (i = 0; i < isec->size; i += 4) { unsigned long insn = bfd_get_32 (isec->owner, contents + i); /* Is this a branch? */ @@ -6762,10 +6753,7 @@ group_sections (struct ppc_link_hash_tab bfd_vma curr_toc; curr = tail; - if (tail->_cooked_size) - total = tail->_cooked_size; - else - total = tail->_raw_size; + total = tail->size; big_sec = total >= stub_group_size; curr_toc = htab->stub_group[tail->id].toc_off; @@ -7091,17 +7079,11 @@ ppc64_elf_size_stubs (bfd *output_bfd, stub_sec != NULL; stub_sec = stub_sec->next) if ((stub_sec->flags & SEC_LINKER_CREATED) == 0) - { - stub_sec->_raw_size = 0; - stub_sec->_cooked_size = 0; - } - htab->brlt->_raw_size = 0; - htab->brlt->_cooked_size = 0; + stub_sec->size = 0; + + htab->brlt->size = 0; if (info->shared) - { - htab->relbrlt->_raw_size = 0; - htab->relbrlt->_cooked_size = 0; - } + htab->relbrlt->size = 0; bfd_hash_traverse (&htab->stub_hash_table, ppc_size_one_stub, info); @@ -7188,22 +7170,21 @@ ppc64_elf_build_stubs (bfd_boolean emit_ int stub_sec_count = 0; htab->emit_stub_syms = emit_stub_syms; + + /* Allocate memory to hold the linker stubs. */ for (stub_sec = htab->stub_bfd->sections; stub_sec != NULL; stub_sec = stub_sec->next) - if ((stub_sec->flags & SEC_LINKER_CREATED) == 0) + if ((stub_sec->flags & SEC_LINKER_CREATED) == 0 + && stub_sec->size != 0) { - bfd_size_type size; - - /* Allocate memory to hold the linker stubs. */ - size = stub_sec->_raw_size; - if (size != 0) - { - stub_sec->contents = bfd_zalloc (htab->stub_bfd, size); - if (stub_sec->contents == NULL) - return FALSE; - } - stub_sec->_cooked_size = 0; + stub_sec->contents = bfd_zalloc (htab->stub_bfd, stub_sec->size); + if (stub_sec->contents == NULL) + return FALSE; + /* We want to check that built size is the same as calculated + size. rawsize is a convenient location to use. */ + stub_sec->rawsize = stub_sec->size; + stub_sec->size = 0; } if (htab->plt != NULL) @@ -7277,7 +7258,7 @@ ppc64_elf_build_stubs (bfd_boolean emit_ /* Build the .glink lazy link call stubs. */ indx = 0; - while (p < htab->glink->contents + htab->glink->_raw_size) + while (p < htab->glink->contents + htab->glink->size) { if (indx < 0x8000) { @@ -7296,20 +7277,20 @@ ppc64_elf_build_stubs (bfd_boolean emit_ indx++; p += 4; } - htab->glink->_cooked_size = p - htab->glink->contents; + htab->glink->rawsize = p - htab->glink->contents; } - if (htab->brlt->_raw_size != 0) + if (htab->brlt->size != 0) { htab->brlt->contents = bfd_zalloc (htab->brlt->owner, - htab->brlt->_raw_size); + htab->brlt->size); if (htab->brlt->contents == NULL) return FALSE; } - if (info->shared && htab->relbrlt->_raw_size != 0) + if (info->shared && htab->relbrlt->size != 0) { htab->relbrlt->contents = bfd_zalloc (htab->relbrlt->owner, - htab->relbrlt->_raw_size); + htab->relbrlt->size); if (htab->relbrlt->contents == NULL) return FALSE; } @@ -7323,12 +7304,12 @@ ppc64_elf_build_stubs (bfd_boolean emit_ if ((stub_sec->flags & SEC_LINKER_CREATED) == 0) { stub_sec_count += 1; - if (stub_sec->_raw_size != stub_sec->_cooked_size) + if (stub_sec->rawsize != stub_sec->size) break; } if (stub_sec != NULL - || htab->glink->_raw_size != htab->glink->_cooked_size) + || htab->glink->rawsize != htab->glink->size) { htab->stub_error = TRUE; (*_bfd_error_handler) (_("stubs don't match calculated size")); @@ -7917,7 +7898,7 @@ ppc64_elf_relocate_section (bfd *output_ { bfd_boolean can_plt_call = 0; - if (rel->r_offset + 8 <= input_section->_cooked_size) + if (rel->r_offset + 8 <= input_section->size) { insn = bfd_get_32 (input_bfd, contents + rel->r_offset + 4); if (insn == NOP @@ -7995,8 +7976,8 @@ ppc64_elf_relocate_section (bfd *output_ blr. We can thus call a weak function without first checking whether the function is defined. We have a blr at the end of .sfpr. */ - BFD_ASSERT (htab->sfpr->_raw_size != 0); - relocation = (htab->sfpr->_raw_size - 4 + BFD_ASSERT (htab->sfpr->size != 0); + relocation = (htab->sfpr->size - 4 + htab->sfpr->output_offset + htab->sfpr->output_section->vma); from = (rel->r_offset @@ -8006,7 +7987,7 @@ ppc64_elf_relocate_section (bfd *output_ /* But let's not be silly about it. If the blr isn't in reach, just go to the next instruction. */ if (relocation - from + (1 << 25) >= (1 << 26) - || htab->sfpr->_raw_size == 0) + || htab->sfpr->size == 0) relocation = from + 4; } break; @@ -8899,7 +8880,7 @@ ppc64_elf_finish_dynamic_sections (bfd * abort (); dyncon = (Elf64_External_Dyn *) sdyn->contents; - dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -8933,7 +8914,7 @@ ppc64_elf_finish_dynamic_sections (bfd * s = bfd_get_section_by_name (output_bfd, ".opd"); if (s == NULL) continue; - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; break; case DT_PLTGOT: @@ -8947,7 +8928,7 @@ ppc64_elf_finish_dynamic_sections (bfd * break; case DT_PLTRELSZ: - dyn.d_un.d_val = htab->relplt->_raw_size; + dyn.d_un.d_val = htab->relplt->size; break; case DT_RELASZ: @@ -8956,7 +8937,7 @@ ppc64_elf_finish_dynamic_sections (bfd * s = htab->relplt; if (s == NULL) continue; - dyn.d_un.d_val -= s->_raw_size; + dyn.d_un.d_val -= s->size; break; case DT_RELA: @@ -8968,7 +8949,7 @@ ppc64_elf_finish_dynamic_sections (bfd * continue; if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset) continue; - dyn.d_un.d_ptr += s->_raw_size; + dyn.d_un.d_ptr += s->size; break; } @@ -8976,7 +8957,7 @@ ppc64_elf_finish_dynamic_sections (bfd * } } - if (htab->got != NULL && htab->got->_raw_size != 0) + if (htab->got != NULL && htab->got->size != 0) { /* Fill in the first entry in the global offset table. We use it to hold the link-time TOCbase. */ @@ -8988,7 +8969,7 @@ ppc64_elf_finish_dynamic_sections (bfd * elf_section_data (htab->got->output_section)->this_hdr.sh_entsize = 8; } - if (htab->plt != NULL && htab->plt->_raw_size != 0) + if (htab->plt != NULL && htab->plt->size != 0) { /* Set .plt entry size. */ elf_section_data (htab->plt->output_section)->this_hdr.sh_entsize @@ -9002,19 +8983,19 @@ ppc64_elf_finish_dynamic_sections (bfd * asection *s; s = ppc64_elf_tdata (dynobj)->got; if (s != NULL - && s->_raw_size != 0 + && s->size != 0 && s->output_section != bfd_abs_section_ptr && !bfd_set_section_contents (output_bfd, s->output_section, s->contents, s->output_offset, - s->_raw_size)) + s->size)) return FALSE; s = ppc64_elf_tdata (dynobj)->relgot; if (s != NULL - && s->_raw_size != 0 + && s->size != 0 && s->output_section != bfd_abs_section_ptr && !bfd_set_section_contents (output_bfd, s->output_section, s->contents, s->output_offset, - s->_raw_size)) + s->size)) return FALSE; } Index: bfd/elf64-s390.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-s390.c,v retrieving revision 1.61 diff -u -p -r1.61 elf64-s390.c --- bfd/elf64-s390.c 22 Apr 2004 14:45:32 -0000 1.61 +++ bfd/elf64-s390.c 22 Jun 2004 01:36:24 -0000 @@ -420,6 +420,7 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, reloc_howto_type *howto = reloc_entry->howto; bfd_vma relocation; bfd_vma insn; + bfd_size_type sz; if (output_bfd != (bfd *) NULL && (symbol->flags & BSF_SECTION_SYM) == 0 @@ -432,7 +433,8 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, if (output_bfd != NULL) return bfd_reloc_continue; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; relocation = (symbol->value @@ -1658,7 +1660,7 @@ elf_s390_adjust_dynamic_symbol (info, h) runtime process image. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { - htab->srelbss->_raw_size += sizeof (Elf64_External_Rela); + htab->srelbss->size += sizeof (Elf64_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1670,7 +1672,7 @@ elf_s390_adjust_dynamic_symbol (info, h) /* Apply the required alignment. */ s = htab->sdynbss; - s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) { if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) @@ -1679,10 +1681,10 @@ elf_s390_adjust_dynamic_symbol (info, h) /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1733,10 +1735,10 @@ allocate_dynrelocs (h, inf) /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_FIRST_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_FIRST_ENTRY_SIZE; - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -1751,14 +1753,14 @@ allocate_dynrelocs (h, inf) } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->_raw_size += GOT_ENTRY_SIZE; + htab->sgotplt->size += GOT_ENTRY_SIZE; /* We also need to make an entry in the .rela.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf64_External_Rela); + htab->srelplt->size += sizeof (Elf64_External_Rela); } else { @@ -1788,8 +1790,8 @@ allocate_dynrelocs (h, inf) to be stored somewhere. The immediate value in the instruction is not bit enough so the value is stored in the got. */ { - h->got.offset = htab->sgot->_raw_size; - htab->sgot->_raw_size += GOT_ENTRY_SIZE; + h->got.offset = htab->sgot->size; + htab->sgot->size += GOT_ENTRY_SIZE; } else h->got.offset = (bfd_vma) -1; @@ -1810,24 +1812,24 @@ allocate_dynrelocs (h, inf) } s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += GOT_ENTRY_SIZE; + h->got.offset = s->size; + s->size += GOT_ENTRY_SIZE; /* R_390_TLS_GD64 needs 2 consecutive GOT slots. */ if (tls_type == GOT_TLS_GD) - s->_raw_size += GOT_ENTRY_SIZE; + s->size += GOT_ENTRY_SIZE; dyn = htab->elf.dynamic_sections_created; /* R_390_TLS_IE64 needs one dynamic relocation, R_390_TLS_GD64 needs one if local symbol and two if global. */ if ((tls_type == GOT_TLS_GD && h->dynindx == -1) || tls_type >= GOT_TLS_IE) - htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); + htab->srelgot->size += sizeof (Elf64_External_Rela); else if (tls_type == GOT_TLS_GD) - htab->srelgot->_raw_size += 2 * sizeof (Elf64_External_Rela); + htab->srelgot->size += 2 * sizeof (Elf64_External_Rela); else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) && (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) - htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); + htab->srelgot->size += sizeof (Elf64_External_Rela); } else h->got.offset = (bfd_vma) -1; @@ -1902,7 +1904,7 @@ allocate_dynrelocs (h, inf) for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela); + sreloc->size += p->count * sizeof (Elf64_External_Rela); } return TRUE; @@ -1965,7 +1967,7 @@ elf_s390_size_dynamic_sections (output_b s = bfd_get_section_by_name (dynobj, ".interp"); if (s == NULL) abort (); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -2004,7 +2006,7 @@ elf_s390_size_dynamic_sections (output_b else if (p->count != 0) { srela = elf_section_data (p->sec)->sreloc; - srela->_raw_size += p->count * sizeof (Elf64_External_Rela); + srela->size += p->count * sizeof (Elf64_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -2025,12 +2027,12 @@ elf_s390_size_dynamic_sections (output_b { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += GOT_ENTRY_SIZE; + *local_got = s->size; + s->size += GOT_ENTRY_SIZE; if (*local_tls_type == GOT_TLS_GD) - s->_raw_size += GOT_ENTRY_SIZE; + s->size += GOT_ENTRY_SIZE; if (info->shared) - srela->_raw_size += sizeof (Elf64_External_Rela); + srela->size += sizeof (Elf64_External_Rela); } else *local_got = (bfd_vma) -1; @@ -2041,9 +2043,9 @@ elf_s390_size_dynamic_sections (output_b { /* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM64 relocs. */ - htab->tls_ldm_got.offset = htab->sgot->_raw_size; - htab->sgot->_raw_size += 2 * GOT_ENTRY_SIZE; - htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); + htab->tls_ldm_got.offset = htab->sgot->size; + htab->sgot->size += 2 * GOT_ENTRY_SIZE; + htab->srelgot->size += sizeof (Elf64_External_Rela); } else htab->tls_ldm_got.offset = -1; @@ -2069,7 +2071,7 @@ elf_s390_size_dynamic_sections (output_b } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->_raw_size != 0 && s != htab->srelplt) + if (s->size != 0 && s != htab->srelplt) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -2082,7 +2084,7 @@ elf_s390_size_dynamic_sections (output_b continue; } - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is to handle .rela.bss and @@ -2103,7 +2105,7 @@ elf_s390_size_dynamic_sections (output_b section's contents are written out. This should not happen, but this way if it does, we get a R_390_NONE reloc instead of garbage. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -2124,7 +2126,7 @@ elf_s390_size_dynamic_sections (output_b return FALSE; } - if (htab->splt->_raw_size != 0) + if (htab->splt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -3271,7 +3273,7 @@ elf_s390_finish_dynamic_sections (output abort (); dyncon = (Elf64_External_Dyn *) sdyn->contents; - dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -3294,10 +3296,7 @@ elf_s390_finish_dynamic_sections (output case DT_PLTRELSZ: s = htab->srelplt->output_section; - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; break; case DT_RELASZ: @@ -3309,10 +3308,7 @@ elf_s390_finish_dynamic_sections (output other relocation sections, we don't have to worry about changing the DT_RELA entry. */ s = htab->srelplt->output_section; - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; + dyn.d_un.d_val -= s->size; break; } @@ -3320,7 +3316,7 @@ elf_s390_finish_dynamic_sections (output } /* Fill in the special first entry in the procedure linkage table. */ - if (htab->splt && htab->splt->_raw_size > 0) + if (htab->splt && htab->splt->size > 0) { /* fill in blueprint for plt 0 entry */ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD0, @@ -3351,7 +3347,7 @@ elf_s390_finish_dynamic_sections (output if (htab->sgotplt) { /* Fill in the first three entries in the global offset table. */ - if (htab->sgotplt->_raw_size > 0) + if (htab->sgotplt->size > 0) { bfd_put_64 (output_bfd, (sdyn == NULL ? (bfd_vma) 0 Index: bfd/elf64-sh64.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-sh64.c,v retrieving revision 1.46 diff -u -p -r1.46 elf64-sh64.c --- bfd/elf64-sh64.c 27 Mar 2004 10:58:07 -0000 1.46 +++ bfd/elf64-sh64.c 22 Jun 2004 01:36:26 -0000 @@ -2191,7 +2191,7 @@ sh_elf64_get_relocated_section_contents symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; memcpy (data, elf_section_data (input_section)->this_hdr.contents, - input_section->_raw_size); + input_section->size); if ((input_section->flags & SEC_RELOC) != 0 && input_section->reloc_count > 0) @@ -2619,7 +2619,7 @@ sh_elf64_check_relocs (bfd *abfd, struct if (hsh->datalabel_got_offset != (bfd_vma) -1) break; - hsh->datalabel_got_offset = sgot->_raw_size; + hsh->datalabel_got_offset = sgot->size; } else { @@ -2628,7 +2628,7 @@ sh_elf64_check_relocs (bfd *abfd, struct /* We have already allocated space in the .got. */ break; } - h->got.offset = sgot->_raw_size; + h->got.offset = sgot->size; } /* Make sure this symbol is output as a dynamic symbol. */ @@ -2638,7 +2638,7 @@ sh_elf64_check_relocs (bfd *abfd, struct return FALSE; } - srelgot->_raw_size += sizeof (Elf64_External_Rela); + srelgot->size += sizeof (Elf64_External_Rela); } else { @@ -2671,7 +2671,7 @@ sh_elf64_check_relocs (bfd *abfd, struct break; } local_got_offsets[symtab_hdr->sh_info - + r_symndx] = sgot->_raw_size; + + r_symndx] = sgot->size; } else { @@ -2680,7 +2680,7 @@ sh_elf64_check_relocs (bfd *abfd, struct /* We have already allocated space in the .got. */ break; } - local_got_offsets[r_symndx] = sgot->_raw_size; + local_got_offsets[r_symndx] = sgot->size; } if (info->shared) @@ -2688,11 +2688,11 @@ sh_elf64_check_relocs (bfd *abfd, struct /* If we are generating a shared object, we need to output a R_SH_RELATIVE reloc so that the dynamic linker can adjust this GOT entry. */ - srelgot->_raw_size += sizeof (Elf64_External_Rela); + srelgot->size += sizeof (Elf64_External_Rela); } } - sgot->_raw_size += 8; + sgot->size += 8; break; @@ -2809,7 +2809,7 @@ sh_elf64_check_relocs (bfd *abfd, struct } } - sreloc->_raw_size += sizeof (Elf64_External_Rela); + sreloc->size += sizeof (Elf64_External_Rela); /* If we are linking with -Bsymbolic, and this is a global symbol, we count the number of PC relative @@ -3434,8 +3434,8 @@ sh64_elf64_adjust_dynamic_symbol (struct /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_ENTRY_SIZE; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -3446,26 +3446,26 @@ sh64_elf64_adjust_dynamic_symbol (struct && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) { h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; } - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* Make room for this entry. */ - s->_raw_size += elf_sh64_sizeof_plt (info); + s->size += elf_sh64_sizeof_plt (info); /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ s = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += 8; + s->size += 8; /* We also need to make an entry in the .rela.plt section. */ s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += sizeof (Elf64_External_Rela); + s->size += sizeof (Elf64_External_Rela); return TRUE; } @@ -3520,7 +3520,7 @@ sh64_elf64_adjust_dynamic_symbol (struct srel = bfd_get_section_by_name (dynobj, ".rela.bss"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf64_External_Rela); + srel->size += sizeof (Elf64_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -3531,8 +3531,7 @@ sh64_elf64_adjust_dynamic_symbol (struct power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (! bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -3541,10 +3540,10 @@ sh64_elf64_adjust_dynamic_symbol (struct /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -3570,7 +3569,7 @@ sh64_elf64_discard_copies (struct elf_sh return TRUE; for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) - s->section->_raw_size -= s->count * sizeof (Elf64_External_Rela); + s->section->size -= s->count * sizeof (Elf64_External_Rela); return TRUE; } @@ -3597,7 +3596,7 @@ sh64_elf64_size_dynamic_sections (bfd *o { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -3610,7 +3609,7 @@ sh64_elf64_size_dynamic_sections (bfd *o below. */ s = bfd_get_section_by_name (dynobj, ".rela.got"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; } /* If this is a -Bsymbolic shared link, then we need to discard all @@ -3643,7 +3642,7 @@ sh64_elf64_size_dynamic_sections (bfd *o if (strcmp (name, ".plt") == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* Strip this section if we don't need it; see the comment below. */ @@ -3657,7 +3656,7 @@ sh64_elf64_size_dynamic_sections (bfd *o } else if (strncmp (name, ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -3714,8 +3713,8 @@ sh64_elf64_size_dynamic_sections (bfd *o } /* Allocate memory for the section contents. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -3984,7 +3983,7 @@ sh64_elf64_finish_dynamic_sections (bfd BFD_ASSERT (sdyn != NULL); dyncon = (Elf64_External_Dyn *) sdyn->contents; - dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -4034,10 +4033,7 @@ sh64_elf64_finish_dynamic_sections (bfd case DT_PLTRELSZ: s = bfd_get_section_by_name (output_bfd, ".rela.plt"); BFD_ASSERT (s != NULL); - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); break; @@ -4053,12 +4049,7 @@ sh64_elf64_finish_dynamic_sections (bfd about changing the DT_RELA entry. */ s = bfd_get_section_by_name (output_bfd, ".rela.plt"); if (s != NULL) - { - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; - } + dyn.d_un.d_val -= s->size; bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); break; } @@ -4066,7 +4057,7 @@ sh64_elf64_finish_dynamic_sections (bfd /* Fill in the first entry in the procedure linkage table. */ splt = bfd_get_section_by_name (dynobj, ".plt"); - if (splt && splt->_raw_size > 0) + if (splt && splt->size > 0) { if (info->shared) { @@ -4102,7 +4093,7 @@ sh64_elf64_finish_dynamic_sections (bfd } /* Fill in the first three entries in the global offset table. */ - if (sgot->_raw_size > 0) + if (sgot->size > 0) { if (sdyn == NULL) bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents); Index: bfd/elf64-sparc.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-sparc.c,v retrieving revision 1.91 diff -u -p -r1.91 elf64-sparc.c --- bfd/elf64-sparc.c 27 Apr 2004 03:13:15 -0000 1.91 +++ bfd/elf64-sparc.c 22 Jun 2004 01:36:28 -0000 @@ -478,7 +478,7 @@ sparc64_elf_slurp_reloc_table (abfd, ase case because relocations against this section may use the dynamic symbol table, and in that case bfd_section_from_shdr in elf.c does not update the RELOC_COUNT. */ - if (asect->_raw_size == 0) + if (asect->size == 0) return TRUE; rel_hdr = &d->this_hdr; @@ -794,6 +794,7 @@ init_insn_reloc (abfd, bfd_vma *pinsn; { bfd_vma relocation; + bfd_size_type sz; reloc_howto_type *howto = reloc_entry->howto; if (output_bfd != (bfd *) NULL @@ -809,7 +810,8 @@ init_insn_reloc (abfd, if (output_bfd != NULL) return bfd_reloc_continue; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; relocation = (symbol->value @@ -1173,7 +1175,7 @@ sparc64_elf_check_relocs (abfd, info, se /* We have already allocated space in the .got. */ break; } - h->got.offset = sgot->_raw_size; + h->got.offset = sgot->size; /* Make sure this symbol is output as a dynamic symbol. */ if (h->dynindx == -1) @@ -1182,7 +1184,7 @@ sparc64_elf_check_relocs (abfd, info, se return FALSE; } - srelgot->_raw_size += sizeof (Elf64_External_Rela); + srelgot->size += sizeof (Elf64_External_Rela); } else { @@ -1207,18 +1209,18 @@ sparc64_elf_check_relocs (abfd, info, se /* We have already allocated space in the .got. */ break; } - local_got_offsets[r_symndx] = sgot->_raw_size; + local_got_offsets[r_symndx] = sgot->size; if (info->shared) { /* If we are generating a shared object, we need to output a R_SPARC_RELATIVE reloc so that the dynamic linker can adjust this GOT entry. */ - srelgot->_raw_size += sizeof (Elf64_External_Rela); + srelgot->size += sizeof (Elf64_External_Rela); } } - sgot->_raw_size += 8; + sgot->size += 8; #if 0 /* Doesn't work for 64-bit -fPIC, since sethi/or builds @@ -1229,7 +1231,7 @@ sparc64_elf_check_relocs (abfd, info, se /* If the .got section is more than 0x1000 bytes, we add 0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13 bit relocations have a greater chance of working. */ - if (sgot->_raw_size >= 0x1000 + if (sgot->size >= 0x1000 && elf_hash_table (info)->hgot->root.u.def.value == 0) elf_hash_table (info)->hgot->root.u.def.value = 0x1000; #endif @@ -1359,7 +1361,7 @@ sparc64_elf_check_relocs (abfd, info, se info->flags |= DF_TEXTREL; } - sreloc->_raw_size += sizeof (Elf64_External_Rela); + sreloc->size += sizeof (Elf64_External_Rela); } break; @@ -1653,11 +1655,11 @@ sparc64_elf_adjust_dynamic_symbol (info, BFD_ASSERT (s != NULL); /* The first four bit in .plt is reserved. */ - if (s->_raw_size == 0) - s->_raw_size = PLT_HEADER_SIZE; + if (s->size == 0) + s->size = PLT_HEADER_SIZE; /* To simplify matters later, just store the plt index here. */ - h->plt.offset = s->_raw_size / PLT_ENTRY_SIZE; + h->plt.offset = s->size / PLT_ENTRY_SIZE; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -1672,18 +1674,18 @@ sparc64_elf_adjust_dynamic_symbol (info, } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .rela.plt section. */ s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); - s->_raw_size += sizeof (Elf64_External_Rela); + s->size += sizeof (Elf64_External_Rela); /* The procedure linkage table size is bounded by the magnitude of the offset we can describe in the entry. */ - if (s->_raw_size >= (bfd_vma)1 << 32) + if (s->size >= (bfd_vma)1 << 32) { bfd_set_error (bfd_error_bad_value); return FALSE; @@ -1737,7 +1739,7 @@ sparc64_elf_adjust_dynamic_symbol (info, srel = bfd_get_section_by_name (dynobj, ".rela.bss"); BFD_ASSERT (srel != NULL); - srel->_raw_size += sizeof (Elf64_External_Rela); + srel->size += sizeof (Elf64_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1749,8 +1751,7 @@ sparc64_elf_adjust_dynamic_symbol (info, power_of_two = 4; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, - (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (! bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -1759,10 +1760,10 @@ sparc64_elf_adjust_dynamic_symbol (info, /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1788,7 +1789,7 @@ sparc64_elf_size_dynamic_sections (outpu { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -1801,7 +1802,7 @@ sparc64_elf_size_dynamic_sections (outpu below. */ s = bfd_get_section_by_name (dynobj, ".rela.got"); if (s != NULL) - s->_raw_size = 0; + s->size = 0; } /* The check_relocs and adjust_dynamic_symbol entry points have @@ -1824,7 +1825,7 @@ sparc64_elf_size_dynamic_sections (outpu if (strncmp (name, ".rela", 5) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is to handle .rela.bss and @@ -1863,8 +1864,8 @@ sparc64_elf_size_dynamic_sections (outpu /* Allocate memory for the section contents. Zero the memory for the benefit of .rela.plt, which has 4 unused entries at the beginning, and we don't want garbage. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; } @@ -2517,7 +2518,7 @@ sparc64_elf_relocate_section (output_bfd case R_SPARC_WDISP30: do_wplt30: if (sec_do_relax (input_section) - && rel->r_offset + 4 < input_section->_raw_size) + && rel->r_offset + 4 < input_section->size) { #define G0 0 #define O7 15 @@ -2724,7 +2725,7 @@ sparc64_elf_finish_dynamic_symbol (outpu } else { - bfd_vma max = splt->_raw_size / PLT_ENTRY_SIZE; + bfd_vma max = splt->size / PLT_ENTRY_SIZE; rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt.offset, max); rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4) -(splt->output_section->vma + splt->output_offset); @@ -2857,7 +2858,7 @@ sparc64_elf_finish_dynamic_sections (out BFD_ASSERT (splt != NULL && sdyn != NULL); dyncon = (Elf64_External_Dyn *) sdyn->contents; - dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -2897,21 +2898,16 @@ sparc64_elf_finish_dynamic_sections (out if (! size) dyn.d_un.d_ptr = s->vma; else - { - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; - } + dyn.d_un.d_val = s->size; } bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); } } /* Initialize the contents of the .plt section. */ - if (splt->_raw_size > 0) + if (splt->size > 0) sparc64_elf_build_plt (output_bfd, splt->contents, - (int) (splt->_raw_size / PLT_ENTRY_SIZE)); + (int) (splt->size / PLT_ENTRY_SIZE)); elf_section_data (splt->output_section)->this_hdr.sh_entsize = PLT_ENTRY_SIZE; @@ -2921,7 +2917,7 @@ sparc64_elf_finish_dynamic_sections (out the dynamic section. */ sgot = bfd_get_section_by_name (dynobj, ".got"); BFD_ASSERT (sgot != NULL); - if (sgot->_raw_size > 0) + if (sgot->size > 0) { if (sdyn == NULL) bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents); Index: bfd/elf64-x86-64.c =================================================================== RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v retrieving revision 1.79 diff -u -p -r1.79 elf64-x86-64.c --- bfd/elf64-x86-64.c 12 Jun 2004 11:30:10 -0000 1.79 +++ bfd/elf64-x86-64.c 22 Jun 2004 01:36:30 -0000 @@ -195,7 +195,7 @@ static bfd_boolean elf64_x86_64_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; - size_t raw_size; + size_t size; switch (note->descsz) { @@ -213,14 +213,14 @@ elf64_x86_64_grok_prstatus (bfd *abfd, E /* pr_reg */ offset = 112; - raw_size = 216; + size = 216; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean @@ -1229,7 +1229,7 @@ elf64_x86_64_adjust_dynamic_symbol (stru runtime process image. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { - htab->srelbss->_raw_size += sizeof (Elf64_External_Rela); + htab->srelbss->size += sizeof (Elf64_External_Rela); h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; } @@ -1244,7 +1244,7 @@ elf64_x86_64_adjust_dynamic_symbol (stru /* Apply the required alignment. */ s = htab->sdynbss; - s->_raw_size = BFD_ALIGN (s->_raw_size, (bfd_size_type) (1 << power_of_two)); + s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) { if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) @@ -1253,10 +1253,10 @@ elf64_x86_64_adjust_dynamic_symbol (stru /* Define the symbol as being at this point in the section. */ h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* Increment the section size to make room for the symbol. */ - s->_raw_size += h->size; + s->size += h->size; return TRUE; } @@ -1300,10 +1300,10 @@ allocate_dynrelocs (struct elf_link_hash /* If this is the first .plt entry, make room for the special first entry. */ - if (s->_raw_size == 0) - s->_raw_size += PLT_ENTRY_SIZE; + if (s->size == 0) + s->size += PLT_ENTRY_SIZE; - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* If this symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to this @@ -1318,14 +1318,14 @@ allocate_dynrelocs (struct elf_link_hash } /* Make room for this entry. */ - s->_raw_size += PLT_ENTRY_SIZE; + s->size += PLT_ENTRY_SIZE; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->_raw_size += GOT_ENTRY_SIZE; + htab->sgotplt->size += GOT_ENTRY_SIZE; /* We also need to make an entry in the .rela.plt section. */ - htab->srelplt->_raw_size += sizeof (Elf64_External_Rela); + htab->srelplt->size += sizeof (Elf64_External_Rela); } else { @@ -1362,25 +1362,25 @@ allocate_dynrelocs (struct elf_link_hash } s = htab->sgot; - h->got.offset = s->_raw_size; - s->_raw_size += GOT_ENTRY_SIZE; + h->got.offset = s->size; + s->size += GOT_ENTRY_SIZE; /* R_X86_64_TLSGD needs 2 consecutive GOT slots. */ if (tls_type == GOT_TLS_GD) - s->_raw_size += GOT_ENTRY_SIZE; + s->size += GOT_ENTRY_SIZE; dyn = htab->elf.dynamic_sections_created; /* R_X86_64_TLSGD needs one dynamic relocation if local symbol and two if global. R_X86_64_GOTTPOFF needs one dynamic relocation. */ if ((tls_type == GOT_TLS_GD && h->dynindx == -1) || tls_type == GOT_TLS_IE) - htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); + htab->srelgot->size += sizeof (Elf64_External_Rela); else if (tls_type == GOT_TLS_GD) - htab->srelgot->_raw_size += 2 * sizeof (Elf64_External_Rela); + htab->srelgot->size += 2 * sizeof (Elf64_External_Rela); else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) && (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) - htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); + htab->srelgot->size += sizeof (Elf64_External_Rela); } else h->got.offset = (bfd_vma) -1; @@ -1461,7 +1461,7 @@ allocate_dynrelocs (struct elf_link_hash for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; - sreloc->_raw_size += p->count * sizeof (Elf64_External_Rela); + sreloc->size += p->count * sizeof (Elf64_External_Rela); } return TRUE; @@ -1521,7 +1521,7 @@ elf64_x86_64_size_dynamic_sections (bfd s = bfd_get_section_by_name (dynobj, ".interp"); if (s == NULL) abort (); - s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; + s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; } } @@ -1560,7 +1560,7 @@ elf64_x86_64_size_dynamic_sections (bfd else if (p->count != 0) { srel = elf_section_data (p->sec)->sreloc; - srel->_raw_size += p->count * sizeof (Elf64_External_Rela); + srel->size += p->count * sizeof (Elf64_External_Rela); if ((p->sec->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; @@ -1582,14 +1582,14 @@ elf64_x86_64_size_dynamic_sections (bfd { if (*local_got > 0) { - *local_got = s->_raw_size; - s->_raw_size += GOT_ENTRY_SIZE; + *local_got = s->size; + s->size += GOT_ENTRY_SIZE; if (*local_tls_type == GOT_TLS_GD) - s->_raw_size += GOT_ENTRY_SIZE; + s->size += GOT_ENTRY_SIZE; if (info->shared || *local_tls_type == GOT_TLS_GD || *local_tls_type == GOT_TLS_IE) - srel->_raw_size += sizeof (Elf64_External_Rela); + srel->size += sizeof (Elf64_External_Rela); } else *local_got = (bfd_vma) -1; @@ -1600,9 +1600,9 @@ elf64_x86_64_size_dynamic_sections (bfd { /* Allocate 2 got entries and 1 dynamic reloc for R_X86_64_TLSLD relocs. */ - htab->tls_ld_got.offset = htab->sgot->_raw_size; - htab->sgot->_raw_size += 2 * GOT_ENTRY_SIZE; - htab->srelgot->_raw_size += sizeof (Elf64_External_Rela); + htab->tls_ld_got.offset = htab->sgot->size; + htab->sgot->size += 2 * GOT_ENTRY_SIZE; + htab->srelgot->size += sizeof (Elf64_External_Rela); } else htab->tls_ld_got.offset = -1; @@ -1628,7 +1628,7 @@ elf64_x86_64_size_dynamic_sections (bfd } else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) { - if (s->_raw_size != 0 && s != htab->srelplt) + if (s->size != 0 && s != htab->srelplt) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -1641,7 +1641,7 @@ elf64_x86_64_size_dynamic_sections (bfd continue; } - if (s->_raw_size == 0) + if (s->size == 0) { /* If we don't need this section, strip it from the output file. This is mostly to handle .rela.bss and @@ -1662,7 +1662,7 @@ elf64_x86_64_size_dynamic_sections (bfd section's contents are written out. This should not happen, but this way if it does, we get a R_X86_64_NONE reloc instead of garbage. */ - s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -1683,7 +1683,7 @@ elf64_x86_64_size_dynamic_sections (bfd return FALSE; } - if (htab->splt->_raw_size != 0) + if (htab->splt->size != 0) { if (!add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) @@ -2110,7 +2110,7 @@ elf64_x86_64_relocate_section (bfd *outp BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset - 4 + i) == tlsgd[i]); - BFD_ASSERT (rel->r_offset + 12 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 12 <= input_section->size); for (i = 0; i < 4; i++) BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 4 + i) @@ -2146,7 +2146,7 @@ elf64_x86_64_relocate_section (bfd *outp reg = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); BFD_ASSERT ((reg & 0xc7) == 5); reg >>= 3; - BFD_ASSERT (rel->r_offset + 4 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 4 <= input_section->size); if (type == 0x8b) { /* movq */ @@ -2283,7 +2283,7 @@ elf64_x86_64_relocate_section (bfd *outp BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset - 4 + i) == tlsgd[i]); - BFD_ASSERT (rel->r_offset + 12 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 12 <= input_section->size); for (i = 0; i < 4; i++) BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 4 + i) @@ -2323,7 +2323,7 @@ elf64_x86_64_relocate_section (bfd *outp == 0x8d); BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset - 1) == 0x3d); - BFD_ASSERT (rel->r_offset + 9 <= input_section->_raw_size); + BFD_ASSERT (rel->r_offset + 9 <= input_section->size); BFD_ASSERT (bfd_get_8 (input_bfd, contents + rel->r_offset + 4) == 0xe8); BFD_ASSERT (rel + 1 < relend); @@ -2657,7 +2657,7 @@ elf64_x86_64_finish_dynamic_sections (bf abort (); dyncon = (Elf64_External_Dyn *) sdyn->contents; - dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); for (; dyncon < dynconend; dyncon++) { Elf_Internal_Dyn dyn; @@ -2681,10 +2681,7 @@ elf64_x86_64_finish_dynamic_sections (bf case DT_PLTRELSZ: s = htab->srelplt->output_section; - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size; - else - dyn.d_un.d_val = s->_raw_size; + dyn.d_un.d_val = s->size; break; case DT_RELASZ: @@ -2698,10 +2695,7 @@ elf64_x86_64_finish_dynamic_sections (bf if (htab->srelplt != NULL) { s = htab->srelplt->output_section; - if (s->_cooked_size != 0) - dyn.d_un.d_val -= s->_cooked_size; - else - dyn.d_un.d_val -= s->_raw_size; + dyn.d_un.d_val -= s->size; } break; } @@ -2710,7 +2704,7 @@ elf64_x86_64_finish_dynamic_sections (bf } /* Fill in the special first entry in the procedure linkage table. */ - if (htab->splt && htab->splt->_raw_size > 0) + if (htab->splt && htab->splt->size > 0) { /* Fill in the first entry in the procedure linkage table. */ memcpy (htab->splt->contents, elf64_x86_64_plt0_entry, @@ -2744,7 +2738,7 @@ elf64_x86_64_finish_dynamic_sections (bf if (htab->sgotplt) { /* Fill in the first three entries in the global offset table. */ - if (htab->sgotplt->_raw_size > 0) + if (htab->sgotplt->size > 0) { /* Set the first entry in the global offset table to the address of the dynamic section. */ @@ -2763,7 +2757,7 @@ elf64_x86_64_finish_dynamic_sections (bf GOT_ENTRY_SIZE; } - if (htab->sgot && htab->sgot->_raw_size > 0) + if (htab->sgot && htab->sgot->size > 0) elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = GOT_ENTRY_SIZE; Index: bfd/elfarm-nabi.c =================================================================== RCS file: /cvs/src/src/bfd/elfarm-nabi.c,v retrieving revision 1.18 diff -u -p -r1.18 elfarm-nabi.c --- bfd/elfarm-nabi.c 31 Mar 2004 10:20:12 -0000 1.18 +++ bfd/elfarm-nabi.c 22 Jun 2004 01:36:30 -0000 @@ -729,7 +729,7 @@ elf32_arm_nabi_grok_prstatus (abfd, note Elf_Internal_Note *note; { int offset; - size_t raw_size; + size_t size; switch (note->descsz) { @@ -745,14 +745,14 @@ elf32_arm_nabi_grok_prstatus (abfd, note /* pr_reg */ offset = 72; - raw_size = 72; + size = 72; break; } /* Make a ".reg/999" section. */ return _bfd_elfcore_make_pseudosection (abfd, ".reg", - raw_size, note->descpos + offset); + size, note->descpos + offset); } static bfd_boolean Index: bfd/elfcode.h =================================================================== RCS file: /cvs/src/src/bfd/elfcode.h,v retrieving revision 1.55 diff -u -p -r1.55 elfcode.h --- bfd/elfcode.h 22 Apr 2004 14:45:31 -0000 1.55 +++ bfd/elfcode.h 22 Jun 2004 01:36:31 -0000 @@ -1,6 +1,6 @@ /* ELF executable support for BFD. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Fred Fish @ Cygnus Support, from information published in "UNIX System V Release 4, Programmers Guide: ANSI C and @@ -1355,7 +1355,7 @@ elf_slurp_reloc_table (bfd *abfd, case because relocations against this section may use the dynamic symbol table, and in that case bfd_section_from_shdr in elf.c does not update the RELOC_COUNT. */ - if (asect->_raw_size == 0) + if (asect->size == 0) return TRUE; rel_hdr = &d->this_hdr; Index: bfd/elflink.c =================================================================== RCS file: /cvs/src/src/bfd/elflink.c,v retrieving revision 1.73 diff -u -p -r1.73 elflink.c --- bfd/elflink.c 21 Jun 2004 14:45:41 -0000 1.73 +++ bfd/elflink.c 22 Jun 2004 01:36:36 -0000 @@ -98,7 +98,7 @@ _bfd_elf_create_got_section (bfd *abfd, } /* The first bit of the global offset table is the header. */ - s->_raw_size += bed->got_header_size + bed->got_symbol_offset; + s->size += bed->got_header_size + bed->got_symbol_offset; return TRUE; } @@ -2653,16 +2653,16 @@ _bfd_elf_add_dynamic_entry (struct bfd_l s = bfd_get_section_by_name (hash_table->dynobj, ".dynamic"); BFD_ASSERT (s != NULL); - newsize = s->_raw_size + bed->s->sizeof_dyn; + newsize = s->size + bed->s->sizeof_dyn; newcontents = bfd_realloc (s->contents, newsize); if (newcontents == NULL) return FALSE; dyn.d_tag = tag; dyn.d_un.d_val = val; - bed->s->swap_dyn_out (hash_table->dynobj, &dyn, newcontents + s->_raw_size); + bed->s->swap_dyn_out (hash_table->dynobj, &dyn, newcontents + s->size); - s->_raw_size = newsize; + s->size = newsize; s->contents = newcontents; return TRUE; @@ -2698,7 +2698,7 @@ elf_add_dt_needed_tag (struct bfd_link_i BFD_ASSERT (sdyn != NULL); for (extdyn = sdyn->contents; - extdyn < sdyn->contents + sdyn->_raw_size; + extdyn < sdyn->contents + sdyn->size; extdyn += bed->s->sizeof_dyn) { Elf_Internal_Dyn dyn; @@ -2787,7 +2787,7 @@ elf_finalize_dynstr (bfd *output_bfd, st /* Update all .dynamic entries referencing .dynstr strings. */ for (extdyn = sdyn->contents; - extdyn < sdyn->contents + sdyn->_raw_size; + extdyn < sdyn->contents + sdyn->size; extdyn += bed->s->sizeof_dyn) { Elf_Internal_Dyn dyn; @@ -2987,12 +2987,12 @@ elf_link_add_object_symbols (bfd *abfd, /* We don't want to issue this warning. Clobber the section size so that the warning does not get copied into the output file. */ - s->_raw_size = 0; + s->size = 0; continue; } } - sz = bfd_section_size (abfd, s); + sz = s->size; prefix_len = strlen (gnu_warning_prefix); msg = bfd_alloc (abfd, prefix_len + sz + 1); if (msg == NULL) @@ -3013,7 +3013,7 @@ elf_link_add_object_symbols (bfd *abfd, { /* Clobber the section size so that the warning does not get copied into the output file. */ - s->_raw_size = 0; + s->size = 0; } } } @@ -3066,11 +3066,7 @@ elf_link_add_object_symbols (bfd *abfd, int elfsec; unsigned long shlink; - dynbuf = bfd_malloc (s->_raw_size); - if (dynbuf == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, s, dynbuf, 0, s->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, s, &dynbuf)) goto error_free_dyn; elfsec = _bfd_elf_section_from_bfd_section (abfd, s); @@ -3079,7 +3075,7 @@ elf_link_add_object_symbols (bfd *abfd, shlink = elf_elfsections (abfd)[elfsec]->sh_link; for (extdyn = dynbuf; - extdyn < dynbuf + s->_raw_size; + extdyn < dynbuf + s->size; extdyn += bed->s->sizeof_dyn) { Elf_Internal_Dyn dyn; @@ -5027,9 +5023,9 @@ bfd_elf_size_dynamic_sections (bfd *outp size += sizeof (Elf_External_Verdaux); } - s->_raw_size = size; - s->contents = bfd_alloc (output_bfd, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->size = size; + s->contents = bfd_alloc (output_bfd, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; /* Fill in the version definition section. */ @@ -5226,8 +5222,8 @@ bfd_elf_size_dynamic_sections (bfd *outp size += sizeof (Elf_External_Vernaux); } - s->_raw_size = size; - s->contents = bfd_alloc (output_bfd, s->_raw_size); + s->size = size; + s->contents = bfd_alloc (output_bfd, s->size); if (s->contents == NULL) return FALSE; @@ -5312,8 +5308,8 @@ bfd_elf_size_dynamic_sections (bfd *outp } else { - s->_raw_size = dynsymcount * sizeof (Elf_External_Versym); - s->contents = bfd_zalloc (output_bfd, s->_raw_size); + s->size = dynsymcount * sizeof (Elf_External_Versym); + s->contents = bfd_zalloc (output_bfd, s->size); if (s->contents == NULL) return FALSE; @@ -5329,9 +5325,9 @@ bfd_elf_size_dynamic_sections (bfd *outp section as we went along in elf_link_add_object_symbols. */ s = bfd_get_section_by_name (dynobj, ".dynsym"); BFD_ASSERT (s != NULL); - s->_raw_size = dynsymcount * bed->s->sizeof_sym; - s->contents = bfd_alloc (output_bfd, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->size = dynsymcount * bed->s->sizeof_sym; + s->contents = bfd_alloc (output_bfd, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; if (dynsymcount != 0) @@ -5355,8 +5351,8 @@ bfd_elf_size_dynamic_sections (bfd *outp s = bfd_get_section_by_name (dynobj, ".hash"); BFD_ASSERT (s != NULL); hash_entry_size = elf_section_data (s)->this_hdr.sh_entsize; - s->_raw_size = ((2 + bucketcount + dynsymcount) * hash_entry_size); - s->contents = bfd_zalloc (output_bfd, s->_raw_size); + s->size = ((2 + bucketcount + dynsymcount) * hash_entry_size); + s->contents = bfd_zalloc (output_bfd, s->size); if (s->contents == NULL) return FALSE; @@ -5371,7 +5367,7 @@ bfd_elf_size_dynamic_sections (bfd *outp elf_finalize_dynstr (output_bfd, info); - s->_raw_size = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr); + s->size = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr); for (dtagcount = 0; dtagcount <= info->spare_dynamic_tags; ++dtagcount) if (!_bfd_elf_add_dynamic_entry (info, DT_NULL, 0)) @@ -5581,10 +5577,10 @@ elf_link_sort_relocs (bfd *abfd, struct bfd_vma r_sym_mask; reldyn = bfd_get_section_by_name (abfd, ".rela.dyn"); - if (reldyn == NULL || reldyn->_raw_size == 0) + if (reldyn == NULL || reldyn->size == 0) { reldyn = bfd_get_section_by_name (abfd, ".rel.dyn"); - if (reldyn == NULL || reldyn->_raw_size == 0) + if (reldyn == NULL || reldyn->size == 0) return 0; ext_size = bed->s->sizeof_rel; swap_in = bed->s->swap_reloc_in; @@ -5596,17 +5592,17 @@ elf_link_sort_relocs (bfd *abfd, struct swap_in = bed->s->swap_reloca_in; swap_out = bed->s->swap_reloca_out; } - count = reldyn->_raw_size / ext_size; + count = reldyn->size / ext_size; size = 0; for (lo = reldyn->link_order_head; lo != NULL; lo = lo->next) if (lo->type == bfd_indirect_link_order) { asection *o = lo->u.indirect.section; - size += o->_raw_size; + size += o->size; } - if (size != reldyn->_raw_size) + if (size != reldyn->size) return 0; sort_elt = (sizeof (struct elf_link_sort_rela) @@ -5631,7 +5627,7 @@ elf_link_sort_relocs (bfd *abfd, struct asection *o = lo->u.indirect.section; erel = o->contents; - erelend = o->contents + o->_raw_size; + erelend = o->contents + o->size; p = sort + o->output_offset / ext_size * sort_elt; while (erel < erelend) { @@ -5673,7 +5669,7 @@ elf_link_sort_relocs (bfd *abfd, struct asection *o = lo->u.indirect.section; erel = o->contents; - erelend = o->contents + o->_raw_size; + erelend = o->contents + o->size; p = sort + o->output_offset / ext_size * sort_elt; while (erel < erelend) { @@ -6497,7 +6493,7 @@ elf_link_input_bfd (struct elf_final_lin } if ((o->flags & SEC_HAS_CONTENTS) == 0 - || (o->_raw_size == 0 && (o->flags & SEC_RELOC) == 0)) + || (o->size == 0 && (o->flags & SEC_RELOC) == 0)) continue; if ((o->flags & SEC_LINKER_CREATED) != 0) @@ -6515,9 +6511,10 @@ elf_link_input_bfd (struct elf_final_lin contents = elf_section_data (o)->this_hdr.contents; else { + bfd_size_type amt = o->rawsize ? o->rawsize : o->size; + contents = finfo->contents; - if (! bfd_get_section_contents (input_bfd, o, contents, 0, - o->_raw_size)) + if (! bfd_get_section_contents (input_bfd, o, contents, 0, amt)) return FALSE; } @@ -6587,7 +6584,7 @@ elf_link_input_bfd (struct elf_final_lin /* Try to preserve debug information. */ if ((o->flags & SEC_DEBUGGING) != 0 && sec->kept_section != NULL - && sec->_raw_size == sec->kept_section->_raw_size) + && sec->size == sec->kept_section->size) h->root.u.def.section = sec->kept_section; else @@ -6616,7 +6613,7 @@ elf_link_input_bfd (struct elf_final_lin /* Try to preserve debug information. */ if ((o->flags & SEC_DEBUGGING) != 0 && sec->kept_section != NULL - && sec->_raw_size == sec->kept_section->_raw_size) + && sec->size == sec->kept_section->size) finfo->sections[r_symndx] = sec->kept_section; else @@ -6934,14 +6931,11 @@ elf_link_input_bfd (struct elf_final_lin break; default: { - bfd_size_type sec_size; - - sec_size = (o->_cooked_size != 0 ? o->_cooked_size : o->_raw_size); if (! (o->flags & SEC_EXCLUDE) && ! bfd_set_section_contents (output_bfd, o->output_section, contents, (file_ptr) o->output_offset, - sec_size)) + o->size)) return FALSE; } break; @@ -7248,10 +7242,10 @@ bfd_elf_final_link (bfd *abfd, struct bf free (relocs); } - if (sec->_raw_size > max_contents_size) - max_contents_size = sec->_raw_size; - if (sec->_cooked_size > max_contents_size) - max_contents_size = sec->_cooked_size; + if (sec->rawsize > max_contents_size) + max_contents_size = sec->rawsize; + if (sec->size > max_contents_size) + max_contents_size = sec->size; /* We are interested in just local symbols, not all symbols. */ @@ -7559,7 +7553,7 @@ bfd_elf_final_link (bfd *abfd, struct bf sec && (sec->flags & SEC_THREAD_LOCAL); sec = sec->next) { - bfd_vma size = sec->_raw_size; + bfd_vma size = sec->size; if (size == 0 && (sec->flags & SEC_HAS_CONTENTS) == 0) { @@ -7835,7 +7829,7 @@ bfd_elf_final_link (bfd *abfd, struct bf BFD_ASSERT (o != NULL); dyncon = o->contents; - dynconend = o->contents + o->_raw_size; + dynconend = o->contents + o->size; for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn) { Elf_Internal_Dyn dyn; @@ -7911,10 +7905,10 @@ bfd_elf_final_link (bfd *abfd, struct bf bfd_get_filename (abfd), name); goto error_return; } - if (o->_raw_size == 0) + if (o->size == 0) (*_bfd_error_handler) (_("warning: %s section has zero size"), name); - dyn.d_un.d_val = o->_raw_size; + dyn.d_un.d_val = o->size; break; case DT_PREINIT_ARRAY: @@ -7998,7 +7992,7 @@ bfd_elf_final_link (bfd *abfd, struct bf for (o = dynobj->sections; o != NULL; o = o->next) { if ((o->flags & SEC_HAS_CONTENTS) == 0 - || o->_raw_size == 0 + || o->size == 0 || o->output_section == bfd_abs_section_ptr) continue; if ((o->flags & SEC_LINKER_CREATED) == 0) @@ -8007,6 +8001,8 @@ bfd_elf_final_link (bfd *abfd, struct bf created by _bfd_elf_link_create_dynamic_sections. */ continue; } + if (elf_hash_table (info)->eh_info.hdr_sec == o) + continue; if ((elf_section_data (o->output_section)->this_hdr.sh_type != SHT_STRTAB) || strcmp (bfd_get_section_name (abfd, o), ".dynstr") != 0) @@ -8014,7 +8010,7 @@ bfd_elf_final_link (bfd *abfd, struct bf if (! bfd_set_section_contents (abfd, o->output_section, o->contents, (file_ptr) o->output_offset, - o->_raw_size)) + o->size)) goto error_return; } else @@ -8865,13 +8861,13 @@ bfd_elf_discard_info (bfd *output_bfd, s eh = bfd_get_section_by_name (abfd, ".eh_frame"); if (info->relocatable || (eh != NULL - && (eh->_raw_size == 0 + && (eh->size == 0 || bfd_is_abs_section (eh->output_section)))) eh = NULL; stab = bfd_get_section_by_name (abfd, ".stab"); if (stab != NULL - && (stab->_raw_size == 0 + && (stab->size == 0 || bfd_is_abs_section (stab->output_section) || stab->sec_info_type != ELF_INFO_TYPE_STABS)) stab = NULL; Index: bfd/elfn32-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elfn32-mips.c,v retrieving revision 1.18 diff -u -p -r1.18 elfn32-mips.c --- bfd/elfn32-mips.c 5 Jan 2004 22:09:38 -0000 1.18 +++ bfd/elfn32-mips.c 22 Jun 2004 01:36:36 -0000 @@ -1,6 +1,6 @@ /* MIPS-specific support for 32-bit ELF Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003 Free Software Foundation, Inc. + 2003, 2004 Free Software Foundation, Inc. Most of the information added by Ian Lance Taylor, Cygnus Support, . @@ -1415,6 +1415,7 @@ gprel32_with_gp (bfd *abfd, asymbol *sym void *data, bfd_vma gp) { bfd_vma relocation; + bfd_size_type sz; unsigned long val; if (bfd_is_com_section (symbol->section)) @@ -1425,7 +1426,8 @@ gprel32_with_gp (bfd *abfd, asymbol *sym relocation += symbol->section->output_section->vma; relocation += symbol->section->output_offset; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; if (reloc_entry->howto->src_mask == 0) @@ -1506,6 +1508,7 @@ mips16_gprel_reloc (bfd *abfd, arelent * unsigned short insn = 0; bfd_signed_vma val; bfd_vma relocation; + bfd_size_type sz; if (output_bfd != NULL) relocatable = TRUE; @@ -1520,7 +1523,8 @@ mips16_gprel_reloc (bfd *abfd, arelent * if (ret != bfd_reloc_ok) return ret; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; if (bfd_is_com_section (symbol->section)) @@ -1760,7 +1764,7 @@ static bfd_boolean elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) { int offset; - unsigned int raw_size; + unsigned int size; switch (note->descsz) { @@ -1776,13 +1780,13 @@ elf32_mips_grok_prstatus (bfd *abfd, Elf /* pr_reg */ offset = 72; - raw_size = 360; + size = 360; break; } /* Make a ".reg/999" section. */ - return _bfd_elfcore_make_pseudosection (abfd, ".reg", raw_size, + return _bfd_elfcore_make_pseudosection (abfd, ".reg", size, note->descpos + offset); } Index: bfd/elfxx-ia64.c =================================================================== RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v retrieving revision 1.129 diff -u -p -r1.129 elfxx-ia64.c --- bfd/elfxx-ia64.c 29 May 2004 19:25:54 -0000 1.129 +++ bfd/elfxx-ia64.c 22 Jun 2004 01:36:39 -0000 @@ -749,11 +749,6 @@ elfNN_ia64_relax_section (abfd, sec, lin && sec->need_finalize_relax == 0)) return TRUE; - /* If this is the first time we have been called for this section, - initialize the cooked size. */ - if (sec->_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; /* Load the relocations for this section. */ @@ -771,12 +766,7 @@ elfNN_ia64_relax_section (abfd, sec, lin contents = elf_section_data (sec)->this_hdr.contents; else { - contents = (bfd_byte *) bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, sec, contents, - (file_ptr) 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto error_return; } @@ -978,7 +968,7 @@ elfNN_ia64_relax_section (abfd, sec, lin size = oor_branch_size; /* Resize the current section to make room for the new branch. */ - trampoff = (sec->_cooked_size + 15) & (bfd_vma) -16; + trampoff = (sec->size + 15) & (bfd_vma) -16; /* If trampoline is out of range, there is nothing we can do. */ @@ -990,7 +980,7 @@ elfNN_ia64_relax_section (abfd, sec, lin contents = (bfd_byte *) bfd_realloc (contents, amt); if (contents == NULL) goto error_return; - sec->_cooked_size = amt; + sec->size = amt; if (tsec == ia64_info->plt_sec) { @@ -1146,8 +1136,7 @@ elfNN_ia64_relax_section (abfd, sec, lin elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_data_got, &data); elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_fptr_got, &data); elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data); - ia64_info->got_sec->_raw_size = data.ofs; - ia64_info->got_sec->_cooked_size = data.ofs; + ia64_info->got_sec->size = data.ofs; /* ??? Resize .rela.got too. */ } @@ -2796,7 +2785,7 @@ allocate_dynrel_entries (dyn_i, data) } if (rent->reltext) ia64_info->reltext = 1; - rent->srel->_raw_size += sizeof (ElfNN_External_Rela) * count; + rent->srel->size += sizeof (ElfNN_External_Rela) * count; } /* Take care of the GOT and PLT relocations. */ @@ -2812,18 +2801,18 @@ allocate_dynrel_entries (dyn_i, data) || !x->info->pie || dyn_i->h == NULL || dyn_i->h->root.type != bfd_link_hash_undefweak) - ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); + ia64_info->rel_got_sec->size += sizeof (ElfNN_External_Rela); } if ((dynamic_symbol || shared) && dyn_i->want_tprel) - ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); + ia64_info->rel_got_sec->size += sizeof (ElfNN_External_Rela); if (dynamic_symbol && dyn_i->want_dtpmod) - ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); + ia64_info->rel_got_sec->size += sizeof (ElfNN_External_Rela); if (dynamic_symbol && dyn_i->want_dtprel) - ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); + ia64_info->rel_got_sec->size += sizeof (ElfNN_External_Rela); if (ia64_info->rel_fptr_sec && dyn_i->want_fptr) { if (dyn_i->h == NULL || dyn_i->h->root.type != bfd_link_hash_undefweak) - ia64_info->rel_fptr_sec->_raw_size += sizeof (ElfNN_External_Rela); + ia64_info->rel_fptr_sec->size += sizeof (ElfNN_External_Rela); } if (!resolved_zero && dyn_i->want_pltoff) @@ -2838,7 +2827,7 @@ allocate_dynrel_entries (dyn_i, data) else if (shared) t = 2 * sizeof (ElfNN_External_Rela); - ia64_info->rel_pltoff_sec->_raw_size += t; + ia64_info->rel_pltoff_sec->size += t; } return TRUE; @@ -2898,7 +2887,7 @@ elfNN_ia64_size_dynamic_sections (output sec = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (sec != NULL); sec->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER; - sec->_raw_size = strlen (ELF_DYNAMIC_INTERPRETER) + 1; + sec->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1; } /* Allocate the GOT entries. */ @@ -2909,7 +2898,7 @@ elfNN_ia64_size_dynamic_sections (output elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_data_got, &data); elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_fptr_got, &data); elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data); - ia64_info->got_sec->_raw_size = data.ofs; + ia64_info->got_sec->size = data.ofs; } /* Allocate the FPTR entries. */ @@ -2918,7 +2907,7 @@ elfNN_ia64_size_dynamic_sections (output { data.ofs = 0; elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_fptr, &data); - ia64_info->fptr_sec->_raw_size = data.ofs; + ia64_info->fptr_sec->size = data.ofs; } /* Now that we've seen all of the input files, we can decide which @@ -2948,12 +2937,12 @@ elfNN_ia64_size_dynamic_sections (output BFD_ASSERT (ia64_info->root.dynamic_sections_created); - ia64_info->plt_sec->_raw_size = data.ofs; + ia64_info->plt_sec->size = data.ofs; /* If we've got a .plt, we need some extra memory for the dynamic linker. We stuff these in .got.plt. */ sec = bfd_get_section_by_name (dynobj, ".got.plt"); - sec->_raw_size = 8 * PLT_RESERVED_WORDS; + sec->size = 8 * PLT_RESERVED_WORDS; } /* Allocate the PLTOFF entries. */ @@ -2962,7 +2951,7 @@ elfNN_ia64_size_dynamic_sections (output { data.ofs = 0; elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_pltoff_entries, &data); - ia64_info->pltoff_sec->_raw_size = data.ofs; + ia64_info->pltoff_sec->size = data.ofs; } if (ia64_info->root.dynamic_sections_created) @@ -2971,7 +2960,7 @@ elfNN_ia64_size_dynamic_sections (output required. */ if (info->shared && ia64_info->self_dtpmod_offset != (bfd_vma) -1) - ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); + ia64_info->rel_got_sec->size += sizeof (ElfNN_External_Rela); elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries, &data); } @@ -2992,7 +2981,7 @@ elfNN_ia64_size_dynamic_sections (output function which decides whether anything needs to go into these sections. */ - strip = (sec->_raw_size == 0); + strip = (sec->size == 0); if (sec == ia64_info->got_sec) strip = FALSE; @@ -3069,8 +3058,8 @@ elfNN_ia64_size_dynamic_sections (output else { /* Allocate memory for the section contents. */ - sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->_raw_size); - if (sec->contents == NULL && sec->_raw_size != 0) + sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->size); + if (sec->contents == NULL && sec->size != 0) return FALSE; } } @@ -3381,8 +3370,7 @@ elfNN_ia64_install_dyn_reloc (abfd, info loc = srel->contents; loc += srel->reloc_count++ * sizeof (ElfNN_External_Rela); bfd_elfNN_swap_reloca_out (abfd, &outrel, loc); - BFD_ASSERT (sizeof (ElfNN_External_Rela) * srel->reloc_count - <= srel->_cooked_size); + BFD_ASSERT (sizeof (ElfNN_External_Rela) * srel->reloc_count <= srel->size); } /* Store an entry for target address TARGET_ADDR in the linkage table @@ -3698,7 +3686,7 @@ elfNN_ia64_choose_gp (abfd, info) continue; lo = os->vma; - hi = os->vma + os->_raw_size; + hi = os->vma + os->size; if (hi < lo) hi = (bfd_vma) -1; @@ -3834,7 +3822,7 @@ elfNN_ia64_final_link (abfd, info) { unwind_output_sec = s->output_section; unwind_output_sec->contents - = bfd_malloc (unwind_output_sec->_raw_size); + = bfd_malloc (unwind_output_sec->size); if (unwind_output_sec->contents == NULL) return FALSE; } @@ -3848,13 +3836,13 @@ elfNN_ia64_final_link (abfd, info) { elfNN_ia64_unwind_entry_compare_bfd = abfd; qsort (unwind_output_sec->contents, - (size_t) (unwind_output_sec->_raw_size / 24), + (size_t) (unwind_output_sec->size / 24), 24, elfNN_ia64_unwind_entry_compare); if (! bfd_set_section_contents (abfd, unwind_output_sec, unwind_output_sec->contents, (bfd_vma) 0, - unwind_output_sec->_raw_size)) + unwind_output_sec->size)) return FALSE; } @@ -4659,7 +4647,7 @@ elfNN_ia64_finish_dynamic_sections (abfd sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (sdyn != NULL); dyncon = (ElfNN_External_Dyn *) sdyn->contents; - dynconend = (ElfNN_External_Dyn *) (sdyn->contents + sdyn->_raw_size); + dynconend = (ElfNN_External_Dyn *) (sdyn->contents + sdyn->size); gp_val = _bfd_get_gp_value (abfd); Index: bfd/elfxx-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elfxx-mips.c,v retrieving revision 1.103 diff -u -p -r1.103 elfxx-mips.c --- bfd/elfxx-mips.c 15 Jun 2004 01:24:22 -0000 1.103 +++ bfd/elfxx-mips.c 22 Jun 2004 01:36:44 -0000 @@ -978,7 +978,7 @@ mips_elf_create_procedure_table (void *h H_PUT_S32 (abfd, -1, (erp + count)->p_adr); /* Set the size and contents of .rtproc section. */ - s->_raw_size = size; + s->size = size; s->contents = rtproc; /* Skip this section later on (I don't think this currently @@ -1028,8 +1028,7 @@ mips_elf_check_mips16_stubs (struct mips /* We don't need the fn_stub; the only references to this symbol are 16 bit calls. Clobber the size to 0 to prevent it from being included in the link. */ - h->fn_stub->_raw_size = 0; - h->fn_stub->_cooked_size = 0; + h->fn_stub->size = 0; h->fn_stub->flags &= ~SEC_RELOC; h->fn_stub->reloc_count = 0; h->fn_stub->flags |= SEC_EXCLUDE; @@ -1041,8 +1040,7 @@ mips_elf_check_mips16_stubs (struct mips /* We don't need the call_stub; this is a 16 bit function, so calls from other 16 bit functions are OK. Clobber the size to 0 to prevent it from being included in the link. */ - h->call_stub->_raw_size = 0; - h->call_stub->_cooked_size = 0; + h->call_stub->size = 0; h->call_stub->flags &= ~SEC_RELOC; h->call_stub->reloc_count = 0; h->call_stub->flags |= SEC_EXCLUDE; @@ -1054,8 +1052,7 @@ mips_elf_check_mips16_stubs (struct mips /* We don't need the call_stub; this is a 16 bit function, so calls from other 16 bit functions are OK. Clobber the size to 0 to prevent it from being included in the link. */ - h->call_fp_stub->_raw_size = 0; - h->call_fp_stub->_cooked_size = 0; + h->call_fp_stub->size = 0; h->call_fp_stub->flags &= ~SEC_RELOC; h->call_fp_stub->reloc_count = 0; h->call_fp_stub->flags |= SEC_EXCLUDE; @@ -1071,6 +1068,7 @@ _bfd_mips_elf_gprel16_with_gp (bfd *abfd { bfd_vma relocation; bfd_signed_vma val; + bfd_size_type sz; bfd_reloc_status_type status; if (bfd_is_com_section (symbol->section)) @@ -1081,7 +1079,8 @@ _bfd_mips_elf_gprel16_with_gp (bfd *abfd relocation += symbol->section->output_section->vma; relocation += symbol->section->output_offset; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Set val to the offset into the section or symbol. */ @@ -1146,8 +1145,10 @@ _bfd_mips_elf_hi16_reloc (bfd *abfd ATTR char **error_message ATTRIBUTE_UNUSED) { struct mips_hi16 *n; + bfd_size_type sz; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; n = bfd_malloc (sizeof *n); @@ -1197,8 +1198,10 @@ _bfd_mips_elf_lo16_reloc (bfd *abfd, are bfd *output_bfd, char **error_message) { bfd_vma vallo; + bfd_size_type sz; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; vallo = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); @@ -1247,12 +1250,14 @@ _bfd_mips_elf_generic_reloc (bfd *abfd A char **error_message ATTRIBUTE_UNUSED) { bfd_signed_vma val; + bfd_size_type sz; bfd_reloc_status_type status; bfd_boolean relocatable; relocatable = (output_bfd != NULL); - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; /* Build up the field adjustment in VAL. */ @@ -1868,7 +1873,7 @@ mips_elf_global_got_index (bfd *abfd, bf BFD_ASSERT (h->dynindx >= global_got_dynindx); index = ((h->dynindx - global_got_dynindx + g->local_gotno) * MIPS_ELF_GOT_SIZE (abfd)); - BFD_ASSERT (index < sgot->_raw_size); + BFD_ASSERT (index < sgot->size); return index; } @@ -2707,7 +2712,7 @@ mips_elf_multi_got (bfd *abfd, struct bf } while (g); - got->_raw_size = (gg->next->local_gotno + got->size = (gg->next->local_gotno + gg->next->global_gotno) * MIPS_ELF_GOT_SIZE (abfd); return TRUE; @@ -2861,7 +2866,7 @@ mips_elf_create_compact_rel_section MIPS_ELF_LOG_FILE_ALIGN (abfd))) return FALSE; - s->_raw_size = sizeof (Elf32_External_compact_rel); + s->size = sizeof (Elf32_External_compact_rel); } return TRUE; @@ -3193,7 +3198,7 @@ mips_elf_calculate_relocation (bfd *abfd else sec = h->call_fp_stub; - BFD_ASSERT (sec->_raw_size > 0); + BFD_ASSERT (sec->size > 0); symbol = sec->output_section->vma + sec->output_offset; } @@ -3767,13 +3772,13 @@ mips_elf_allocate_dynamic_relocations (b s = mips_elf_rel_dyn_section (abfd, FALSE); BFD_ASSERT (s != NULL); - if (s->_raw_size == 0) + if (s->size == 0) { /* Make room for a null element. */ - s->_raw_size += MIPS_ELF_REL_SIZE (abfd); + s->size += MIPS_ELF_REL_SIZE (abfd); ++s->reloc_count; } - s->_raw_size += n * MIPS_ELF_REL_SIZE (abfd); + s->size += n * MIPS_ELF_REL_SIZE (abfd); } /* Create a rel.dyn relocation for the dynamic linker to resolve. REL @@ -3801,7 +3806,7 @@ mips_elf_create_dynamic_relocation (bfd BFD_ASSERT (sreloc != NULL); BFD_ASSERT (sreloc->contents != NULL); BFD_ASSERT (sreloc->reloc_count * MIPS_ELF_REL_SIZE (output_bfd) - < sreloc->_raw_size); + < sreloc->size); skip = FALSE; outrel[0].r_offset = @@ -4531,7 +4536,7 @@ _bfd_mips_elf_fake_sections (bfd *abfd, if (strcmp (name, ".liblist") == 0) { hdr->sh_type = SHT_MIPS_LIBLIST; - hdr->sh_info = sec->_raw_size / sizeof (Elf32_Lib); + hdr->sh_info = sec->size / sizeof (Elf32_Lib); /* The sh_link field is set in final_write_processing. */ } else if (strcmp (name, ".conflict") == 0) @@ -5476,7 +5481,6 @@ _bfd_mips_relax_section (bfd *abfd, asec Elf_Internal_Rela *irel, *irelend; Elf_Internal_Shdr *symtab_hdr; bfd_byte *contents = NULL; - bfd_byte *free_contents = NULL; size_t extsymoff; bfd_boolean changed_contents = FALSE; bfd_vma sec_start = sec->output_section->vma + sec->output_offset; @@ -5597,13 +5601,7 @@ _bfd_mips_relax_section (bfd *abfd, asec contents = elf_section_data (sec)->this_hdr.contents; else { - contents = bfd_malloc (sec->_raw_size); - if (contents == NULL) - goto relax_return; - - free_contents = contents; - if (! bfd_get_section_contents (abfd, sec, contents, - 0, sec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) goto relax_return; } } @@ -5638,8 +5636,9 @@ _bfd_mips_relax_section (bfd *abfd, asec return TRUE; relax_return: - if (free_contents != NULL) - free (free_contents); + if (contents != NULL + && elf_section_data (sec)->this_hdr.contents != contents) + free (contents); return FALSE; } @@ -5707,13 +5706,13 @@ _bfd_mips_elf_adjust_dynamic_symbol (str BFD_ASSERT (s != NULL); h->root.u.def.section = s; - h->root.u.def.value = s->_raw_size; + h->root.u.def.value = s->size; /* XXX Write this stub address somewhere. */ - h->plt.offset = s->_raw_size; + h->plt.offset = s->size; /* Make room for this stub code. */ - s->_raw_size += MIPS_FUNCTION_STUB_SIZE; + s->size += MIPS_FUNCTION_STUB_SIZE; /* The last half word of the stub will be filled with the index of this symbol in .dynsym section. */ @@ -5797,7 +5796,7 @@ _bfd_mips_elf_always_size_sections (bfd { if ((subsection->flags & SEC_ALLOC) == 0) continue; - loadable_size += ((subsection->_raw_size + 0xf) + loadable_size += ((subsection->size + 0xf) &~ (bfd_size_type) 0xf); } } @@ -5827,12 +5826,12 @@ _bfd_mips_elf_always_size_sections (bfd local_gotno = (loadable_size >> 16) + 5; g->local_gotno += local_gotno; - s->_raw_size += g->local_gotno * MIPS_ELF_GOT_SIZE (output_bfd); + s->size += g->local_gotno * MIPS_ELF_GOT_SIZE (output_bfd); g->global_gotno = i; - s->_raw_size += i * MIPS_ELF_GOT_SIZE (output_bfd); + s->size += i * MIPS_ELF_GOT_SIZE (output_bfd); - if (s->_raw_size > MIPS_ELF_GOT_MAX_SIZE (output_bfd) + if (s->size > MIPS_ELF_GOT_MAX_SIZE (output_bfd) && ! mips_elf_multi_got (output_bfd, info, g, s, local_gotno)) return FALSE; @@ -5859,7 +5858,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd { s = bfd_get_section_by_name (dynobj, ".interp"); BFD_ASSERT (s != NULL); - s->_raw_size + s->size = strlen (ELF_DYNAMIC_INTERPRETER (output_bfd)) + 1; s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER (output_bfd); @@ -5886,7 +5885,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd if (strncmp (name, ".rel", 4) == 0) { - if (s->_raw_size == 0) + if (s->size == 0) { /* We only strip the section if the output section name has the same name. Otherwise, there might be several @@ -5986,7 +5985,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd { /* IRIX rld assumes that the function stub isn't at the end of .text section. So put a dummy. XXX */ - s->_raw_size += MIPS_FUNCTION_STUB_SIZE; + s->size += MIPS_FUNCTION_STUB_SIZE; } else if (! info->shared && ! mips_elf_hash_table (info)->use_rld_obj_head @@ -5994,11 +5993,11 @@ _bfd_mips_elf_size_dynamic_sections (bfd { /* We add a room for __rld_map. It will be filled in by the rtld to contain a pointer to the _r_debug structure. */ - s->_raw_size += 4; + s->size += 4; } else if (SGI_COMPAT (output_bfd) && strncmp (name, ".compact_rel", 12) == 0) - s->_raw_size += mips_elf_hash_table (info)->compact_rel_size; + s->size += mips_elf_hash_table (info)->compact_rel_size; else if (strncmp (name, ".init", 5) != 0) { /* It's not one of our sections, so don't allocate space. */ @@ -6012,8 +6011,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd } /* Allocate memory for the section contents. */ - s->contents = bfd_zalloc (dynobj, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->contents = bfd_zalloc (dynobj, s->size); + if (s->contents == NULL && s->size != 0) { bfd_set_error (bfd_error_no_memory); return FALSE; @@ -6580,7 +6579,7 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd bfd_put_32 (output_bfd, STUB_JALR, stub + 8); bfd_put_32 (output_bfd, STUB_LI16 (output_bfd) + h->dynindx, stub + 12); - BFD_ASSERT (h->plt.offset <= s->_raw_size); + BFD_ASSERT (h->plt.offset <= s->size); memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE); /* Mark the symbol as undefined. plt.offset != -1 occurs @@ -6785,7 +6784,7 @@ _bfd_mips_elf_finish_dynamic_sections (b BFD_ASSERT (g != NULL); for (b = sdyn->contents; - b < sdyn->contents + sdyn->_raw_size; + b < sdyn->contents + sdyn->size; b += MIPS_ELF_DYN_SIZE (dynobj)) { Elf_Internal_Dyn dyn; @@ -6876,10 +6875,7 @@ _bfd_mips_elf_finish_dynamic_sections (b s = bfd_get_section_by_name (output_bfd, name); BFD_ASSERT (s != NULL); - if (s->_cooked_size != 0) - dyn.d_un.d_val = s->_cooked_size / elemsize; - else - dyn.d_un.d_val = s->_raw_size / elemsize; + dyn.d_un.d_val = s->size / elemsize; break; case DT_MIPS_HIPAGENO: @@ -6922,7 +6918,7 @@ _bfd_mips_elf_finish_dynamic_sections (b /* The first entry of the global offset table will be filled at runtime. The second entry will be used by some runtime loaders. This isn't the case of IRIX rld. */ - if (sgot != NULL && sgot->_raw_size > 0) + if (sgot != NULL && sgot->size > 0) { MIPS_ELF_PUT_WORD (output_bfd, 0, sgot->contents); MIPS_ELF_PUT_WORD (output_bfd, 0x80000000, @@ -6996,8 +6992,8 @@ _bfd_mips_elf_finish_dynamic_sections (b { file_ptr dummy_offset; - BFD_ASSERT (s->_raw_size >= MIPS_FUNCTION_STUB_SIZE); - dummy_offset = s->_raw_size - MIPS_FUNCTION_STUB_SIZE; + BFD_ASSERT (s->size >= MIPS_FUNCTION_STUB_SIZE); + dummy_offset = s->size - MIPS_FUNCTION_STUB_SIZE; memset (s->contents + dummy_offset, 0, MIPS_FUNCTION_STUB_SIZE); } @@ -7009,7 +7005,7 @@ _bfd_mips_elf_finish_dynamic_sections (b s = mips_elf_rel_dyn_section (dynobj, FALSE); if (s != NULL - && s->_raw_size > (bfd_vma)2 * MIPS_ELF_REL_SIZE (output_bfd)) + && s->size > (bfd_vma)2 * MIPS_ELF_REL_SIZE (output_bfd)) { reldyn_sorting_bfd = output_bfd; @@ -7404,9 +7400,7 @@ _bfd_mips_elf_modify_segment_map (bfd *a if (low > s->vma) low = s->vma; - sz = s->_cooked_size; - if (sz == 0) - sz = s->_raw_size; + sz = s->size; if (high < s->vma + sz) high = s->vma + sz; } @@ -7416,9 +7410,7 @@ _bfd_mips_elf_modify_segment_map (bfd *a for (s = abfd->sections; s != NULL; s = s->next) if ((s->flags & SEC_LOAD) != 0 && s->vma >= low - && ((s->vma - + (s->_cooked_size != - 0 ? s->_cooked_size : s->_raw_size)) <= high)) + && s->vma + s->size <= high) ++c; amt = sizeof *n + (bfd_size_type) (c - 1) * sizeof (asection *); @@ -7433,9 +7425,7 @@ _bfd_mips_elf_modify_segment_map (bfd *a { if ((s->flags & SEC_LOAD) != 0 && s->vma >= low - && ((s->vma - + (s->_cooked_size != 0 ? - s->_cooked_size : s->_raw_size)) <= high)) + && s->vma + s->size <= high) { n->sections[i] = s; ++i; @@ -7648,15 +7638,15 @@ _bfd_mips_elf_discard_info (bfd *abfd, s o = bfd_get_section_by_name (abfd, ".pdr"); if (! o) return FALSE; - if (o->_raw_size == 0) + if (o->size == 0) return FALSE; - if (o->_raw_size % PDR_SIZE != 0) + if (o->size % PDR_SIZE != 0) return FALSE; if (o->output_section != NULL && bfd_is_abs_section (o->output_section)) return FALSE; - tdata = bfd_zmalloc (o->_raw_size / PDR_SIZE); + tdata = bfd_zmalloc (o->size / PDR_SIZE); if (! tdata) return FALSE; @@ -7671,7 +7661,7 @@ _bfd_mips_elf_discard_info (bfd *abfd, s cookie->rel = cookie->rels; cookie->relend = cookie->rels + o->reloc_count; - for (i = 0, skip = 0; i < o->_raw_size / PDR_SIZE; i ++) + for (i = 0, skip = 0; i < o->size / PDR_SIZE; i ++) { if (bfd_elf_reloc_symbol_deleted_p (i * PDR_SIZE, cookie)) { @@ -7683,7 +7673,7 @@ _bfd_mips_elf_discard_info (bfd *abfd, s if (skip != 0) { mips_elf_section_data (o)->u.tdata = tdata; - o->_cooked_size = o->_raw_size - skip * PDR_SIZE; + o->size -= skip * PDR_SIZE; ret = TRUE; } else @@ -7717,7 +7707,7 @@ _bfd_mips_elf_write_section (bfd *output return FALSE; to = contents; - end = contents + sec->_raw_size; + end = contents + sec->size; for (from = contents, i = 0; from < end; from += PDR_SIZE, i++) @@ -7729,7 +7719,7 @@ _bfd_mips_elf_write_section (bfd *output to += PDR_SIZE; } bfd_set_section_contents (output_bfd, sec->output_section, contents, - sec->output_offset, sec->_cooked_size); + sec->output_offset, sec->size); return TRUE; } @@ -7866,13 +7856,7 @@ _bfd_mips_elf_set_section_contents (bfd c = mips_elf_section_data (section)->u.tdata; if (c == NULL) { - bfd_size_type size; - - if (section->_cooked_size != 0) - size = section->_cooked_size; - else - size = section->_raw_size; - c = bfd_zalloc (abfd, size); + c = bfd_zalloc (abfd, section->size); if (c == NULL) return FALSE; mips_elf_section_data (section)->u.tdata = c; @@ -7900,6 +7884,7 @@ _bfd_elf_mips_get_relocated_section_cont /* Get enough memory to hold the stuff */ bfd *input_bfd = link_order->u.indirect.section->owner; asection *input_section = link_order->u.indirect.section; + bfd_size_type sz; long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); arelent **reloc_vector = NULL; @@ -7913,13 +7898,10 @@ _bfd_elf_mips_get_relocated_section_cont goto error_return; /* read in the section */ - if (!bfd_get_section_contents (input_bfd, input_section, data, 0, - input_section->_raw_size)) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (!bfd_get_section_contents (input_bfd, input_section, data, 0, sz)) goto error_return; - /* We're not relaxing the section, so just copy the size info */ - input_section->_cooked_size = input_section->_raw_size; - reloc_count = bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector, @@ -8264,11 +8246,6 @@ _bfd_mips_elf_final_link (bfd *abfd, str input_section = p->u.indirect.section; input_bfd = input_section->owner; - /* The linker emulation code has probably clobbered the - size to be zero bytes. */ - if (input_section->_raw_size == 0) - input_section->_raw_size = sizeof (Elf32_External_RegInfo); - if (! bfd_get_section_contents (input_bfd, input_section, &ext, 0, sizeof ext)) return FALSE; @@ -8291,7 +8268,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str } /* Size has been set in _bfd_mips_elf_always_size_sections. */ - BFD_ASSERT(o->_raw_size == sizeof (Elf32_External_RegInfo)); + BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo)); /* Skip this section later on (I don't think this currently matters, but someday it might). */ @@ -8359,7 +8336,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str if (s != NULL) { esym.asym.value = s->vma; - last = s->vma + s->_raw_size; + last = s->vma + s->size; } else esym.asym.value = last; @@ -8400,7 +8377,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str input_swap = (get_elf_backend_data (input_bfd) ->elf_backend_ecoff_debug_swap); - BFD_ASSERT (p->size == input_section->_raw_size); + BFD_ASSERT (p->size == input_section->size); /* The ECOFF linking code expects that we have already read in the debugging information and set up an @@ -8504,7 +8481,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str return FALSE; /* Set the size of the .mdebug section. */ - o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap); + o->size = bfd_ecoff_debug_size (abfd, &debug, swap); /* Skip this section later on (I don't think this currently matters, but someday it might). */ @@ -8622,7 +8599,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str /* Combine the gptab entries for this input section one by one. We know that the input gptab entries are sorted by ascending -G value. */ - size = bfd_section_size (input_bfd, input_section); + size = input_section->size; last = 0; for (gpentry = sizeof (Elf32_External_gptab); gpentry < size; @@ -8719,7 +8696,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str bfd_mips_elf32_swap_gptab_out (abfd, tab + j, ext_tab + j); free (tab); - o->_raw_size = c * sizeof (Elf32_External_gptab); + o->size = c * sizeof (Elf32_External_gptab); o->contents = (bfd_byte *) ext_tab; /* Skip this section later on (I don't think this currently @@ -8758,7 +8735,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str { if (! bfd_set_section_contents (abfd, gptab_data_sec, gptab_data_sec->contents, - 0, gptab_data_sec->_raw_size)) + 0, gptab_data_sec->size)) return FALSE; } @@ -8766,7 +8743,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str { if (! bfd_set_section_contents (abfd, gptab_bss_sec, gptab_bss_sec->contents, - 0, gptab_bss_sec->_raw_size)) + 0, gptab_bss_sec->size)) return FALSE; } @@ -8777,7 +8754,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str { if (! bfd_set_section_contents (abfd, rtproc_sec, rtproc_sec->contents, - 0, rtproc_sec->_raw_size)) + 0, rtproc_sec->size)) return FALSE; } } @@ -8958,7 +8935,7 @@ _bfd_mips_elf_merge_private_bfd_data (bf which are automatically generated by gas. */ if (strcmp (sec->name, ".reginfo") && strcmp (sec->name, ".mdebug") - && (sec->_raw_size != 0 + && (sec->size != 0 || (strcmp (sec->name, ".text") && strcmp (sec->name, ".data") && strcmp (sec->name, ".bss")))) Index: bfd/hp300hpux.c =================================================================== RCS file: /cvs/src/src/bfd/hp300hpux.c,v retrieving revision 1.12 diff -u -p -r1.12 hp300hpux.c --- bfd/hp300hpux.c 30 Nov 2003 18:40:41 -0000 1.12 +++ bfd/hp300hpux.c 22 Jun 2004 01:36:45 -0000 @@ -1,6 +1,6 @@ /* BFD backend for hp-ux 9000/300 - Copyright 1990, 1991, 1993, 1994, 1995, 1997, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1990, 1991, 1993, 1994, 1995, 1997, 2000, 2001, 2002, 2003, + 2004 Free Software Foundation, Inc. Written by Glenn Engel. This file is part of BFD, the Binary File Descriptor library. @@ -232,7 +232,7 @@ MY (callback) (abfd) struct internal_exec *execp = exec_hdr (abfd); /* Calculate the file positions of the parts of a newly read aout header */ - obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp); + obj_textsec (abfd)->size = N_TXTSIZE (*execp); /* The virtual memory addresses of the sections */ obj_textsec (abfd)->vma = N_TXTADDR (*execp); Index: bfd/hppabsd-core.c =================================================================== RCS file: /cvs/src/src/bfd/hppabsd-core.c,v retrieving revision 1.12 diff -u -p -r1.12 hppabsd-core.c --- bfd/hppabsd-core.c 5 May 2004 15:46:35 -0000 1.12 +++ bfd/hppabsd-core.c 22 Jun 2004 01:36:45 -0000 @@ -81,11 +81,11 @@ struct hppabsd_core_struct #define core_regsec(bfd) (core_hdr(bfd)->reg_section) static asection * -make_bfd_asection (abfd, name, flags, _raw_size, offset, alignment_power) +make_bfd_asection (abfd, name, flags, size, offset, alignment_power) bfd *abfd; const char *name; flagword flags; - bfd_size_type _raw_size; + bfd_size_type size; file_ptr offset; unsigned int alignment_power; { @@ -96,7 +96,7 @@ make_bfd_asection (abfd, name, flags, _r return NULL; asect->flags = flags; - asect->_raw_size = _raw_size; + asect->size = size; asect->filepos = offset; asect->alignment_power = alignment_power; Index: bfd/hpux-core.c =================================================================== RCS file: /cvs/src/src/bfd/hpux-core.c,v retrieving revision 1.12 diff -u -p -r1.12 hpux-core.c --- bfd/hpux-core.c 22 Apr 2004 23:17:07 -0000 1.12 +++ bfd/hpux-core.c 22 Jun 2004 01:36:45 -0000 @@ -115,11 +115,11 @@ static void swap_abort PARAMS ((void)); static asection * -make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power) +make_bfd_asection (abfd, name, flags, size, vma, alignment_power) bfd *abfd; const char *name; flagword flags; - bfd_size_type _raw_size; + bfd_size_type size; bfd_vma vma; unsigned int alignment_power; { @@ -137,7 +137,7 @@ make_bfd_asection (abfd, name, flags, _r return NULL; asect->flags = flags; - asect->_raw_size = _raw_size; + asect->size = size; asect->vma = vma; asect->filepos = bfd_tell (abfd); asect->alignment_power = alignment_power; Index: bfd/i386linux.c =================================================================== RCS file: /cvs/src/src/bfd/i386linux.c,v retrieving revision 1.11 diff -u -p -r1.11 i386linux.c --- bfd/i386linux.c 30 Nov 2003 18:40:41 -0000 1.11 +++ bfd/i386linux.c 22 Jun 2004 01:36:45 -0000 @@ -1,5 +1,5 @@ /* BFD back-end for linux flavored i386 a.out binaries. - Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2001, 2002, 2003 + Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -316,7 +316,7 @@ linux_link_create_dynamic_sections (abfd || ! bfd_set_section_flags (abfd, s, flags) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; - s->_raw_size = 0; + s->size = 0; s->contents = 0; return TRUE; @@ -594,9 +594,9 @@ bfd_i386linux_size_dynamic_sections (out ".linux-dynamic"); if (s != NULL) { - s->_raw_size = linux_hash_table (info)->fixup_count + 1; - s->_raw_size *= 8; - s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size); + s->size = linux_hash_table (info)->fixup_count + 1; + s->size *= 8; + s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->size); if (s->contents == NULL) return FALSE; } @@ -761,7 +761,7 @@ linux_finish_dynamic_link (output_bfd, i SEEK_SET) != 0) return FALSE; - if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd) != s->_raw_size) + if (bfd_bwrite ((PTR) s->contents, s->size, output_bfd) != s->size) return FALSE; return TRUE; Index: bfd/i386msdos.c =================================================================== RCS file: /cvs/src/src/bfd/i386msdos.c,v retrieving revision 1.15 diff -u -p -r1.15 i386msdos.c --- bfd/i386msdos.c 15 Jun 2004 01:24:22 -0000 1.15 +++ bfd/i386msdos.c 22 Jun 2004 01:36:46 -0000 @@ -83,12 +83,11 @@ msdos_write_object_contents (abfd) /* Find the total size of the program on disk and in memory. */ for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next) { - if (bfd_get_section_size (sec) == 0) + if (sec->size == 0) continue; if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC) { - bfd_vma sec_vma = (bfd_get_section_vma (abfd, sec) - + bfd_get_section_size (sec)); + bfd_vma sec_vma = bfd_get_section_vma (abfd, sec) + sec->size; if (sec_vma > high_vma) high_vma = sec_vma; } @@ -96,7 +95,7 @@ msdos_write_object_contents (abfd) { file_ptr sec_end = (sizeof (hdr) + bfd_get_section_vma (abfd, sec) - + bfd_get_section_size (sec)); + + sec->size); if (sec_end > outfile_size) outfile_size = sec_end; } Index: bfd/i386os9k.c =================================================================== RCS file: /cvs/src/src/bfd/i386os9k.c,v retrieving revision 1.13 diff -u -p -r1.13 i386os9k.c --- bfd/i386os9k.c 30 Apr 2004 14:23:39 -0000 1.13 +++ bfd/i386os9k.c 22 Jun 2004 01:36:46 -0000 @@ -170,7 +170,7 @@ os9k_callback (abfd) obj_datasec (abfd)->vma = execp->a_dload; /* And reload the sizes, since the aout module zaps them. */ - obj_textsec (abfd)->_raw_size = execp->a_text; + obj_textsec (abfd)->size = execp->a_text; bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section. */ obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign); @@ -229,9 +229,9 @@ os9k_write_object_contents (abfd) exec_hdr (abfd)->a_info = BMAGIC; - exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size; - exec_hdr (abfd)->a_data = obj_datasec (abfd)->_raw_size; - exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_raw_size; + exec_hdr (abfd)->a_text = obj_textsec (abfd)->size; + exec_hdr (abfd)->a_data = obj_datasec (abfd)->size; + exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->size; exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist); exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd); exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) * @@ -295,7 +295,7 @@ os9k_set_section_contents (abfd, section obj_textsec (abfd)->filepos = sizeof (struct internal_exec); obj_datasec (abfd)->filepos = obj_textsec (abfd)->filepos - + obj_textsec (abfd)->_raw_size; + + obj_textsec (abfd)->size; } /* Regardless, once we know what we're doing, we might as well get going. */ Index: bfd/ieee.c =================================================================== RCS file: /cvs/src/src/bfd/ieee.c,v retrieving revision 1.37 diff -u -p -r1.37 ieee.c --- bfd/ieee.c 30 Apr 2004 14:23:39 -0000 1.37 +++ bfd/ieee.c 22 Jun 2004 01:36:47 -0000 @@ -704,7 +704,7 @@ parse_expression (ieee, value, symbol, p next_byte (&(ieee->h)); PUSH (NOSYMBOL, 0, - ieee->section_table[must_parse_int (&(ieee->h))]->_raw_size); + ieee->section_table[must_parse_int (&(ieee->h))]->size); break; case ieee_variable_I_enum: /* Push the address of variable n. */ @@ -1021,7 +1021,7 @@ ieee_slurp_external_symbols (abfd) val = symbol->symbol.value; for (s = abfd->sections; s != NULL; s = s->next) { - if (val >= s->vma && val < s->vma + s->_raw_size) + if (val >= s->vma && val < s->vma + s->size) { symbol->symbol.section = s; symbol->symbol.value -= s->vma; @@ -1378,11 +1378,11 @@ ieee_slurp_sections (abfd) { case ieee_section_size_enum: section = ieee->section_table[must_parse_int (&(ieee->h))]; - section->_raw_size = must_parse_int (&(ieee->h)); + section->size = must_parse_int (&(ieee->h)); break; case ieee_physical_region_size_enum: section = ieee->section_table[must_parse_int (&(ieee->h))]; - section->_raw_size = must_parse_int (&(ieee->h)); + section->size = must_parse_int (&(ieee->h)); break; case ieee_region_base_address_enum: section = ieee->section_table[must_parse_int (&(ieee->h))]; @@ -1441,7 +1441,7 @@ ieee_slurp_debug (abfd) sec->filepos = ieee->w.r.debug_information_part; debug_end = ieee_part_after (ieee, ieee->w.r.debug_information_part); - sec->_raw_size = debug_end - ieee->w.r.debug_information_part; + sec->size = debug_end - ieee->w.r.debug_information_part; return TRUE; } @@ -2060,7 +2060,7 @@ ieee_slurp_section_data (abfd) ieee_per_section_type *per = ieee_per_section (s); if ((s->flags & SEC_DEBUGGING) != 0) continue; - per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size); + per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->size); if (!per->data) return FALSE; per->reloc_tail_ptr = @@ -2106,7 +2106,7 @@ ieee_slurp_section_data (abfd) &pcrel, &extra, 0); current_map->pc = value; - BFD_ASSERT ((unsigned) (value - s->vma) <= s->_raw_size); + BFD_ASSERT ((unsigned) (value - s->vma) <= s->size); } break; @@ -2336,7 +2336,7 @@ ieee_write_section_part (abfd) || ! ieee_write_byte (abfd, (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)) - || ! ieee_write_int (abfd, s->_raw_size)) + || ! ieee_write_int (abfd, s->size)) return FALSE; if (abfd->flags & EXEC_P) { @@ -2398,14 +2398,14 @@ do_with_relocs (abfd, s) { /* If there aren't any relocations then output the load constant byte opcode rather than the load with relocation opcode. */ - while (current_byte_index < s->_raw_size) + while (current_byte_index < s->size) { bfd_size_type run; unsigned int MAXRUN = 127; run = MAXRUN; - if (run > s->_raw_size - current_byte_index) - run = s->_raw_size - current_byte_index; + if (run > s->size - current_byte_index) + run = s->size - current_byte_index; if (run != 0) { @@ -2433,11 +2433,11 @@ do_with_relocs (abfd, s) if ((PTR) stream == (PTR) NULL) { /* Outputting a section without data, fill it up. */ - stream = (unsigned char *) bfd_zalloc (abfd, s->_raw_size); + stream = (unsigned char *) bfd_zalloc (abfd, s->size); if (!stream) return FALSE; } - while (current_byte_index < s->_raw_size) + while (current_byte_index < s->size) { bfd_size_type run; unsigned int MAXRUN = 127; @@ -2451,8 +2451,8 @@ do_with_relocs (abfd, s) else run = MAXRUN; - if (run > s->_raw_size - current_byte_index) - run = s->_raw_size - current_byte_index; + if (run > s->size - current_byte_index) + run = s->size - current_byte_index; if (run != 0) { @@ -2561,7 +2561,7 @@ do_as_repeat (abfd, s) bfd *abfd; asection *s; { - if (s->_raw_size) + if (s->size) { if (! ieee_write_byte (abfd, ieee_set_current_section_enum) || ! ieee_write_byte (abfd, @@ -2586,7 +2586,7 @@ do_as_repeat (abfd, s) } if (! ieee_write_byte (abfd, ieee_repeat_data_enum) - || ! ieee_write_int (abfd, s->_raw_size) + || ! ieee_write_int (abfd, s->size) || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum) || ! ieee_write_byte (abfd, 1) || ! ieee_write_byte (abfd, 0)) @@ -2612,7 +2612,7 @@ do_without_relocs (abfd, s) { unsigned int i; - for (i = 0; i < s->_raw_size; i++) + for (i = 0; i < s->size; i++) { if (stream[i] != 0) { @@ -3342,7 +3342,7 @@ ieee_write_debug_part (abfd) } ieee->w.r.debug_information_part = here; - if (bfd_bwrite (s->contents, s->_raw_size, abfd) != s->_raw_size) + if (bfd_bwrite (s->contents, s->size, abfd) != s->size) return FALSE; } else @@ -3420,9 +3420,9 @@ init_for_output (abfd) { if ((s->flags & SEC_DEBUGGING) != 0) continue; - if (s->_raw_size != 0) + if (s->size != 0) { - bfd_size_type size = s->_raw_size; + bfd_size_type size = s->size; ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, size)); if (!ieee_per_section (s)->data) return FALSE; @@ -3448,7 +3448,7 @@ ieee_set_section_contents (abfd, section { if (section->contents == NULL) { - bfd_size_type size = section->_raw_size; + bfd_size_type size = section->size; section->contents = (unsigned char *) bfd_alloc (abfd, size); if (section->contents == NULL) return FALSE; Index: bfd/ihex.c =================================================================== RCS file: /cvs/src/src/bfd/ihex.c,v retrieving revision 1.22 diff -u -p -r1.22 ihex.c --- bfd/ihex.c 30 Apr 2004 14:23:39 -0000 1.22 +++ bfd/ihex.c 22 Jun 2004 01:36:48 -0000 @@ -381,11 +381,11 @@ ihex_scan (abfd) case 0: /* This is a data record. */ if (sec != NULL - && sec->vma + sec->_raw_size == extbase + segbase + addr) + && sec->vma + sec->size == extbase + segbase + addr) { /* This data goes at the end of the section we are currently building. */ - sec->_raw_size += len; + sec->size += len; } else if (len > 0) { @@ -405,7 +405,7 @@ ihex_scan (abfd) sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC; sec->vma = extbase + segbase + addr; sec->lma = extbase + segbase + addr; - sec->_raw_size = len; + sec->size = len; sec->filepos = pos; } break; @@ -635,7 +635,7 @@ ihex_read_section (abfd, section, conten for (i = 0; i < len; i++) *p++ = HEX2 (buf + 2 * i); - if ((bfd_size_type) (p - contents) >= section->_raw_size) + if ((bfd_size_type) (p - contents) >= section->size) { /* We've read everything in the section. */ if (buf != NULL) @@ -648,7 +648,7 @@ ihex_read_section (abfd, section, conten goto error_return; } - if ((bfd_size_type) (p - contents) < section->_raw_size) + if ((bfd_size_type) (p - contents) < section->size) { (*_bfd_error_handler) (_("%s: bad section length in ihex_read_section"), @@ -680,7 +680,7 @@ ihex_get_section_contents (abfd, section { if (section->used_by_bfd == NULL) { - section->used_by_bfd = bfd_alloc (abfd, section->_raw_size); + section->used_by_bfd = bfd_alloc (abfd, section->size); if (section->used_by_bfd == NULL) return FALSE; if (! ihex_read_section (abfd, section, section->used_by_bfd)) Index: bfd/irix-core.c =================================================================== RCS file: /cvs/src/src/bfd/irix-core.c,v retrieving revision 1.11 diff -u -p -r1.11 irix-core.c --- bfd/irix-core.c 15 Mar 2004 14:21:42 -0000 1.11 +++ bfd/irix-core.c 22 Jun 2004 01:36:48 -0000 @@ -161,11 +161,11 @@ do_sections (abfd, coreout) } static asection * -make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) +make_bfd_asection (abfd, name, flags, size, vma, filepos) bfd *abfd; const char *name; flagword flags; - bfd_size_type _raw_size; + bfd_size_type size; bfd_vma vma; file_ptr filepos; { @@ -176,7 +176,7 @@ make_bfd_asection (abfd, name, flags, _r return NULL; asect->flags = flags; - asect->_raw_size = _raw_size; + asect->size = size; asect->vma = vma; asect->filepos = filepos; asect->alignment_power = 4; Index: bfd/libaout.h =================================================================== RCS file: /cvs/src/src/bfd/libaout.h,v retrieving revision 1.16 diff -u -p -r1.16 libaout.h --- bfd/libaout.h 21 May 2004 14:56:07 -0000 1.16 +++ bfd/libaout.h 22 Jun 2004 01:36:49 -0000 @@ -666,8 +666,8 @@ extern bfd_boolean NAME(aout,bfd_free_ca && obj_textsec (abfd) != NULL \ && obj_datasec (abfd) != NULL \ && (sec)->vma >= (obj_textsec (abfd)->vma + \ - obj_textsec (abfd)->_cooked_size) \ - && ((sec)->vma + (sec)->_cooked_size) <= obj_datasec (abfd)->vma \ + obj_textsec (abfd)->size) \ + && ((sec)->vma + (sec)->size) <= obj_datasec (abfd)->vma \ && ((abfd)->flags & D_PAGED) != 0) #endif /* ! defined (LIBAOUT_H) */ Index: bfd/libbfd-in.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd-in.h,v retrieving revision 1.36 diff -u -p -r1.36 libbfd-in.h --- bfd/libbfd-in.h 25 May 2004 06:33:47 -0000 1.36 +++ bfd/libbfd-in.h 22 Jun 2004 01:36:49 -0000 @@ -518,7 +518,7 @@ extern bfd_boolean _bfd_write_stab_strin sections. */ extern bfd_vma _bfd_stab_section_offset - (bfd *, void **, asection *, void **, bfd_vma); + (asection *, void *, bfd_vma); /* Register a SEC_MERGE section as a candidate for merging. */ Index: bfd/libbfd.c =================================================================== RCS file: /cvs/src/src/bfd/libbfd.c,v retrieving revision 1.31 diff -u -p -r1.31 libbfd.c --- bfd/libbfd.c 15 Mar 2004 14:21:42 -0000 1.31 +++ bfd/libbfd.c 22 Jun 2004 01:36:49 -0000 @@ -692,10 +692,12 @@ _bfd_generic_get_section_contents (bfd * file_ptr offset, bfd_size_type count) { + bfd_size_type sz; if (count == 0) return TRUE; - if (offset + count > section->_raw_size) + sz = section->rawsize ? section->rawsize : section->size; + if (offset + count > sz) { bfd_set_error (bfd_error_invalid_operation); return FALSE; @@ -717,6 +719,8 @@ _bfd_generic_get_section_contents_in_win bfd_size_type count ATTRIBUTE_UNUSED) { #ifdef USE_MMAP + bfd_size_type sz; + if (count == 0) return TRUE; if (abfd->xvec->_bfd_get_section_contents @@ -744,7 +748,8 @@ _bfd_generic_get_section_contents_in_win w->data = w->i->data; return bfd_get_section_contents (abfd, section, w->data, offset, count); } - if (offset + count > section->_raw_size + sz = section->rawsize ? section->rawsize : section->size; + if (offset + count > sz || ! bfd_get_file_window (abfd, section->filepos + offset, count, w, TRUE)) return FALSE; Index: bfd/linker.c =================================================================== RCS file: /cvs/src/src/bfd/linker.c,v retrieving revision 1.35 diff -u -p -r1.35 linker.c --- bfd/linker.c 22 Mar 2004 22:58:02 -0000 1.35 +++ bfd/linker.c 22 Jun 2004 01:36:52 -0000 @@ -2684,7 +2684,7 @@ default_indirect_link_order (bfd *output BFD_ASSERT (input_section->output_section == output_section); BFD_ASSERT (input_section->output_offset == link_order->offset); - BFD_ASSERT (input_section->_cooked_size == link_order->size); + BFD_ASSERT (input_section->size == link_order->size); if (info->relocatable && input_section->reloc_count > 0 @@ -2756,7 +2756,7 @@ default_indirect_link_order (bfd *output } /* Get and relocate the section contents. */ - sec_size = bfd_section_size (input_bfd, input_section); + sec_size = input_section->size; contents = bfd_malloc (sec_size); if (contents == NULL && sec_size != 0) goto error_return; Index: bfd/lynx-core.c =================================================================== RCS file: /cvs/src/src/bfd/lynx-core.c,v retrieving revision 1.6 diff -u -p -r1.6 lynx-core.c --- bfd/lynx-core.c 30 Nov 2002 08:39:40 -0000 1.6 +++ bfd/lynx-core.c 22 Jun 2004 01:36:52 -0000 @@ -1,5 +1,6 @@ /* BFD back end for Lynx core files - Copyright 1993, 1994, 1995, 2001, 2002 Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 2001, 2002, 2004 + Free Software Foundation, Inc. Written by Stu Grossman of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -53,11 +54,11 @@ struct lynx_core_struct /* Handle Lynx core dump file. */ static asection * -make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) +make_bfd_asection (abfd, name, flags, size, vma, filepos) bfd *abfd; const char *name; flagword flags; - bfd_size_type _raw_size; + bfd_size_type size; bfd_vma vma; file_ptr filepos; { @@ -75,7 +76,7 @@ make_bfd_asection (abfd, name, flags, _r return NULL; asect->flags = flags; - asect->_raw_size = _raw_size; + asect->size = size; asect->vma = vma; asect->filepos = filepos; asect->alignment_power = 2; Index: bfd/m68klinux.c =================================================================== RCS file: /cvs/src/src/bfd/m68klinux.c,v retrieving revision 1.14 diff -u -p -r1.14 m68klinux.c --- bfd/m68klinux.c 30 Nov 2003 18:40:41 -0000 1.14 +++ bfd/m68klinux.c 22 Jun 2004 01:36:52 -0000 @@ -1,6 +1,6 @@ /* BFD back-end for linux flavored m68k a.out binaries. - Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, + 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -320,7 +320,7 @@ linux_link_create_dynamic_sections (abfd || ! bfd_set_section_flags (abfd, s, flags) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; - s->_raw_size = 0; + s->size = 0; s->contents = 0; return TRUE; @@ -598,9 +598,9 @@ bfd_m68klinux_size_dynamic_sections (out ".linux-dynamic"); if (s != NULL) { - s->_raw_size = linux_hash_table (info)->fixup_count + 1; - s->_raw_size *= 8; - s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size); + s->size = linux_hash_table (info)->fixup_count + 1; + s->size *= 8; + s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->size); if (s->contents == NULL) { bfd_set_error (bfd_error_no_memory); @@ -766,7 +766,7 @@ linux_finish_dynamic_link (output_bfd, i SEEK_SET) != 0) return FALSE; - if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd) != s->_raw_size) + if (bfd_bwrite ((PTR) s->contents, s->size, output_bfd) != s->size) return FALSE; return TRUE; Index: bfd/mach-o.c =================================================================== RCS file: /cvs/src/src/bfd/mach-o.c,v retrieving revision 1.9 diff -u -p -r1.9 mach-o.c --- bfd/mach-o.c 17 May 2004 16:40:00 -0000 1.9 +++ bfd/mach-o.c 22 Jun 2004 01:36:53 -0000 @@ -584,7 +584,7 @@ bfd_mach_o_make_bfd_section (abfd, secti bfdsec->vma = section->addr; bfdsec->lma = section->addr; - bfdsec->_raw_size = section->size; + bfdsec->size = section->size; bfdsec->filepos = section->offset; bfdsec->alignment_power = section->align; @@ -1032,7 +1032,7 @@ bfd_mach_o_scan_read_dylinker (abfd, com bfdsec->vma = 0; bfdsec->lma = 0; - bfdsec->_raw_size = command->len - 8; + bfdsec->size = command->len - 8; bfdsec->filepos = command->offset + 8; bfdsec->alignment_power = 0; bfdsec->flags = SEC_HAS_CONTENTS; @@ -1090,7 +1090,7 @@ bfd_mach_o_scan_read_dylib (abfd, comman bfdsec->vma = 0; bfdsec->lma = 0; - bfdsec->_raw_size = command->len - 8; + bfdsec->size = command->len - 8; bfdsec->filepos = command->offset + 8; bfdsec->alignment_power = 0; bfdsec->flags = SEC_HAS_CONTENTS; @@ -1213,7 +1213,7 @@ bfd_mach_o_scan_read_thread (abfd, comma bfdsec->vma = 0; bfdsec->lma = 0; - bfdsec->_raw_size = cmd->flavours[i].size; + bfdsec->size = cmd->flavours[i].size; bfdsec->filepos = cmd->flavours[i].offset; bfdsec->alignment_power = 0x0; bfdsec->flags = SEC_HAS_CONTENTS; @@ -1320,7 +1320,7 @@ bfd_mach_o_scan_read_symtab (abfd, comma bfdsec->vma = 0; bfdsec->lma = 0; - bfdsec->_raw_size = seg->nsyms * 12; + bfdsec->size = seg->nsyms * 12; bfdsec->filepos = seg->symoff; bfdsec->alignment_power = 0; bfdsec->flags = SEC_HAS_CONTENTS; @@ -1339,7 +1339,7 @@ bfd_mach_o_scan_read_symtab (abfd, comma bfdsec->vma = 0; bfdsec->lma = 0; - bfdsec->_raw_size = seg->strsize; + bfdsec->size = seg->strsize; bfdsec->filepos = seg->stroff; bfdsec->alignment_power = 0; bfdsec->flags = SEC_HAS_CONTENTS; @@ -1390,7 +1390,7 @@ bfd_mach_o_scan_read_segment (abfd, comm bfdsec->vma = seg->vmaddr; bfdsec->lma = seg->vmaddr; - bfdsec->_raw_size = seg->filesize; + bfdsec->size = seg->filesize; bfdsec->filepos = seg->fileoff; bfdsec->alignment_power = 0x0; bfdsec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE; Index: bfd/merge.c =================================================================== RCS file: /cvs/src/src/bfd/merge.c,v retrieving revision 1.20 diff -u -p -r1.20 merge.c --- bfd/merge.c 25 May 2004 06:33:47 -0000 1.20 +++ bfd/merge.c 22 Jun 2004 01:36:54 -0000 @@ -1,5 +1,5 @@ /* SEC_MERGE support. - Copyright 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Jakub Jelinek . This file is part of BFD, the Binary File Descriptor library. @@ -340,7 +340,7 @@ _bfd_add_merge_section (bfd *abfd, void || (sec->flags & SEC_MERGE) == 0) abort (); - if (sec->_raw_size == 0 + if (sec->size == 0 || (sec->flags & SEC_EXCLUDE) != 0 || sec->entsize == 0) return TRUE; @@ -391,7 +391,7 @@ _bfd_add_merge_section (bfd *abfd, void /* Read the section from abfd. */ - amt = sizeof (struct sec_merge_sec_info) + sec->_raw_size - 1; + amt = sizeof (struct sec_merge_sec_info) + sec->size - 1; *psecinfo = bfd_alloc (abfd, amt); if (*psecinfo == NULL) goto error_return; @@ -410,8 +410,9 @@ _bfd_add_merge_section (bfd *abfd, void secinfo->htab = sinfo->htab; secinfo->first_str = NULL; + sec->rawsize = sec->size; if (! bfd_get_section_contents (sec->owner, sec, secinfo->contents, - 0, sec->_raw_size)) + 0, sec->size)) goto error_return; return TRUE; @@ -434,7 +435,7 @@ record_section (struct sec_merge_info *s unsigned int align, i; align = sec->alignment_power; - end = secinfo->contents + sec->_raw_size; + end = secinfo->contents + sec->size; nul = FALSE; mask = ((bfd_vma) 1 << align) - 1; if (sec->flags & SEC_STRINGS) @@ -638,7 +639,7 @@ alloc_failure: { if (e->secinfo != secinfo) { - secinfo->sec->_cooked_size = size; + secinfo->sec->size = size; secinfo = e->secinfo; } if (e->alignment) @@ -653,7 +654,7 @@ alloc_failure: size += e->len; } } - secinfo->sec->_cooked_size = size; + secinfo->sec->size = size; /* And now adjust the rest, removing them from the chain (but not hashtable) at the same time. */ @@ -725,7 +726,7 @@ _bfd_merge_sections (bfd *abfd ATTRIBUTE if (e->secinfo->first_str == NULL) { if (secinfo) - secinfo->sec->_cooked_size = size; + secinfo->sec->size = size; e->secinfo->first_str = e; size = 0; } @@ -735,7 +736,7 @@ _bfd_merge_sections (bfd *abfd ATTRIBUTE size += e->len; secinfo = e->secinfo; } - secinfo->sec->_cooked_size = size; + secinfo->sec->size = size; } /* Finally remove all input sections which have not made it into @@ -786,15 +787,15 @@ _bfd_merged_section_offset (bfd *output_ secinfo = (struct sec_merge_sec_info *) psecinfo; - if (offset >= sec->_raw_size) + if (offset >= sec->rawsize) { - if (offset > sec->_raw_size) + if (offset > sec->rawsize) { (*_bfd_error_handler) (_("%s: access beyond end of merged section (%ld)"), bfd_get_filename (sec->owner), (long) offset); } - return (secinfo->first_str ? sec->_cooked_size : 0); + return secinfo->first_str ? sec->size : 0; } if (secinfo->htab->strings) Index: bfd/mmo.c =================================================================== RCS file: /cvs/src/src/bfd/mmo.c,v retrieving revision 1.18 diff -u -p -r1.18 mmo.c --- bfd/mmo.c 17 May 2004 16:40:00 -0000 1.18 +++ bfd/mmo.c 22 Jun 2004 01:36:56 -0000 @@ -665,7 +665,7 @@ mmo_find_sec_w_addr (abfd, sec, p) != (SEC_LOAD | SEC_ALLOC)) return; - if (infop->addr >= vma && infop->addr < vma + sec->_raw_size) + if (infop->addr >= vma && infop->addr < vma + sec->size) infop->sec = sec; } @@ -1168,8 +1168,7 @@ mmo_get_spec_section (abfd, spec_data_nu bfd_sec_flags_from_mmo_flags (flags) | bfd_get_section_flags (abfd, sec) | (section_length != 0 ? SEC_HAS_CONTENTS : 0)) - || ! bfd_set_section_size (abfd, sec, - sec->_cooked_size + section_length) + || ! bfd_set_section_size (abfd, sec, sec->size + section_length) /* Set VMA only for the first occurrence. */ || (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, section_vma))) @@ -1545,8 +1544,8 @@ mmo_get_loc (sec, vma, size) non-32-bit-aligned sections should do all allocation and size-setting by themselves or at least set the section size after the last allocating call to this function. */ - if (vma + size > sec->vma + sec->_raw_size) - sec->_raw_size += (vma + size) - (sec->vma + sec->_raw_size); + if (vma + size > sec->vma + sec->size) + sec->size += (vma + size) - (sec->vma + sec->size); return datap->data + vma - datap->where; } @@ -1608,8 +1607,8 @@ mmo_get_loc (sec, vma, size) /* Update the section size. This happens only when we add contents and re-size as we go. The section size will then be aligned to 32 bits. */ - if (vma + size > sec->vma + sec->_raw_size) - sec->_raw_size += (vma + size) - (sec->vma + sec->_raw_size); + if (vma + size > sec->vma + sec->size) + sec->size += (vma + size) - (sec->vma + sec->size); return entry->data; } @@ -1621,7 +1620,6 @@ mmo_map_set_sizes (abfd, sec, ignored) asection *sec; PTR ignored ATTRIBUTE_UNUSED; { - sec->_cooked_size = sec->_raw_size; sec->lma = sec->vma; } @@ -2269,7 +2267,7 @@ mmo_canonicalize_symtab (abfd, alocation if (textsec != NULL && c->value >= textsec->vma - && c->value <= textsec->vma + textsec->_cooked_size) + && c->value <= textsec->vma + textsec->size) { c->section = textsec; c->value -= c->section->vma; @@ -2486,7 +2484,7 @@ mmo_internal_write_section (abfd, sec) /* Ignore sections that are just allocated or empty; we write out _contents_ here. */ else if ((bfd_get_section_flags (abfd, sec) & SEC_HAS_CONTENTS) != 0 - && sec->_raw_size != 0) + && sec->size != 0) { /* Keep the document-comment formatted the way it is. */ /* @@ -2592,7 +2590,7 @@ EXAMPLE mmo_write_tetra (abfd, mmo_sec_flags_from_bfd_flags (bfd_get_section_flags (abfd, sec))); - mmo_write_octa (abfd, sec->_raw_size); + mmo_write_octa (abfd, sec->size); mmo_write_octa (abfd, bfd_get_section_vma (abfd, sec)); /* Writing a LOP_LOC ends the LOP_SPEC data, and makes data actually @@ -3181,11 +3179,11 @@ mmo_write_object_contents (abfd) of the register contents section and check that it corresponds to the length of the section. */ if (z < 32 || z >= 255 || (sec->vma & 7) != 0 - || sec->vma != 256 * 8 - sec->_raw_size - 8) + || sec->vma != 256 * 8 - sec->size - 8) { bfd_set_error (bfd_error_bad_value); - if (sec->_raw_size == 0) + if (sec->size == 0) /* There must always be at least one such register. */ (*_bfd_error_handler) (_("%s: no initialized registers; section length 0\n"), @@ -3196,13 +3194,13 @@ mmo_write_object_contents (abfd) (*_bfd_error_handler) (_("%s: too many initialized registers; section length %ld\n"), bfd_get_filename (abfd), - (long) sec->_raw_size); + (long) sec->size); else (*_bfd_error_handler) (_("%s: invalid start address for initialized registers of\ length %ld: 0x%lx%08lx\n"), bfd_get_filename (abfd), - (long) sec->_raw_size, + (long) sec->size, (unsigned long) (sec->vma >> 32), (unsigned long) (sec->vma)); return FALSE; Index: bfd/netbsd-core.c =================================================================== RCS file: /cvs/src/src/bfd/netbsd-core.c,v retrieving revision 1.17 diff -u -p -r1.17 netbsd-core.c --- bfd/netbsd-core.c 24 May 2004 21:52:38 -0000 1.17 +++ bfd/netbsd-core.c 22 Jun 2004 01:36:56 -0000 @@ -139,7 +139,7 @@ netbsd_core_file_p (abfd) goto punt; asect->flags = flags; - asect->_raw_size = coreseg.c_size; + asect->size = coreseg.c_size; asect->vma = coreseg.c_addr; asect->filepos = offset; asect->alignment_power = 2; @@ -149,7 +149,7 @@ netbsd_core_file_p (abfd) && coreseg.c_size > CORE_WCOOKIE_OFFSET) { /* Truncate the .reg section. */ - asect->_raw_size = CORE_WCOOKIE_OFFSET; + asect->size = CORE_WCOOKIE_OFFSET; /* And create the .wcookie section. */ asect = bfd_make_section_anyway (abfd, ".wcookie"); @@ -157,7 +157,7 @@ netbsd_core_file_p (abfd) goto punt; asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS; - asect->_raw_size = 4; + asect->size = 4; asect->vma = 0; asect->filepos = offset + CORE_WCOOKIE_OFFSET; asect->alignment_power = 2; Index: bfd/nlm32-alpha.c =================================================================== RCS file: /cvs/src/src/bfd/nlm32-alpha.c,v retrieving revision 1.10 diff -u -p -r1.10 nlm32-alpha.c --- bfd/nlm32-alpha.c 4 Dec 2003 12:08:42 -0000 1.10 +++ bfd/nlm32-alpha.c 22 Jun 2004 01:36:56 -0000 @@ -1,5 +1,5 @@ /* Support for 32-bit Alpha NLM (NetWare Loadable Module) - Copyright 1993, 1994, 2000, 2001, 2002, 2003 + Copyright 1993, 1994, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. @@ -490,7 +490,7 @@ nlm_alpha_read_reloc (abfd, sym, secp, r or .data section. R_NW_RELOC relocs don't really have a section, so we put them in .text. */ if (r_type == ALPHA_R_NW_RELOC - || r_vaddr < bfd_section_size (abfd, code_sec)) + || r_vaddr < code_sec->size) { *secp = code_sec; rel->address = r_vaddr; @@ -498,7 +498,7 @@ nlm_alpha_read_reloc (abfd, sym, secp, r else { *secp = data_sec; - rel->address = r_vaddr - bfd_section_size (abfd, code_sec); + rel->address = r_vaddr - code_sec->size; } /* We must adjust the addend based on the type. */ @@ -689,9 +689,7 @@ nlm_alpha_write_import (abfd, sec, rel) { r_vaddr = bfd_get_section_vma (abfd, sec) + rel->address; if ((sec->flags & SEC_CODE) == 0) - r_vaddr += bfd_section_size (abfd, - bfd_get_section_by_name (abfd, - NLM_CODE_NAME)); + r_vaddr += bfd_get_section_by_name (abfd, NLM_CODE_NAME) -> size; if (bfd_is_und_section (bfd_get_section (sym))) { r_extern = 1; @@ -791,7 +789,7 @@ nlm_alpha_set_public_section (abfd, sym) code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME); data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME); - if (sym->symbol.value < bfd_section_size (abfd, code_sec)) + if (sym->symbol.value < code_sec->size) { sym->symbol.section = code_sec; sym->symbol.flags |= BSF_FUNCTION; @@ -799,9 +797,9 @@ nlm_alpha_set_public_section (abfd, sym) else { sym->symbol.section = data_sec; - sym->symbol.value -= bfd_section_size (abfd, code_sec); + sym->symbol.value -= code_sec->size; /* The data segment had better be aligned. */ - BFD_ASSERT ((bfd_section_size (abfd, code_sec) & 0xf) == 0); + BFD_ASSERT ((code_sec->size & 0xf) == 0); } return TRUE; } Index: bfd/nlm32-ppc.c =================================================================== RCS file: /cvs/src/src/bfd/nlm32-ppc.c,v retrieving revision 1.8 diff -u -p -r1.8 nlm32-ppc.c --- bfd/nlm32-ppc.c 4 Nov 2003 10:41:52 -0000 1.8 +++ bfd/nlm32-ppc.c 22 Jun 2004 01:36:57 -0000 @@ -1,5 +1,5 @@ /* Support for 32-bit PowerPC NLM (NetWare Loadable Module) - Copyright 1994, 1995, 2000, 2001, 2002, 2003 + Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -621,7 +621,7 @@ nlm_powerpc_read_reloc (abfd, sym, secp, else if (l_rsecnm == 1) { *secp = data_sec; - l_vaddr -= bfd_section_size (abfd, code_sec); + l_vaddr -= code_sec->size; } else { @@ -858,7 +858,7 @@ nlm_powerpc_write_reloc (abfd, sec, rel, else if (sec == data_sec) { l_rsecnm = 1; - address += bfd_section_size (abfd, code_sec); + address += code_sec->size; } else { Index: bfd/nlm32-sparc.c =================================================================== RCS file: /cvs/src/src/bfd/nlm32-sparc.c,v retrieving revision 1.9 diff -u -p -r1.9 nlm32-sparc.c --- bfd/nlm32-sparc.c 4 Nov 2003 10:41:52 -0000 1.9 +++ bfd/nlm32-sparc.c 22 Jun 2004 01:36:57 -0000 @@ -1,5 +1,5 @@ /* Support for 32-bit SPARC NLM (NetWare Loadable Module) - Copyright 1993, 1994, 2000, 2001, 2002, 2003 + Copyright 1993, 1994, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -325,9 +325,9 @@ nlm_sparc_write_import (abfd, sec, rel) if (symsec == code) base = 0; else if (symsec == data) - base = bfd_section_size (abfd, code); + base = code->size; else if (symsec == bss) - base = bfd_section_size (abfd, code) + bfd_section_size (abfd, data); + base = code->size + data->size; else base = 0; Index: bfd/nlmcode.h =================================================================== RCS file: /cvs/src/src/bfd/nlmcode.h,v retrieving revision 1.11 diff -u -p -r1.11 nlmcode.h --- bfd/nlmcode.h 4 Nov 2003 10:41:52 -0000 1.11 +++ bfd/nlmcode.h 22 Jun 2004 01:36:58 -0000 @@ -1,5 +1,5 @@ /* NLM (NetWare Loadable Module) executable support for BFD. - Copyright 1993, 1994, 1995, 1998, 2000, 2001, 2002, 2003 + Copyright 1993, 1994, 1995, 1998, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Fred Fish @ Cygnus Support, using ELF support as the @@ -236,7 +236,7 @@ add_bfd_section (abfd, name, offset, siz return FALSE; newsect->vma = 0; /* NLM's are relocatable. */ - newsect->_raw_size = size; + newsect->size = size; newsect->filepos = offset; newsect->flags = flags; newsect->alignment_power = bfd_log2 ((bfd_vma) 0); /* FIXME */ @@ -630,7 +630,7 @@ nlm_swap_auxiliary_headers_in (abfd) newsec = bfd_make_section_anyway (abfd, name); if (newsec == (asection *) NULL) return FALSE; - newsec->_raw_size = size; + newsec->size = size; if (filepos != 0) { newsec->filepos = filepos; @@ -1437,12 +1437,12 @@ nlm_compute_section_file_positions (abfd { flagword f; - sec->_raw_size = BFD_ALIGN (sec->_raw_size, 1 << sec->alignment_power); + sec->size = BFD_ALIGN (sec->size, 1 << sec->alignment_power); f = bfd_get_section_flags (abfd, sec); if (f & SEC_CODE) { - text += sec->_raw_size; + text += sec->size; if (bfd_get_section_vma (abfd, sec) < text_low) text_low = bfd_get_section_vma (abfd, sec); if (sec->alignment_power > text_align) @@ -1450,7 +1450,7 @@ nlm_compute_section_file_positions (abfd } else if (f & SEC_DATA) { - data += sec->_raw_size; + data += sec->size; if (bfd_get_section_vma (abfd, sec) < data_low) data_low = bfd_get_section_vma (abfd, sec); if (sec->alignment_power > data_align) @@ -1462,7 +1462,7 @@ nlm_compute_section_file_positions (abfd other_align = sec->alignment_power; } else if (f & SEC_ALLOC) - bss += sec->_raw_size; + bss += sec->size; } nlm_set_text_low (abfd, text_low); @@ -1498,17 +1498,17 @@ nlm_compute_section_file_positions (abfd if (f & SEC_CODE) { sec->filepos = text_ptr; - text_ptr += sec->_raw_size; + text_ptr += sec->size; } else if (f & SEC_DATA) { sec->filepos = data_ptr; - data_ptr += sec->_raw_size; + data_ptr += sec->size; } else if (f & SEC_HAS_CONTENTS) { sec->filepos = other_ptr; - other_ptr += sec->_raw_size; + other_ptr += sec->size; } } @@ -1539,7 +1539,7 @@ nlm_compute_section_file_positions (abfd symbol (which is the old value of the symbol). */ sym->section = bss_sec; size = sym->value; - sym->value = bss_sec->_raw_size + add; + sym->value = bss_sec->size + add; add += size; add = BFD_ALIGN (add, 1 << bss_sec->alignment_power); } @@ -1552,7 +1552,7 @@ nlm_compute_section_file_positions (abfd abort (); } nlm_fixed_header (abfd)->uninitializedDataSize += add; - bss_sec->_raw_size += add; + bss_sec->size += add; } } Index: bfd/oasys.c =================================================================== RCS file: /cvs/src/src/bfd/oasys.c,v retrieving revision 1.23 diff -u -p -r1.23 oasys.c --- bfd/oasys.c 30 Apr 2004 14:23:40 -0000 1.23 +++ bfd/oasys.c 22 Jun 2004 01:36:59 -0000 @@ -507,7 +507,7 @@ oasys_object_p (abfd) BFD_FAIL (); } - s->_raw_size = H_GET_32 (abfd, record.section.value); + s->size = H_GET_32 (abfd, record.section.value); s->vma = H_GET_32 (abfd, record.section.vma); s->flags = 0; had_usefull = TRUE; @@ -657,7 +657,7 @@ oasys_slurp_section_data (abfd) if (! per->initialized) { - per->data = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size); + per->data = (bfd_byte *) bfd_zalloc (abfd, section->size); if (!per->data) return FALSE; per->reloc_tail_ptr @@ -1055,7 +1055,7 @@ oasys_write_sections (abfd) return FALSE; } out.relb = RELOCATION_TYPE_REL | s->target_index; - H_PUT_32 (abfd, s->_cooked_size, out.value); + H_PUT_32 (abfd, s->size, out.value); H_PUT_32 (abfd, s->vma, out.vma); if (! oasys_write_record (abfd, @@ -1159,7 +1159,7 @@ oasys_write_data (abfd) current_byte_index = 0; processed_data.relb = s->target_index | RELOCATION_TYPE_REL; - while (current_byte_index < s->_cooked_size) + while (current_byte_index < s->size) { /* Scan forwards by eight bytes or however much is left and see if there are any relocations going on */ @@ -1180,7 +1180,7 @@ oasys_write_data (abfd) 1 modification byte + 2 data = 8 bytes total). That's where the magic number 8 comes from. */ - while (current_byte_index < s->_raw_size && dst <= + while (current_byte_index < s->size && dst <= &processed_data.data[sizeof (processed_data.data) - 8]) { @@ -1355,7 +1355,7 @@ oasys_set_section_contents (abfd, sectio if (oasys_per_section (section)->data == (bfd_byte *) NULL) { oasys_per_section (section)->data = - (bfd_byte *) (bfd_alloc (abfd, section->_cooked_size)); + (bfd_byte *) (bfd_alloc (abfd, section->size)); if (!oasys_per_section (section)->data) return FALSE; } Index: bfd/opncls.c =================================================================== RCS file: /cvs/src/src/bfd/opncls.c,v retrieving revision 1.23 diff -u -p -r1.23 opncls.c --- bfd/opncls.c 23 Apr 2004 00:22:57 -0000 1.23 +++ bfd/opncls.c 22 Jun 2004 01:36:59 -0000 @@ -1,6 +1,6 @@ /* opncls.c -- open and close a BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, - 2001, 2002, 2003 + 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Cygnus Support. @@ -976,12 +976,10 @@ DESCRIPTION static char * get_debug_link_info (bfd *abfd, unsigned long *crc32_out) { - asection * sect; - bfd_size_type debuglink_size; + asection *sect; unsigned long crc32; - char * contents; + bfd_byte *contents; int crc_offset; - bfd_boolean ret; BFD_ASSERT (abfd); BFD_ASSERT (crc32_out); @@ -991,16 +989,10 @@ get_debug_link_info (bfd *abfd, unsigned if (sect == NULL) return NULL; - debuglink_size = bfd_section_size (abfd, sect); - - contents = malloc (debuglink_size); - if (contents == NULL) - return NULL; - - ret = bfd_get_section_contents (abfd, sect, contents, 0, debuglink_size); - if (! ret) + if (!bfd_malloc_and_get_section (abfd, sect, &contents)) { - free (contents); + if (contents != NULL) + free (contents); return NULL; } Index: bfd/osf-core.c =================================================================== RCS file: /cvs/src/src/bfd/osf-core.c,v retrieving revision 1.11 diff -u -p -r1.11 osf-core.c --- bfd/osf-core.c 15 Mar 2004 14:21:43 -0000 1.11 +++ bfd/osf-core.c 22 Jun 2004 01:36:59 -0000 @@ -56,11 +56,11 @@ struct osf_core_struct #define core_command(bfd) (core_hdr(bfd)->cmd) static asection * -make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) +make_bfd_asection (abfd, name, flags, size, vma, filepos) bfd *abfd; const char *name; flagword flags; - bfd_size_type _raw_size; + bfd_size_type size; bfd_vma vma; file_ptr filepos; { @@ -71,7 +71,7 @@ make_bfd_asection (abfd, name, flags, _r return NULL; asect->flags = flags; - asect->_raw_size = _raw_size; + asect->size = size; asect->vma = vma; asect->filepos = filepos; asect->alignment_power = 8; Index: bfd/pdp11.c =================================================================== RCS file: /cvs/src/src/bfd/pdp11.c,v retrieving revision 1.22 diff -u -p -r1.22 pdp11.c --- bfd/pdp11.c 15 Jun 2004 01:24:22 -0000 1.22 +++ bfd/pdp11.c 22 Jun 2004 01:37:02 -0000 @@ -741,8 +741,8 @@ NAME(aout,some_aout_object_p) (abfd, exe if (! NAME(aout,make_sections) (abfd)) return NULL; - obj_datasec (abfd)->_raw_size = execp->a_data; - obj_bsssec (abfd)->_raw_size = execp->a_bss; + obj_datasec (abfd)->size = execp->a_data; + obj_bsssec (abfd)->size = execp->a_bss; obj_textsec (abfd)->flags = (execp->a_trsize != 0 @@ -768,7 +768,6 @@ NAME(aout,some_aout_object_p) (abfd, exe struct exec *execp = exec_hdr (abfd); obj_textsec (abfd)->size = N_TXTSIZE(*execp); - obj_textsec (abfd)->raw_size = N_TXTSIZE(*execp); /* data and bss are already filled in since they're so standard */ /* The virtual memory addresses of the sections */ @@ -826,7 +825,7 @@ NAME(aout,some_aout_object_p) (abfd, exe if (execp->a_entry != 0 || (execp->a_entry >= obj_textsec(abfd)->vma - && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size)) + && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->size)) abfd->flags |= EXEC_P; #ifdef STAT_FOR_EXEC else @@ -1074,8 +1073,8 @@ adjust_o_magic (abfd, execp) else vma = obj_textsec (abfd)->vma; - pos += obj_textsec (abfd)->_raw_size; - vma += obj_textsec (abfd)->_raw_size; + pos += obj_textsec (abfd)->size; + vma += obj_textsec (abfd)->size; /* Data. */ if (!obj_datasec (abfd)->user_set_vma) @@ -1083,7 +1082,7 @@ adjust_o_magic (abfd, execp) #if 0 /* ?? Does alignment in the file image really matter? */ pad = align_power (vma, obj_datasec (abfd)->alignment_power) - vma; #endif - obj_textsec (abfd)->_raw_size += pad; + obj_textsec (abfd)->size += pad; pos += pad; vma += pad; obj_datasec (abfd)->vma = vma; @@ -1091,8 +1090,8 @@ adjust_o_magic (abfd, execp) else vma = obj_datasec (abfd)->vma; obj_datasec (abfd)->filepos = pos; - pos += obj_datasec (abfd)->_raw_size; - vma += obj_datasec (abfd)->_raw_size; + pos += obj_datasec (abfd)->size; + vma += obj_datasec (abfd)->size; /* BSS. */ if (! obj_bsssec (abfd)->user_set_vma) @@ -1100,7 +1099,7 @@ adjust_o_magic (abfd, execp) #if 0 pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma; #endif - obj_datasec (abfd)->_raw_size += pad; + obj_datasec (abfd)->size += pad; pos += pad; vma += pad; obj_bsssec (abfd)->vma = vma; @@ -1113,16 +1112,16 @@ adjust_o_magic (abfd, execp) pad = obj_bsssec (abfd)->vma - vma; if (pad > 0) { - obj_datasec (abfd)->_raw_size += pad; + obj_datasec (abfd)->size += pad; pos += pad; } } obj_bsssec (abfd)->filepos = pos; /* Fix up the exec header. */ - execp->a_text = obj_textsec (abfd)->_raw_size; - execp->a_data = obj_datasec (abfd)->_raw_size; - execp->a_bss = obj_bsssec (abfd)->_raw_size; + execp->a_text = obj_textsec (abfd)->size; + execp->a_data = obj_datasec (abfd)->size; + execp->a_bss = obj_bsssec (abfd)->size; N_SET_MAGIC (*execp, OMAGIC); } @@ -1172,7 +1171,7 @@ adjust_z_magic (abfd, execp) /* Find start of data. */ if (ztih) { - text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->_raw_size; + text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->size; text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end; } else @@ -1180,33 +1179,33 @@ adjust_z_magic (abfd, execp) /* Note that if page_size == zmagic_disk_block_size, then filepos == page_size, and this case is the same as the ztih case. */ - text_end = obj_textsec (abfd)->_raw_size; + text_end = obj_textsec (abfd)->size; text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end; text_end += obj_textsec (abfd)->filepos; } - obj_textsec (abfd)->_raw_size += text_pad; + obj_textsec (abfd)->size += text_pad; text_end += text_pad; /* Data. */ if (!obj_datasec(abfd)->user_set_vma) { bfd_vma vma; - vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size; + vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->size; obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size); } if (abdp && abdp->zmagic_mapped_contiguous) { text_pad = (obj_datasec(abfd)->vma - obj_textsec(abfd)->vma - - obj_textsec(abfd)->_raw_size); - obj_textsec(abfd)->_raw_size += text_pad; + - obj_textsec(abfd)->size); + obj_textsec(abfd)->size += text_pad; } obj_datasec (abfd)->filepos = (obj_textsec (abfd)->filepos - + obj_textsec (abfd)->_raw_size); + + obj_textsec (abfd)->size); /* Fix up exec header while we're at it. */ - execp->a_text = obj_textsec(abfd)->_raw_size; + execp->a_text = obj_textsec(abfd)->size; if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted))) execp->a_text += adata(abfd).exec_bytes_size; if (obj_aout_subformat (abfd) == q_magic_format) @@ -1215,17 +1214,17 @@ adjust_z_magic (abfd, execp) N_SET_MAGIC (*execp, ZMAGIC); /* Spec says data section should be rounded up to page boundary. */ - obj_datasec(abfd)->_raw_size - = align_power (obj_datasec(abfd)->_raw_size, + obj_datasec(abfd)->size + = align_power (obj_datasec(abfd)->size, obj_bsssec(abfd)->alignment_power); - execp->a_data = BFD_ALIGN (obj_datasec(abfd)->_raw_size, + execp->a_data = BFD_ALIGN (obj_datasec(abfd)->size, adata(abfd).page_size); - data_pad = execp->a_data - obj_datasec(abfd)->_raw_size; + data_pad = execp->a_data - obj_datasec(abfd)->size; /* BSS. */ if (!obj_bsssec(abfd)->user_set_vma) obj_bsssec(abfd)->vma = (obj_datasec(abfd)->vma - + obj_datasec(abfd)->_raw_size); + + obj_datasec(abfd)->size); /* If the BSS immediately follows the data section and extra space in the page is left after the data section, fudge data in the header so that the bss section looks smaller by that @@ -1234,11 +1233,11 @@ adjust_z_magic (abfd, execp) could have explicitly set the BSS vma to immediately follow the data section.) */ if (align_power (obj_bsssec(abfd)->vma, obj_bsssec(abfd)->alignment_power) - == obj_datasec(abfd)->vma + obj_datasec(abfd)->_raw_size) - execp->a_bss = (data_pad > obj_bsssec(abfd)->_raw_size) ? 0 : - obj_bsssec(abfd)->_raw_size - data_pad; + == obj_datasec(abfd)->vma + obj_datasec(abfd)->size) + execp->a_bss = (data_pad > obj_bsssec(abfd)->size) ? 0 : + obj_bsssec(abfd)->size - data_pad; else - execp->a_bss = obj_bsssec(abfd)->_raw_size; + execp->a_bss = obj_bsssec(abfd)->size; } static void @@ -1256,8 +1255,8 @@ adjust_n_magic (abfd, execp) obj_textsec(abfd)->vma = vma; else vma = obj_textsec(abfd)->vma; - pos += obj_textsec(abfd)->_raw_size; - vma += obj_textsec(abfd)->_raw_size; + pos += obj_textsec(abfd)->size; + vma += obj_textsec(abfd)->size; /* Data. */ obj_datasec(abfd)->filepos = pos; @@ -1266,10 +1265,10 @@ adjust_n_magic (abfd, execp) vma = obj_datasec(abfd)->vma; /* Since BSS follows data immediately, see if it needs alignment. */ - vma += obj_datasec(abfd)->_raw_size; + vma += obj_datasec(abfd)->size; pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma; - obj_datasec(abfd)->_raw_size += pad; - pos += obj_datasec(abfd)->_raw_size; + obj_datasec(abfd)->size += pad; + pos += obj_datasec(abfd)->size; /* BSS. */ if (!obj_bsssec(abfd)->user_set_vma) @@ -1278,9 +1277,9 @@ adjust_n_magic (abfd, execp) vma = obj_bsssec(abfd)->vma; /* Fix up exec header. */ - execp->a_text = obj_textsec(abfd)->_raw_size; - execp->a_data = obj_datasec(abfd)->_raw_size; - execp->a_bss = obj_bsssec(abfd)->_raw_size; + execp->a_text = obj_textsec(abfd)->size; + execp->a_data = obj_datasec(abfd)->size; + execp->a_bss = obj_bsssec(abfd)->size; N_SET_MAGIC (*execp, NMAGIC); } @@ -1298,11 +1297,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, if (adata(abfd).magic != undecided_magic) return TRUE; - obj_textsec(abfd)->_raw_size = - align_power(obj_textsec(abfd)->_raw_size, + obj_textsec(abfd)->size = + align_power(obj_textsec(abfd)->size, obj_textsec(abfd)->alignment_power); - *text_size = obj_textsec (abfd)->_raw_size; + *text_size = obj_textsec (abfd)->size; /* Rule (heuristic) for when to pad to a new page. Note that there are (at least) two ways demand-paged (ZMAGIC) files have been handled. Most Berkeley-based systems start the text segment at @@ -1336,11 +1335,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, } str; }), - obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size, + obj_textsec(abfd)->vma, obj_textsec(abfd)->size, obj_textsec(abfd)->alignment_power, - obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size, + obj_datasec(abfd)->vma, obj_datasec(abfd)->size, obj_datasec(abfd)->alignment_power, - obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size, + obj_bsssec(abfd)->vma, obj_bsssec(abfd)->size, obj_bsssec(abfd)->alignment_power); #endif #endif @@ -1362,11 +1361,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, #ifdef BFD_AOUT_DEBUG fprintf (stderr, " text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n", - obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size, + obj_textsec(abfd)->vma, obj_textsec(abfd)->size, obj_textsec(abfd)->filepos, - obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size, + obj_datasec(abfd)->vma, obj_datasec(abfd)->size, obj_datasec(abfd)->filepos, - obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size); + obj_bsssec(abfd)->vma, obj_bsssec(abfd)->size); #endif return TRUE; @@ -2314,7 +2313,7 @@ NAME(aout,squirt_out_relocs) (abfd, sect return TRUE; #endif - natsize = bfd_get_section_size (section); + natsize = section->size; native = (unsigned char *) bfd_zalloc (abfd, natsize); if (!native) return FALSE; @@ -3469,10 +3468,10 @@ NAME(aout,final_link) (abfd, info, callb if (bfd_get_flavour (sub) == bfd_target_aout_flavour) { - sz = bfd_section_size (sub, obj_textsec (sub)); + sz = obj_textsec (sub)->size; if (sz > max_contents_size) max_contents_size = sz; - sz = bfd_section_size (sub, obj_datasec (sub)); + sz = obj_datasec (sub)->size; if (sz > max_contents_size) max_contents_size = sz; @@ -4424,7 +4423,7 @@ aout_link_input_section (finfo, input_bf PTR relocs; /* Get the section contents. */ - input_size = bfd_section_size (input_bfd, input_section); + input_size = input_section->size; if (! bfd_get_section_contents (input_bfd, input_section, (PTR) finfo->contents, (file_ptr) 0, input_size)) Index: bfd/peXXigen.c =================================================================== RCS file: /cvs/src/src/bfd/peXXigen.c,v retrieving revision 1.24 diff -u -p -r1.24 peXXigen.c --- bfd/peXXigen.c 7 May 2004 15:08:49 -0000 1.24 +++ bfd/peXXigen.c 22 Jun 2004 01:37:03 -0000 @@ -189,8 +189,7 @@ _bfd_XXi_swap_sym_in (abfd, ext1, in1) sec->vma = 0; sec->lma = 0; - sec->_cooked_size = 0; - sec->_raw_size = 0; + sec->size = 0; sec->filepos = 0; sec->rel_filepos = 0; sec->reloc_count = 0; @@ -664,7 +663,7 @@ _bfd_XXi_swap_aouthdr_out (abfd, in, out for (sec = abfd->sections; sec; sec = sec->next) { - int rounded = FA(sec->_raw_size); + int rounded = FA(sec->size); /* The first non-zero section filepos is the header size. Sections without contents will have a filepos of 0. */ @@ -1109,7 +1108,6 @@ pe_print_idata (abfd, vfile) bfd_size_type datasize = 0; bfd_size_type dataoff; bfd_size_type i; - bfd_size_type amt; int onaline = 20; pe_data_type *pe = pe_data (abfd); @@ -1127,7 +1125,7 @@ pe_print_idata (abfd, vfile) return TRUE; addr = section->vma; - datasize = bfd_section_size (abfd, section); + datasize = section->size; if (datasize == 0) return TRUE; } @@ -1136,7 +1134,7 @@ pe_print_idata (abfd, vfile) addr += extra->ImageBase; for (section = abfd->sections; section != NULL; section = section->next) { - datasize = bfd_section_size (abfd, section); + datasize = section->size; if (addr >= section->vma && addr < section->vma + datasize) break; } @@ -1156,7 +1154,7 @@ pe_print_idata (abfd, vfile) datasize -= dataoff; #ifdef POWERPC_LE_PE - if (rel_section != 0 && bfd_section_size (abfd, rel_section) != 0) + if (rel_section != 0 && rel_section->size != 0) { /* The toc address can be found by taking the starting address, which on the PPC locates a function descriptor. The @@ -1168,16 +1166,15 @@ pe_print_idata (abfd, vfile) bfd_vma loadable_toc_address; bfd_vma toc_address; bfd_vma start_address; - bfd_byte *data = 0; + bfd_byte *data; int offset; - amt = bfd_section_size (abfd, rel_section); - data = (bfd_byte *) bfd_malloc (amt); - if (data == NULL && amt != 0) - return FALSE; - - bfd_get_section_contents (abfd, rel_section, (PTR) data, (bfd_vma) 0, - amt); + if (!bfd_malloc_and_get_section (abfd, rel_section, &data)) + { + if (data != NULL) + free (data); + return FALSE; + } offset = abfd->start_address - rel_section->vma; @@ -1191,6 +1188,8 @@ pe_print_idata (abfd, vfile) fprintf (file, _("\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"), start_address, loadable_toc_address, toc_address); + if (data != NULL) + free (data); } else { @@ -1207,14 +1206,13 @@ pe_print_idata (abfd, vfile) vma: Hint Time Forward DLL First\n\ Table Stamp Chain Name Thunk\n")); - amt = dataoff + datasize; - data = (bfd_byte *) bfd_malloc (amt); - if (data == NULL) - return FALSE; - /* Read the whole section. Some of the fields might be before dataoff. */ - if (! bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, amt)) - return FALSE; + if (!bfd_malloc_and_get_section (abfd, section, &data)) + { + if (data != NULL) + free (data); + return FALSE; + } adj = section->vma - extra->ImageBase; @@ -1281,7 +1279,7 @@ pe_print_idata (abfd, vfile) ft_section != NULL; ft_section = ft_section->next) { - ft_datasize = bfd_section_size (abfd, ft_section); + ft_datasize = ft_section->size; if (ft_addr >= ft_section->vma && ft_addr < ft_section->vma + ft_datasize) break; @@ -1411,7 +1409,7 @@ pe_print_edata (abfd, vfile) return TRUE; addr = section->vma; - datasize = bfd_section_size (abfd, section); + datasize = section->size; if (datasize == 0) return TRUE; } @@ -1421,7 +1419,7 @@ pe_print_edata (abfd, vfile) for (section = abfd->sections; section != NULL; section = section->next) { - datasize = bfd_section_size (abfd, section); + datasize = section->size; if (addr >= section->vma && addr < section->vma + datasize) break; @@ -1632,16 +1630,16 @@ pe_print_pdata (abfd, vfile) \t\tAddress Address Handler Data Address Mask\n")); #endif - datasize = bfd_section_size (abfd, section); + datasize = section->size; if (datasize == 0) return TRUE; - data = (bfd_byte *) bfd_malloc (datasize); - if (data == NULL && datasize != 0) - return FALSE; - - bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, - datasize); + if (!bfd_malloc_and_get_section (abfd, section, &data)) + { + if (data != NULL) + free (data); + return FALSE; + } start = 0; @@ -1751,23 +1749,23 @@ pe_print_reloc (abfd, vfile) if (section == NULL) return TRUE; - if (bfd_section_size (abfd, section) == 0) + if (section->size == 0) return TRUE; fprintf (file, _("\n\nPE File Base Relocations (interpreted .reloc section contents)\n")); - datasize = bfd_section_size (abfd, section); - data = (bfd_byte *) bfd_malloc (datasize); - if (data == NULL && datasize != 0) - return FALSE; - - bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, - datasize); + datasize = section->size; + if (!bfd_malloc_and_get_section (abfd, section, &data)) + { + if (data != NULL) + free (data); + return FALSE; + } start = 0; - stop = bfd_section_size (abfd, section); + stop = section->size; for (i = start; i < stop;) { Index: bfd/pef.c =================================================================== RCS file: /cvs/src/src/bfd/pef.c,v retrieving revision 1.7 diff -u -p -r1.7 pef.c --- bfd/pef.c 30 Apr 2004 14:23:40 -0000 1.7 +++ bfd/pef.c 22 Jun 2004 01:37:04 -0000 @@ -330,7 +330,7 @@ bfd_pef_make_bfd_section (abfd, section) bfdsec->vma = section->default_address + section->container_offset; bfdsec->lma = section->default_address + section->container_offset; - bfdsec->_raw_size = section->container_length; + bfdsec->size = section->container_length; bfdsec->filepos = section->container_offset; bfdsec->alignment_power = section->alignment; @@ -472,7 +472,7 @@ bfd_pef_print_loader_section (abfd, file if (loadersec == NULL) return -1; - loaderlen = bfd_section_size (abfd, loadersec); + loaderlen = loadersec->size; loaderbuf = (unsigned char *) bfd_malloc (loaderlen); if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0) { @@ -517,7 +517,7 @@ bfd_pef_scan_start_address (abfd) if (loadersec == NULL) goto end; - loaderlen = bfd_section_size (abfd, loadersec); + loaderlen = loadersec->size; loaderbuf = (unsigned char *) bfd_malloc (loaderlen); if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0) goto error; @@ -960,7 +960,7 @@ static long bfd_pef_parse_symbols (abfd, codesec = bfd_get_section_by_name (abfd, "code"); if (codesec != NULL) { - codelen = bfd_section_size (abfd, codesec); + codelen = codesec->size; codebuf = (unsigned char *) bfd_malloc (codelen); if (bfd_seek (abfd, codesec->filepos, SEEK_SET) < 0) goto end; @@ -971,7 +971,7 @@ static long bfd_pef_parse_symbols (abfd, loadersec = bfd_get_section_by_name (abfd, "loader"); if (loadersec != NULL) { - loaderlen = bfd_section_size (abfd, loadersec); + loaderlen = loadersec->size; loaderbuf = (unsigned char *) bfd_malloc (loaderlen); if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0) goto end; Index: bfd/ppcboot.c =================================================================== RCS file: /cvs/src/src/bfd/ppcboot.c,v retrieving revision 1.18 diff -u -p -r1.18 ppcboot.c --- bfd/ppcboot.c 17 May 2004 16:40:01 -0000 1.18 +++ bfd/ppcboot.c 22 Jun 2004 01:37:04 -0000 @@ -210,7 +210,7 @@ ppcboot_object_p (abfd) return NULL; sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_CODE | SEC_HAS_CONTENTS; sec->vma = 0; - sec->_raw_size = statbuf.st_size - sizeof (ppcboot_hdr_t); + sec->size = statbuf.st_size - sizeof (ppcboot_hdr_t); sec->filepos = sizeof (ppcboot_hdr_t); ppcboot_mkobject (abfd); @@ -311,7 +311,7 @@ ppcboot_canonicalize_symtab (abfd, aloca /* End symbol. */ syms[1].the_bfd = abfd; syms[1].name = mangle_name (abfd, "end"); - syms[1].value = sec->_raw_size; + syms[1].value = sec->size; syms[1].flags = BSF_GLOBAL; syms[1].section = sec; syms[1].udata.p = NULL; @@ -319,7 +319,7 @@ ppcboot_canonicalize_symtab (abfd, aloca /* Size symbol. */ syms[2].the_bfd = abfd; syms[2].name = mangle_name (abfd, "size"); - syms[2].value = sec->_raw_size; + syms[2].value = sec->size; syms[2].flags = BSF_GLOBAL; syms[2].section = bfd_abs_section_ptr; syms[2].udata.p = NULL; Index: bfd/ptrace-core.c =================================================================== RCS file: /cvs/src/src/bfd/ptrace-core.c,v retrieving revision 1.10 diff -u -p -r1.10 ptrace-core.c --- bfd/ptrace-core.c 15 Mar 2004 14:21:43 -0000 1.10 +++ bfd/ptrace-core.c 22 Jun 2004 01:37:04 -0000 @@ -108,9 +108,9 @@ ptrace_unix_core_file_p (abfd) core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; core_regsec (abfd)->flags = SEC_HAS_CONTENTS; - core_datasec (abfd)->_raw_size = u.pt_dsize; - core_stacksec (abfd)->_raw_size = u.pt_ssize; - core_regsec (abfd)->_raw_size = sizeof (u); + core_datasec (abfd)->size = u.pt_dsize; + core_stacksec (abfd)->size = u.pt_ssize; + core_regsec (abfd)->size = sizeof (u); core_datasec (abfd)->vma = u.pt_o_data_start; core_stacksec (abfd)->vma = USRSTACK - u.pt_ssize; Index: bfd/reloc.c =================================================================== RCS file: /cvs/src/src/bfd/reloc.c,v retrieving revision 1.103 diff -u -p -r1.103 reloc.c --- bfd/reloc.c 15 Jun 2004 01:24:22 -0000 1.103 +++ bfd/reloc.c 22 Jun 2004 01:37:06 -0000 @@ -587,6 +587,7 @@ bfd_perform_relocation (bfd *abfd, { bfd_vma relocation; bfd_reloc_status_type flag = bfd_reloc_ok; + bfd_size_type sz; bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); bfd_vma output_base = 0; reloc_howto_type *howto = reloc_entry->howto; @@ -623,8 +624,8 @@ bfd_perform_relocation (bfd *abfd, } /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > (input_section->_cooked_size - / bfd_octets_per_byte (abfd))) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz / bfd_octets_per_byte (abfd)) return bfd_reloc_outofrange; /* Work out which section the relocation is targeted at and the @@ -980,6 +981,7 @@ bfd_install_relocation (bfd *abfd, { bfd_vma relocation; bfd_reloc_status_type flag = bfd_reloc_ok; + bfd_size_type sz; bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); bfd_vma output_base = 0; reloc_howto_type *howto = reloc_entry->howto; @@ -1013,8 +1015,8 @@ bfd_install_relocation (bfd *abfd, } /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > (input_section->_cooked_size - / bfd_octets_per_byte (abfd))) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz / bfd_octets_per_byte (abfd)) return bfd_reloc_outofrange; /* Work out which section the relocation is targeted at and the @@ -1348,9 +1350,11 @@ _bfd_final_link_relocate (reloc_howto_ty bfd_vma addend) { bfd_vma relocation; + bfd_size_type sz; /* Sanity check the address. */ - if (address > input_section->_raw_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (address > sz) return bfd_reloc_outofrange; /* This function assumes that we are dealing with a basic relocation @@ -4176,8 +4180,7 @@ SYNOPSIS DESCRIPTION Provides default handling for relaxing for back ends which - don't do relaxing -- i.e., does nothing except make sure that the - final size of the section is set. + don't do relaxing. */ bfd_boolean @@ -4186,11 +4189,6 @@ bfd_generic_relax_section (bfd *abfd ATT struct bfd_link_info *link_info ATTRIBUTE_UNUSED, bfd_boolean *again) { - /* We're not relaxing the section, so just copy the size info if it's - zero. Someone else, like bfd_merge_sections, might have set it, so - don't overwrite a non-zero value. */ - if (section->_cooked_size == 0) - section->_cooked_size = section->_raw_size; *again = FALSE; return TRUE; } @@ -4269,6 +4267,7 @@ bfd_generic_get_relocated_section_conten long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); arelent **reloc_vector = NULL; long reloc_count; + bfd_size_type sz; if (reloc_size < 0) goto error_return; @@ -4278,20 +4277,10 @@ bfd_generic_get_relocated_section_conten goto error_return; /* Read in the section. */ - if (!bfd_get_section_contents (input_bfd, - input_section, - data, - 0, - input_section->_raw_size)) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (!bfd_get_section_contents (input_bfd, input_section, data, 0, sz)) goto error_return; - /* Don't set input_section->_cooked_size here. The caller has set - _cooked_size or called bfd_relax_section, which sets _cooked_size. - Despite using this generic relocation function, some targets perform - target-specific relaxation or string merging, which happens before - this function is called. We do not want to clobber the _cooked_size - they computed. */ - reloc_count = bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector, Index: bfd/reloc16.c =================================================================== RCS file: /cvs/src/src/bfd/reloc16.c,v retrieving revision 1.11 diff -u -p -r1.11 reloc16.c --- bfd/reloc16.c 30 Nov 2003 18:40:41 -0000 1.11 +++ bfd/reloc16.c 22 Jun 2004 01:37:06 -0000 @@ -1,6 +1,6 @@ /* 8 and 16 bit COFF relocation functions, for BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001, - 2002, 2003 Free Software Foundation, Inc. + 2002, 2003, 2004 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -230,7 +230,7 @@ bfd_coff_reloc16_relax_section (abfd, in free ((char *) shrinks); } - input_section->_cooked_size -= shrink; + input_section->size -= shrink; free ((char *) reloc_vector); return TRUE; } @@ -255,6 +255,7 @@ bfd_coff_reloc16_get_relocated_section_c long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); arelent **reloc_vector; long reloc_count; + bfd_size_type sz; if (reloc_size < 0) return NULL; @@ -267,11 +268,8 @@ bfd_coff_reloc16_get_relocated_section_c symbols); /* Read in the section. */ - if (!bfd_get_section_contents (input_bfd, - input_section, - data, - (bfd_vma) 0, - input_section->_raw_size)) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (!bfd_get_section_contents (input_bfd, input_section, data, 0, sz)) return NULL; reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size); Index: bfd/riscix.c =================================================================== RCS file: /cvs/src/src/bfd/riscix.c,v retrieving revision 1.9 diff -u -p -r1.9 riscix.c --- bfd/riscix.c 30 Nov 2002 08:39:40 -0000 1.9 +++ bfd/riscix.c 22 Jun 2004 01:37:07 -0000 @@ -1,5 +1,5 @@ /* BFD back-end for RISC iX (Acorn, arm) binaries. - Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 + Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) @@ -577,8 +577,8 @@ riscix_some_aout_object_p (abfd, execp, if (! NAME(aout,make_sections) (abfd)) return NULL; - obj_datasec (abfd)->_raw_size = execp->a_data; - obj_bsssec (abfd)->_raw_size = execp->a_bss; + obj_datasec (abfd)->size = execp->a_data; + obj_bsssec (abfd)->size = execp->a_bss; obj_textsec (abfd)->flags = (execp->a_trsize != 0 @@ -619,7 +619,7 @@ riscix_some_aout_object_p (abfd, execp, At some point we should probably break down and stat the file and declare it executable if (one of) its 'x' bits are on... */ if ((execp->a_entry >= obj_textsec(abfd)->vma) && - (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size)) + (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->size)) abfd->flags |= EXEC_P; #endif /* MACH */ if (result) Index: bfd/rs6000-core.c =================================================================== RCS file: /cvs/src/src/bfd/rs6000-core.c,v retrieving revision 1.13 diff -u -p -r1.13 rs6000-core.c --- bfd/rs6000-core.c 30 Nov 2002 08:39:40 -0000 1.13 +++ bfd/rs6000-core.c 22 Jun 2004 01:37:07 -0000 @@ -1,6 +1,6 @@ /* IBM RS/6000 "XCOFF" back-end for BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, - 2001, 2002 + 2001, 2002, 2004 Free Software Foundation, Inc. FIXME: Can someone provide a transliteration of this name into ASCII? Using the following chars caused a compiler warning on HIUX (so I replaced @@ -277,11 +277,11 @@ read_hdr (bfd *abfd, CoreHdr *core) } static asection * -make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) +make_bfd_asection (abfd, name, flags, size, vma, filepos) bfd *abfd; const char *name; flagword flags; - bfd_size_type _raw_size; + bfd_size_type size; bfd_vma vma; file_ptr filepos; { @@ -292,7 +292,7 @@ make_bfd_asection (abfd, name, flags, _r return NULL; asect->flags = flags; - asect->_raw_size = _raw_size; + asect->size = size; asect->vma = vma; asect->filepos = filepos; asect->alignment_power = 8; Index: bfd/sco5-core.c =================================================================== RCS file: /cvs/src/src/bfd/sco5-core.c,v retrieving revision 1.12 diff -u -p -r1.12 sco5-core.c --- bfd/sco5-core.c 5 May 2004 15:46:35 -0000 1.12 +++ bfd/sco5-core.c 22 Jun 2004 01:37:07 -0000 @@ -52,11 +52,11 @@ bfd_boolean sco5_core_file_matches_execu static void swap_abort PARAMS ((void)); static asection * -make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) +make_bfd_asection (abfd, name, flags, size, vma, filepos) bfd *abfd; const char *name; flagword flags; - bfd_size_type _raw_size; + bfd_size_type size; bfd_vma vma; file_ptr filepos; { @@ -66,7 +66,7 @@ make_bfd_asection (abfd, name, flags, _r if (!asect) return NULL; asect->flags = flags; - asect->_raw_size = _raw_size; + asect->size = size; asect->vma = vma; asect->filepos = filepos; asect->alignment_power = 2; Index: bfd/section.c =================================================================== RCS file: /cvs/src/src/bfd/section.c,v retrieving revision 1.72 diff -u -p -r1.72 section.c --- bfd/section.c 15 Jun 2004 01:24:22 -0000 1.72 +++ bfd/section.c 22 Jun 2004 01:37:08 -0000 @@ -421,13 +421,17 @@ CODE_FRAGMENT . . {* The size of the section in octets, as it will be output. . Contains a value even if the section has no contents (e.g., the -. size of <<.bss>>). This will be filled in after relocation. *} -. bfd_size_type _cooked_size; +. size of <<.bss>>). *} +. bfd_size_type size; . -. {* The original size on disk of the section, in octets. Normally this -. value is the same as the size, but if some relaxing has -. been done, then this value will be bigger. *} -. bfd_size_type _raw_size; +. {* The original size on disk of the section, in octets. This field +. is used by the linker relaxation code. It is currently only set +. for sections where the linker relaxation scheme doesn't cache +. altered section and reloc contents (stabs, eh_frame, SEC_MERGE), +. and thus the original size needs to be kept to read the section +. multiple times. If non-zero, rawsize will be used in address +. checks during relocation and to read section contents. *} +. bfd_size_type rawsize; . . {* If this section is going to be output, then this value is the . offset in *bytes* into the output section of the first byte in the @@ -617,10 +621,10 @@ static const asymbol global_syms[] = /* need_finalize_relax, reloc_done, */ \ 0, 0, \ \ - /* vma, lma, _cooked_size, _raw_size, */ \ - 0, 0, 0, 0, \ + /* vma, lma, size, rawsize */ \ + 0, 0, 0, 0, \ \ - /* output_offset, output_section, alignment_power, */ \ + /* output_offset, output_section, alignment_power, */ \ 0, (struct bfd_section *) &SEC, 0, \ \ /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \ @@ -1196,9 +1200,7 @@ bfd_set_section_size (bfd *abfd, sec_ptr return FALSE; } - ptr->_cooked_size = val; - ptr->_raw_size = val; - + ptr->size = val; return TRUE; } @@ -1244,7 +1246,7 @@ bfd_set_section_contents (bfd *abfd, return FALSE; } - sz = section->_cooked_size != 0 ? section->_cooked_size : section->_raw_size; + sz = section->size; if ((bfd_size_type) offset > sz || count > sz || offset + count > sz @@ -1324,7 +1326,7 @@ bfd_get_section_contents (bfd *abfd, return TRUE; } - sz = section->_raw_size; + sz = section->rawsize ? section->rawsize : section->size; if ((bfd_size_type) offset > sz || count > sz || offset + count > sz @@ -1356,6 +1358,36 @@ bfd_get_section_contents (bfd *abfd, /* FUNCTION + bfd_malloc_and_get_section + +SYNOPSIS + bfd_boolean bfd_malloc_and_get_section + (bfd *abfd, asection *section, bfd_byte **buf); + +DESCRIPTION + Read all data from @var{section} in BFD @var{abfd} + into a buffer, *@var{buf}, malloc'd by this function. +*/ + +bfd_boolean +bfd_malloc_and_get_section (bfd *abfd, sec_ptr sec, bfd_byte **buf) +{ + bfd_size_type sz = sec->rawsize ? sec->rawsize : sec->size; + bfd_byte *p = NULL; + + *buf = p; + if (sz == 0) + return TRUE; + + p = bfd_malloc (sz); + if (p == NULL) + return FALSE; + *buf = p; + + return bfd_get_section_contents (abfd, sec, p, 0, sz); +} +/* +FUNCTION bfd_copy_private_section_data SYNOPSIS Index: bfd/simple.c =================================================================== RCS file: /cvs/src/src/bfd/simple.c,v retrieving revision 1.15 diff -u -p -r1.15 simple.c --- bfd/simple.c 16 Apr 2004 03:29:13 -0000 1.15 +++ bfd/simple.c 22 Jun 2004 01:37:09 -0000 @@ -140,11 +140,10 @@ bfd_simple_get_relocated_section_content bfd_byte *contents, *data; int storage_needed; void *saved_offsets; - bfd_size_type old_cooked_size; if (! (sec->flags & SEC_RELOC)) { - bfd_size_type size = bfd_section_size (abfd, sec); + bfd_size_type size = sec->rawsize ? sec->rawsize : sec->size; if (outbuf == NULL) contents = bfd_malloc (size); @@ -176,13 +175,13 @@ bfd_simple_get_relocated_section_content link_order.next = NULL; link_order.type = bfd_indirect_link_order; link_order.offset = 0; - link_order.size = bfd_section_size (abfd, sec); + link_order.size = sec->size; link_order.u.indirect.section = sec; data = NULL; if (outbuf == NULL) { - data = bfd_malloc (bfd_section_size (abfd, sec)); + data = bfd_malloc (sec->size); if (data == NULL) return NULL; outbuf = data; @@ -218,12 +217,6 @@ bfd_simple_get_relocated_section_content else storage_needed = 0; - /* This function might be called before _cooked_size has been set, and - bfd_perform_relocation needs _cooked_size to be valid. */ - old_cooked_size = sec->_cooked_size; - if (old_cooked_size == 0) - sec->_cooked_size = sec->_raw_size; - contents = bfd_get_relocated_section_contents (abfd, &link_info, &link_order, @@ -247,7 +240,6 @@ bfd_simple_get_relocated_section_content free (symbol_table); #endif - sec->_cooked_size = old_cooked_size; bfd_map_over_sections (abfd, simple_restore_output_info, saved_offsets); free (saved_offsets); Index: bfd/som.c =================================================================== RCS file: /cvs/src/src/bfd/som.c,v retrieving revision 1.43 diff -u -p -r1.43 som.c --- bfd/som.c 17 May 2004 16:40:01 -0000 1.43 +++ bfd/som.c 22 Jun 2004 01:37:12 -0000 @@ -1836,7 +1836,7 @@ som_object_setup (abfd, file_hdrp, aux_h continue; entry = aux_hdrp->exec_entry; if (entry >= section->vma - && entry < section->vma + section->_cooked_size) + && entry < section->vma + section->size) found = 1; } if (aux_hdrp->exec_entry == 0 @@ -2098,8 +2098,7 @@ setup_sections (abfd, file_hdr, current_ save_subspace = subspace; subspace_asect->vma = subspace.subspace_start; - subspace_asect->_cooked_size = subspace.subspace_length; - subspace_asect->_raw_size = subspace.subspace_length; + subspace_asect->size = subspace.subspace_length; subspace_asect->filepos = (subspace.file_loc_init_value + current_offset); subspace_asect->alignment_power = exact_log2 (subspace.alignment); @@ -2110,21 +2109,13 @@ setup_sections (abfd, file_hdr, current_ /* This can happen for a .o which defines symbols in otherwise empty subspaces. */ if (!save_subspace.file_loc_init_value) - { - space_asect->_cooked_size = 0; - space_asect->_raw_size = 0; - } + space_asect->size = 0; else - { - /* Setup the sizes for the space section based upon the info in the - last subspace of the space. */ - space_asect->_cooked_size = (save_subspace.subspace_start - - space_asect->vma - + save_subspace.subspace_length); - space_asect->_raw_size = (save_subspace.file_loc_init_value - - space_asect->filepos - + save_subspace.initialization_length); - } + /* Setup the size for the space section based upon the info in the + last subspace of the space. */ + space_asect->size = (save_subspace.subspace_start + - space_asect->vma + + save_subspace.subspace_length); } /* Now that we've read in all the subspace records, we need to assign a target index to each subspace. */ @@ -2429,9 +2420,9 @@ som_prep_headers (abfd) som_section_data (section)->subspace_dict->subspace_start = section->vma; som_section_data (section)->subspace_dict->subspace_length = - bfd_section_size (abfd, section); + section->size; som_section_data (section)->subspace_dict->initialization_length = - bfd_section_size (abfd, section); + section->size; som_section_data (section)->subspace_dict->alignment = 1 << section->alignment_power; @@ -3069,8 +3060,7 @@ som_write_fixups (abfd, current_offset, /* Last BFD relocation for a subspace has been processed. Map the rest of the subspace with R_NO_RELOCATION fixups. */ - p = som_reloc_skip (abfd, (bfd_section_size (abfd, subsection) - - reloc_offset), + p = som_reloc_skip (abfd, subsection->size - reloc_offset, p, &subspace_reloc_size, reloc_queue); /* Scribble out the relocations. */ @@ -3611,22 +3601,22 @@ som_begin_writing (abfd) /* Update the size of the code & data. */ if (abfd->flags & (EXEC_P | DYNAMIC) && subsection->flags & SEC_CODE) - exec_header->exec_tsize += subsection->_cooked_size; + exec_header->exec_tsize += subsection->size; else if (abfd->flags & (EXEC_P | DYNAMIC) && subsection->flags & SEC_DATA) - exec_header->exec_dsize += subsection->_cooked_size; + exec_header->exec_dsize += subsection->size; som_section_data (subsection)->subspace_dict->file_loc_init_value = current_offset; subsection->filepos = current_offset; - current_offset += bfd_section_size (abfd, subsection); - subspace_offset += bfd_section_size (abfd, subsection); + current_offset += subsection->size; + subspace_offset += subsection->size; } /* Looks like uninitialized data. */ else { /* Update the size of the bss section. */ if (abfd->flags & (EXEC_P | DYNAMIC)) - exec_header->exec_bsize += subsection->_cooked_size; + exec_header->exec_bsize += subsection->size; som_section_data (subsection)->subspace_dict->file_loc_init_value = 0; @@ -3676,7 +3666,7 @@ som_begin_writing (abfd) som_section_data (subsection)->subspace_dict->file_loc_init_value = current_offset; subsection->filepos = current_offset; - current_offset += bfd_section_size (abfd, subsection); + current_offset += subsection->size; } /* Looks like uninitialized data. */ else @@ -3684,7 +3674,7 @@ som_begin_writing (abfd) som_section_data (subsection)->subspace_dict->file_loc_init_value = 0; som_section_data (subsection)->subspace_dict-> - initialization_length = bfd_section_size (abfd, subsection); + initialization_length = subsection->size; } } /* Goto the next section. */ @@ -4373,7 +4363,7 @@ bfd_section_from_som_symbol (abfd, symbo for (section = abfd->sections; section; section = section->next) { if (value >= section->vma - && value <= section->vma + section->_cooked_size + && value <= section->vma + section->size && som_is_subspace (section)) return section; } @@ -4963,16 +4953,16 @@ som_set_reloc_info (fixup, end, internal /* Got to read the damn contents first. We don't bother saving the contents (yet). Add it one day if the need arises. */ - section->contents = bfd_malloc (section->_raw_size); - if (section->contents == NULL) - return (unsigned) -1; - + bfd_bute *contents; + if (!bfd_malloc_and_get_section (section->owner, section, + &contents)) + { + if (contents != NULL) + free (contents); + return (unsigned) -1; + } + section->contents = contents; deallocate_contents = 1; - bfd_get_section_contents (section->owner, - section, - section->contents, - (bfd_vma) 0, - section->_raw_size); } else if (rptr->addend == 0) rptr->addend = bfd_get_32 (section->owner, @@ -5407,7 +5397,7 @@ som_get_section_contents (abfd, section, { if (count == 0 || ((section->flags & SEC_HAS_CONTENTS) == 0)) return TRUE; - if ((bfd_size_type) (offset+count) > section->_raw_size + if ((bfd_size_type) (offset+count) > section->size || bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0 || bfd_bread (location, count, abfd) != count) return FALSE; /* On error. */ @@ -6378,7 +6368,7 @@ som_bfd_link_split_section (abfd, sec) bfd *abfd ATTRIBUTE_UNUSED; asection *sec; { - return (som_is_subspace (sec) && sec->_raw_size > 240000); + return (som_is_subspace (sec) && sec->size > 240000); } #define som_close_and_cleanup som_bfd_free_cached_info Index: bfd/sparclinux.c =================================================================== RCS file: /cvs/src/src/bfd/sparclinux.c,v retrieving revision 1.13 diff -u -p -r1.13 sparclinux.c --- bfd/sparclinux.c 30 Nov 2003 18:40:41 -0000 1.13 +++ bfd/sparclinux.c 22 Jun 2004 01:37:12 -0000 @@ -1,6 +1,6 @@ /* BFD back-end for linux flavored sparc a.out binaries. - Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, + 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -317,7 +317,7 @@ linux_link_create_dynamic_sections (abfd || ! bfd_set_section_flags (abfd, s, flags) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; - s->_raw_size = 0; + s->size = 0; s->contents = 0; return TRUE; @@ -596,9 +596,9 @@ bfd_sparclinux_size_dynamic_sections (ou ".linux-dynamic"); if (s != NULL) { - s->_raw_size = linux_hash_table (info)->fixup_count + 1; - s->_raw_size *= 8; - s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size); + s->size = linux_hash_table (info)->fixup_count + 1; + s->size *= 8; + s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->size); if (s->contents == NULL) return FALSE; } @@ -763,7 +763,7 @@ linux_finish_dynamic_link (output_bfd, i SEEK_SET) != 0) return FALSE; - if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd) != s->_raw_size) + if (bfd_bwrite ((PTR) s->contents, s->size, output_bfd) != s->size) return FALSE; return TRUE; Index: bfd/srec.c =================================================================== RCS file: /cvs/src/src/bfd/srec.c,v retrieving revision 1.28 diff -u -p -r1.28 srec.c --- bfd/srec.c 30 Apr 2004 14:23:40 -0000 1.28 +++ bfd/srec.c 22 Jun 2004 01:37:13 -0000 @@ -564,11 +564,11 @@ srec_scan (abfd) bytes -= 2; if (sec != NULL - && sec->vma + sec->_raw_size == address) + && sec->vma + sec->size == address) { /* This data goes at the end of the section we are currently building. */ - sec->_raw_size += bytes; + sec->size += bytes; } else { @@ -586,7 +586,7 @@ srec_scan (abfd) sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC; sec->vma = address; sec->lma = address; - sec->_raw_size = bytes; + sec->size = bytes; sec->filepos = pos; } @@ -763,7 +763,7 @@ srec_read_section (abfd, section, conten switch (hdr[0]) { default: - BFD_ASSERT (sofar == section->_raw_size); + BFD_ASSERT (sofar == section->size); if (buf != NULL) free (buf); return TRUE; @@ -788,7 +788,7 @@ srec_read_section (abfd, section, conten if (address != section->vma + sofar) { /* We've come to the end of this section. */ - BFD_ASSERT (sofar == section->_raw_size); + BFD_ASSERT (sofar == section->size); if (buf != NULL) free (buf); return TRUE; @@ -811,7 +811,7 @@ srec_read_section (abfd, section, conten if (error) goto error_return; - BFD_ASSERT (sofar == section->_raw_size); + BFD_ASSERT (sofar == section->size); if (buf != NULL) free (buf); @@ -836,8 +836,8 @@ srec_get_section_contents (abfd, section { if (section->used_by_bfd == NULL) { - section->used_by_bfd = bfd_alloc (abfd, section->_raw_size); - if (section->used_by_bfd == NULL && section->_raw_size != 0) + section->used_by_bfd = bfd_alloc (abfd, section->size); + if (section->used_by_bfd == NULL && section->size != 0) return FALSE; if (! srec_read_section (abfd, section, section->used_by_bfd)) Index: bfd/stabs.c =================================================================== RCS file: /cvs/src/src/bfd/stabs.c,v retrieving revision 1.18 diff -u -p -r1.18 stabs.c --- bfd/stabs.c 1 Apr 2004 08:40:05 -0000 1.18 +++ bfd/stabs.c 22 Jun 2004 01:37:14 -0000 @@ -194,14 +194,14 @@ _bfd_link_section_stabs (abfd, psinfo, s bfd_size_type stroff, next_stroff, skip; bfd_size_type *pstridx; - if (stabsec->_raw_size == 0 - || stabstrsec->_raw_size == 0) + if (stabsec->size == 0 + || stabstrsec->size == 0) { /* This file does not contain stabs debugging information. */ return TRUE; } - if (stabsec->_raw_size % STABSIZE != 0) + if (stabsec->size % STABSIZE != 0) { /* Something is wrong with the format of these stab symbols. Don't try to optimize them. */ @@ -254,7 +254,7 @@ _bfd_link_section_stabs (abfd, psinfo, s /* Initialize the information we are going to store for this .stab section. */ - count = stabsec->_raw_size / STABSIZE; + count = stabsec->size / STABSIZE; amt = sizeof (struct stab_section_info); amt += (count - 1) * sizeof (bfd_size_type); @@ -264,20 +264,14 @@ _bfd_link_section_stabs (abfd, psinfo, s secinfo = (struct stab_section_info *) *psecinfo; secinfo->excls = NULL; + stabsec->rawsize = stabsec->size; secinfo->cumulative_skips = NULL; memset (secinfo->stridxs, 0, (size_t) count * sizeof (bfd_size_type)); /* Read the stabs information from abfd. */ - stabbuf = (bfd_byte *) bfd_malloc (stabsec->_raw_size); - stabstrbuf = (bfd_byte *) bfd_malloc (stabstrsec->_raw_size); - if (stabbuf == NULL || stabstrbuf == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, stabsec, stabbuf, (bfd_vma) 0, - stabsec->_raw_size) - || ! bfd_get_section_contents (abfd, stabstrsec, stabstrbuf, (bfd_vma) 0, - stabstrsec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, stabsec, &stabbuf) + || !bfd_malloc_and_get_section (abfd, stabstrsec, &stabstrbuf)) goto error_return; /* Look through the stabs symbols, work out the new string indices, @@ -291,7 +285,7 @@ _bfd_link_section_stabs (abfd, psinfo, s next_stroff = pstring_offset ? *pstring_offset : 0; skip = 0; - symend = stabbuf + stabsec->_raw_size; + symend = stabbuf + stabsec->size; for (sym = stabbuf, pstridx = secinfo->stridxs; sym < symend; sym += STABSIZE, ++pstridx) @@ -327,7 +321,7 @@ _bfd_link_section_stabs (abfd, psinfo, s /* Store the string in the hash table, and record the index. */ symstroff = stroff + bfd_get_32 (abfd, sym + STRDXOFF); - if (symstroff >= stabstrsec->_raw_size) + if (symstroff >= stabstrsec->size) { (*_bfd_error_handler) (_("%s(%s+0x%lx): Stabs entry has invalid string index."), @@ -513,11 +507,11 @@ _bfd_link_section_stabs (abfd, psinfo, s from the link. We record the size of the strtab in the first .stabstr section we saw, and make sure we don't set SEC_EXCLUDE for that section. */ - stabsec->_cooked_size = (count - skip) * STABSIZE; - if (stabsec->_cooked_size == 0) + stabsec->size = (count - skip) * STABSIZE; + if (stabsec->size == 0) stabsec->flags |= SEC_EXCLUDE; stabstrsec->flags |= SEC_EXCLUDE; - sinfo->stabstr->_cooked_size = _bfd_stringtab_size (sinfo->strings); + sinfo->stabstr->size = _bfd_stringtab_size (sinfo->strings); /* Calculate the `cumulative_skips' array now that stabs have been deleted for this section. */ @@ -555,7 +549,6 @@ _bfd_link_section_stabs (abfd, psinfo, s free (stabstrbuf); return FALSE; } - /* This function is called for each input file before the stab section is relocated. It discards stab entries for discarded @@ -580,13 +573,13 @@ _bfd_discard_section_stabs (abfd, stabse bfd_size_type *pstridx; int deleting; - if (stabsec->_raw_size == 0) + if (stabsec->size == 0) { /* This file does not contain stabs debugging information. */ return FALSE; } - if (stabsec->_raw_size % STABSIZE != 0) + if (stabsec->size % STABSIZE != 0) { /* Something is wrong with the format of these stab symbols. Don't try to optimize them. */ @@ -607,17 +600,12 @@ _bfd_discard_section_stabs (abfd, stabse if (psecinfo == NULL) return FALSE; - count = stabsec->_raw_size / STABSIZE; + count = stabsec->rawsize / STABSIZE; secinfo = (struct stab_section_info *) psecinfo; /* Read the stabs information from abfd. */ - stabbuf = (bfd_byte *) bfd_malloc (stabsec->_raw_size); - if (stabbuf == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, stabsec, stabbuf, (bfd_vma) 0, - stabsec->_raw_size)) + if (!bfd_malloc_and_get_section (abfd, stabsec, &stabbuf)) goto error_return; /* Look through the stabs symbols and discard any information for @@ -626,7 +614,7 @@ _bfd_discard_section_stabs (abfd, stabse skip = 0; deleting = -1; - symend = stabbuf + stabsec->_raw_size; + symend = stabbuf + stabsec->rawsize; for (sym = stabbuf, pstridx = secinfo->stridxs; sym < symend; sym += STABSIZE, ++pstridx) @@ -684,8 +672,8 @@ _bfd_discard_section_stabs (abfd, stabse stabbuf = NULL; /* Shrink the stabsec as needed. */ - stabsec->_cooked_size -= skip * STABSIZE; - if (stabsec->_cooked_size == 0) + stabsec->size -= skip * STABSIZE; + if (stabsec->size == 0) stabsec->flags |= SEC_EXCLUDE; /* Recalculate the `cumulative_skips' array now that stabs have been @@ -748,16 +736,15 @@ _bfd_write_section_stabs (output_bfd, ps if (secinfo == NULL) return bfd_set_section_contents (output_bfd, stabsec->output_section, - contents, - (file_ptr) stabsec->output_offset, - stabsec->_raw_size); + contents, stabsec->output_offset, + stabsec->size); /* Handle each N_BINCL entry. */ for (e = secinfo->excls; e != NULL; e = e->next) { bfd_byte *excl_sym; - BFD_ASSERT (e->offset < stabsec->_raw_size); + BFD_ASSERT (e->offset < stabsec->rawsize); excl_sym = contents + e->offset; bfd_put_32 (output_bfd, e->val, excl_sym + VALOFF); excl_sym[TYPEOFF] = e->type; @@ -766,7 +753,7 @@ _bfd_write_section_stabs (output_bfd, ps /* Copy over all the stabs symbols, omitting the ones we don't want, and correcting the string indices for those we do want. */ tosym = contents; - symend = contents + stabsec->_raw_size; + symend = contents + stabsec->rawsize; for (sym = contents, pstridx = secinfo->stridxs; sym < symend; sym += STABSIZE, ++pstridx) @@ -787,7 +774,7 @@ _bfd_write_section_stabs (output_bfd, ps bfd_put_32 (output_bfd, _bfd_stringtab_size (sinfo->strings), tosym + VALOFF); bfd_put_16 (output_bfd, - stabsec->output_section->_raw_size / STABSIZE - 1, + stabsec->output_section->size / STABSIZE - 1, tosym + DESCOFF); } @@ -795,11 +782,11 @@ _bfd_write_section_stabs (output_bfd, ps } } - BFD_ASSERT ((bfd_size_type) (tosym - contents) == stabsec->_cooked_size); + BFD_ASSERT ((bfd_size_type) (tosym - contents) == stabsec->size); return bfd_set_section_contents (output_bfd, stabsec->output_section, contents, (file_ptr) stabsec->output_offset, - stabsec->_cooked_size); + stabsec->size); } /* Write out the .stabstr section. */ @@ -824,7 +811,7 @@ _bfd_write_stab_strings (output_bfd, psi BFD_ASSERT ((sinfo->stabstr->output_offset + _bfd_stringtab_size (sinfo->strings)) - <= sinfo->stabstr->output_section->_raw_size); + <= sinfo->stabstr->output_section->size); if (bfd_seek (output_bfd, (file_ptr) (sinfo->stabstr->output_section->filepos @@ -847,22 +834,20 @@ _bfd_write_stab_strings (output_bfd, psi or -1 if the address refers to a stab which has been removed. */ bfd_vma -_bfd_stab_section_offset (output_bfd, psinfo, stabsec, psecinfo, offset) - bfd *output_bfd ATTRIBUTE_UNUSED; - PTR *psinfo ATTRIBUTE_UNUSED; +_bfd_stab_section_offset (stabsec, psecinfo, offset) asection *stabsec; - PTR *psecinfo; + PTR psecinfo; bfd_vma offset; { struct stab_section_info *secinfo; - secinfo = (struct stab_section_info *) *psecinfo; + secinfo = (struct stab_section_info *) psecinfo; if (secinfo == NULL) return offset; - if (offset >= stabsec->_raw_size) - return offset - (stabsec->_cooked_size - stabsec->_raw_size); + if (offset >= stabsec->rawsize) + return offset - stabsec->rawsize + stabsec->size; if (secinfo->cumulative_skips) { Index: bfd/sunos.c =================================================================== RCS file: /cvs/src/src/bfd/sunos.c,v retrieving revision 1.14 diff -u -p -r1.14 sunos.c --- bfd/sunos.c 22 Apr 2004 14:45:31 -0000 1.14 +++ bfd/sunos.c 22 Jun 2004 01:37:15 -0000 @@ -1,6 +1,6 @@ /* BFD backend for SunOS binaries. Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000, 2001, - 2002, 2003 Free Software Foundation, Inc. + 2002, 2003, 2004 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -197,7 +197,7 @@ sunos_read_dynamic_info (abfd) else dynsec = obj_datasec (abfd); dynoff -= bfd_get_section_vma (abfd, dynsec); - if (dynoff > bfd_section_size (abfd, dynsec)) + if (dynoff > dynsec->size) return TRUE; /* This executable appears to be dynamically linked in a way that we @@ -854,8 +854,8 @@ sunos_create_dynamic_sections (abfd, inf dynobj = sunos_hash_table (info)->dynobj; s = bfd_get_section_by_name (dynobj, ".got"); - if (s->_raw_size == 0) - s->_raw_size = BYTES_IN_WORD; + if (s->size == 0) + s->size = BYTES_IN_WORD; sunos_hash_table (info)->dynamic_sections_needed = TRUE; sunos_hash_table (info)->got_needed = TRUE; @@ -1378,7 +1378,7 @@ bfd_sunos_size_dynamic_sections (output_ so that 13 bit relocations have a greater chance of working. */ s = bfd_get_section_by_name (dynobj, ".got"); BFD_ASSERT (s != NULL); - if (s->_raw_size >= 0x1000) + if (s->size >= 0x1000) h->root.root.u.def.value = 0x1000; else h->root.root.u.def.value = 0; @@ -1395,7 +1395,7 @@ bfd_sunos_size_dynamic_sections (output_ /* The .dynamic section is always the same size. */ s = *sdynptr; BFD_ASSERT (s != NULL); - s->_raw_size = (sizeof (struct external_sun4_dynamic) + s->size = (sizeof (struct external_sun4_dynamic) + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE + sizeof (struct external_sun4_dynamic_link)); @@ -1409,9 +1409,9 @@ bfd_sunos_size_dynamic_sections (output_ sunos_scan_dynamic_symbol. */ s = bfd_get_section_by_name (dynobj, ".dynsym"); BFD_ASSERT (s != NULL); - s->_raw_size = dynsymcount * sizeof (struct external_nlist); - s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) + s->size = dynsymcount * sizeof (struct external_nlist); + s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->size); + if (s->contents == NULL && s->size != 0) return FALSE; /* The number of buckets is just the number of symbols divided @@ -1436,7 +1436,7 @@ bfd_sunos_size_dynamic_sections (output_ return FALSE; for (i = 0; i < bucketcount; i++) PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE); - s->_raw_size = bucketcount * HASH_ENTRY_SIZE; + s->size = bucketcount * HASH_ENTRY_SIZE; sunos_hash_table (info)->bucketcount = bucketcount; @@ -1454,19 +1454,19 @@ bfd_sunos_size_dynamic_sections (output_ important, but it can't hurt much. */ s = bfd_get_section_by_name (dynobj, ".dynstr"); BFD_ASSERT (s != NULL); - if ((s->_raw_size & 7) != 0) + if ((s->size & 7) != 0) { bfd_size_type add; bfd_byte *contents; - add = 8 - (s->_raw_size & 7); + add = 8 - (s->size & 7); contents = (bfd_byte *) bfd_realloc (s->contents, - s->_raw_size + add); + s->size + add); if (contents == NULL) return FALSE; - memset (contents + s->_raw_size, 0, (size_t) add); + memset (contents + s->size, 0, (size_t) add); s->contents = contents; - s->_raw_size += add; + s->size += add; } } @@ -1474,9 +1474,9 @@ bfd_sunos_size_dynamic_sections (output_ table and the dynamic relocs, allocate storage for them. */ s = bfd_get_section_by_name (dynobj, ".plt"); BFD_ASSERT (s != NULL); - if (s->_raw_size != 0) + if (s->size != 0) { - s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_alloc (dynobj, s->size); if (s->contents == NULL) return FALSE; @@ -1497,9 +1497,9 @@ bfd_sunos_size_dynamic_sections (output_ } s = bfd_get_section_by_name (dynobj, ".dynrel"); - if (s->_raw_size != 0) + if (s->size != 0) { - s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_alloc (dynobj, s->size); if (s->contents == NULL) return FALSE; } @@ -1509,7 +1509,7 @@ bfd_sunos_size_dynamic_sections (output_ /* Make space for the global offset table. */ s = bfd_get_section_by_name (dynobj, ".got"); - s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size); + s->contents = (bfd_byte *) bfd_alloc (dynobj, s->size); if (s->contents == NULL) return FALSE; @@ -1683,8 +1683,8 @@ sunos_scan_std_relocs (info, abfd, sec, sgot = bfd_get_section_by_name (dynobj, ".got"); BFD_ASSERT (sgot != NULL); - if (sgot->_raw_size == 0) - sgot->_raw_size = BYTES_IN_WORD; + if (sgot->size == 0) + sgot->size = BYTES_IN_WORD; sunos_hash_table (info)->got_needed = TRUE; } @@ -1703,7 +1703,7 @@ sunos_scan_std_relocs (info, abfd, sec, { /* Presumably this symbol was marked as being undefined by an earlier reloc. */ - srel->_raw_size += RELOC_STD_SIZE; + srel->size += RELOC_STD_SIZE; } else if ((h->root.root.u.def.section->flags & SEC_CODE) == 0) { @@ -1712,7 +1712,7 @@ sunos_scan_std_relocs (info, abfd, sec, /* This reloc is not in the .text section. It must be copied into the dynamic relocs. We mark the symbol as being undefined. */ - srel->_raw_size += RELOC_STD_SIZE; + srel->size += RELOC_STD_SIZE; sub = h->root.root.u.def.section->owner; h->root.root.type = bfd_link_hash_undefined; h->root.root.u.undef.abfd = sub; @@ -1726,21 +1726,21 @@ sunos_scan_std_relocs (info, abfd, sec, be handled correctly. */ if (h->plt_offset == 0) { - if (splt->_raw_size == 0) - splt->_raw_size = M68K_PLT_ENTRY_SIZE; - h->plt_offset = splt->_raw_size; + if (splt->size == 0) + splt->size = M68K_PLT_ENTRY_SIZE; + h->plt_offset = splt->size; if ((h->flags & SUNOS_DEF_REGULAR) == 0) { h->root.root.u.def.section = splt; - h->root.root.u.def.value = splt->_raw_size; + h->root.root.u.def.value = splt->size; } - splt->_raw_size += M68K_PLT_ENTRY_SIZE; + splt->size += M68K_PLT_ENTRY_SIZE; /* We may also need a dynamic reloc entry. */ if ((h->flags & SUNOS_DEF_REGULAR) == 0) - srel->_raw_size += RELOC_STD_SIZE; + srel->size += RELOC_STD_SIZE; } } } @@ -1837,8 +1837,8 @@ sunos_scan_ext_relocs (info, abfd, sec, BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL); /* Make sure we have an initial entry in the .got table. */ - if (sgot->_raw_size == 0) - sgot->_raw_size = BYTES_IN_WORD; + if (sgot->size == 0) + sgot->size = BYTES_IN_WORD; sunos_hash_table (info)->got_needed = TRUE; } @@ -1847,7 +1847,7 @@ sunos_scan_ext_relocs (info, abfd, sec, if (h->got_offset != 0) continue; - h->got_offset = sgot->_raw_size; + h->got_offset = sgot->size; } else { @@ -1871,10 +1871,10 @@ sunos_scan_ext_relocs (info, abfd, sec, if (adata (abfd).local_got_offsets[r_index] != 0) continue; - adata (abfd).local_got_offsets[r_index] = sgot->_raw_size; + adata (abfd).local_got_offsets[r_index] = sgot->size; } - sgot->_raw_size += BYTES_IN_WORD; + sgot->size += BYTES_IN_WORD; /* If we are making a shared library, or if the symbol is defined by a dynamic object, we will need a dynamic reloc @@ -1883,7 +1883,7 @@ sunos_scan_ext_relocs (info, abfd, sec, || (h != NULL && (h->flags & SUNOS_DEF_DYNAMIC) != 0 && (h->flags & SUNOS_DEF_REGULAR) == 0)) - srel->_raw_size += RELOC_EXT_SIZE; + srel->size += RELOC_EXT_SIZE; continue; } @@ -1908,7 +1908,7 @@ sunos_scan_ext_relocs (info, abfd, sec, BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL); } - srel->_raw_size += RELOC_EXT_SIZE; + srel->size += RELOC_EXT_SIZE; } continue; @@ -1955,8 +1955,8 @@ sunos_scan_ext_relocs (info, abfd, sec, BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL); /* Make sure we have an initial entry in the .got table. */ - if (sgot->_raw_size == 0) - sgot->_raw_size = BYTES_IN_WORD; + if (sgot->size == 0) + sgot->size = BYTES_IN_WORD; sunos_hash_table (info)->got_needed = TRUE; } @@ -1980,7 +1980,7 @@ sunos_scan_ext_relocs (info, abfd, sec, { /* Presumably this symbol was marked as being undefined by an earlier reloc. */ - srel->_raw_size += RELOC_EXT_SIZE; + srel->size += RELOC_EXT_SIZE; } else if (r_type != RELOC_JMP_TBL && (h->root.root.u.def.section->flags & SEC_CODE) == 0) @@ -1990,7 +1990,7 @@ sunos_scan_ext_relocs (info, abfd, sec, /* This reloc is not in the .text section. It must be copied into the dynamic relocs. We mark the symbol as being undefined. */ - srel->_raw_size += RELOC_EXT_SIZE; + srel->size += RELOC_EXT_SIZE; if ((h->flags & SUNOS_DEF_REGULAR) == 0) { sub = h->root.root.u.def.section->owner; @@ -2007,31 +2007,31 @@ sunos_scan_ext_relocs (info, abfd, sec, be handled correctly. */ if (h->plt_offset == 0) { - if (splt->_raw_size == 0) - splt->_raw_size = SPARC_PLT_ENTRY_SIZE; - h->plt_offset = splt->_raw_size; + if (splt->size == 0) + splt->size = SPARC_PLT_ENTRY_SIZE; + h->plt_offset = splt->size; if ((h->flags & SUNOS_DEF_REGULAR) == 0) { if (h->root.root.type == bfd_link_hash_undefined) h->root.root.type = bfd_link_hash_defined; h->root.root.u.def.section = splt; - h->root.root.u.def.value = splt->_raw_size; + h->root.root.u.def.value = splt->size; } - splt->_raw_size += SPARC_PLT_ENTRY_SIZE; + splt->size += SPARC_PLT_ENTRY_SIZE; /* We will also need a dynamic reloc entry, unless this is a JMP_TBL reloc produced by linking PIC compiled code, and we are not making a shared library. */ if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0) - srel->_raw_size += RELOC_EXT_SIZE; + srel->size += RELOC_EXT_SIZE; } /* If we are creating a shared library, we need to copy over any reloc other than a jump table reloc. */ if (info->shared && r_type != RELOC_JMP_TBL) - srel->_raw_size += RELOC_EXT_SIZE; + srel->size += RELOC_EXT_SIZE; } } @@ -2120,14 +2120,14 @@ sunos_scan_dynamic_symbol (h, data) s = bfd_get_section_by_name (dynobj, ".dynstr"); BFD_ASSERT (s != NULL); contents = (bfd_byte *) bfd_realloc (s->contents, - s->_raw_size + len + 1); + s->size + len + 1); if (contents == NULL) return FALSE; s->contents = contents; - h->dynstr_index = s->_raw_size; - strcpy ((char *) contents + s->_raw_size, h->root.root.root.string); - s->_raw_size += len + 1; + h->dynstr_index = s->size; + strcpy ((char *) contents + s->size, h->root.root.root.string); + s->size += len + 1; /* Add it to the dynamic hash table. */ name = (unsigned char *) h->root.root.root.string; @@ -2150,11 +2150,11 @@ sunos_scan_dynamic_symbol (h, data) (s->contents + hash * HASH_ENTRY_SIZE + BYTES_IN_WORD)); - PUT_WORD (dynobj, s->_raw_size / HASH_ENTRY_SIZE, + PUT_WORD (dynobj, s->size / HASH_ENTRY_SIZE, s->contents + hash * HASH_ENTRY_SIZE + BYTES_IN_WORD); - PUT_WORD (dynobj, h->dynindx, s->contents + s->_raw_size); - PUT_WORD (dynobj, next, s->contents + s->_raw_size + BYTES_IN_WORD); - s->_raw_size += HASH_ENTRY_SIZE; + PUT_WORD (dynobj, h->dynindx, s->contents + s->size); + PUT_WORD (dynobj, next, s->contents + s->size + BYTES_IN_WORD); + s->size += HASH_ENTRY_SIZE; } } @@ -2255,7 +2255,7 @@ sunos_write_dynamic_symbol (output_bfd, { BFD_ASSERT (h->dynindx >= 0); BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) - < s->_raw_size); + < s->size); p = s->contents + s->reloc_count * obj_reloc_entry_size (output_bfd); if (obj_reloc_entry_size (output_bfd) == RELOC_STD_SIZE) { @@ -2562,7 +2562,7 @@ sunos_check_dynamic_reloc (info, input_b s = bfd_get_section_by_name (dynobj, ".dynrel"); BFD_ASSERT (s != NULL); BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) - < s->_raw_size); + < s->size); p = (s->contents + s->reloc_count * obj_reloc_entry_size (dynobj)); @@ -2691,7 +2691,7 @@ sunos_check_dynamic_reloc (info, input_b s = bfd_get_section_by_name (dynobj, ".dynrel"); BFD_ASSERT (s != NULL); - BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->_raw_size); + BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->size); p = s->contents + s->reloc_count * obj_reloc_entry_size (dynobj); @@ -2797,7 +2797,7 @@ sunos_finish_dynamic_link (abfd, info) real addresses. Now that we know the section location, we can fill in the final values. */ s = bfd_get_section_by_name (dynobj, ".need"); - if (s != NULL && s->_raw_size != 0) + if (s != NULL && s->size != 0) { file_ptr filepos; bfd_byte *p; @@ -2821,7 +2821,7 @@ sunos_finish_dynamic_link (abfd, info) dynamic information, unless this is a shared library. */ s = bfd_get_section_by_name (dynobj, ".got"); BFD_ASSERT (s != NULL); - if (info->shared || sdyn->_raw_size == 0) + if (info->shared || sdyn->size == 0) PUT_WORD (dynobj, 0, s->contents); else PUT_WORD (dynobj, sdyn->output_section->vma + sdyn->output_offset, @@ -2837,12 +2837,12 @@ sunos_finish_dynamic_link (abfd, info) if (! bfd_set_section_contents (abfd, o->output_section, o->contents, (file_ptr) o->output_offset, - o->_raw_size)) + o->size)) return FALSE; } } - if (sdyn->_raw_size > 0) + if (sdyn->size > 0) { struct external_sun4_dynamic esd; struct external_sun4_dynamic_link esdl; @@ -2868,14 +2868,14 @@ sunos_finish_dynamic_link (abfd, info) PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_loaded); s = bfd_get_section_by_name (dynobj, ".need"); - if (s == NULL || s->_raw_size == 0) + if (s == NULL || s->size == 0) PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_need); else PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, esdl.ld_need); s = bfd_get_section_by_name (dynobj, ".rules"); - if (s == NULL || s->_raw_size == 0) + if (s == NULL || s->size == 0) PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_rules); else PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, @@ -2890,12 +2890,12 @@ sunos_finish_dynamic_link (abfd, info) BFD_ASSERT (s != NULL); PUT_WORD (dynobj, s->output_section->vma + s->output_offset, esdl.ld_plt); - PUT_WORD (dynobj, s->_raw_size, esdl.ld_plt_sz); + PUT_WORD (dynobj, s->size, esdl.ld_plt_sz); s = bfd_get_section_by_name (dynobj, ".dynrel"); BFD_ASSERT (s != NULL); BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) - == s->_raw_size); + == s->size); PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, esdl.ld_rel); @@ -2918,13 +2918,13 @@ sunos_finish_dynamic_link (abfd, info) BFD_ASSERT (s != NULL); PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, esdl.ld_symbols); - PUT_WORD (dynobj, s->_raw_size, esdl.ld_symb_size); + PUT_WORD (dynobj, s->size, esdl.ld_symb_size); /* The size of the text area is the size of the .text section rounded up to a page boundary. FIXME: Should the page size be conditional on something? */ PUT_WORD (dynobj, - BFD_ALIGN (obj_textsec (abfd)->_raw_size, 0x2000), + BFD_ALIGN (obj_textsec (abfd)->size, 0x2000), esdl.ld_text); pos = sdyn->output_offset; Index: bfd/syms.c =================================================================== RCS file: /cvs/src/src/bfd/syms.c,v retrieving revision 1.35 diff -u -p -r1.35 syms.c --- bfd/syms.c 30 Nov 2003 18:40:41 -0000 1.35 +++ bfd/syms.c 22 Jun 2004 01:37:16 -0000 @@ -1,6 +1,6 @@ /* Generic symbol-table support for the BFD library. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003 + 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Cygnus Support. @@ -934,8 +934,12 @@ _bfd_stab_section_find_nearest_line (bfd return TRUE; } - stabsize = info->stabsec->_raw_size; - strsize = info->strsec->_raw_size; + stabsize = (info->stabsec->rawsize + ? info->stabsec->rawsize + : info->stabsec->size); + strsize = (info->strsec->rawsize + ? info->strsec->rawsize + : info->strsec->size); } else { @@ -965,8 +969,12 @@ _bfd_stab_section_find_nearest_line (bfd return TRUE; } - stabsize = info->stabsec->_raw_size; - strsize = info->strsec->_raw_size; + stabsize = (info->stabsec->rawsize + ? info->stabsec->rawsize + : info->stabsec->size); + strsize = (info->strsec->rawsize + ? info->strsec->rawsize + : info->strsec->size); info->stabs = bfd_alloc (abfd, stabsize); info->strs = bfd_alloc (abfd, strsize); @@ -974,9 +982,9 @@ _bfd_stab_section_find_nearest_line (bfd return FALSE; if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, - (bfd_vma) 0, stabsize) + 0, stabsize) || ! bfd_get_section_contents (abfd, info->strsec, info->strs, - (bfd_vma) 0, strsize)) + 0, strsize)) return FALSE; /* If this is a relocatable object file, we have to relocate Index: bfd/tekhex.c =================================================================== RCS file: /cvs/src/src/bfd/tekhex.c,v retrieving revision 1.19 diff -u -p -r1.19 tekhex.c --- bfd/tekhex.c 30 Apr 2004 14:23:40 -0000 1.19 +++ bfd/tekhex.c 22 Jun 2004 01:37:16 -0000 @@ -429,7 +429,7 @@ first_phase (abfd, type, src) case '1': /* section range */ src++; section->vma = getvalue (&src); - section->_raw_size = getvalue (&src) - section->vma; + section->size = getvalue (&src) - section->vma; section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC; break; case '0': @@ -688,7 +688,7 @@ tekhex_set_section_contents (abfd, secti if (s->flags & SEC_LOAD) { for (vma = s->vma & ~(bfd_vma) CHUNK_MASK; - vma < s->vma + s->_raw_size; + vma < s->vma + s->size; vma += CHUNK_MASK) find_chunk (abfd, vma); } @@ -862,7 +862,7 @@ tekhex_write_object_contents (abfd) writesym (&dst, s->name); *dst++ = '1'; writevalue (&dst, s->vma); - writevalue (&dst, s->vma + s->_raw_size); + writevalue (&dst, s->vma + s->size); out (abfd, '3', buffer, dst); } Index: bfd/trad-core.c =================================================================== RCS file: /cvs/src/src/bfd/trad-core.c,v retrieving revision 1.17 diff -u -p -r1.17 trad-core.c --- bfd/trad-core.c 5 May 2004 15:46:35 -0000 1.17 +++ bfd/trad-core.c 22 Jun 2004 01:37:16 -0000 @@ -173,13 +173,13 @@ trad_unix_core_file_p (abfd) core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; core_regsec (abfd)->flags = SEC_HAS_CONTENTS; - core_datasec (abfd)->_raw_size = NBPG * u.u_dsize + core_datasec (abfd)->size = NBPG * u.u_dsize #ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE - NBPG * u.u_tsize #endif ; - core_stacksec (abfd)->_raw_size = NBPG * u.u_ssize; - core_regsec (abfd)->_raw_size = NBPG * UPAGES; /* Larger than sizeof struct u */ + core_stacksec (abfd)->size = NBPG * u.u_ssize; + core_regsec (abfd)->size = NBPG * UPAGES; /* Larger than sizeof struct u */ /* What a hack... we'd like to steal it from the exec file, since the upage does not seem to provide it. FIXME. */ Index: bfd/versados.c =================================================================== RCS file: /cvs/src/src/bfd/versados.c,v retrieving revision 1.21 diff -u -p -r1.21 versados.c --- bfd/versados.c 30 Apr 2004 14:23:40 -0000 1.21 +++ bfd/versados.c 22 Jun 2004 01:37:17 -0000 @@ -320,7 +320,7 @@ process_esd (abfd, esd, pass) case ESD_STD_REL_SEC: case ESD_SHRT_REL_SEC: { - sec->_raw_size = get_4 (&ptr); + sec->size = get_4 (&ptr); sec->flags |= SEC_ALLOC; } break; @@ -470,7 +470,7 @@ process_otr (abfd, otr, pass) else { need_contents = 1; - if (dst_idx < esdid->section->_raw_size) + if (dst_idx < esdid->section->size) if (pass == 2) { /* absolute code, comes in 16 bit lumps */ @@ -485,7 +485,7 @@ process_otr (abfd, otr, pass) if (!contents && need_contents) { - bfd_size_type size = esdid->section->_raw_size; + bfd_size_type size = esdid->section->size; esdid->contents = (unsigned char *) bfd_alloc (abfd, size); } } Index: bfd/vms-gsd.c =================================================================== RCS file: /cvs/src/src/bfd/vms-gsd.c,v retrieving revision 1.13 diff -u -p -r1.13 vms-gsd.c --- bfd/vms-gsd.c 30 Nov 2003 18:40:41 -0000 1.13 +++ bfd/vms-gsd.c 22 Jun 2004 01:37:17 -0000 @@ -1,6 +1,6 @@ /* vms-gsd.c -- BFD back-end for VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. go and read the openVMS linker manual (esp. appendix B) @@ -358,9 +358,9 @@ _bfd_vms_slurp_gsd (abfd, objtype) return -1; } old_flags = bfd_getl16 (vms_rec + 2); - section->_raw_size = bfd_getl32 (vms_rec + 4); /* allocation */ + section->size = bfd_getl32 (vms_rec + 4); /* allocation */ new_flags = vms_secflag_by_name (abfd, vax_section_flags, name, - section->_raw_size > 0); + section->size > 0); if (old_flags & EGPS_S_V_REL) new_flags |= SEC_RELOC; if (old_flags & GPS_S_M_OVR) @@ -377,7 +377,7 @@ _bfd_vms_slurp_gsd (abfd, objtype) if ((base_addr % align_addr) != 0) base_addr += (align_addr - (base_addr % align_addr)); section->vma = (bfd_vma)base_addr; - base_addr += section->_raw_size; + base_addr += section->size; /* global section is common symbol */ @@ -401,21 +401,21 @@ _bfd_vms_slurp_gsd (abfd, objtype) if (old_section != 0) { section->contents = old_section->contents; - if (section->_raw_size < old_section->_raw_size) + if (section->size < old_section->size) { (*_bfd_error_handler) (_("Size mismatch section %s=%lx, %s=%lx"), old_section->name, - (unsigned long) old_section->_raw_size, + (unsigned long) old_section->size, section->name, - (unsigned long) section->_raw_size); + (unsigned long) section->size); return -1; } - else if (section->_raw_size > old_section->_raw_size) + else if (section->size > old_section->size) { section->contents = ((unsigned char *) bfd_realloc (old_section->contents, - section->_raw_size)); + section->size)); if (section->contents == NULL) { bfd_set_error (bfd_error_no_memory); @@ -426,19 +426,18 @@ _bfd_vms_slurp_gsd (abfd, objtype) else { section->contents = ((unsigned char *) - bfd_zmalloc (section->_raw_size)); + bfd_zmalloc (section->size)); if (section->contents == NULL) { bfd_set_error (bfd_error_no_memory); return -1; } } - section->_cooked_size = section->_raw_size; #if VMS_DEBUG vms_debug (4, "gsd psc %d (%s, flags %04x=%s) ", section->index, name, old_flags, flag2str (gpsflagdesc, old_flags)); vms_debug (4, "%d bytes at 0x%08lx (mem %p)\n", - section->_raw_size, section->vma, section->contents); + section->size, section->vma, section->contents); #endif gsd_size = vms_rec[8] + 9; @@ -603,9 +602,9 @@ _bfd_vms_slurp_gsd (abfd, objtype) if (!section) return -1; old_flags = bfd_getl16 (vms_rec + 6); - section->_raw_size = bfd_getl32 (vms_rec + 8); /* allocation */ + section->size = bfd_getl32 (vms_rec + 8); /* allocation */ new_flags = vms_secflag_by_name (abfd, evax_section_flags, name, - section->_raw_size > 0); + section->size > 0); if (old_flags & EGPS_S_V_REL) new_flags |= SEC_RELOC; if (!bfd_set_section_flags (abfd, section, new_flags)) @@ -615,17 +614,16 @@ _bfd_vms_slurp_gsd (abfd, objtype) if ((base_addr % align_addr) != 0) base_addr += (align_addr - (base_addr % align_addr)); section->vma = (bfd_vma)base_addr; - base_addr += section->_raw_size; + base_addr += section->size; section->contents = ((unsigned char *) - bfd_zmalloc (section->_raw_size)); + bfd_zmalloc (section->size)); if (section->contents == NULL) return -1; - section->_cooked_size = section->_raw_size; #if VMS_DEBUG vms_debug(4, "egsd psc %d (%s, flags %04x=%s) ", section->index, name, old_flags, flag2str(gpsflagdesc, old_flags)); vms_debug(4, "%d bytes at 0x%08lx (mem %p)\n", - section->_raw_size, section->vma, section->contents); + section->size, section->vma, section->contents); #endif } break; @@ -758,7 +756,7 @@ _bfd_vms_write_gsd (abfd, objtype) while (section != 0) { #if VMS_DEBUG - vms_debug (3, "Section #%d %s, %d bytes\n", section->index, section->name, (int)section->_raw_size); + vms_debug (3, "Section #%d %s, %d bytes\n", section->index, section->name, (int)section->size); #endif /* 13 bytes egsd, max 31 chars name -> should be 44 bytes */ @@ -824,10 +822,10 @@ _bfd_vms_write_gsd (abfd, objtype) else { new_flags = vms_esecflag_by_name (evax_section_flags, sname, - section->_raw_size > 0); + section->size > 0); } _bfd_vms_output_short (abfd, new_flags); - _bfd_vms_output_long (abfd, (unsigned long) section->_raw_size); + _bfd_vms_output_long (abfd, (unsigned long) section->size); _bfd_vms_output_counted (abfd, sname); _bfd_vms_output_flush (abfd); Index: bfd/vms-misc.c =================================================================== RCS file: /cvs/src/src/bfd/vms-misc.c,v retrieving revision 1.18 diff -u -p -r1.18 vms-misc.c --- bfd/vms-misc.c 30 Nov 2003 18:40:41 -0000 1.18 +++ bfd/vms-misc.c 22 Jun 2004 01:37:18 -0000 @@ -1,6 +1,6 @@ /* vms-misc.c -- Miscellaneous functions for VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Klaus K"ampf (kkaempf@rmi.de) @@ -595,11 +595,11 @@ add_new_contents (abfd, section) (bfd_size_type) sizeof (vms_section)); if (newptr == (vms_section *) NULL) return NULL; - newptr->contents = (unsigned char *) bfd_alloc (abfd, section->_raw_size); + newptr->contents = (unsigned char *) bfd_alloc (abfd, section->size); if (newptr->contents == (unsigned char *) NULL) return NULL; newptr->offset = 0; - newptr->size = section->_raw_size; + newptr->size = section->size; newptr->next = 0; PRIV (vms_section_table)[section->index] = newptr; return newptr; Index: bfd/vms-tir.c =================================================================== RCS file: /cvs/src/src/bfd/vms-tir.c,v retrieving revision 1.10 diff -u -p -r1.10 vms-tir.c --- bfd/vms-tir.c 30 Nov 2002 08:39:40 -0000 1.10 +++ bfd/vms-tir.c 22 Jun 2004 01:37:19 -0000 @@ -1,6 +1,6 @@ /* vms-tir.c -- BFD back-end for VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. TIR record handling functions @@ -93,7 +93,7 @@ check_section (abfd, size) bfd_size_type offset; offset = PRIV (image_ptr) - PRIV (image_section)->contents; - if (offset + size > PRIV (image_section)->_raw_size) + if (offset + size > PRIV (image_section)->size) { PRIV (image_section)->contents = bfd_realloc (PRIV (image_section)->contents, offset + size); @@ -102,7 +102,7 @@ check_section (abfd, size) (*_bfd_error_handler) (_("No Mem !")); return -1; } - PRIV (image_section)->_raw_size = offset + size; + PRIV (image_section)->size = offset + size; PRIV (image_ptr) = PRIV (image_section)->contents + offset; } @@ -951,10 +951,9 @@ new_section (abfd, idx) return 0; } - section->_raw_size = 0; + section->size = 0; section->vma = 0; section->contents = 0; - section->_cooked_size = 0; section->name = name; section->index = idx; @@ -2031,7 +2030,7 @@ _bfd_vms_write_tir (abfd, objtype) #if VMS_DEBUG _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", section->index, section->name, - (int) (section->_raw_size)); + (int) (section->size)); #endif if (section->flags & SEC_RELOC) Index: bfd/vms.c =================================================================== RCS file: /cvs/src/src/bfd/vms.c,v retrieving revision 1.29 diff -u -p -r1.29 vms.c --- bfd/vms.c 17 May 2004 16:40:01 -0000 1.29 +++ bfd/vms.c 22 Jun 2004 01:37:19 -0000 @@ -1670,7 +1670,7 @@ vms_set_section_contents (abfd, section, #if VMS_DEBUG vms_debug (1, "vms_set_section_contents(%p, sec %s, loc %p, off %ld, count %d)\n", abfd, section->name, location, (long int)offset, (int)count); - vms_debug (2, "secraw %d, seccooked %d\n", (int)section->_raw_size, (int)section->_cooked_size); + vms_debug (2, "size %d\n", (int) section->size); #endif return _bfd_save_vms_section(abfd, section, location, offset, count); } Index: bfd/xcofflink.c =================================================================== RCS file: /cvs/src/src/bfd/xcofflink.c,v retrieving revision 1.33 diff -u -p -r1.33 xcofflink.c --- bfd/xcofflink.c 2 Dec 2003 22:59:59 -0000 1.33 +++ bfd/xcofflink.c 22 Jun 2004 01:37:24 -0000 @@ -1,5 +1,5 @@ /* POWER/PowerPC XCOFF linker support. - Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Ian Lance Taylor , Cygnus Support. @@ -171,15 +171,14 @@ xcoff_get_section_contents (abfd, sec) if (coff_section_data (abfd, sec)->contents == NULL) { - coff_section_data (abfd, sec)->contents = ((bfd_byte *) - bfd_malloc (sec->_raw_size)); - if (coff_section_data (abfd, sec)->contents == NULL) - return FALSE; - - if (! bfd_get_section_contents (abfd, sec, - coff_section_data (abfd, sec)->contents, - (file_ptr) 0, sec->_raw_size)) - return FALSE; + bfd_byte *contents; + if (!bfd_malloc_and_get_section (abfd, sec, &contents)) + { + if (contents != NULL) + free (contents); + return FALSE; + } + coff_section_data (abfd, sec)->contents = contents; } return TRUE; @@ -1514,7 +1513,7 @@ xcoff_link_add_symbols (abfd, info) if (! bfd_is_abs_section (enclosing) && ((bfd_vma) sym.n_value < enclosing->vma || ((bfd_vma) sym.n_value + aux.x_csect.x_scnlen.l - > enclosing->vma + enclosing->_raw_size))) + > enclosing->vma + enclosing->size))) { (*_bfd_error_handler) (_("%s: csect `%s' not in enclosing section"), @@ -1526,7 +1525,7 @@ xcoff_link_add_symbols (abfd, info) csect->filepos = (enclosing->filepos + sym.n_value - enclosing->vma); - csect->_raw_size = aux.x_csect.x_scnlen.l; + csect->size = aux.x_csect.x_scnlen.l; csect->flags |= SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp); @@ -1563,7 +1562,7 @@ xcoff_link_add_symbols (abfd, info) + relindx * bfd_coff_relsz (abfd)); while (relindx < enclosing->reloc_count && *rel_csect == NULL - && rel->r_vaddr < csect->vma + csect->_raw_size) + && rel->r_vaddr < csect->vma + csect->size) { *rel_csect = csect; @@ -1664,7 +1663,7 @@ xcoff_link_add_symbols (abfd, info) if (csect == NULL) goto error_return; csect->vma = sym.n_value; - csect->_raw_size = aux.x_csect.x_scnlen.l; + csect->size = aux.x_csect.x_scnlen.l; csect->flags |= SEC_ALLOC; csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp); /* There are a number of other fields and section flags @@ -1690,7 +1689,7 @@ xcoff_link_add_symbols (abfd, info) if (sym.n_sclass == C_EXT) { csect->flags |= SEC_IS_COMMON; - csect->_raw_size = 0; + csect->size = 0; section = csect; value = aux.x_csect.x_scnlen.l; } @@ -1895,7 +1894,7 @@ xcoff_link_add_symbols (abfd, info) || (*sym_hash)->root.u.c.p->section != csect) { /* We don't need the common csect we just created. */ - csect->_raw_size = 0; + csect->size = 0; } else { @@ -1937,7 +1936,7 @@ xcoff_link_add_symbols (abfd, info) the .debug section, since we need to read it below in bfd_xcoff_size_dynamic_sections. */ if (strcmp (bfd_get_section_name (abfd, o), ".debug") != 0) - o->_raw_size = 0; + o->size = 0; o->lineno_count = 0; if ((o->flags & SEC_RELOC) != 0) @@ -2511,7 +2510,7 @@ xcoff_sweep (info) o->flags |= SEC_MARK; else { - o->_raw_size = 0; + o->size = 0; o->reloc_count = 0; o->lineno_count = 0; } @@ -3035,8 +3034,8 @@ bfd_xcoff_size_dynamic_sections (output_ /* We now know the final size of the .loader section. Allocate space for it. */ lsec = xcoff_hash_table (info)->loader_section; - lsec->_raw_size = stoff + ldhdr->l_stlen; - lsec->contents = (bfd_byte *) bfd_zalloc (output_bfd, lsec->_raw_size); + lsec->size = stoff + ldhdr->l_stlen; + lsec->contents = (bfd_byte *) bfd_zalloc (output_bfd, lsec->size); if (lsec->contents == NULL) goto error_return; @@ -3085,23 +3084,23 @@ bfd_xcoff_size_dynamic_sections (output_ /* Allocate space for the magic sections. */ sec = xcoff_hash_table (info)->linkage_section; - if (sec->_raw_size > 0) + if (sec->size > 0) { - sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size); + sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->size); if (sec->contents == NULL) goto error_return; } sec = xcoff_hash_table (info)->toc_section; - if (sec->_raw_size > 0) + if (sec->size > 0) { - sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size); + sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->size); if (sec->contents == NULL) goto error_return; } sec = xcoff_hash_table (info)->descriptor_section; - if (sec->_raw_size > 0) + if (sec->size > 0) { - sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size); + sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->size); if (sec->contents == NULL) goto error_return; } @@ -3122,14 +3121,14 @@ bfd_xcoff_size_dynamic_sections (output_ if (sub->xvec != info->hash->creator) continue; subdeb = bfd_get_section_by_name (sub, ".debug"); - if (subdeb == NULL || subdeb->_raw_size == 0) + if (subdeb == NULL || subdeb->size == 0) continue; if (info->strip == strip_all || info->strip == strip_debugger || info->discard == discard_all) { - subdeb->_raw_size = 0; + subdeb->size = 0; continue; } @@ -3148,11 +3147,7 @@ bfd_xcoff_size_dynamic_sections (output_ bfd_alloc, because I expect that, when linking many files together, many of the strings will be the same. Storing the strings in the hash table should save space in this case. */ - debug_contents = (bfd_byte *) bfd_malloc (subdeb->_raw_size); - if (debug_contents == NULL) - goto error_return; - if (! bfd_get_section_contents (sub, subdeb, (PTR) debug_contents, - (file_ptr) 0, subdeb->_raw_size)) + if (!bfd_malloc_and_get_section (sub, subdeb, &debug_contents)) goto error_return; csectpp = xcoff_data (sub)->csects; @@ -3200,7 +3195,7 @@ bfd_xcoff_size_dynamic_sections (output_ /* Clear the size of subdeb, so that it is not included directly in the output file. */ - subdeb->_raw_size = 0; + subdeb->size = 0; if (! info->keep_memory) { @@ -3210,7 +3205,7 @@ bfd_xcoff_size_dynamic_sections (output_ } if (info->strip != strip_all) - xcoff_hash_table (info)->debug_section->_raw_size = + xcoff_hash_table (info)->debug_section->size = _bfd_stringtab_size (debug_strtab); return TRUE; @@ -3369,10 +3364,10 @@ xcoff_build_ldsyms (h, p) sec = xcoff_hash_table (ldinfo->info)->linkage_section; h->root.type = bfd_link_hash_defined; h->root.u.def.section = sec; - h->root.u.def.value = sec->_raw_size; + h->root.u.def.value = sec->size; h->smclas = XMC_GL; h->flags |= XCOFF_DEF_REGULAR; - sec->_raw_size += bfd_xcoff_glink_code_size(ldinfo->output_bfd); + sec->size += bfd_xcoff_glink_code_size(ldinfo->output_bfd); /* The global linkage code requires a TOC entry for the descriptor. */ @@ -3396,8 +3391,8 @@ xcoff_build_ldsyms (h, p) return FALSE; hds->toc_section = xcoff_hash_table (ldinfo->info)->toc_section; - hds->u.toc_offset = hds->toc_section->_raw_size; - hds->toc_section->_raw_size += byte_size; + hds->u.toc_offset = hds->toc_section->size; + hds->toc_section->size += byte_size; ++xcoff_hash_table (ldinfo->info)->ldrel_count; ++hds->toc_section->reloc_count; hds->indx = -2; @@ -3432,13 +3427,13 @@ xcoff_build_ldsyms (h, p) sec = xcoff_hash_table (ldinfo->info)->descriptor_section; h->root.type = bfd_link_hash_defined; h->root.u.def.section = sec; - h->root.u.def.value = sec->_raw_size; + h->root.u.def.value = sec->size; h->smclas = XMC_DS; h->flags |= XCOFF_DEF_REGULAR; /* The size of the function descriptor depends if this is an xcoff32 (12) or xcoff64 (24). */ - sec->_raw_size += + sec->size += bfd_xcoff_function_descriptor_size(ldinfo->output_bfd); /* A function descriptor uses two relocs: one for the @@ -3465,10 +3460,10 @@ xcoff_build_ldsyms (h, p) if (h->root.type == bfd_link_hash_common && (! xcoff_hash_table (ldinfo->info)->gc || (h->flags & XCOFF_MARK) != 0) - && h->root.u.c.p->section->_raw_size == 0) + && h->root.u.c.p->section->size == 0) { BFD_ASSERT (bfd_is_com_section (h->root.u.c.p->section)); - h->root.u.c.p->section->_raw_size = h->root.u.c.size; + h->root.u.c.p->section->size = h->root.u.c.size; } /* We need to add a symbol to the .loader section if it is mentioned @@ -3618,8 +3613,10 @@ _bfd_xcoff_bfd_final_link (abfd, info) o->reloc_count += sec->reloc_count; - if (sec->_raw_size > max_contents_size) - max_contents_size = sec->_raw_size; + if (sec->rawsize > max_contents_size) + max_contents_size = sec->rawsize; + if (sec->size > max_contents_size) + max_contents_size = sec->size; if (sec->lineno_count > max_lineno_count) max_lineno_count = sec->lineno_count; if (coff_section_data (sec->owner, sec) != NULL @@ -3722,11 +3719,11 @@ _bfd_xcoff_bfd_final_link (abfd, info) { bfd_vma pageoff; - BFD_ASSERT (o->_raw_size == 0); + BFD_ASSERT (o->size == 0); pageoff = sofar & (file_align - 1); if (pageoff != 0) { - o->_raw_size = file_align - pageoff; + o->size = file_align - pageoff; sofar += file_align - pageoff; o->flags |= SEC_HAS_CONTENTS; } @@ -3734,7 +3731,7 @@ _bfd_xcoff_bfd_final_link (abfd, info) else { if ((o->flags & SEC_HAS_CONTENTS) != 0) - sofar += BFD_ALIGN (o->_raw_size, + sofar += BFD_ALIGN (o->size, 1 << o->alignment_power); } } @@ -4083,27 +4080,27 @@ _bfd_xcoff_bfd_final_link (abfd, info) + xcoff_hash_table (info)->ldhdr.l_impoff)); o = xcoff_hash_table (info)->loader_section; if (! bfd_set_section_contents (abfd, o->output_section, o->contents, - (file_ptr) o->output_offset, o->_raw_size)) + (file_ptr) o->output_offset, o->size)) goto error_return; /* Write out the magic sections. */ o = xcoff_hash_table (info)->linkage_section; - if (o->_raw_size > 0 + if (o->size > 0 && ! bfd_set_section_contents (abfd, o->output_section, o->contents, (file_ptr) o->output_offset, - o->_raw_size)) + o->size)) goto error_return; o = xcoff_hash_table (info)->toc_section; - if (o->_raw_size > 0 + if (o->size > 0 && ! bfd_set_section_contents (abfd, o->output_section, o->contents, (file_ptr) o->output_offset, - o->_raw_size)) + o->size)) goto error_return; o = xcoff_hash_table (info)->descriptor_section; - if (o->_raw_size > 0 + if (o->size > 0 && ! bfd_set_section_contents (abfd, o->output_section, o->contents, (file_ptr) o->output_offset, - o->_raw_size)) + o->size)) goto error_return; /* Write out the string table. */ @@ -4128,7 +4125,7 @@ _bfd_xcoff_bfd_final_link (abfd, info) struct bfd_strtab_hash *debug_strtab; debug_strtab = xcoff_hash_table (info)->debug_strtab; - BFD_ASSERT (o->output_section->_raw_size - o->output_offset + BFD_ASSERT (o->output_section->size - o->output_offset >= _bfd_stringtab_size (debug_strtab)); pos = o->output_section->filepos + o->output_offset; if (bfd_seek (abfd, pos, SEEK_SET) != 0) @@ -4423,7 +4420,7 @@ xcoff_link_input_bfd (finfo, input_bfd) output section, as it does in the default linker script. */ tocend = ((*csectpp)->output_section->vma - + (*csectpp)->output_section->_raw_size); + + (*csectpp)->output_section->size); for (inp = finfo->info->input_bfds; inp != NULL; inp = inp->link_next) @@ -4435,7 +4432,7 @@ xcoff_link_input_bfd (finfo, input_bfd) bfd_vma new_toc_end; new_toc_end = (o->output_section->vma + o->output_offset - + o->_cooked_size); + + o->size); if (new_toc_end > tocend) tocend = new_toc_end; } @@ -5053,7 +5050,7 @@ xcoff_link_input_bfd (finfo, input_bfd) } if ((o->flags & SEC_HAS_CONTENTS) == 0 - || o->_raw_size == 0 + || o->size == 0 || (o->flags & SEC_IN_MEMORY) != 0) continue; @@ -5062,12 +5059,13 @@ xcoff_link_input_bfd (finfo, input_bfd) if (coff_section_data (input_bfd, o) != NULL && coff_section_data (input_bfd, o)->contents != NULL) contents = coff_section_data (input_bfd, o)->contents; - else { - if (! bfd_get_section_contents (input_bfd, o, finfo->contents, - (file_ptr) 0, o->_raw_size)) - return FALSE; - contents = finfo->contents; - } + else + { + bfd_size_type sz = o->rawsize ? o->rawsize : o->size; + if (!bfd_get_section_contents (input_bfd, o, finfo->contents, 0, sz)) + return FALSE; + contents = finfo->contents; + } if ((o->flags & SEC_RELOC) != 0) { @@ -5352,9 +5350,7 @@ xcoff_link_input_bfd (finfo, input_bfd) /* Write out the modified section contents. */ if (! bfd_set_section_contents (output_bfd, o->output_section, contents, (file_ptr) o->output_offset, - (o->_cooked_size != 0 - ? o->_cooked_size - : o->_raw_size))) + o->size)) return FALSE; } Index: bfd/xsym.c =================================================================== RCS file: /cvs/src/src/bfd/xsym.c,v retrieving revision 1.6 diff -u -p -r1.6 xsym.c --- bfd/xsym.c 30 Apr 2004 14:23:40 -0000 1.6 +++ bfd/xsym.c 22 Jun 2004 01:37:24 -0000 @@ -2346,7 +2346,7 @@ bfd_sym_scan (abfd, version, mdata) bfdsec->vma = 0; bfdsec->lma = 0; - bfdsec->_raw_size = 0; + bfdsec->size = 0; bfdsec->filepos = 0; bfdsec->alignment_power = 0; Index: binutils/objcopy.c =================================================================== RCS file: /cvs/src/src/binutils/objcopy.c,v retrieving revision 1.69 diff -u -p -r1.69 objcopy.c --- binutils/objcopy.c 15 Jun 2004 01:19:13 -0000 1.69 +++ binutils/objcopy.c 22 Jun 2004 01:37:26 -0000 @@ -2070,8 +2070,6 @@ copy_section (bfd *ibfd, sec_ptr isectio free (relpp); } - isection->_cooked_size = isection->_raw_size; - if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS && bfd_get_section_flags (obfd, osection) & SEC_HAS_CONTENTS) { Index: include/bfdlink.h =================================================================== RCS file: /cvs/src/src/include/bfdlink.h,v retrieving revision 1.43 diff -u -p -r1.43 bfdlink.h --- include/bfdlink.h 11 May 2004 17:08:38 -0000 1.43 +++ include/bfdlink.h 22 Jun 2004 01:37:52 -0000 @@ -556,7 +556,7 @@ struct bfd_link_order /* Section to include. If this is used, then section->output_section must be the section the link_order is attached to, section->output_offset must - equal the link_order offset field, and section->_raw_size + equal the link_order offset field, and section->size must equal the link_order size field. Maybe these restrictions should be relaxed someday. */ asection *section; Index: ld/ldexp.c =================================================================== RCS file: /cvs/src/src/ld/ldexp.c,v retrieving revision 1.30 diff -u -p -r1.30 ldexp.c --- ld/ldexp.c 11 May 2004 17:08:34 -0000 1.30 +++ ld/ldexp.c 22 Jun 2004 01:37:57 -0000 @@ -618,7 +618,7 @@ fold_name (etree_type *tree, os = lang_output_section_find (tree->name.name); if (os && os->processed > 0) - result = new_abs (os->bfd_section->_raw_size / opb); + result = new_abs (os->bfd_section->size / opb); } break; Index: ld/ldlang.c =================================================================== RCS file: /cvs/src/src/ld/ldlang.c,v retrieving revision 1.154 diff -u -p -r1.154 ldlang.c --- ld/ldlang.c 14 Jun 2004 12:46:43 -0000 1.154 +++ ld/ldlang.c 22 Jun 2004 02:19:50 -0000 @@ -991,8 +991,7 @@ section_already_linked (bfd *abfd, asect either. */ /* Fall through. */ case SEC_LINK_DUPLICATES_SAME_SIZE: - if (bfd_section_size (abfd, sec) - != bfd_section_size (l->sec->owner, l->sec)) + if (sec->size != l->sec->size) einfo (_("%P: %B: warning: duplicate section `%s'" " has different size\n"), abfd, name); @@ -2339,7 +2338,7 @@ print_output_section_statement ++len; } - minfo ("0x%V %W", section->vma, section->_raw_size); + minfo ("0x%V %W", section->vma, section->size); if (output_section_statement->load_base != NULL) { @@ -2451,7 +2450,7 @@ static void print_input_section (lang_input_section_type *in) { asection *i = in->section; - bfd_size_type size = i->_cooked_size != 0 ? i->_cooked_size : i->_raw_size; + bfd_size_type size = i->size; init_opb (); if (size != 0) @@ -2484,7 +2483,7 @@ print_input_section (lang_input_section_ minfo ("0x%V %W %B\n", addr, TO_ADDR (size), i->owner); - if (size != i->_raw_size) + if (size != i->rawsize && i->rawsize != 0) { len = SECTION_NAME_MAP_LENGTH + 3; #ifdef BFD64 @@ -2498,7 +2497,7 @@ print_input_section (lang_input_section_ --len; } - minfo (_("%W (size before relaxing)\n"), i->_raw_size); + minfo (_("%W (size before relaxing)\n"), i->rawsize); } if (i->output_section != NULL && (i->flags & SEC_EXCLUDE) == 0) @@ -2867,7 +2866,7 @@ insert_pad (lang_statement_union_type ** } pad->padding_statement.output_offset = dot - output_section->vma; pad->padding_statement.size = alignment_needed; - output_section->_raw_size += alignment_needed; + output_section->size += alignment_needed; } /* Work out how much this section will move the dot point. */ @@ -2912,11 +2911,8 @@ size_input_section i->output_offset = dot - o->vma; /* Mark how big the output section must be to contain this now. */ - if (i->_cooked_size != 0) - dot += TO_ADDR (i->_cooked_size); - else - dot += TO_ADDR (i->_raw_size); - o->_raw_size = TO_SIZE (dot - o->vma); + dot += TO_ADDR (i->size); + o->size = TO_SIZE (dot - o->vma); } else { @@ -2926,11 +2922,11 @@ size_input_section return dot; } -#define IGNORE_SECTION(bfd, s) \ +#define IGNORE_SECTION(s) \ (((s->flags & SEC_THREAD_LOCAL) != 0 \ ? (s->flags & (SEC_LOAD | SEC_NEVER_LOAD)) != SEC_LOAD \ : (s->flags & (SEC_ALLOC | SEC_NEVER_LOAD)) != SEC_ALLOC) \ - || bfd_section_size (bfd, s) == 0) + || s->size == 0) /* Check to see if any allocated sections overlap with other allocated sections. This can happen when the linker script specifically specifies @@ -2947,7 +2943,7 @@ lang_check_section_addresses (void) asection *os; /* Ignore sections which are not loaded or which have no contents. */ - if (IGNORE_SECTION (output_bfd, s)) + if (IGNORE_SECTION (s)) continue; /* Once we reach section 's' stop our seach. This prevents two @@ -2961,7 +2957,7 @@ lang_check_section_addresses (void) bfd_vma os_end; /* Only consider loadable sections with real contents. */ - if (IGNORE_SECTION (output_bfd, os)) + if (IGNORE_SECTION (os)) continue; /* We must check the sections' LMA addresses not their @@ -2969,8 +2965,8 @@ lang_check_section_addresses (void) overlapping VMAs but they must have distinct LMAs. */ s_start = bfd_section_lma (output_bfd, s); os_start = bfd_section_lma (output_bfd, os); - s_end = s_start + TO_ADDR (bfd_section_size (output_bfd, s)) - 1; - os_end = os_start + TO_ADDR (bfd_section_size (output_bfd, os)) - 1; + s_end = s_start + TO_ADDR (s->size) - 1; + os_end = os_start + TO_ADDR (os->size) - 1; /* Look for an overlap. */ if ((s_end < os_start) || (s_start > os_end)) @@ -3070,7 +3066,7 @@ lang_size_sections_1 bfd_set_section_vma (os->bfd_section->owner, os->bfd_section, bfd_section_vma (input->owner, input)); - os->bfd_section->_raw_size = input->_raw_size; + os->bfd_section->size = input->size; break; } @@ -3097,7 +3093,7 @@ lang_size_sections_1 /* If a loadable section is using the default memory region, and some non default memory regions were defined, issue an error message. */ - if (!IGNORE_SECTION (output_bfd, os->bfd_section) + if (!IGNORE_SECTION (os->bfd_section) && ! link_info.relocatable && check_regions && strcmp (os->region->name, @@ -3180,14 +3176,14 @@ lang_size_sections_1 /* Put the section within the requested block size, or align at the block boundary. */ after = ((os->bfd_section->vma - + TO_ADDR (os->bfd_section->_raw_size) + + TO_ADDR (os->bfd_section->size) + os->block_value - 1) & - (bfd_vma) os->block_value); if (bfd_is_abs_section (os->bfd_section)) ASSERT (after == os->bfd_section->vma); else - os->bfd_section->_raw_size + os->bfd_section->size = TO_SIZE (after - os->bfd_section->vma); dot = os->bfd_section->vma; @@ -3195,7 +3191,7 @@ lang_size_sections_1 if ((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0 || (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0 || link_info.relocatable) - dot += TO_ADDR (os->bfd_section->_raw_size); + dot += TO_ADDR (os->bfd_section->size); os->processed = 1; @@ -3232,7 +3228,7 @@ lang_size_sections_1 /* Set load_base, which will be handled later. */ os->load_base = exp_intop (os->lma_region->current); os->lma_region->current += - TO_ADDR (os->bfd_section->_raw_size); + TO_ADDR (os->bfd_section->size); if (check_regions) os_region_check (os, os->lma_region, NULL, os->bfd_section->lma); @@ -3283,7 +3279,7 @@ lang_size_sections_1 if (size < TO_SIZE ((unsigned) 1)) size = TO_SIZE ((unsigned) 1); dot += TO_ADDR (size); - output_section_statement->bfd_section->_raw_size += size; + output_section_statement->bfd_section->size += size; /* The output section gets contents, and then we inspect for any flags set in the input script which override any ALLOC. */ output_section_statement->bfd_section->flags |= SEC_HAS_CONTENTS; @@ -3305,7 +3301,7 @@ lang_size_sections_1 output_section_statement->bfd_section; size = bfd_get_reloc_size (s->reloc_statement.howto); dot += TO_ADDR (size); - output_section_statement->bfd_section->_raw_size += size; + output_section_statement->bfd_section->size += size; } break; @@ -3330,12 +3326,7 @@ lang_size_sections_1 asection *i; i = (*prev)->input_section.section; - if (! relax) - { - if (i->_cooked_size == 0) - i->_cooked_size = i->_raw_size; - } - else + if (relax) { bfd_boolean again; @@ -3447,7 +3438,6 @@ lang_size_sections bfd_boolean check_regions) { bfd_vma result; - asection *o; /* Callers of exp_fold_tree need to increment this. */ lang_statement_iteration++; @@ -3487,14 +3477,6 @@ lang_size_sections } } - /* Some backend relaxers want to refer to the output section size. Give - them a section size that does not change on the next call while they - relax. We can't set this at top because lang_reset_memory_regions - which is called before we get here, sets _raw_size to 0 on relaxing - rounds. */ - for (o = output_bfd->sections; o != NULL; o = o->next) - o->_cooked_size = o->_raw_size; - return result; } @@ -3531,7 +3513,7 @@ lang_do_assignments_1 if ((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0 || (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0 || link_info.relocatable) - dot += TO_ADDR (os->bfd_section->_raw_size); + dot += TO_ADDR (os->bfd_section->size); } if (os->load_base) { @@ -3618,12 +3600,7 @@ lang_do_assignments_1 asection *in = s->input_section.section; if ((in->flags & SEC_EXCLUDE) == 0) - { - if (in->_cooked_size != 0) - dot += TO_ADDR (in->_cooked_size); - else - dot += TO_ADDR (in->_raw_size); - } + dot += TO_ADDR (in->size); } break; @@ -3714,10 +3691,7 @@ lang_set_startof (void) if (h != NULL && h->type == bfd_link_hash_undefined) { h->type = bfd_link_hash_defined; - if (s->_cooked_size != 0) - h->u.def.value = TO_ADDR (s->_cooked_size); - else - h->u.def.value = TO_ADDR (s->_raw_size); + h->u.def.value = TO_ADDR (s->size); h->u.def.section = bfd_abs_section_ptr; } @@ -3931,8 +3905,8 @@ lang_one_common (struct bfd_link_hash_en section = h->u.c.p->section; /* Increase the size of the section to align the common sym. */ - section->_cooked_size += ((bfd_vma) 1 << (power_of_two + opb_shift)) - 1; - section->_cooked_size &= (- (bfd_vma) 1 << (power_of_two + opb_shift)); + section->size += ((bfd_vma) 1 << (power_of_two + opb_shift)) - 1; + section->size &= (- (bfd_vma) 1 << (power_of_two + opb_shift)); /* Adjust the alignment if necessary. */ if (power_of_two > section->alignment_power) @@ -3941,10 +3915,10 @@ lang_one_common (struct bfd_link_hash_en /* Change the symbol from common to defined. */ h->type = bfd_link_hash_defined; h->u.def.section = section; - h->u.def.value = section->_cooked_size; + h->u.def.value = section->size; /* Increase the size of the section. */ - section->_cooked_size += size; + section->size += size; /* Make sure the section is allocated in memory, and make sure that it is no longer a common section. */ @@ -4261,7 +4235,7 @@ lang_reset_memory_regions (void) } for (o = output_bfd->sections; o != NULL; o = o->next) - o->_raw_size = 0; + o->size = 0; } /* Worker for lang_gc_sections_1. */ @@ -4466,7 +4440,7 @@ lang_process (void) NULL, 0); /* We must do this after lang_do_assignments, because it uses - _raw_size. */ + size. */ lang_reset_memory_regions (); /* Perform another relax pass - this time we know where the @@ -4801,7 +4775,7 @@ lang_abs_symbol_at_end_of (const char *s h->u.def.value = 0; else h->u.def.value = (bfd_get_section_vma (output_bfd, sec) - + TO_ADDR (bfd_section_size (output_bfd, sec))); + + TO_ADDR (sec->size)); h->u.def.section = bfd_abs_section_ptr; } @@ -5640,7 +5614,7 @@ lang_do_version_exports_section (void) if (sec == NULL) continue; - len = bfd_section_size (is->the_bfd, sec); + len = sec->size; contents = xmalloc (len); if (!bfd_get_section_contents (is->the_bfd, sec, contents, 0, len)) einfo (_("%X%P: unable to read .exports section contents\n"), sec); Index: ld/ldwrite.c =================================================================== RCS file: /cvs/src/src/ld/ldwrite.c,v retrieving revision 1.17 diff -u -p -r1.17 ldwrite.c --- ld/ldwrite.c 15 Jun 2004 01:13:20 -0000 1.17 +++ ld/ldwrite.c 22 Jun 2004 01:38:00 -0000 @@ -251,10 +251,7 @@ build_link_order (lang_statement_union_t link_order->u.indirect.section = i; ASSERT (i->output_section == output_section); } - if (i->_cooked_size) - link_order->size = i->_cooked_size; - else - link_order->size = bfd_get_section_size (i); + link_order->size = i->size; link_order->offset = i->output_offset; } } @@ -368,8 +365,7 @@ clone_section (bfd *abfd, asection *s, c n->vma = s->vma; n->user_set_vma = s->user_set_vma; n->lma = s->lma; - n->_cooked_size = 0; - n->_raw_size = 0; + n->size = 0; n->output_offset = s->output_offset; n->output_section = n; n->orelocation = 0; @@ -383,7 +379,7 @@ static void ds (asection *s) { struct bfd_link_order *l = s->link_order_head; - printf ("vma %x size %x\n", s->vma, s->_raw_size); + printf ("vma %x size %x\n", s->vma, s->size); while (l) { if (l->type == bfd_indirect_link_order) @@ -469,10 +465,7 @@ split_sections (bfd *abfd, struct bfd_li if (info->relocatable) thisrelocs = sec->reloc_count; - if (sec->_cooked_size != 0) - thissize = sec->_cooked_size; - else - thissize = sec->_raw_size; + thissize = sec->size; } else if (info->relocatable @@ -507,13 +500,8 @@ split_sections (bfd *abfd, struct bfd_li dump ("before snip", cursor, n); shift_offset = p->offset; - if (cursor->_cooked_size != 0) - { - n->_cooked_size = cursor->_cooked_size - shift_offset; - cursor->_cooked_size = shift_offset; - } - n->_raw_size = cursor->_raw_size - shift_offset; - cursor->_raw_size = shift_offset; + n->size = cursor->size - shift_offset; + cursor->size = shift_offset; vma += shift_offset; n->lma = n->vma = vma; Index: ld/pe-dll.c =================================================================== RCS file: /cvs/src/src/ld/pe-dll.c,v retrieving revision 1.70 diff -u -p -r1.70 pe-dll.c --- ld/pe-dll.c 15 Jun 2004 01:13:20 -0000 1.70 +++ ld/pe-dll.c 22 Jun 2004 01:38:02 -0000 @@ -515,7 +515,7 @@ process_def_file (bfd *abfd ATTRIBUTE_UN s = bfd_get_section_by_name (b, ".drectve"); if (s) { - int size = bfd_get_section_size (s); + long size = s->size; char *buf = xmalloc (size); bfd_get_section_contents (b, s, buf, 0, size); @@ -1252,7 +1252,7 @@ generate_reloc (bfd *abfd, struct bfd_li if (page_ptr != (unsigned long) -1) bfd_put_32 (abfd, reloc_sz - page_ptr, reloc_d + page_ptr + 4); - while (reloc_sz < reloc_s->_raw_size) + while (reloc_sz < reloc_s->size) reloc_d[reloc_sz++] = 0; } Index: ld/emultempl/elf32.em =================================================================== RCS file: /cvs/src/src/ld/emultempl/elf32.em,v retrieving revision 1.117 diff -u -p -r1.117 elf32.em --- ld/emultempl/elf32.em 28 May 2004 05:42:30 -0000 1.117 +++ ld/emultempl/elf32.em 22 Jun 2004 01:38:03 -0000 @@ -840,7 +840,7 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" != if (sinterp != NULL) { sinterp->contents = ${ELF_INTERPRETER_NAME}; - sinterp->_raw_size = strlen (sinterp->contents) + 1; + sinterp->size = strlen (sinterp->contents) + 1; } " @@ -883,7 +883,7 @@ ${ELF_INTERPRETER_SET_DEFAULT} && sinterp != NULL) { sinterp->contents = (bfd_byte *) command_line.interpreter; - sinterp->_raw_size = strlen (command_line.interpreter) + 1; + sinterp->size = strlen (command_line.interpreter) + 1; } /* Look for any sections named .gnu.warning. As a GNU extensions, @@ -908,7 +908,7 @@ ${ELF_INTERPRETER_SET_DEFAULT} if (s == NULL) continue; - sz = bfd_section_size (is->the_bfd, s); + sz = s->size; prefix_len = strlen (gnu_warning_prefix); msg = xmalloc ((size_t) (prefix_len + sz + 1)); strcpy (msg, gnu_warning_prefix); @@ -926,7 +926,7 @@ ${ELF_INTERPRETER_SET_DEFAULT} /* Clobber the section size, so that we don't waste copying the warning into the output file. */ - s->_raw_size = 0; + s->size = 0; } } } Index: ld/emultempl/mmix-elfnmmo.em =================================================================== RCS file: /cvs/src/src/ld/emultempl/mmix-elfnmmo.em,v retrieving revision 1.10 diff -u -p -r1.10 mmix-elfnmmo.em --- ld/emultempl/mmix-elfnmmo.em 18 Oct 2003 15:49:09 -0000 1.10 +++ ld/emultempl/mmix-elfnmmo.em 22 Jun 2004 01:38:03 -0000 @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. # @@ -76,7 +76,7 @@ mmix_after_allocation (void) if (sec == NULL) return; - regvma = 256 * 8 - sec->_raw_size - 8; + regvma = 256 * 8 - sec->size - 8; /* If we start on a local register, we have too many global registers. We treat this error as nonfatal (meaning processing will continue in @@ -85,23 +85,13 @@ mmix_after_allocation (void) if (regvma < 32 * 8) { einfo ("%X%P: Too many global registers: %u, max 223\n", - (unsigned) sec->_raw_size / 8); + (unsigned) sec->size / 8); regvma = 32 * 8; } /* Set vma to correspond to first such register number * 8. */ bfd_set_section_vma (output_bfd, sec, (bfd_vma) regvma); - /* ??? Why isn't the section size (_cooked_size) set? Doesn't it get - set regardless of presence of relocations? */ - if (sec->_cooked_size == 0 - && ! bfd_set_section_size (output_bfd, sec, sec->_raw_size)) - { - /* This is a fatal error; make the einfo call not return. */ - einfo ("%F%P: Can't set section %s size to %u\n", - MMIX_REG_CONTENTS_SECTION_NAME, (unsigned) sec->_raw_size); - } - /* Simplify symbol output for the register section (without contents; created for register symbols) by setting the output offset to 0. This section is only present when there are register symbols. */ Index: ld/emultempl/sh64elf.em =================================================================== RCS file: /cvs/src/src/ld/emultempl/sh64elf.em,v retrieving revision 1.7 diff -u -p -r1.7 sh64elf.em --- ld/emultempl/sh64elf.em 27 Mar 2004 10:58:35 -0000 1.7 +++ ld/emultempl/sh64elf.em 22 Jun 2004 01:38:03 -0000 @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. # @@ -152,7 +152,7 @@ sh64_elf_${EMULATION_NAME}_before_alloca isec = isec->next) { if (isec->output_section == osec - && isec->_raw_size != 0 + && isec->size != 0 && (bfd_get_section_flags (isec->owner, isec) & SEC_EXCLUDE) == 0) { @@ -179,7 +179,7 @@ sh64_elf_${EMULATION_NAME}_before_alloca isec = isec->next) { if (isec->output_section == osec - && isec->_raw_size != 0 + && isec->size != 0 && (bfd_get_section_flags (isec->owner, isec) & SEC_EXCLUDE) == 0) { @@ -283,7 +283,7 @@ sh64_elf_${EMULATION_NAME}_after_allocat isec = isec->next) { if (isec->output_section == osec - && isec->_raw_size != 0 + && isec->size != 0 && (bfd_get_section_flags (isec->owner, isec) & SEC_EXCLUDE) == 0) { @@ -310,7 +310,7 @@ sh64_elf_${EMULATION_NAME}_after_allocat isec = isec->next) { if (isec->output_section == osec - && isec->_raw_size != 0 + && isec->size != 0 && (bfd_get_section_flags (isec->owner, isec) & SEC_EXCLUDE) == 0) { @@ -363,7 +363,7 @@ sh64_elf_${EMULATION_NAME}_after_allocat isec = isec->next) { if (isec->output_section == osec - && isec->_raw_size != 0 + && isec->size != 0 && (bfd_get_section_flags (isec->owner, isec) & SEC_EXCLUDE) == 0 && ((elf_section_data (isec)->this_hdr.sh_flags @@ -388,7 +388,7 @@ sh64_elf_${EMULATION_NAME}_after_allocat /* Make sure we have .cranges in memory even if there were only assembler-generated .cranges. */ cranges_growth = new_cranges * SH64_CRANGE_SIZE; - cranges->contents = xcalloc (cranges->_raw_size + cranges_growth, 1); + cranges->contents = xcalloc (cranges->size + cranges_growth, 1); bfd_set_section_flags (cranges->owner, cranges, bfd_get_section_flags (cranges->owner, cranges) | SEC_IN_MEMORY); @@ -403,7 +403,7 @@ sh64_elf_${EMULATION_NAME}_after_allocat return; } - crangesp = cranges->contents + cranges->_raw_size; + crangesp = cranges->contents + cranges->size; /* Now pass over the sections again, and make reloc orders for the new .cranges entries. Constants are set as we go. */ @@ -437,7 +437,7 @@ sh64_elf_${EMULATION_NAME}_after_allocat as containing mixed data, thus already having .cranges entries. */ if (isec->output_section == osec - && isec->_raw_size != 0 + && isec->size != 0 && (bfd_get_section_flags (isec->owner, isec) & SEC_EXCLUDE) == 0 && ((elf_section_data (isec)->this_hdr.sh_flags @@ -458,9 +458,7 @@ sh64_elf_${EMULATION_NAME}_after_allocat else cr_type = CRT_SH5_ISA16; - cr_size - = (isec->_cooked_size - ? isec->_cooked_size : isec->_raw_size); + cr_size = isec->size; /* Sections can be empty, like .text in a file that only contains other sections. Ranges shouldn't be @@ -563,8 +561,7 @@ sh64_elf_${EMULATION_NAME}_after_allocat Sorting before writing is done by sh64_elf_final_write_processing. */ - cranges->_cooked_size = crangesp - cranges->contents; sh64_elf_section_data (cranges)->sh64_info->cranges_growth - = cranges->_cooked_size - cranges->_raw_size; - cranges->_raw_size = cranges->_cooked_size; + = crangesp - cranges->contents - cranges->size; + cranges->size = crangesp - cranges->contents; } Index: ld/emultempl/sunos.em =================================================================== RCS file: /cvs/src/src/ld/emultempl/sunos.em,v retrieving revision 1.16 diff -u -p -r1.16 sunos.em --- ld/emultempl/sunos.em 3 Jan 2004 11:09:07 -0000 1.16 +++ ld/emultempl/sunos.em 22 Jun 2004 01:38:04 -0000 @@ -744,7 +744,7 @@ gld${EMULATION_NAME}_before_allocation ( dynamic object. */ ASSERT (need_entries != 0); - sneed->_raw_size = need_size; + sneed->size = need_size; sneed->contents = (bfd_byte *) xmalloc (need_size); need_contents = sneed->contents; @@ -764,7 +764,7 @@ gld${EMULATION_NAME}_before_allocation ( option. */ if (command_line.rpath) { - srules->_raw_size = strlen (command_line.rpath); + srules->size = strlen (command_line.rpath); srules->contents = (bfd_byte *) command_line.rpath; } else @@ -776,7 +776,7 @@ gld${EMULATION_NAME}_before_allocation ( for (search = search_head; search != NULL; search = search->next) if (search->cmdline) size += strlen (search->name) + 1; - srules->_raw_size = size; + srules->size = size; if (size > 0) { char *p; Index: ld/emultempl/xtensaelf.em =================================================================== RCS file: /cvs/src/src/ld/emultempl/xtensaelf.em,v retrieving revision 1.3 diff -u -p -r1.3 xtensaelf.em --- ld/emultempl/xtensaelf.em 27 Jun 2003 00:38:25 -0000 1.3 +++ ld/emultempl/xtensaelf.em 22 Jun 2004 01:38:04 -0000 @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2003 +# Copyright 2003, 2004 # Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. @@ -1252,7 +1252,7 @@ ld_assign_relative_paged_dot (bfd_vma do bfd_boolean sec_is_target = section_is_target (deps, l); bfd_boolean sec_is_source = section_is_source (deps, l); - if (section->_raw_size != 0 + if (section->size != 0 && (first_section || (in_literals && !sec_is_target) || (!in_literals && sec_is_target))) @@ -1260,7 +1260,7 @@ ld_assign_relative_paged_dot (bfd_vma do do_xtensa_alignment = TRUE; } first_section = FALSE; - if (section->_raw_size != 0) + if (section->size != 0) in_literals = (sec_is_target && !sec_is_source); } @@ -1269,7 +1269,7 @@ ld_assign_relative_paged_dot (bfd_vma do dot = align_power (dot, align_pow); section->output_offset = dot; - dot += section->_raw_size; + dot += section->size; } break; case lang_fill_statement_enum: @@ -1336,7 +1336,7 @@ ld_local_file_relocations_fit (lang_stat && e->tgt->output_offset != 0) { bfd_vma l32r_addr = - align_power (e->src->output_offset + e->src->_raw_size, 2); + align_power (e->src->output_offset + e->src->size, 2); bfd_vma target_addr = e->tgt->output_offset & ~3; if (l32r_addr < target_addr) { @@ -1386,7 +1386,7 @@ ld_xtensa_insert_page_offsets (bfd_vma d if (lit_align) { - if (section->_raw_size != 0 + if (section->size != 0 && (first_section || (in_literals && !section_is_target (deps, l)) || (!in_literals && section_is_target (deps, l)))) @@ -1394,7 +1394,7 @@ ld_xtensa_insert_page_offsets (bfd_vma d do_xtensa_alignment = TRUE; } first_section = FALSE; - if (section->_raw_size != 0) + if (section->size != 0) { in_literals = (section_is_target (deps, l) && !section_is_source (deps, l));