summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog365
-rw-r--r--bfd/aix386-core.c6
-rw-r--r--bfd/aix5ppc-core.c14
-rw-r--r--bfd/aout-adobe.c23
-rw-r--r--bfd/aout-target.h14
-rw-r--r--bfd/aout-tic30.c32
-rw-r--r--bfd/aoutf1.h10
-rw-r--r--bfd/aoutx.h107
-rw-r--r--bfd/bfd-in.h4
-rw-r--r--bfd/bfd-in2.h23
-rw-r--r--bfd/binary.c10
-rw-r--r--bfd/bout.c16
-rw-r--r--bfd/cisco-core.c8
-rw-r--r--bfd/coff-alpha.c16
-rw-r--r--bfd/coff-arm.c12
-rw-r--r--bfd/coff-h8300.c10
-rw-r--r--bfd/coff-mips.c8
-rw-r--r--bfd/coff-ppc.c12
-rw-r--r--bfd/coff-rs6000.c5
-rw-r--r--bfd/coff-sh.c123
-rw-r--r--bfd/coff64-rs6000.c15
-rw-r--r--bfd/coffcode.h44
-rw-r--r--bfd/coffgen.c8
-rw-r--r--bfd/cofflink.c41
-rw-r--r--bfd/cpu-arm.c31
-rw-r--r--bfd/cpu-ns32k.c10
-rw-r--r--bfd/dwarf1.c8
-rw-r--r--bfd/dwarf2.c18
-rw-r--r--bfd/ecoff.c57
-rw-r--r--bfd/elf-eh-frame.c73
-rw-r--r--bfd/elf-hppa.h10
-rw-r--r--bfd/elf-m10200.c20
-rw-r--r--bfd/elf-m10300.c154
-rw-r--r--bfd/elf.c111
-rw-r--r--bfd/elf32-arm.h78
-rw-r--r--bfd/elf32-cris.c90
-rw-r--r--bfd/elf32-d30v.c10
-rw-r--r--bfd/elf32-dlx.c6
-rw-r--r--bfd/elf32-frv.c72
-rw-r--r--bfd/elf32-h8300.c18
-rw-r--r--bfd/elf32-hppa.c99
-rw-r--r--bfd/elf32-i370.c34
-rw-r--r--bfd/elf32-i386.c100
-rw-r--r--bfd/elf32-i860.c16
-rw-r--r--bfd/elf32-ip2k.c46
-rw-r--r--bfd/elf32-m32r.c103
-rw-r--r--bfd/elf32-m68hc11.c34
-rw-r--r--bfd/elf32-m68hc12.c8
-rw-r--r--bfd/elf32-m68hc1x.c12
-rw-r--r--bfd/elf32-m68k.c77
-rw-r--r--bfd/elf32-mips.c16
-rw-r--r--bfd/elf32-or32.c6
-rw-r--r--bfd/elf32-ppc.c164
-rw-r--r--bfd/elf32-s390.c85
-rw-r--r--bfd/elf32-sh.c162
-rw-r--r--bfd/elf32-sh64-com.c20
-rw-r--r--bfd/elf32-sh64.c13
-rw-r--r--bfd/elf32-sparc.c96
-rw-r--r--bfd/elf32-v850.c30
-rw-r--r--bfd/elf32-vax.c67
-rw-r--r--bfd/elf32-xstormy16.c26
-rw-r--r--bfd/elf32-xtensa.c233
-rw-r--r--bfd/elf64-alpha.c101
-rw-r--r--bfd/elf64-hppa.c48
-rw-r--r--bfd/elf64-mips.c20
-rw-r--r--bfd/elf64-mmix.c110
-rw-r--r--bfd/elf64-ppc.c235
-rw-r--r--bfd/elf64-s390.c84
-rw-r--r--bfd/elf64-sh64.c73
-rw-r--r--bfd/elf64-sparc.c70
-rw-r--r--bfd/elf64-x86-64.c92
-rw-r--r--bfd/elfarm-nabi.c6
-rw-r--r--bfd/elfcode.h4
-rw-r--r--bfd/elflink.c108
-rw-r--r--bfd/elfn32-mips.c16
-rw-r--r--bfd/elfxx-ia64.c66
-rw-r--r--bfd/elfxx-mips.c171
-rw-r--r--bfd/hp300hpux.c6
-rw-r--r--bfd/hppabsd-core.c6
-rw-r--r--bfd/hpux-core.c6
-rw-r--r--bfd/i386linux.c12
-rw-r--r--bfd/i386msdos.c7
-rw-r--r--bfd/i386os9k.c10
-rw-r--r--bfd/ieee.c44
-rw-r--r--bfd/ihex.c12
-rw-r--r--bfd/irix-core.c6
-rw-r--r--bfd/libaout.h4
-rw-r--r--bfd/libbfd-in.h2
-rw-r--r--bfd/libbfd.c9
-rw-r--r--bfd/libbfd.h2
-rw-r--r--bfd/linker.c4
-rw-r--r--bfd/lynx-core.c9
-rw-r--r--bfd/m68klinux.c14
-rw-r--r--bfd/mach-o.c14
-rw-r--r--bfd/merge.c25
-rw-r--r--bfd/mmo.c28
-rw-r--r--bfd/netbsd-core.c6
-rw-r--r--bfd/nlm32-alpha.c16
-rw-r--r--bfd/nlm32-ppc.c6
-rw-r--r--bfd/nlm32-sparc.c6
-rw-r--r--bfd/nlmcode.h24
-rw-r--r--bfd/oasys.c12
-rw-r--r--bfd/opncls.c20
-rw-r--r--bfd/osf-core.c6
-rw-r--r--bfd/pdp11.c103
-rw-r--r--bfd/peXXigen.c80
-rw-r--r--bfd/pef.c10
-rw-r--r--bfd/ppcboot.c6
-rw-r--r--bfd/ptrace-core.c6
-rw-r--r--bfd/reloc.c37
-rw-r--r--bfd/reloc16.c12
-rw-r--r--bfd/riscix.c8
-rw-r--r--bfd/rs6000-core.c8
-rw-r--r--bfd/sco5-core.c6
-rw-r--r--bfd/section.c62
-rw-r--r--bfd/simple.c14
-rw-r--r--bfd/som.c70
-rw-r--r--bfd/sparclinux.c14
-rw-r--r--bfd/srec.c16
-rw-r--r--bfd/stabs.c79
-rw-r--r--bfd/sunos.c138
-rw-r--r--bfd/syms.c22
-rw-r--r--bfd/tekhex.c6
-rw-r--r--bfd/trad-core.c6
-rw-r--r--bfd/versados.c6
-rw-r--r--bfd/vms-gsd.c40
-rw-r--r--bfd/vms-misc.c6
-rw-r--r--bfd/vms-tir.c11
-rw-r--r--bfd/vms.c2
-rw-r--r--bfd/xcofflink.c132
-rw-r--r--bfd/xsym.c2
-rw-r--r--binutils/ChangeLog28
-rw-r--r--binutils/objcopy.c2
-rw-r--r--include/ChangeLog4
-rw-r--r--include/bfdlink.h2
-rw-r--r--ld/ChangeLog40
-rw-r--r--ld/emultempl/elf32.em8
-rw-r--r--ld/emultempl/mmix-elfnmmo.em16
-rw-r--r--ld/emultempl/sh64elf.em27
-rw-r--r--ld/emultempl/sunos.em6
-rw-r--r--ld/emultempl/xtensaelf.em14
-rw-r--r--ld/ldexp.c2
-rw-r--r--ld/ldlang.c94
-rw-r--r--ld/ldwrite.c24
-rw-r--r--ld/pe-dll.c4
145 files changed, 2857 insertions, 2975 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5b145c363be..112d4c7b36b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,364 @@
+2004-06-24 Alan Modra <amodra@bigpond.net.au>
+
+ * section.c (struct sec): Rename "_cooked_size" to "size".
+ Rename "_raw_size" to "rawsize".
+ (STD_SECTION): Adjust comments.
+ (bfd_set_section_size, bfd_get_section_contents): Use size.
+ (bfd_malloc_and_get_section): New function.
+ * bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
+ * coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
+ Correctly free reloc and contents memory.
+ * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
+ and fake CIE now that we can shink section size to zero.
+ (_bfd_elf_write_section_eh_frame): Likewise..
+ * elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
+ * elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
+ _bfd_stab_section_offset. Use _bfd_elf_section_offset.
+ * stabs.c (_bfd_stab_section_offset_): Remove unused args and
+ unneeded indirection.
+ * elf.c (_bfd_elf_section_offset): .. and update call.
+ * libbfd-in.h (_bfd_stab_section_offset): Update prototype.
+ * libbfd.h: Regenerate.
+ * bfd-in2.h: Regenerate.
+
+ Replace occurrences of "_raw_size" and "_cooked_size" in most places
+ with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
+ sections. Use "rawsize", if non-zero, for bfd_get_section_contents
+ calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
+ Similarly use "rawsize", if non-zero, in reloc functions to validate
+ reloc addresses. Use new bfd_malloc_and_get_section in most places
+ where bfd_get_section_contents was called. Expand all occurrences of
+ bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
+ grok_prstatus and similar functions to "size".
+ * aix386-core.c (aix386_core_file_p): ..
+ * aix5ppc-core.c (xcoff64_core_p): ..
+ * aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
+ aout_adobe_set_section_contents): ..
+ * aout-target.h (callback): ..
+ * aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
+ MY_bfd_final_link): ..
+ * aoutf1.h (sunos4_core_file_p): ..
+ * aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
+ adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
+ final_link, aout_link_input_section): ..
+ * binary.c (binary_object_p, binary_canonicalize_symtab,
+ binary_set_section_contents): ..
+ * bout.c (b_out_callback, b_out_write_object_contents,
+ b_out_set_section_contents, b_out_bfd_relax_section,
+ b_out_bfd_get_relocated_section_contents): ..
+ * cisco-core.c (cisco_core_file_validate): ..
+ * coff-alpha.c (alpha_ecoff_object_p,
+ alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
+ * coff-arm.c (coff_arm_relocate_section,
+ bfd_arm_allocate_interworking_sections): ..
+ * coff-h8300.c (h8300_reloc16_extra_cases,
+ h8300_bfd_link_add_symbols): ..
+ * coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
+ * coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
+ ppc_bfd_coff_final_link): ..
+ * coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
+ * coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
+ sh_align_loads, sh_coff_get_relocated_section_contents): ..
+ * coff64-rs6000.c (xcoff64_write_object_contents,
+ xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
+ * coffcode.h (coff_compute_section_file_positions,
+ coff_write_object_contents): ..
+ * coffgen.c (make_a_section_from_file, coff_write_symbols,
+ coff_section_symbol, build_debug_section): ..
+ * cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
+ process_embedded_commands, _bfd_coff_link_input_bfd,
+ _bfd_coff_write_global_sym): ..
+ * cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
+ * cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
+ * dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
+ * dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
+ _bfd_dwarf2_find_nearest_line): ..
+ * ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
+ ecoff_compute_section_file_positions,
+ _bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
+ * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
+ _bfd_elf_discard_section_eh_frame_hdr,
+ _bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
+ _bfd_elf_write_section_eh_frame,
+ _bfd_elf_write_section_eh_frame_hdr): ..
+ * elf-hppa.h (elf_hppa_sort_unwind): ..
+ * elf-m10200.c (mn10200_elf_relax_section,
+ mn10200_elf_relax_delete_bytes,
+ mn10200_elf_get_relocated_section_contents): ..
+ * elf-m10300.c (_bfd_mn10300_elf_create_got_section,
+ mn10300_elf_check_relocs, mn10300_elf_relax_section,
+ mn10300_elf_relax_delete_bytes,
+ mn10300_elf_get_relocated_section_contents,
+ _bfd_mn10300_elf_adjust_dynamic_symbol,
+ _bfd_mn10300_elf_discard_copies,
+ _bfd_mn10300_elf_size_dynamic_sections,
+ _bfd_mn10300_elf_finish_dynamic_sections): ..
+ * elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
+ _bfd_elf_make_section_from_phdr, elf_fake_sections,
+ bfd_elf_set_group_contents, map_sections_to_segments,
+ elf_sort_sections, assign_file_positions_for_segments,
+ SECTION_SIZE, copy_private_bfd_data,
+ _bfd_elf_get_dynamic_reloc_upper_bound,
+ _bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
+ _bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
+ elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
+ elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
+ _bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
+ * elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
+ bfd_elf32_arm_process_before_allocation,
+ elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
+ elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
+ elf32_arm_write_section): ..
+ * elf32-cris.c (cris_elf_grok_prstatus,
+ elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
+ elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
+ cris_elf_check_relocs, elf_cris_size_dynamic_sections,
+ elf_cris_discard_excess_dso_dynamics,
+ elf_cris_discard_excess_program_dynamics): ..
+ * elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
+ * elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
+ * elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
+ _frv_create_got_section, _frvfdpic_assign_plt_entries,
+ elf32_frvfdpic_size_dynamic_sections,
+ elf32_frvfdpic_modify_segment_map,
+ elf32_frvfdpic_finish_dynamic_sections): ..
+ * elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
+ elf32_h8_get_relocated_section_contents): ..
+ * elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
+ elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
+ allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
+ elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
+ elf32_hppa_finish_dynamic_sections): ..
+ * elf32-i370.c (i370_elf_adjust_dynamic_symbol,
+ i370_elf_size_dynamic_sections, i370_elf_check_relocs,
+ i370_elf_finish_dynamic_sections): ..
+ * elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
+ allocate_dynrelocs, elf_i386_size_dynamic_sections,
+ elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
+ * elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
+ i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
+ * elf32-ip2k.c (ip2k_is_switch_table_128,
+ ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
+ ip2k_relax_switch_table_256, ip2k_elf_relax_section,
+ adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
+ * elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
+ m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
+ allocate_dynrelocs, m32r_elf_size_dynamic_sections,
+ m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
+ m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
+ m32r_elf_get_relocated_section_contents): ..
+ * elf32-m68hc11.c (m68hc11_elf_build_one_stub,
+ m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
+ m68hc11_elf_relax_delete_bytes): ..
+ * elf32-m68hc12.c (m68hc12_elf_build_one_stub,
+ m68hc12_elf_size_one_stub): ..
+ * elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
+ elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
+ * elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
+ elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
+ elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
+ * elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
+ elf32_mips_grok_prstatus): ..
+ * elf32-or32.c (or32_elf_consth_reloc): ..
+ * elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
+ elf_create_pointer_linker_section, ppc_elf_create_linker_section,
+ ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
+ allocate_dynrelocs, ppc_elf_size_dynamic_sections,
+ ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
+ ppc_elf_final_write_processing): ..
+ * elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
+ allocate_dynrelocs, elf_s390_size_dynamic_sections,
+ elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
+ * elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
+ sh_elf_relax_delete_bytes, sh_elf_align_loads,
+ sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
+ sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
+ sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
+ * elf32-sh64-com.c (sh64_address_in_cranges,
+ sh64_get_contents_type): ..
+ * elf32-sh64.c (sh64_find_section_for_address,
+ sh64_elf_final_write_processing): ..
+ * elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
+ sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
+ allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
+ elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
+ * elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
+ * elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
+ elf_vax_size_dynamic_sections, elf_vax_discard_copies,
+ elf_vax_instantiate_got_entries, elf_vax_relocate_section,
+ elf_vax_finish_dynamic_sections): ..
+ * elf32-xstormy16.c (xstormy16_elf_24_reloc,
+ xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
+ xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
+ xstormy16_elf_finish_dynamic_sections): ..
+ * elf32-xtensa.c (xtensa_read_table_entries,
+ elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
+ elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
+ bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
+ elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
+ elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
+ get_relocation_opcode, retrieve_contents, find_relaxable_sections,
+ collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
+ relax_section, shrink_dynamic_reloc_sections, relax_property_section,
+ xtensa_callback_required_dependence): ..
+ * elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
+ elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
+ elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
+ elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
+ elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
+ elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
+ elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
+ elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
+ * elf64-hppa.c (allocate_dynrel_entries,
+ elf64_hppa_size_dynamic_sections,
+ elf64_hppa_finish_dynamic_sections): ..
+ * elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
+ mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
+ elf64_mips_grok_prstatus): ..
+ * elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
+ mmix_elf_relocate_section, mmix_elf_final_link,
+ mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
+ mmix_elf_relax_section, mmix_elf_get_section_contents): ..
+ * elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
+ ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
+ ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
+ allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
+ ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
+ toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
+ ppc64_elf_build_stubs, ppc64_elf_relocate_section,
+ ppc64_elf_finish_dynamic_sections): ..
+ * elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
+ allocate_dynrelocs, elf_s390_size_dynamic_sections,
+ elf_s390_finish_dynamic_sections): ..
+ * elf64-sh64.c (sh_elf64_get_relocated_section_contents,
+ sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
+ sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
+ sh64_elf64_finish_dynamic_sections): ..
+ * elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
+ sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
+ sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
+ sparc64_elf_finish_dynamic_symbol,
+ sparc64_elf_finish_dynamic_sections): ..
+ * elf64-x86-64.c (elf64_x86_64_grok_prstatus,
+ elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
+ elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
+ elf64_x86_64_finish_dynamic_sections): ..
+ * elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
+ * elfcode.h (elf_slurp_reloc_table): ..
+ * elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
+ elf_finalize_dynstr, elf_link_add_object_symbols,
+ bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
+ elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
+ * elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
+ elf32_mips_grok_prstatus): ..
+ * elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
+ elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
+ elfNN_ia64_choose_gp, elfNN_ia64_final_link,
+ elfNN_ia64_finish_dynamic_sections): ..
+ * elfxx-mips.c (mips_elf_create_procedure_table,
+ mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
+ _bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
+ mips_elf_global_got_index, mips_elf_multi_got,
+ mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
+ mips_elf_allocate_dynamic_relocations,
+ mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
+ _bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
+ _bfd_mips_elf_always_size_sections,
+ _bfd_mips_elf_size_dynamic_sections,
+ _bfd_mips_elf_finish_dynamic_symbol,
+ _bfd_mips_elf_finish_dynamic_sections,
+ _bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
+ _bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
+ _bfd_elf_mips_get_relocated_section_contents,
+ _bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
+ * hp300hpux.c (callback): ..
+ * hppabsd-core.c (make_bfd_asection): ..
+ * hpux-core.c (make_bfd_asection): ..
+ * i386linux.c (linux_link_create_dynamic_sections,
+ bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
+ * i386msdos.c (msdos_write_object_contents): ..
+ * i386os9k.c (os9k_callback, os9k_write_object_contents,
+ os9k_set_section_contents): ..
+ * ieee.c (parse_expression, ieee_slurp_external_symbols,
+ ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
+ ieee_write_section_part, do_with_relocs, do_as_repeat,
+ do_without_relocs, ieee_write_debug_part, init_for_output,
+ ieee_set_section_contents): ..
+ * ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
+ * irix-core.c (do_sections, make_bfd_asection): ..
+ * libaout.h (aout_section_merge_with_text_p): ..
+ * libbfd.c (_bfd_generic_get_section_contents,
+ _bfd_generic_get_section_contents_in_window): ..
+ * linker.c (default_indirect_link_order): ..
+ * lynx-core.c (make_bfd_asection): ..
+ * m68klinux.c (linux_link_create_dynamic_sections,
+ bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
+ * mach-o.c (bfd_mach_o_make_bfd_section,
+ bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
+ bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
+ bfd_mach_o_scan_read_segment): ..
+ * merge.c (_bfd_add_merge_section, record_section, merge_strings,
+ _bfd_merge_sections): ..
+ * mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
+ mmo_map_set_sizes, mmo_canonicalize_symtab,
+ mmo_internal_write_section, mmo_write_object_contents): ..
+ * netbsd-core.c (netbsd_core_file_p): ..
+ * nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
+ nlm_alpha_set_public_section): ..
+ * nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
+ * nlm32-sparc.c (nlm_sparc_write_import): ..
+ * nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
+ nlm_compute_section_file_positions): ..
+ * oasys.c (oasys_object_p, oasys_slurp_section_data,
+ oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
+ * opncls.c (get_debug_link_info): ..
+ * osf-core.c (make_bfd_asection): ..
+ * pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
+ adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
+ final_link, aout_link_input_section): ..
+ * peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
+ pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
+ * pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
+ bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
+ * ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
+ * ptrace-core.c (ptrace_unix_core_file_p): ..
+ * reloc.c (bfd_perform_relocation, bfd_install_relocation,
+ _bfd_final_link_relocate, bfd_generic_relax_section,
+ bfd_generic_get_relocated_section_contents): ..
+ * reloc16.c (bfd_coff_reloc16_relax_section,
+ bfd_coff_reloc16_get_relocated_section_c): ..
+ * riscix.c (riscix_some_aout_object_p): ..
+ * rs6000-core.c (read_hdr, make_bfd_asection): ..
+ * sco5-core.c (make_bfd_asection): ..
+ * simple.c (bfd_simple_get_relocated_section_contents): ..
+ * som.c (som_object_setup, setup_sections, som_prep_headers,
+ som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
+ som_set_reloc_info, som_get_section_contents,
+ som_bfd_link_split_section): ..
+ * sparclinux.c (linux_link_create_dynamic_sections,
+ bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
+ * srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
+ * stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
+ _bfd_write_stab_strings, _bfd_stab_section_offset): ..
+ * sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
+ bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
+ sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
+ sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
+ sunos_finish_dynamic_link): ..
+ * syms.c (_bfd_stab_section_find_nearest_line): ..
+ * tekhex.c (first_phase, tekhex_set_section_contents,
+ tekhex_write_object_contents): ..
+ * trad-core.c (trad_unix_core_file_p): ..
+ * versados.c (process_esd, process_otr, process_otr): ..
+ * vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
+ * vms-misc.c (add_new_contents): ..
+ * vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
+ * vms.c (vms_set_section_contents): ..
+ * xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
+ xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
+ _bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
+ * xsym.c (bfd_sym_scan): .. See above.
+
2004-06-21 H.J. Lu <hongjiu.lu@intel.com>
* elfxx-ia64.c (elfNN_ia64_relax_section): Add addend when
@@ -295,7 +656,7 @@
section names by inserting a new substring after .gnu.linkonce, except
for .gnu.linkonce.t.* where the "t." is replaced.
-2004-05-17 Adam Nemet <anemet@lnxw.com>
+2004-05-17 Adam Nemet <anemet@lnxw.com>
* config.bfd (sparc-*-lynxos* case): Add to obsolete list.
(m68-*-lynxos* case): Likewise.
@@ -390,7 +751,7 @@
(_frvfdpic_add_rofixup): Likewise.
2004-05-07 Brian Ford <ford@vss.fsi.com>
- DJ Delorie <dj@redhat.com>
+ DJ Delorie <dj@redhat.com>
* coffcode.h (coff_write_object_contents) [COFF_IMAGE_WITH_PE]:
Propagate IMAGE_FILE_LARGE_ADDRESS_AWARE.
diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c
index 22d045ae124..38be16150b9 100644
--- a/bfd/aix386-core.c
+++ b/bfd/aix386-core.c
@@ -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;
diff --git a/bfd/aix5ppc-core.c b/bfd/aix5ppc-core.c
index 03510765e18..fa066ecd537 100644
--- a/bfd/aix5ppc-core.c
+++ b/bfd/aix5ppc-core.c
@@ -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;
}
diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c
index c13f80fc24f..2e3a65f8a55 100644
--- a/bfd/aout-adobe.c
+++ b/bfd/aout-adobe.c
@@ -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, section, location, offset, count)
{
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, section, location, offset, count)
{
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, section, location, offset, count)
{
sect->filepos = section_start;
/* FIXME: Round to alignment. */
- section_start += sect->_raw_size;
+ section_start += sect->size;
}
}
}
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index fd344a45d59..5fb58d00669 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -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;
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index af99c4bde99..81ee1b6d5c3 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -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, input_bfd, input_section, contents,
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;
diff --git a/bfd/aoutf1.h b/bfd/aoutf1.h
index 352dadf4e54..eb5b2f935aa 100644
--- a/bfd/aoutf1.h
+++ b/bfd/aoutf1.h
@@ -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;
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 3282f87dfe2..ef64bb1cf37 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -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, execp, callback_to_real_object_p)
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, execp, callback_to_real_object_p)
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, execp, callback_to_real_object_p)
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, text_size, text_end)
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, text_size, text_end)
}
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, text_size, text_end)
#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, cache_ptr)
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, callback)
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_bfd, input_section, reloff_ptr,
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))
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 5f98164cba2..f2739484cf5 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -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)
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 87dd250d670..5001cf87b51 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -315,8 +315,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)
@@ -1270,13 +1270,17 @@ typedef struct bfd_section
/* 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
@@ -1469,6 +1473,9 @@ bfd_boolean bfd_get_section_contents
(bfd *abfd, asection *section, void *location, file_ptr offset,
bfd_size_type count);
+bfd_boolean bfd_malloc_and_get_section
+ (bfd *abfd, asection *section, bfd_byte **buf);
+
bfd_boolean bfd_copy_private_section_data
(bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
diff --git a/bfd/binary.c b/bfd/binary.c
index c8d8941ec55..2669ed3f814 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -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, alocation)
/* 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, alocation)
/* 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, data, offset, size)
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, data, offset, size)
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
diff --git a/bfd/bout.c b/bfd/bout.c
index f0281923519..63c30844bc4 100644
--- a/bfd/bout.c
+++ b/bfd/bout.c
@@ -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, section, location, offset, count)
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_info, again)
}
}
}
- 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 (output_bfd, link_info, link_order,
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 (output_bfd, link_info, link_order,
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);
diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c
index 6b3a71b0ab3..70ea03b7b46 100644
--- a/bfd/cisco-core.c
+++ b/bfd/cisco-core.c
@@ -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_info_loc)
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_info_loc)
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_info_loc)
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;
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 1f928d84b64..7f3f83137e4 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -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_contents (abfd, link_info, link_order,
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_contents (abfd, link_info, link_order,
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, input_bfd, input_section,
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
diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c
index e51d07d583c..eb7e038ae51 100644
--- a/bfd/coff-arm.c
+++ b/bfd/coff-arm.c
@@ -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, info, input_bfd, input_section,
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 (info)
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 (info)
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;
}
diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c
index e4d1399e31f..4cd8829f9a2 100644
--- a/bfd/coff-h8300.c
+++ b/bfd/coff-h8300.c
@@ -1231,7 +1231,7 @@ h8300_reloc16_extra_cases (bfd *abfd, struct bfd_link_info *link_info,
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, struct bfd_link_info *info)
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, struct bfd_link_info *info)
/* 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;
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index 9ef19852df7..ca3376d9fa0 100644
--- a/bfd/coff-mips.c
+++ b/bfd/coff-mips.c
@@ -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);
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c
index c1c2c32a178..799178e0891 100644
--- a/bfd/coff-ppc.c
+++ b/bfd/coff-ppc.c
@@ -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, info, input_bfd, input_section,
/* 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)
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index cbd3a914c37..79c5ae1cec4 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -2948,8 +2948,7 @@ xcoff_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto,
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, info, input_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. */
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index d78cc16d681..ade10fca025 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -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, <sac@cygnus.com>.
Relaxing code written by Ian Lance Taylor, <ian@cygnus.com>.
@@ -698,11 +698,9 @@ sh_relax_section (abfd, sec, link_info, again)
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, again)
|| 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, again)
(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, again)
/* 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, again)
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, again)
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, again)
#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, again)
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, again)
/* 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, again)
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, count)
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, count)
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, count)
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_relocs, contents, pswapped)
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 (output_bfd, link_info, link_order,
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)
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 41459b5c5a6..098ea420c6d 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -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_section, output_bfd, rel, sym, howto,
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, info, input_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. */
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index d261d866490..d40cc80e9d4 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -3023,7 +3023,7 @@ coff_compute_section_file_positions (abfd)
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 (abfd)
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 (abfd)
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 (abfd)
#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 (abfd)
}
#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 (abfd)
#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 (abfd)
{
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;
}
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index acb78b3cc11..22a85b3f6e6 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -131,7 +131,7 @@ make_a_section_from_file (abfd, hdr, target_index)
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;
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 4ad566cc22e..f9e89180aed 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -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_bfd,
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, &copy))
{
- 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_final_link_info *finfo, bfd *input_bfd)
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_final_link_info *finfo, bfd *input_bfd)
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_final_link_info *finfo, bfd *input_bfd)
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_link_hash_entry *h, void *data)
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? */
diff --git a/bfd/cpu-arm.c b/bfd/cpu-arm.c
index 17889f3b472..39367a80fa6 100644
--- a/bfd/cpu-arm.c
+++ b/bfd/cpu-arm.c
@@ -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_section)
{
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_section)
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_section)
}
FAIL:
- free (buffer);
+ if (buffer != NULL)
+ free (buffer);
return bfd_mach_arm_unknown;
}
diff --git a/bfd/cpu-ns32k.c b/bfd/cpu-ns32k.c
index 39e5b23937b..074eb70a62c 100644
--- a/bfd/cpu-ns32k.c
+++ b/bfd/cpu-ns32k.c
@@ -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, symbol, data, input_section, output_bfd,
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, symbol, data, input_section, output_bfd,
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, input_bfd, input_section, contents,
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
diff --git a/bfd/dwarf1.c b/bfd/dwarf1.c
index 6c3f4139079..6fa74fc4a96 100644
--- a/bfd/dwarf1.c
+++ b/bfd/dwarf1.c
@@ -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, section, symbols, offset,
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;
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 6f3664cc5a8..a09265755a0 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -281,6 +281,7 @@ read_indirect_string (struct comp_unit* 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* 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 offset, struct dwarf2_debug *stash)
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, struct dwarf2_debug *stash)
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;
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 576045f674a..40faea70c33 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -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, asym, ext, weak)
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, asym, ext, weak)
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 (abfd)
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 (abfd)
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, info, output_section, link_order)
{
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, info, output_section, link_order)
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, info, output_section, link_order)
/* 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
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 6dfd01ca828..be4e3072345 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -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 (bfd *abfd, struct bfd_link_info *info)
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 (struct bfd_link_info *info)
/* 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 *output_bfd ATTRIBUTE_UNUSED,
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 *abfd,
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 *abfd,
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 *abfd,
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 *abfd, struct bfd_link_info *info)
retval = bfd_set_section_contents (abfd, sec->output_section,
contents, (file_ptr) sec->output_offset,
- sec->_cooked_size);
+ sec->size);
free (contents);
return retval;
}
diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h
index 1f79147a880..1e280b71efd 100644
--- a/bfd/elf-hppa.h
+++ b/bfd/elf-hppa.h
@@ -1042,16 +1042,12 @@ static bfd_boolean elf_hppa_sort_unwind (bfd *abfd)
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))
diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c
index 52685253062..c9e32be1020 100644
--- a/bfd/elf-m10200.c
+++ b/bfd/elf-m10200.c
@@ -505,11 +505,6 @@ mn10200_elf_relax_section (abfd, sec, link_info, again)
|| (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, link_info, again)
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, link_info, again)
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, sec, addr, count)
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, sec, addr, count)
/* 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_contents (output_bfd, link_info, link_order,
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)
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index 9f5ab836a61..1dc9b147411 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -656,7 +656,7 @@ _bfd_mn10300_elf_create_got_section (abfd, info)
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, sec, relocs)
/* 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, sec, relocs)
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, sec, relocs)
/* 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, sec, relocs)
}
}
- 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, input_bfd, output_bfd,
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, input_bfd, output_bfd,
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, input_bfd, output_bfd,
}
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, link_info, again)
/* 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, link_info, again)
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, link_info, again)
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, link_info, again)
|| (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, link_info, again)
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, link_info, again)
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, sec, addr, count)
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, sec, addr, count)
/* 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_contents (output_bfd, link_info, link_order,
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 (info, h)
/* 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 (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 += 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 (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;
}
@@ -4328,8 +4283,7 @@ _bfd_mn10300_elf_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))
@@ -4338,10 +4292,10 @@ _bfd_mn10300_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;
}
@@ -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 (output_bfd, info)
{
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
}
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
/* 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 (output_bfd, info)
}
/* 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);
diff --git a/bfd/elf.c b/bfd/elf.c
index 93a3d3ac9f8..39e5ee2c5ca 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1030,10 +1030,7 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
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 *abfd, void *farg)
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 *abfd,
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 *abfd,
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 *asect, void *failedptrarg)
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 *asect, void *failedptrarg)
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, asection *sec, void *failedptrarg)
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, asection *sec, void *failedptrarg)
}
}
- 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, const void *arg2)
/* 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) starts at 0x%x whereas the segment starts a
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) starts at 0x%x whereas the segment starts a
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) starts at 0x%x whereas the segment starts a
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 *obfd)
#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 *obfd)
&& 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 *obfd)
&& 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 *obfd)
/* 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 (bfd *abfd)
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 *abfd,
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 *name, asection *sect)
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 *abfd,
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 *abfd,
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_Internal_Note *note)
/* 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_Internal_Note *note)
/* 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_Internal_Note *note)
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_Internal_Note *note)
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, Elf_Internal_Note *note)
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, Elf_Internal_Note *note)
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_Internal_Note *note)
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_Internal_Note *note, pid_t *tid)
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_Internal_Note *note, pid_t tid)
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, asymbol **dynsyms, asymbol **ret)
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++)
diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h
index 1cb2b37d615..6854b7d181b 100644
--- a/bfd/elf32-arm.h
+++ b/bfd/elf32-arm.h
@@ -589,7 +589,7 @@ bfd_elf32_arm_allocate_interworking_sections (info)
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_sections (info)
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 (abfd, link_info,
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_bfd, info)
{
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_bfd, info)
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_bfd, info)
{
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_bfd, info)
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_bfd, info)
}
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_bfd, info)
}
/* 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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
}
/* 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 (output_bfd, info)
}
/* 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 ATTRIBUTE_UNUSED, asection *sec,
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;
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 775fd0e7c32..ab98304be59 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -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, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
}
/* 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, relocs)
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, relocs)
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, relocs)
}
/* 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, relocs)
/* 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, relocs)
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_bfd, info)
{
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_bfd, info)
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_bfd, info)
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_bfd, info)
}
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_bfd, info)
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, inf)
|| 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 (h, inf)
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
diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c
index b08977f2f96..ffce4988d84 100644
--- a/bfd/elf32-d30v.c
+++ b/bfd/elf32-d30v.c
@@ -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, symbol, data, input_section, output_bfd,
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, symbol, data, input_section, output_bfd,
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, symbol, data, input_section, output_bf
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, symbol, data, input_section, output_bf
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
diff --git a/bfd/elf32-dlx.c b/bfd/elf32-dlx.c
index 7fb6d0c19e2..2301dae451b 100644
--- a/bfd/elf32-dlx.c
+++ b/bfd/elf32-dlx.c
@@ -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_entry, symbol, data,
{
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_entry, symbol, data,
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
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index ad2c324dfbd..3b64a0e8cf2 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -934,7 +934,7 @@ _frvfdpic_add_dyn_reloc (bfd *output_bfd, asection *sreloc, bfd_vma offset,
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, asection *rofixup, bfd_vma offset,
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, struct bfd_link_info *info)
}
/* 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 **entryp, void *info_)
/* 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 **entryp, void *info_)
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 (bfd *output_bfd,
{
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 (bfd *output_bfd,
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 (bfd *output_bfd,
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 (bfd *output_bfd,
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 (bfd *output_bfd,
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 (bfd *output_bfd,
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 (bfd *output_bfd,
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 *output_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 (bfd *output_bfd,
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 (bfd *output_bfd,
_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 (bfd *output_bfd,
}
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 *output_bfd,
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 (bfd *output_bfd,
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;
}
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index 877da8a6a31..3daef62c939 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -679,11 +679,6 @@ elf32_h8_relax_section (bfd *abfd, asection *sec,
|| (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, asection *sec,
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, asection *sec, bfd_vma addr, int count)
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, asection *sec, bfd_vma addr, int count)
/* 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 (bfd *output_bfd,
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)
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 54dbb9a62b9..4c35bbe4ea3 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -672,7 +672,7 @@ hppa_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
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_entry *gen_entry, void *in_arg)
/* 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_entry *gen_entry, void *in_arg)
return FALSE;
}
- stub_sec->_raw_size += size;
+ stub_sec->size += size;
return TRUE;
}
@@ -879,7 +879,7 @@ hppa_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
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 bfd_link_info *info,
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 bfd_link_info *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 (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 bfd_link_info *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;
}
@@ -1807,8 +1806,8 @@ allocate_plt_static (struct elf_link_hash_entry *h, void *inf)
/* 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_entry *h, void *inf)
{
/* 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_entry *h, void *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;
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_entry *h, void *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;
@@ -2041,7 +2040,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
{
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 *output_bfd ATTRIBUTE_UNUSED,
{
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
/* 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 *output_bfd ATTRIBUTE_UNUSED,
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_hash_table *htab,
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_link_info *info)
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_link_info *info)
{
/* 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_info *info)
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 *output_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 *output_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 *output_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 *output_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 *output_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 *output_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 *output_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))
{
diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c
index f7829250081..49ecbb2583f 100644
--- a/bfd/elf32-i370.c
+++ b/bfd/elf32-i370.c
@@ -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_bfd, info)
{
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_bfd, info)
{
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_bfd, info)
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_bfd, info)
}
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_bfd, info)
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, relocs)
}
}
- 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, info)
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_bfd, info)
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);
}
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index dee26a025cd..97891a58783 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -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_Internal_Note *note)
/* 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_Internal_Note *note)
/* pr_reg */
offset = 72;
- raw_size = 68;
+ size = 68;
break;
}
@@ -394,7 +394,7 @@ elf_i386_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
/* 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 bfd_link_info *info,
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 bfd_link_info *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 (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 bfd_link_info *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;
}
@@ -1500,10 +1500,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *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
@@ -1518,14 +1518,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *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
{
@@ -1562,11 +1562,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
}
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_entry *h, void *inf)
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_entry *h, void *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_Rel);
+ sreloc->size += p->count * sizeof (Elf32_External_Rel);
}
return TRUE;
@@ -1725,7 +1725,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
{
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 *output_bfd ATTRIBUTE_UNUSED,
{
/* 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 *output_bfd ATTRIBUTE_UNUSED,
}
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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_bfd,
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_bfd,
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_bfd,
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_bfd,
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_bfd,
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_bfd,
/* 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_bfd,
== 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 *output_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;
@@ -3185,7 +3185,7 @@ elf_i386_finish_dynamic_sections (bfd *output_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_RELSZ:
@@ -3198,7 +3198,7 @@ elf_i386_finish_dynamic_sections (bfd *output_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_REL:
@@ -3210,7 +3210,7 @@ elf_i386_finish_dynamic_sections (bfd *output_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;
}
@@ -3218,7 +3218,7 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd,
}
/* 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 *output_bfd,
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 *output_bfd,
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;
diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c
index f156bc51e1a..863d7aecbe1 100644
--- a/bfd/elf32-i860.c
+++ b/bfd/elf32-i860.c
@@ -38,6 +38,7 @@ i860_howto_pc26_reloc (bfd *abfd ATTRIBUTE_UNUSED,
{
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 ATTRIBUTE_UNUSED,
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;
diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c
index 6493be69959..758842b8373 100644
--- a/bfd/elf32-ip2k.c
+++ b/bfd/elf32-ip2k.c
@@ -503,7 +503,7 @@ ip2k_is_switch_table_128 (abfd, sec, addr, contents)
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, irel, again, misc)
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, addr, contents)
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, irel, again, misc)
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_info, again)
|| (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_info, again)
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_info, again)
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_info, again)
}
/* 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, endaddr, count, noadj)
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, endaddr, count, noadj)
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, addr, count)
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;
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 21d37b176ce..14aec619ef3 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -859,11 +859,13 @@ m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset,
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, symbol, data,
{
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, symbol, data,
}
/* 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_entry, symbol, data,
{
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_entry, symbol, data,
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()\n");
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()\n");
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()\n");
/* 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()\n");
{
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()\n");
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()\n");
{
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()\n");
}
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()\n");
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()\n");
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()\n");
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, info, input_bfd, input_section,
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, info, input_bfd, input_section,
}
/* 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()\n");
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()\n");
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()\n");
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()\n");
/* 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()\n");
}
/* 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_info, again)
|| 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_info, again)
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_info, again)
/* 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_info, again)
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, addr, count)
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 (output_bfd, link_info, link_order,
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)
diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c
index 42010b01dd2..00df7aab386 100644
--- a/bfd/elf32-m68hc11.c
+++ b/bfd/elf32-m68hc11.c
@@ -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_hash_entry *gen_entry, void *in_arg)
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_hash_entry *gen_entry,
/* 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, asection *sec,
|| (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, asection *sec,
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, asection *sec,
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, asection *sec,
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, asection *sec,
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, asection *sec,
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 *abfd, asection *sec,
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 *abfd, asection *sec,
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++)
diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c
index cfc265efd73..6115ee43a1b 100644
--- a/bfd/elf32-m68hc12.c
+++ b/bfd/elf32-m68hc12.c
@@ -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_hash_entry *gen_entry, void *in_arg)
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_hash_entry *gen_entry,
/* 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;
}
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index 2a139a405c2..ba501d1235c 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -534,8 +534,7 @@ elf32_m68hc11_size_stubs (bfd *output_bfd, bfd *stub_bfd,
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, struct bfd_link_info *info)
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 ATTRIBUTE_UNUSED,
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 ATTRIBUTE_UNUSED,
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();
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 39832be83cf..842f38cd725 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -513,9 +513,9 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
}
/* 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, relocs)
}
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, relocs)
|| 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, relocs)
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, relocs)
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_bfd, info)
{
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_bfd, info)
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_bfd, info)
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_bfd, info)
}
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_bfd, info)
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, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
}
/* 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);
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 2e6eeb9f5d0..188fa1c0c3f 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -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,
<ian@cygnus.com>.
@@ -824,6 +824,7 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
{
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 *symbol, arelent *reloc_entry,
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 *reloc_entry, asymbol *symbol,
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 *reloc_entry, asymbol *symbol,
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_Internal_Note *note)
/* 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
diff --git a/bfd/elf32-or32.c b/bfd/elf32-or32.c
index 65f8e2617d3..ee5b2c5a382 100644
--- a/bfd/elf32-or32.c
+++ b/bfd/elf32-or32.c
@@ -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 <ivang@opencores.org>
This file is part of BFD, the Binary File Descriptor library.
@@ -400,6 +400,7 @@ or32_elf_consth_reloc (abfd, reloc_entry, symbol, data, input_section,
{
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, symbol, data, input_section,
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. */
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index c4b46f6e242..f9710337e34 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -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);
@@ -1911,6 +1892,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)
@@ -1956,11 +1951,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;
@@ -2162,6 +2157,7 @@ ppc_elf_addr16_ha_reloc (bfd *abfd ATTRIBUTE_UNUSED,
char **error_message ATTRIBUTE_UNUSED)
{
bfd_vma relocation;
+ bfd_size_type sz;
if (output_bfd != NULL)
{
@@ -2169,7 +2165,8 @@ ppc_elf_addr16_ha_reloc (bfd *abfd ATTRIBUTE_UNUSED,
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))
@@ -2431,7 +2428,7 @@ elf_create_pointer_linker_section (bfd *abfd,
}
if (lsect->rel_section)
- lsect->rel_section->_raw_size += sizeof (Elf32_External_Rela);
+ lsect->rel_section->size += sizeof (Elf32_External_Rela);
}
else
{
@@ -2467,7 +2464,7 @@ elf_create_pointer_linker_section (bfd *abfd,
output a R_<xxx>_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);
}
}
@@ -2486,14 +2483,14 @@ elf_create_pointer_linker_section (bfd *abfd,
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;
@@ -2692,11 +2689,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)
@@ -2756,11 +2753,11 @@ ppc_elf_additional_program_headers (bfd *abfd)
++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;
@@ -3000,7 +2997,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
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;
}
@@ -3011,8 +3008,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *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 (htab->elf.dynobj, s))
{
if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
@@ -3021,10 +3017,10 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *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;
}
@@ -3078,15 +3074,15 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
/* 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
@@ -3103,13 +3099,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
/* 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
{
@@ -3141,20 +3137,20 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
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))
@@ -3162,12 +3158,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|| 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);
}
}
}
@@ -3258,7 +3254,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *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;
@@ -3319,17 +3315,17 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
{
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;
@@ -3367,7 +3363,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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))
@@ -3396,30 +3392,30 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
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
@@ -3447,7 +3443,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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
@@ -3475,14 +3471,14 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
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;
}
@@ -3503,7 +3499,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
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)
@@ -4567,7 +4563,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
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;
@@ -4583,7 +4579,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_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_JMPREL:
@@ -5825,7 +5821,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)
{
@@ -5841,14 +5837,14 @@ ppc_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
/* 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
@@ -5994,7 +5990,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info)
if (asec)
{
++ num_input_sections;
- output_section_size += asec->_raw_size;
+ output_section_size += asec->size;
}
}
@@ -6026,7 +6022,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info)
if (asec == NULL)
continue;
- length = asec->_raw_size;
+ length = asec->size;
if (length < 24)
{
error_message = _("corrupt or empty %s section in %s");
@@ -6127,7 +6123,7 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
if (apuinfo_list_length () == 0)
return;
- length = asec->_raw_size;
+ length = asec->size;
if (length < 20)
return;
@@ -6153,7 +6149,7 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
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))
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index fb8758b37cc..597b4cda630 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -398,6 +398,7 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, symbol, data, input_section,
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, symbol, data, input_section,
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_bfd, info)
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_bfd, info)
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_bfd, info)
{
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_bfd, info)
{
/* 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_bfd, info)
}
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
}
/* 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_bfd, info)
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
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 480fa4bea66..2e220a5f03d 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -1843,10 +1843,12 @@ sh_elf_reloc_loop (int r_type ATTRIBUTE_UNUSED, bfd *input_bfd,
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_UNUSED, bfd *input_bfd,
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, asection *sec,
}
#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, asection *sec,
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, asection *sec,
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, asection *sec,
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, asection *sec,
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, asection *sec, bfd_vma addr,
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, asection *sec, bfd_vma 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;
@@ -2908,13 +2892,13 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr,
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, asection *sec, bfd_vma addr,
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_UNUSED, asection *sec,
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_link_info *info,
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_link_info *info,
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_link_info *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;
}
@@ -4224,10 +4208,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *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
@@ -4242,14 +4226,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *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
{
@@ -4279,24 +4263,24 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
}
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_entry *h, void *inf)
}
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_entry *h, void *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;
@@ -4454,7 +4438,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
{
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
{
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 *output_bfd ATTRIBUTE_UNUSED,
{
/* 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 *output_bfd ATTRIBUTE_UNUSED,
}
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 (bfd *output_bfd,
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 *output_bfd, struct bfd_link_info *info)
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 *output_bfd, struct bfd_link_info *info)
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 *output_bfd, struct bfd_link_info *info)
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 *output_bfd, struct bfd_link_info *info)
/* 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 *output_bfd, struct bfd_link_info *info)
}
/* 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, Elf_Internal_Note *note)
/* 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
diff --git a/bfd/elf32-sh64-com.c b/bfd/elf32-sh64-com.c
index 4c219e8a8d4..98f47a9ffcf 100644
--- a/bfd/elf32-sh64-com.c
+++ b/bfd/elf32-sh64-com.c
@@ -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 *cranges, bfd_vma addr,
{
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 *cranges, bfd_vma addr,
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 *cranges, bfd_vma addr,
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, bfd_vma addr, sh64_elf_crange *rangep)
&& 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
diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c
index 8d7bd14e810..f9d5e383571 100644
--- a/bfd/elf32-sh64.c
+++ b/bfd/elf32-sh64.c
@@ -605,6 +605,7 @@ sh64_find_section_for_address (bfd *abfd ATTRIBUTE_UNUSED,
{
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 ATTRIBUTE_UNUSED,
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 *abfd,
= 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 *abfd,
/* 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);
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 3809567627a..f895220cf81 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -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, h)
.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, 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 (dynobj, s))
{
if (! bfd_set_section_alignment (dynobj, s, power_of_two))
@@ -1584,10 +1589,10 @@ elf32_sparc_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;
}
@@ -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 (output_bfd, info)
{
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 (output_bfd, info)
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 (output_bfd, info)
{
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 (output_bfd, info)
{
/* 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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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, info, input_bfd, input_section,
}
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
/* 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 (output_bfd, info)
/* 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);
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index b9dcf3c5ae7..05935e640af 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -1334,6 +1334,7 @@ v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err)
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, data, isection, obfd, err)
/* 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_info, again)
|| 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_info, again)
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_info, again)
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_info, again)
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_info, again)
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_info, again)
#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:
diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c
index 8ce4678e291..a0249b19f3d 100644
--- a/bfd/elf32-vax.c
+++ b/bfd/elf32-vax.c
@@ -777,7 +777,7 @@ elf_vax_check_relocs (abfd, info, sec, relocs)
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_bfd, info)
{
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_bfd, info)
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_bfd, info)
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_bfd, info)
}
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_bfd, info)
}
/* 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, infoptr)
}
/* 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, info, input_bfd, input_section,
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, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
}
/* 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);
diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c
index bbf6ee01487..6bf53e95106 100644
--- a/bfd/elf32-xstormy16.c
+++ b/bfd/elf32-xstormy16.c
@@ -372,6 +372,7 @@ xstormy16_elf_24_reloc (abfd, reloc_entry, symbol, data, input_section,
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_entry, symbol, data, input_section,
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, sec, relocs)
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, splt, info, again)
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, splt, info, again)
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, splt, info, again)
/* 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, splt, info, again)
}
}
- splt->_raw_size = splt->_cooked_size;
return TRUE;
}
@@ -749,7 +745,7 @@ xstormy16_elf_always_size_sections (output_bfd, info)
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 (abfd, info)
&& (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);
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 5e4d3ad2f65..495c275027d 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -504,8 +504,7 @@ xtensa_read_table_entries (abfd, section, table_p, sec_name)
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, table_p, sec_name)
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, srelgot)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_section, relocation,
/* 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_section, relocation,
{
/* 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, symbol, data, input_section,
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, symbol, data, input_section,
}
/* 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, info, input_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, info, input_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, info, input_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, sxtlit, sgotloc)
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_bfd, sxtlit, sgotloc)
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_bfd, sxtlit, sgotloc)
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 (output_bfd, info)
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 (output_bfd, info)
}
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 (output_bfd, info)
}
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 (output_bfd, info)
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 (output_bfd, info)
/* 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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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 (abfd, cookie, info, sec)
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 (abfd, cookie, info, sec)
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 (abfd, cookie, info, sec)
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, irel)
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_memory)
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_info, is_relaxable_p)
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_info)
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, contents, irel, link_info,
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, values)
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, values)
/* 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, abfd, input_section, rel)
/* 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, abfd, input_section, rel)
= 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, abfd, input_section, rel)
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_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;
@@ -5126,7 +5093,7 @@ relax_property_section (abfd, sec, link_info)
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_info)
/* 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_info)
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 (abfd, sec, link_info, callback, closure)
/* 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 (abfd, sec, link_info, callback, closure)
/* 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;
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 21785d50c30..a8f2cf0ff34 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -1036,6 +1036,7 @@ elf64_alpha_reloc_gpdisp (abfd, reloc_entry, sym, data, input_section,
{
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_entry, sym, data, input_section,
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, link_info, again)
|| 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, link_info, again)
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, sec, relocs)
{
/* 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, h)
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, h)
/* 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 (h, arg)
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_bfd, info)
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 (output_bfd, info)
{
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 (output_bfd, info)
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 (output_bfd, info)
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, srel, offset, dynindx, rtype, addend)
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
}
/* 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;
}
}
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 76dcc18b243..25431d410e1 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -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_bfd, info)
{
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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;
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index fa3b494b998..743444240aa 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -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, arelent *reloc_entry, asymbol *symbol,
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, arelent *reloc_entry, asymbol *symbol,
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 *reloc_entry, asymbol *symbol,
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 *reloc_entry, asymbol *symbol,
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 (bfd *abfd, arelent **storage,
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, asection *asect,
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_Internal_Note *note)
/* 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
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index bb3ac17d94e..992a3211561 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -991,10 +991,10 @@ mmix_elf_perform_relocation (isec, howto, datap, addr, value)
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, datap, addr, value)
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, datap, addr, value)
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, datap, addr, value)
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, datap, addr, value)
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, symbol, data, input_section,
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, symbol, data, input_section,
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, info, input_bfd, input_section,
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, info, input_bfd, input_section,
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, info, input_bfd, input_section,
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, info, input_bfd, input_section,
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, link_info)
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_info, again)
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_info, again)
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_info, again)
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_info, again)
*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_info, again)
&& 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_info, again)
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, section, location, offset, count)
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
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index a0d81d0550e..2b640414c41 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -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_Internal_Note *note)
/* 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, struct bfd_link_info *info,
};
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, struct bfd_link_info *info,
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 ATTRIBUTE_UNUSED,
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 ATTRIBUTE_UNUSED,
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 ATTRIBUTE_UNUSED,
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 bfd_link_info *info,
.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 bfd_link_info *info,
/* 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 bfd_link_info *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;
}
@@ -4970,7 +4970,7 @@ ppc64_elf_edit_opd (bfd *obfd, struct bfd_link_info *info)
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 bfd_link_info *info)
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 bfd_link_info *info)
}
}
- 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_entry *h, void *inf)
/* 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_entry *h, void *inf)
}
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_entry *h, void *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;
@@ -5843,7 +5843,7 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
{
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
}
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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_entry *gen_entry, void *in_arg)
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_entry *gen_entry, void *in_arg)
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 *gen_entry, void *in_arg)
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 *gen_entry, void *in_arg)
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 *gen_entry, void *in_arg)
}
}
- 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_link_info *info, asection *isec)
{
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_link_info *info, asection *isec)
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_link_info *info, asection *isec)
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_link_info *info, asection *isec)
/* 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_table *htab,
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_stub_syms,
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_stub_syms,
/* 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_stub_syms,
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_stub_syms,
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,
{
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_bfd,
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_bfd,
/* 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 *output_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 *output_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 *output_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 *output_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 *output_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 *output_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 *output_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 *output_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;
}
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 63e995070a9..788406f2686 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -420,6 +420,7 @@ s390_elf_ldisp_reloc (abfd, reloc_entry, symbol, data, input_section,
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, symbol, data, input_section,
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_bfd, info)
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_bfd, info)
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_bfd, info)
{
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_bfd, info)
{
/* 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_bfd, info)
}
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
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_bfd, info)
}
/* 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_bfd, info)
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
diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c
index ad6ca1c5037..e94aff18c88 100644
--- a/bfd/elf64-sh64.c
+++ b/bfd/elf64-sh64.c
@@ -2191,7 +2191,7 @@ sh_elf64_get_relocated_section_contents (bfd *output_bfd,
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 bfd_link_info *info,
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 bfd_link_info *info,
/* 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 bfd_link_info *info,
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 bfd_link_info *info,
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 bfd_link_info *info,
/* 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 bfd_link_info *info,
/* 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 bfd_link_info *info,
}
}
- 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 bfd_link_info *info,
/* 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 bfd_link_info *info,
&& (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 bfd_link_info *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;
}
@@ -3531,8 +3531,7 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info,
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 bfd_link_info *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;
}
@@ -3570,7 +3569,7 @@ sh64_elf64_discard_copies (struct elf_sh64_link_hash_entry *h,
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 *output_bfd,
{
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 *output_bfd,
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 *output_bfd,
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 *output_bfd,
}
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 *output_bfd,
}
/* 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 *output_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 *output_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 *output_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 *output_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 *output_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);
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index 905890e98a9..51f68bd0ba0 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -478,7 +478,7 @@ sparc64_elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
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, sec, relocs)
/* 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, sec, relocs)
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, sec, relocs)
/* 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, sec, relocs)
/* 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, sec, relocs)
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, h)
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, h)
}
/* 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, h)
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, 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))
@@ -1759,10 +1760,10 @@ sparc64_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;
}
@@ -1788,7 +1789,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
{
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
/* 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, info, input_bfd, input_section,
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 (output_bfd, info, h, sym)
}
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 (output_bfd, info)
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 (output_bfd, info)
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 (output_bfd, info)
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);
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index a701e45cef5..a24616b7880 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -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, Elf_Internal_Note *note)
/* 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 (struct bfd_link_info *info,
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 (struct bfd_link_info *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 (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 (struct bfd_link_info *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;
}
@@ -1300,10 +1300,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * 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
@@ -1318,14 +1318,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * 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
{
@@ -1362,25 +1362,25 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * 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_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_entry *h, void * 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;
@@ -1521,7 +1521,7 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
{
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 *output_bfd ATTRIBUTE_UNUSED,
{
/* 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 *output_bfd ATTRIBUTE_UNUSED,
}
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd ATTRIBUTE_UNUSED,
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 *output_bfd, struct bfd_link_info *info,
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 *output_bfd, struct bfd_link_info *info,
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 *output_bfd, struct bfd_link_info *info,
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 *output_bfd, struct bfd_link_info *info,
== 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 (bfd *output_bfd, struct bfd_link_info *inf
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 (bfd *output_bfd, struct bfd_link_info *inf
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 (bfd *output_bfd, struct bfd_link_info *inf
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 (bfd *output_bfd, struct bfd_link_info *inf
}
/* 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 (bfd *output_bfd, struct bfd_link_info *inf
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 (bfd *output_bfd, struct bfd_link_info *inf
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;
diff --git a/bfd/elfarm-nabi.c b/bfd/elfarm-nabi.c
index 961a52a0ccb..e2e34f3f62b 100644
--- a/bfd/elfarm-nabi.c
+++ b/bfd/elfarm-nabi.c
@@ -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
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 0c7be886d32..4a2d7a430d0 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -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;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 622d40680d9..51d20f8b364 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -98,7 +98,7 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
}
/* 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_link_info *info,
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_info *info,
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, struct bfd_link_info *info)
/* 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, struct bfd_link_info *info)
/* 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, struct bfd_link_info *info)
{
/* 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, struct bfd_link_info *info)
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, struct bfd_link_info *info)
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 *output_bfd,
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 *output_bfd,
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 *output_bfd,
}
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 *output_bfd,
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 *output_bfd,
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 *output_bfd,
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_link_info *info, asection **psec)
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 bfd_link_info *info, asection **psec)
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 bfd_link_info *info, asection **psec)
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 bfd_link_info *info, asection **psec)
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_link_info *finfo, bfd *input_bfd)
}
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_link_info *finfo, bfd *input_bfd)
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_link_info *finfo, bfd *input_bfd)
/* 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_link_info *finfo, bfd *input_bfd)
/* 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_link_info *finfo, bfd *input_bfd)
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 bfd_link_info *info)
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 bfd_link_info *info)
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 bfd_link_info *info)
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 bfd_link_info *info)
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 bfd_link_info *info)
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 bfd_link_info *info)
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 bfd_link_info *info)
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, struct bfd_link_info *info)
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;
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index 973edd52daf..dc93e17b844 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -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,
<ian@cygnus.com>.
@@ -1415,6 +1415,7 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
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 *symbol, arelent *reloc_entry,
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 *reloc_entry, asymbol *symbol,
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 *reloc_entry, asymbol *symbol,
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_Internal_Note *note)
/* 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);
}
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index e5a6214c452..6f0c06e0ab4 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -749,11 +749,6 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
&& 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, link_info, again)
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;
}
@@ -1006,7 +996,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
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. */
@@ -1018,7 +1008,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
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)
{
@@ -1174,8 +1164,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
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. */
}
@@ -2824,7 +2813,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. */
@@ -2840,18 +2829,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)
@@ -2866,7 +2855,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;
@@ -2926,7 +2915,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
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. */
@@ -2937,7 +2926,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
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. */
@@ -2946,7 +2935,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
{
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
@@ -2976,12 +2965,12 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
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. */
@@ -2990,7 +2979,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
{
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)
@@ -2999,7 +2988,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
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);
}
@@ -3020,7 +3009,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
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;
@@ -3097,8 +3086,8 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
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;
}
}
@@ -3409,8 +3398,7 @@ elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type,
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
@@ -3726,7 +3714,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;
@@ -3862,7 +3850,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;
}
@@ -3876,13 +3864,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;
}
@@ -4687,7 +4675,7 @@ elfNN_ia64_finish_dynamic_sections (abfd, info)
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);
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index cd43f8b555f..596c328baf6 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -978,7 +978,7 @@ mips_elf_create_procedure_table (void *handle, bfd *abfd,
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_elf_link_hash_entry *h,
/* 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_elf_link_hash_entry *h,
/* 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_elf_link_hash_entry *h,
/* 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, asymbol *symbol,
{
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, asymbol *symbol,
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 ATTRIBUTE_UNUSED, arelent *reloc_entry,
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, arelent *reloc_entry, asymbol *symbol,
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 ATTRIBUTE_UNUSED, arelent *reloc_entry,
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, bfd *ibfd, struct elf_link_hash_entry *h)
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 bfd_link_info *info,
}
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, bfd *input_bfd,
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 (bfd *abfd, unsigned int n)
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 *output_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, Elf_Internal_Shdr *hdr, asection *sec)
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, asection *sec,
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, asection *sec,
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, asection *sec,
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 (struct bfd_link_info *info,
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 *output_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 *output_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 *output_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 *output_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 *output_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 *output_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 *output_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 *output_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 (bfd *output_bfd,
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 (bfd *output_bfd,
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 (bfd *output_bfd,
/* 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 (bfd *output_bfd,
{
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 (bfd *output_bfd,
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 *abfd,
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 *abfd,
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 *abfd,
{
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, struct elf_reloc_cookie *cookie,
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, struct elf_reloc_cookie *cookie,
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, struct elf_reloc_cookie *cookie,
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_bfd, asection *sec,
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_bfd, asection *sec,
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 *abfd, sec_ptr section,
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_contents
/* 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_contents
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, struct bfd_link_info *info)
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, struct bfd_link_info *info)
}
/* 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, struct bfd_link_info *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;
@@ -8400,7 +8377,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *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
@@ -8504,7 +8481,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *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). */
@@ -8622,7 +8599,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info)
/* 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, struct bfd_link_info *info)
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, struct bfd_link_info *info)
{
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, struct bfd_link_info *info)
{
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, struct bfd_link_info *info)
{
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 (bfd *ibfd, bfd *obfd)
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"))))
diff --git a/bfd/hp300hpux.c b/bfd/hp300hpux.c
index f6cdd192154..732073a989a 100644
--- a/bfd/hp300hpux.c
+++ b/bfd/hp300hpux.c
@@ -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);
diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c
index be07c78ce92..542930f7574 100644
--- a/bfd/hppabsd-core.c
+++ b/bfd/hppabsd-core.c
@@ -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, _raw_size, offset, alignment_power)
return NULL;
asect->flags = flags;
- asect->_raw_size = _raw_size;
+ asect->size = size;
asect->filepos = offset;
asect->alignment_power = alignment_power;
diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c
index d624ad5d704..32b4eb41788 100644
--- a/bfd/hpux-core.c
+++ b/bfd/hpux-core.c
@@ -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, _raw_size, vma, alignment_power)
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;
diff --git a/bfd/i386linux.c b/bfd/i386linux.c
index da36e75c784..7ef0946597e 100644
--- a/bfd/i386linux.c
+++ b/bfd/i386linux.c
@@ -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, info)
|| ! 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 (output_bfd, info)
".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, info)
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;
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index cd41d0b049f..65080e3c6d5 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -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;
}
diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c
index 3be6bdd92b0..1a272d21aa6 100644
--- a/bfd/i386os9k.c
+++ b/bfd/i386os9k.c
@@ -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, location, offset, count)
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. */
diff --git a/bfd/ieee.c b/bfd/ieee.c
index fcabf750a0d..ac0dcc3798f 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -704,7 +704,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section)
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, location, offset, count)
{
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;
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 5c4c438e1a8..e818034c8e2 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -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, contents)
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, contents)
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, location, offset, count)
{
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))
diff --git a/bfd/irix-core.c b/bfd/irix-core.c
index 486842214f4..740907b86ec 100644
--- a/bfd/irix-core.c
+++ b/bfd/irix-core.c
@@ -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, _raw_size, vma, filepos)
return NULL;
asect->flags = flags;
- asect->_raw_size = _raw_size;
+ asect->size = size;
asect->vma = vma;
asect->filepos = filepos;
asect->alignment_power = 4;
diff --git a/bfd/libaout.h b/bfd/libaout.h
index 63242391359..a7628954889 100644
--- a/bfd/libaout.h
+++ b/bfd/libaout.h
@@ -666,8 +666,8 @@ extern bfd_boolean NAME(aout,bfd_free_cached_info)
&& 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) */
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index fd7f29662f3..2e4f1762f82 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -518,7 +518,7 @@ extern bfd_boolean _bfd_write_stab_strings
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. */
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index be090e9b069..d76a12e0317 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -692,10 +692,12 @@ _bfd_generic_get_section_contents (bfd *abfd,
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_window
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_window
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;
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 30890bc15b7..c17c4f3f83c 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -523,7 +523,7 @@ extern bfd_boolean _bfd_write_stab_strings
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. */
diff --git a/bfd/linker.c b/bfd/linker.c
index 58befc3632e..6ad32ba9535 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -2684,7 +2684,7 @@ default_indirect_link_order (bfd *output_bfd,
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_bfd,
}
/* 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;
diff --git a/bfd/lynx-core.c b/bfd/lynx-core.c
index 08bf2331c53..8eadd2e9ff4 100644
--- a/bfd/lynx-core.c
+++ b/bfd/lynx-core.c
@@ -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, _raw_size, vma, filepos)
return NULL;
asect->flags = flags;
- asect->_raw_size = _raw_size;
+ asect->size = size;
asect->vma = vma;
asect->filepos = filepos;
asect->alignment_power = 2;
diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c
index 996e5161424..d238e267098 100644
--- a/bfd/m68klinux.c
+++ b/bfd/m68klinux.c
@@ -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, info)
|| ! 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 (output_bfd, info)
".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, info)
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;
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index b2401c4359c..194898c171e 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -584,7 +584,7 @@ bfd_mach_o_make_bfd_section (abfd, section)
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, command)
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, command)
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, command)
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, command)
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, command)
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, command)
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;
diff --git a/bfd/merge.c b/bfd/merge.c
index 6b367b5734a..eb8ec667ead 100644
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -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 <jakub@redhat.com>.
This file is part of BFD, the Binary File Descriptor library.
@@ -340,7 +340,7 @@ _bfd_add_merge_section (bfd *abfd, void **psinfo, asection *sec,
|| (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 **psinfo, asection *sec,
/* 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 **psinfo, asection *sec,
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 *sinfo,
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_UNUSED, struct bfd_link_info *info,
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_UNUSED, struct bfd_link_info *info,
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_bfd ATTRIBUTE_UNUSED, asection **psec,
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)
diff --git a/bfd/mmo.c b/bfd/mmo.c
index fc6c21330f1..03244620fd5 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -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_number)
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;
diff --git a/bfd/netbsd-core.c b/bfd/netbsd-core.c
index b7dfcd65f7e..6c43e9ebe0f 100644
--- a/bfd/netbsd-core.c
+++ b/bfd/netbsd-core.c
@@ -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;
diff --git a/bfd/nlm32-alpha.c b/bfd/nlm32-alpha.c
index 990ce8d5a7a..3bf597b1787 100644
--- a/bfd/nlm32-alpha.c
+++ b/bfd/nlm32-alpha.c
@@ -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, rel)
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, rel)
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;
}
diff --git a/bfd/nlm32-ppc.c b/bfd/nlm32-ppc.c
index aafe2cc9971..9fb59b0416f 100644
--- a/bfd/nlm32-ppc.c
+++ b/bfd/nlm32-ppc.c
@@ -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, rel)
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, indx)
else if (sec == data_sec)
{
l_rsecnm = 1;
- address += bfd_section_size (abfd, code_sec);
+ address += code_sec->size;
}
else
{
diff --git a/bfd/nlm32-sparc.c b/bfd/nlm32-sparc.c
index e973d42a7be..847220e6b4f 100644
--- a/bfd/nlm32-sparc.c
+++ b/bfd/nlm32-sparc.c
@@ -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;
diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h
index 68e4a2a8723..bf41f27170a 100644
--- a/bfd/nlmcode.h
+++ b/bfd/nlmcode.h
@@ -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, size, flags)
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;
}
}
diff --git a/bfd/oasys.c b/bfd/oasys.c
index 2108bda25db..7df9c879685 100644
--- a/bfd/oasys.c
+++ b/bfd/oasys.c
@@ -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, section, location, offset, count)
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;
}
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 76030301ce1..e54e099d07d 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -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 long *crc32_out)
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;
}
diff --git a/bfd/osf-core.c b/bfd/osf-core.c
index 8273504e59a..7fe2b08f056 100644
--- a/bfd/osf-core.c
+++ b/bfd/osf-core.c
@@ -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, _raw_size, vma, filepos)
return NULL;
asect->flags = flags;
- asect->_raw_size = _raw_size;
+ asect->size = size;
asect->vma = vma;
asect->filepos = filepos;
asect->alignment_power = 8;
diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index db5b267270c..3bff3a63786 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -741,8 +741,8 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
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, execp, callback_to_real_object_p)
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, execp, callback_to_real_object_p)
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, text_size, text_end)
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, text_size, text_end)
}
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, text_size, text_end)
#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, section)
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, callback)
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_bfd, input_section, reloff_ptr,
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))
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 1b939e1013b..6a41e9bcaa5 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -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;)
{
diff --git a/bfd/pef.c b/bfd/pef.c
index e1bb5a76db5..8e63359c61d 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -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, csym)
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, csym)
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;
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
index cc4dc277410..5c80561fbfb 100644
--- a/bfd/ppcboot.c
+++ b/bfd/ppcboot.c
@@ -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, alocation)
/* 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, alocation)
/* 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;
diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c
index 15b6777e121..c22864a742f 100644
--- a/bfd/ptrace-core.c
+++ b/bfd/ptrace-core.c
@@ -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;
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 8300915b141..12cbb7ad396 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -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_type *howto,
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 ATTRIBUTE_UNUSED,
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_contents (bfd *abfd,
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_contents (bfd *abfd,
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,
diff --git a/bfd/reloc16.c b/bfd/reloc16.c
index 720e2d6abc2..4e809537dca 100644
--- a/bfd/reloc16.c
+++ b/bfd/reloc16.c
@@ -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, input_section, link_info, again)
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_contents (in_abfd,
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_contents (in_abfd,
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);
diff --git a/bfd/riscix.c b/bfd/riscix.c
index 519514e4cf6..f9b5ae2cd89 100644
--- a/bfd/riscix.c
+++ b/bfd/riscix.c
@@ -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, callback_to_real_object_p)
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, callback_to_real_object_p)
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)
diff --git a/bfd/rs6000-core.c b/bfd/rs6000-core.c
index 3fa0975dc31..98cae9a15c0 100644
--- a/bfd/rs6000-core.c
+++ b/bfd/rs6000-core.c
@@ -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, _raw_size, vma, filepos)
return NULL;
asect->flags = flags;
- asect->_raw_size = _raw_size;
+ asect->size = size;
asect->vma = vma;
asect->filepos = filepos;
asect->alignment_power = 8;
diff --git a/bfd/sco5-core.c b/bfd/sco5-core.c
index b88bd7b1af3..33592b2d316 100644
--- a/bfd/sco5-core.c
+++ b/bfd/sco5-core.c
@@ -52,11 +52,11 @@ bfd_boolean sco5_core_file_matches_executable_p
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, _raw_size, vma, filepos)
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;
diff --git a/bfd/section.c b/bfd/section.c
index 666f06d4f8c..70727ac74d7 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -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;
-.
-. {* 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;
+. size of <<.bss>>). *}
+. bfd_size_type 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 ptr, bfd_size_type val)
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
diff --git a/bfd/simple.c b/bfd/simple.c
index fc2472eefd2..0744215d24d 100644
--- a/bfd/simple.c
+++ b/bfd/simple.c
@@ -140,11 +140,10 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
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_contents (bfd *abfd,
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_contents (bfd *abfd,
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_contents (bfd *abfd,
free (symbol_table);
#endif
- sec->_cooked_size = old_cooked_size;
bfd_map_over_sections (abfd, simple_restore_output_info, saved_offsets);
free (saved_offsets);
diff --git a/bfd/som.c b/bfd/som.c
index e05d4af81bf..752467819c4 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1836,7 +1836,7 @@ som_object_setup (abfd, file_hdrp, aux_hdrp, current_offset)
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_offset)
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_offset)
/* 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, total_reloc_sizep)
/* 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, symbol)
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_relocs, section, symbols, just_count)
/* 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, location, offset, count)
{
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
diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c
index ecaaa0f9bf3..0b6acd70d6e 100644
--- a/bfd/sparclinux.c
+++ b/bfd/sparclinux.c
@@ -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, info)
|| ! 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 (output_bfd, info)
".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, info)
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;
diff --git a/bfd/srec.c b/bfd/srec.c
index 2eba70d588a..d75fa5113ac 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -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, contents)
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, contents)
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, contents)
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, location, offset, count)
{
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))
diff --git a/bfd/stabs.c b/bfd/stabs.c
index 04b91f68004..62bac2da910 100644
--- a/bfd/stabs.c
+++ b/bfd/stabs.c
@@ -194,14 +194,14 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo, pstring_of
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, stabsec, stabstrsec, psecinfo, pstring_of
/* 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, stabsec, stabstrsec, psecinfo, pstring_of
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, stabsec, stabstrsec, psecinfo, pstring_of
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, stabsec, stabstrsec, psecinfo, pstring_of
/* 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, stabsec, stabstrsec, psecinfo, pstring_of
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, stabsec, stabstrsec, psecinfo, pstring_of
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, stabsec, psecinfo,
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, stabsec, psecinfo,
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, stabsec, psecinfo,
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, stabsec, psecinfo,
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, psinfo, stabsec, psecinfo, contents)
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, psinfo, stabsec, psecinfo, contents)
/* 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, psinfo, stabsec, psecinfo, contents)
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, psinfo, stabsec, psecinfo, contents)
}
}
- 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, psinfo)
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, psinfo)
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)
{
diff --git a/bfd/sunos.c b/bfd/sunos.c
index 4d5099a40ad..e06bcaf1408 100644
--- a/bfd/sunos.c
+++ b/bfd/sunos.c
@@ -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, info, needed)
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_bfd, info, sdynptr, sneedptr,
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_bfd, info, sdynptr, sneedptr,
/* 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_bfd, info, sdynptr, sneedptr,
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_bfd, info, sdynptr, sneedptr,
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_bfd, info, sdynptr, sneedptr,
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_bfd, info, sdynptr, sneedptr,
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_bfd, info, sdynptr, sneedptr,
}
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_bfd, info, sdynptr, sneedptr,
/* 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, relocs, rel_size)
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, relocs, rel_size)
{
/* 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, relocs, rel_size)
/* 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, relocs, rel_size)
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, relocs, rel_size)
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, relocs, rel_size)
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, relocs, rel_size)
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, relocs, rel_size)
|| (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, relocs, rel_size)
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, relocs, rel_size)
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, relocs, rel_size)
{
/* 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, relocs, rel_size)
/* 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, relocs, rel_size)
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, info, harg)
{
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_bfd, input_section, harg, reloc,
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_bfd, input_section, harg, reloc,
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;
diff --git a/bfd/syms.c b/bfd/syms.c
index c07f48b4a9a..6b615a2b5f4 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -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 *abfd,
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 *abfd,
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 *abfd,
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
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 278e30358e8..b5ec8030bee 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -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, section, locationp, offset, bytes_to_do)
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);
}
diff --git a/bfd/trad-core.c b/bfd/trad-core.c
index 1b9e69f2a91..dda2e815471 100644
--- a/bfd/trad-core.c
+++ b/bfd/trad-core.c
@@ -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. */
diff --git a/bfd/versados.c b/bfd/versados.c
index cd5926ebfed..e454cf3af09 100644
--- a/bfd/versados.c
+++ b/bfd/versados.c
@@ -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);
}
}
diff --git a/bfd/vms-gsd.c b/bfd/vms-gsd.c
index 660c06cbc4c..5a107e18c7c 100644
--- a/bfd/vms-gsd.c
+++ b/bfd/vms-gsd.c
@@ -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);
diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c
index d0a24c7efa0..4b3fecc3762 100644
--- a/bfd/vms-misc.c
+++ b/bfd/vms-misc.c
@@ -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;
diff --git a/bfd/vms-tir.c b/bfd/vms-tir.c
index bd748ca3fa7..aa3e5360442 100644
--- a/bfd/vms-tir.c
+++ b/bfd/vms-tir.c
@@ -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)
diff --git a/bfd/vms.c b/bfd/vms.c
index f6d3c1a7f54..9d160e9d4a0 100644
--- a/bfd/vms.c
+++ b/bfd/vms.c
@@ -1670,7 +1670,7 @@ vms_set_section_contents (abfd, section, location, offset, count)
#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);
}
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index ccd82befdac..2d195ca78ca 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -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 <ian@cygnus.com>, 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_bfd, info, libpath, entry,
/* 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_bfd, info, libpath, entry,
/* 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_bfd, info, libpath, entry,
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, info, libpath, entry,
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_bfd, info, libpath, entry,
/* 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_bfd, info, libpath, entry,
}
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;
}
diff --git a/bfd/xsym.c b/bfd/xsym.c
index e5889d474f3..aa44e971c68 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -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;
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index b4d386d81bc..b50a534c16e 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2004-06-24 Alan Modra <amodra@bigpond.net.au>
+
+ * objcopy.c (copy_section): Don't set _cooked_size.
+
2004-06-22 Alan Modra <amodra@bigpond.net.au>
* readelf.c (Elf32_Word): Delete.
@@ -32,7 +36,7 @@
(get_64bit_dynamic_segment): Rename to get_64bit_dynamic_section.
Remove tag counting code as it is no longer needed.
(process_dynamic_segment): Rename to process_dynamic_section.
-
+
2004-06-15 Alan Modra <amodra@bigpond.net.au>
* objcopy.c (copy_section): Use bfd_get_section_size instead of
@@ -56,7 +60,7 @@
2004-05-17 David Heine <dlheine@tensilica.com>
- * objcopy.c (setup_bfd_headers): New function.
+ * objcopy.c (setup_bfd_headers): New function.
(copy_object): Call setup_bfd_headers.
2004-05-13 Paul Brook <paul@codesourcery.com>
@@ -250,8 +254,8 @@
* objcopy.c (copy_object): Make the function boolean, returning
FALSE upon failure.
- (copy_archive): Handle the return value from copy_object.
- (copy_file): Likewise.
+ (copy_archive): Handle the return value from copy_object.
+ (copy_file): Likewise.
2004-01-07 Nick Clifton <nickc@redhat.com>
@@ -259,14 +263,14 @@
section.
(get_debug_line_pointer_sizes): New function: Initialises the
debug_line_pointer_sizes array.
- (display_debug_lines): Call get_debug_line_pointer_sizes.
- (display_debug_loc): Likewise.
- (load_debug_loc): Use find_section.
- (load_debug_str): Likewise.
- (display_debug_info): Likewise.
- (prescan_debug_info): Delete.
- (debug_displays): Remove prescan field.
- (process_section_contents): Do not perform prescans.
+ (display_debug_lines): Call get_debug_line_pointer_sizes.
+ (display_debug_loc): Likewise.
+ (load_debug_loc): Use find_section.
+ (load_debug_str): Likewise.
+ (display_debug_info): Likewise.
+ (prescan_debug_info): Delete.
+ (debug_displays): Remove prescan field.
+ (process_section_contents): Do not perform prescans.
2004-01-03 Alan Modra <amodra@bigpond.net.au>
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 406ddc67e02..44e93313e9f 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2070,8 +2070,6 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
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)
{
diff --git a/include/ChangeLog b/include/ChangeLog
index 804d97f7128..d8173b71094 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2004-06-24 Alan Modra <amodra@bigpond.net.au>
+
+ * bfdlink.h (struct bfd_link_order): Update comment.
+
2004-05-11 Jakub Jelinek <jakub@redhat.com>
* bfdlink.h (struct bfd_link_info): Add relro, relro_start and
diff --git a/include/bfdlink.h b/include/bfdlink.h
index 881d7d4796d..9a57dfe1d64 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -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;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index c3927de4ee0..64956810977 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,29 @@
+2004-06-24 Alan Modra <amodra@bigpond.net.au>
+
+ * ldlang.c (print_output_section_statement): Don't print size before
+ relaxation.
+ (IGNORE_SECTION): Remove bfd arg. Update all callers.
+
+ * ldexp.c (fold_name): .. See below.
+ * ldlang.c (section_already_linked, print_output_section_statement,
+ print_input_section, insert_pad, size_input_section,
+ lang_check_section_addresses, lang_size_sections_1,
+ lang_size_sections, lang_do_assignments_1, lang_set_startof,
+ lang_one_common, lang_reset_memory_regions, lang_process,
+ lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
+ * ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
+ * pe-dll.c (process_def_file, generate_reloc): ..
+ * emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
+ gld${EMULATION_NAME}_before_allocation): ..
+ * emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
+ * emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
+ sh64_elf_${EMULATION_NAME}_after_allocation): ..
+ * emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
+ * emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
+ ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
+ "size" instead of "_raw_size" and "_cooked_size". Expand
+ bfd_section_size macro invocations.
+
2004-06-22 Aaron W. LaFramboise <aaron98wiridge9@aaronwl.com>
* ld/scripttemp/pe.sc (.CRT): Define ___crt_xc_start__,
@@ -10,10 +36,10 @@
* emulparams/elf32frvfd.sh (GENERATE_PIE_SCRIPT): Set to yes.
-2004-06-18 Adam Nemet <anemet@lnxw.com>
+2004-06-18 Adam Nemet <anemet@lnxw.com>
- * configure.in: Set EXTRA_SHLIB_EXTENSION to .a for LynxOS.
- * configure: Regenerate.
+ * configure.in: Set EXTRA_SHLIB_EXTENSION to .a for LynxOS.
+ * configure: Regenerate.
2004-06-15 Jakub Jelinek <jakub@redhat.com>
@@ -181,7 +207,7 @@
* scripttempl/elf.sc (.eh_frame, .gcc_except_table): Move into text
segment if all input sections are readonly.
-2004-05-19 Adam Nemet <anemet@lnxw.com>
+2004-05-19 Adam Nemet <anemet@lnxw.com>
* scripttempl/i386lynx.sc: Remove file.
@@ -189,7 +215,7 @@
* ld.texinfo (Output Section Address): Correct subsection name.
-2004-05-17 Adam Nemet <anemet@lnxw.com>
+2004-05-17 Adam Nemet <anemet@lnxw.com>
* configure.tgt (powerpc-*-lynxos* case): New case.
* configure.host (i[3-7]86-*-lynxos* case): Remove case.
@@ -248,7 +274,7 @@
before printing it with %W.
2004-05-07 Brian Ford <ford@vss.fsi.com>
- DJ Delorie <dj@redhat.com>
+ DJ Delorie <dj@redhat.com>
* emultempl/pe.em (real_flags): New static.
(OPTION_LARGE_ADDRESS_AWARE): New define.
@@ -278,7 +304,7 @@
2004-04-30 Eric Botcazou <ebotcazou@act-europe.fr>
- * ld.texinfo (--gc-sections): Remove restriction for
+ * ld.texinfo (--gc-sections): Remove restriction for
dynamic linking.
2004-04-29 Brian Ford <ford@vss.fsi.com>
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 2039846804a..8dbd60a5735 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -840,7 +840,7 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_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;
}
}
}
diff --git a/ld/emultempl/mmix-elfnmmo.em b/ld/emultempl/mmix-elfnmmo.em
index 9777fa307ba..4afa7ed7b08 100644
--- a/ld/emultempl/mmix-elfnmmo.em
+++ b/ld/emultempl/mmix-elfnmmo.em
@@ -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. */
diff --git a/ld/emultempl/sh64elf.em b/ld/emultempl/sh64elf.em
index 83bfe676bb1..0682f5ca980 100644
--- a/ld/emultempl/sh64elf.em
+++ b/ld/emultempl/sh64elf.em
@@ -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_allocation (void)
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_allocation (void)
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_allocation (void)
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_allocation (void)
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_allocation (void)
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_allocation (void)
/* 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_allocation (void)
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_allocation (void)
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_allocation (void)
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_allocation (void)
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;
}
diff --git a/ld/emultempl/sunos.em b/ld/emultempl/sunos.em
index 358bc9aabb9..13850bc58bf 100644
--- a/ld/emultempl/sunos.em
+++ b/ld/emultempl/sunos.em
@@ -744,7 +744,7 @@ gld${EMULATION_NAME}_before_allocation (void)
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 (void)
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 (void)
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;
diff --git a/ld/emultempl/xtensaelf.em b/ld/emultempl/xtensaelf.em
index 87629200f65..ffd4add1b71 100644
--- a/ld/emultempl/xtensaelf.em
+++ b/ld/emultempl/xtensaelf.em
@@ -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 dot,
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 dot,
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 dot,
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_statement_union_type *statement,
&& 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 dot,
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 dot,
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));
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 52e70a6cf3a..06b1fa1a2e2 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -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;
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 4db0a5f45b0..3d4098207f5 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -991,8 +991,7 @@ section_already_linked (bfd *abfd, asection *sec, void *data)
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_type *in)
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_type *in)
--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 **ptr,
}
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_entry *h, void *info)
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_entry *h, void *info)
/* 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 *secname, const char *name)
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);
diff --git a/ld/ldwrite.c b/ld/ldwrite.c
index 83670750d1b..a41a0e96c1f 100644
--- a/ld/ldwrite.c
+++ b/ld/ldwrite.c
@@ -251,10 +251,7 @@ build_link_order (lang_statement_union_type *statement)
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, const char *name, int *count)
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_link_info *info)
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_link_info *info)
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;
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 2b5609c09f2..43be40bb71e 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -515,7 +515,7 @@ process_def_file (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info)
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_link_info *info)
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;
}