Commit Graph

495 Commits

Author SHA1 Message Date
Nick Clifton 91d6fa6a03 Add -Wshadow to the gcc command line options used when compiling the binutils.
Fix up all warnings generated by the addition of this switch.
2009-12-11 13:42:17 +00:00
Alan Modra 3281215912 * elf.c (write_zeros): New function.
(assign_file_positions_for_load_sections): Allocate file space for
	NOBITS sections that are followed by PROGBITS sections in a segment.
2009-12-08 03:43:23 +00:00
Nick Clifton caa83f8b08 PR 10478
* elf.c (bfd_section_from_shdr): Allow SHN_BEFORE and SHN_AFTER
        section link values in x86 binaries.
        * elfcode.h (elf_object_p): Likewise.
        * readelf.c (get_elf_section_flags): Allow SHN_BEFORE and
        SHN_AFTER section link values in x86 binaries.
        (process_section_headers): Likewise.
2009-09-28 09:45:33 +00:00
Nick Clifton a50b1753d4 Updated soruces in bfd/* to compile cleanly with -Wc++-compat.
* bfd/aoutx.h: Add casts.
        * bfd/archive.c: Add casts.
        * bfd/archive64.c: Add casts.
        * bfd/archures.c: Add casts.
        * bfd/bfd-in2.h: Regenerated.
        * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top
        level.
        * bfd/bfdio.c: Add casts.
        * bfd/binary.c: Add casts.
        * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated
        parameter to use enum value instead of int.
        * bfd/coffcode.h: Add casts.
        * bfd/coffgen.c: Add casts.
        * bfd/cofflink.c: Add casts.
        * bfd/compress.c: Add casts.
        * bfd/dwarf1.c: Add casts.
        * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member
        bfd to bfd_ptr. Update code to use new name.
        * bfd/elf-attrs.c: Add casts.
        * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to
        anonymous struct. (union gotplt_union, struct
        elf_link_virtual_table_entry): Move to top level.
        * bfd/elf-eh-frame.c: Add casts.
        * bfd/elf-strtab.c: Add casts.
        * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change
        argument name from typename to type_name.
        * bfd/elf32-i386.c: Add casts.
        * bfd/elf64-x86-64.c: Add casts.
        * bfd/elfcode.h: Add casts.
        * bfd/elfcore.h: Add casts.
        * bfd/elflink.c: Add casts.
        * bfd/format.c: Add casts.
        * bfd/hash.c: Add casts.
        * bfd/ihex.c: Add casts.
        * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to
        top level.
        * bfd/libbfd.c: Add casts.
        * bfd/linker.c: Add casts.
        * bfd/merge.c: Add casts.
        * bfd/opncls.c: Add casts.
        * bfd/peXXigen.c: Add casts.
        * bfd/peicode.h: Add casts.
        * bfd/reloc.c: Add casts.
        * bfd/section.c: Add casts.
        * bfd/simple.c: Add casts.
        * bfd/srec.c: Add casts.
        * bfd/stabs.c: Add casts.
        * bfd/syms.c: Add casts.
        * bfd/targets.c: Add casts.
        * bfd/tekhex.c: Add casts.
        * bfd/verilog.c: Add casts.
        * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to
        top level.
2009-09-09 21:38:59 +00:00
Nick Clifton cfcac11dc8 PR 10478:
* elf.c (bfd_section_from_shdr): Do not reject sparc binaries with
        section headers containing sh_link values of SHN_BEFORE or
        SHN_AFTER.
        * elfcode.h (elf_object_p): Likewise.

        readelf.c (get_elf_section_flags): Add support for SHF_EXCLUDE and
        SHF_ORDERED.
        (process_section_headers): Warn about out of range sh_link
        values.  When displaying detailed section header information
        annote the SHN_BEFORE and SHN_AFTER values.
2009-09-09 15:03:54 +00:00
Jan Beulich 94be91de01 bfd/
2009-08-31  Jan Beulich  <jbeulich@novell.com>

	* elf-bfd.h (bfd_elf_get_default_section_type): Declare.
	* elf.c (bfd_elf_get_default_section_type): New.
	(elf_fake_sections): Use bfd_elf_get_default_section_type.

gas/
2009-08-31  Jan Beulich  <jbeulich@novell.com>

	* config/obj-elf.c (obj_elf_change_section): Set default type
	by calling bfd_elf_get_default_section_type.

gas/testsuite/
2009-08-31  Jan Beulich  <jbeulich@novell.com>

	* gas/elf/section5.l: Remove no longer issued warning pattern.
2009-08-31 12:02:36 +00:00
Alan Modra e7e75368a3 PR 10494
* elf.c (_bfd_elf_make_section_from_shdr): When setting up section
	LMAs, use ELF_IS_SECTION_IN_SEGMENT to match sections with headers.
2009-08-08 01:43:28 +00:00
Jakub Jelinek e47bf6909e PR binutils/10492
* elf.c (sym_is_global): Return true even for BSF_GNU_UNIQUE
	symbols.
	* elf32-mips.c (mips_elf_sym_is_global): Likewise.
	* elfn32-mips.c (mips_elf_sym_is_global): Likewise.
2009-08-06 13:08:24 +00:00
H.J. Lu 45b222d606 2009-08-03 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/10363
	* elf.c (bfd_elf_string_from_elf_section): Return NULL on
	invalid string offset.
2009-08-03 23:56:08 +00:00
Nick Clifton 3e7a7d11f1 * config/obj-elf.c (obj_elf_type): Add code to support a type of
gnu_unique_object.
        * doc/as.texinfo: Document new feature of .type directive.
        * NEWS: Mention support for gnu_unique_object symbol type.

        * common.h (STB_GNU_UNIQUE): Define.

        * NEWS: Mention the linker's support for symbols with a binding of
        STB_GNU_UNIQUE.

        * gas/elf/type.s: Add unique global symbol definition.
        * gas/elf/type.e: Add expected readelf output for global unique
        symbol.

        * elfcpp.h (enum STB): Add STB_GNU_UNIQUE.

        * readelf.c (get_symbol_binding): For Linux targeted files return
        UNIQUE for symbols with the STB_GNU_UNIQUE binding.
        * doc/binutils.texi: Document the meaning of the 'u' symbol
        binding in the output of nm and objdump --syms.

        * elf-bfd.h (struct elf_link_hash_entry): Add unique_global field.
        * elf.c (swap_out_syms): Set binding to STB_GNU_UNIQUE for symbols
        with the BSF_GNU_UNIQUE flag bit set.
        * elfcode.h (elf_slurp_symbol_table): Set the BSF_GNU_UNIQUE flag
        for symbols with STB_GNU_UNIQUE binding.
        * elflink.c (_bfd_elf_merge_symbol): Set unique_global for symbols
        with the STB_GNU_UNIQUE binding.
        (elf_link_add_object_symbols): Set the BSF_GNU_UNIQUE flag for
        symbols with STB_GNU_UNIQUE binding.  Set STB_GNU_UNIQUE for
        symbols with the unique_global field set.
        (elf_link_output_extsym): Set unique_global field for symbols with
        the STB_GNU_UNIQUE binding.
        * syms.c (struct bfd_symbol): Define BSF_GNU_UNIQUE flag bit.
        (bfd_print_symbol_vandf): Print a 'u' character for BSF_GNU_UNIQUE
        symbols.
        (bfd_decode_symclass): Return a 'u' character for BSF_GNU_UNIQUE
        symbols.
        * bfd-in2.h: Regenerate.
2009-07-23 13:00:30 +00:00
H.J. Lu 1d77084592 bfd/
2009-07-10  H.J. Lu  <hongjiu.lu@intel.com>

	* elf.c (_bfd_elf_get_synthetic_symtab): Remove leading zeros
	when reporting  addends.


ld/testsuite/

2009-07-10  H.J. Lu  <hongjiu.lu@intel.com>

	* ld-ifunc/ifunc-1-local-x86.d: Updated.
	* ld-ifunc/ifunc-1-x86.d: Likewise.Likewise.
	* ld-ifunc/ifunc-2-local-x86-64.d: Likewise.Likewise.
	* ld-ifunc/ifunc-2-x86-64.d: Likewise.
	* ld-ifunc/ifunc-3a-x86.d: Likewise.Likewise.
2009-07-10 14:03:03 +00:00
Alan Modra 041de40dc8 * elf.c (_bfd_elf_get_synthetic_symtab): Report addends. 2009-07-10 10:33:19 +00:00
H.J. Lu 83b89087cf bfd/
2009-06-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10337
	* elf.c (bfd_section_from_shdr): Don't change sh_link for
	SHT_REL/SHT_RELA sections on executable nor shared library.
	Treat SHT_REL/SHT_RELA sections with sh_link set to SHN_UNDEF
	as a normal section.

ld/testsuite/

2009-06-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10337
	* ld-ifunc/binutils.exp: New.
2009-06-27 16:07:10 +00:00
Alan Modra 87d72d41b0 * elf-bfd.h (struct sym_sec_cache): Delete.
(struct sym_cache): New.
	(bfd_section_from_r_symndx): Delete prototype.
	(bfd_sym_from_r_symndx): Define prototype.
	* elf.c (bfd_section_from_r_symndx): Delete, replace with..
	(bfd_sym_from_r_symndx): ..new function.
	* elf32-arm.c: Update all uses of struct sym_sec_cache and
	bfd_section_from_r_symndx to new struct and function.
	* elf32-bfin.c: Likewise.
	* elf32-hppa.c: Likewise.
	* elf32-i386.c: Likewise.
	* elf32-m32r.c: Likewise.
	* elf32-m68hc1x.c: Likewise.
	* elf32-m68hc1x.h: Likewise.
	* elf32-m68k.c: Likewise.
	* elf32-ppc.c: Likewise.
	* elf32-s390.c: Likewise.
	* elf32-sh.c: Likewise.
	* elf64-ppc.c: Likewise.
	* elf64-s390.c: Likewise.
	* elf64-x86-64.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* elfxx-sparc.h: Likewise.
2009-06-18 14:18:29 +00:00
Nick Clifton d8045f234d include/elf
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * common.h (STT_GNU_IFUNC): Define.

elfcpp
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * (enum STT): Add STT_GNU_IFUNC.

gas
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * config/obj-elf.c (obj_elf_type): Add support for a
        gnu_indirect_function type.
        * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups
        against indirect function symbols.
        * doc/as.texinfo (.type): Document the support for the
        gnu_indirect_function symbol type.
        * NEWS: Mention the new feature.

gas/testsuite
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * gas/elf/elf.exp: Extend type test to include an ifunc symbol.
        Provide an alternative test for targets which do not support ifunc
        symbols.
        (type.s): Add entry for an ifunc symbol.
        (type.e): Add ifunc entry to expected symbol dump.
        (section2.e-armelf): Add  entry for ifunc symbol.
        (type-noifunc.s): New file.
        (type-noifunc.e): New file.

bfd/
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs
        section pointer.
        (struct elf_obj_data): Add has_ifunc_symbols boolean.
        * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags
        into a STT_GNU_IFUNC symbol type.
        (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function
        type.
        (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if
        the binary contains ifunc symbols.
        * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC
        symbol type into a BSF_GNU_INDIRECT_FUNCTION flag.
        * elf32-i386.c (is_indirect_function): New function.
        (elf_i386_check_relocs): Create an ifunc output section.
        (allocate_dynrelocs): Create dynamic relocs in the ifunc output
        section if necessary.
        (elf_i386_relocate_section): Emit a reloc against an ifunc symbol
        if necessary.
        (elf_i386_add_symbol_hook): New function. Set the
        has_ifunc_symbols field of the elf_obj_data structure if an ifunc
        symbol is encountered.
        (elf_backend_post_process_headers): Define.
        (elf_backend_add_symbol_hook): Define.
        (elf_i386_post_process_headers): Rename to
        elf_i388_fbsd_post_process_headers.
        * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro.
        (is_indirect_function): New function.
        (elf64_x86_64_check_relocs): Create an ifunc output section.
        (allocate_dynrelocs): Create dynamic relocs in the ifunc output
        section if necessary.
        (elf64_x86_64_relocate_section): Emit a reloc against an ifunc
        symbol if necessary.
        (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the
        elf_obj_data structure if an ifunc symbol is encountered.
        (elf_backend_post_process_headers): Define.
        * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT
        if we have ifunc symbols to handle.
        (get_ifunc_reloc_section_name): New function.  Computes the name
        for an ifunc section.
        (_bfd_elf_make_ifunc_reloc_section): New function.  Creates a
        section to hold ifunc relocs.
        * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define.
        (bfd_print_symbol_vandf): Handle ifunc symbols.
        (bfd_decode_symclass): Likewise.
        * bfd-in2.h: Regenerate.

binutils
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * readelf.c (dump_relocations): Display a relocation against an
        ifunc symbol as if it were a function invocation.
        (get_symbol_type): Handle STT_GNU_IFUNC.

ld
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * NEWS: Mention support for IFUNC symbols.

ld/testsuite
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * ld-ifunc: New directory.
        * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests.
        * ld-ifunc/prog.c: New file.
        * ld-ifunc/lib.c: New file.
2009-04-30 15:47:13 +00:00
Alan Modra 9433b9b16e PR 6494
* elf.c (copy_elf_program_header): Do not check that PT_GNU_RELRO
	p_filesz and p_memsz are equal.  Use p_memsz as the segment size.
	(assign_file_positions_for_non_load_sections): Zap PT_GNU_RELRO
	if we don't find matching PT_LOAD when copying.
2009-03-26 12:23:52 +00:00
Mark Kettenis 67cc50334e * elf.c (elfcore_grok_openbsd_procinfo)
(elfcore_grok_openbsd_note): New functions.
(elf_parse_notes): Handle notes from OpenBSD ELF core files.
2009-03-18 16:26:54 +00:00
H.J. Lu 3516e9841c bfd/
2009-03-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/9945
	* elf.c (assign_section_numbers): Generate symbol table if there
	is any relocation in output.
	(_bfd_elf_compute_section_file_positions): Likewise.

binutils/

2009-03-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/9945
	* objcopy.c (copy_object): Clear HAS_RELOC when stripping all.
2009-03-13 13:39:57 +00:00
H.J. Lu b9d678e09f 2009-02-25 H.J. Lu <hongjiu.lu@intel.com>
* elf.c (elf_find_function): Use is_function_type to check
	function symbol.
2009-02-25 14:39:35 +00:00
Alan Modra 72a80a16c6 * elf-bfd.h (bfd_elf_get_str_section): Don't declare.
(bfd_elf_find_section, _sh_elf_set_mach_from_flags): Likewise.
	* elf.c (bfd_elf_get_str_section): Make static.
	(bfd_elf_find_section): Delete.
	* libbfd.h: Regenerate.
2009-02-02 03:52:38 +00:00
Nick Clifton 01e1a5bc12 * include/elf/ia64.h (SHT_IA_64_VMS_DISPLAY_NAME_INFO,
EF_IA_64_ARCHVER_1): New macros. Minor reformatting.

        * bfd/Makefile.am (BFD32_BACKENDS): Add new object vmsutil.lo
        (BFD32_BACKENDS_CFILES): Add new file vmsutil.c
        (vmsutil.lo): Add dependency rule
        * bfd/Makefile.in: Regenerate
        * bfd/config.bfd (ia64*-*-*vms*): Add case.
        * bfd/configure.in (bfd_elf64_ia64_vms_vec): Add case.
        * bfd/configure: Regenerate
        * bfd/vmsutil.[ch]: New files
        * bfd/elf-bfd.h (struct bfd_elf_special_section): Change type of
        attr to bfd_vma.
        * bfd/elfxx-ia64.c (elfNN_vms_post_process_headers,
        elfNN_vms_section_processing, elfNN_vms_final_write_processing,
        elfNN_vms_close_and_cleanup, elfNN_vms_section_from_shdr,
        elfNN_vms_object_p): New functions
        * bfd/targets.c (bfd_elf64_ia64_vms_vec): New target.

        * gas/configure.tgt(ia64-*-*vms*): New target.
        * gas/dwarf2dbg.h (dwarf2_loc_mark_labels): Make extern.
        * gas/tc.h (md_number_to_chars): Declare iff undefined.
        * gas/config/obj-elf.c (obj_elf_change_section): Change type of
        arg attr to bfd_vma.
        (obj_elf_parse_section_letters): Return a bfd_vma. Change type of
        variables attr, md_attr to bfd_vma.
        (obj_elf_section_word): Likewise.
        (obj_elf_section): Change type of variable attr to bfd_vma
        * gas/config/obj-elf.h (obj_elf_change_section): Change type of
        arg attr to bfd_vma
        * gas/config/tc-ia64.c (bfdver.h,time.h): Include.
        (ia64_elf_section_letter): Now returns a bfd_vma.
        Handle VMS specific attributes.
        (ia64_elf_section_flags): Arg attr now a bfd_vma.
        (ia64_init): Don't turn on dependency checking for VMS.
        (ia64_target_format): Check for VMS flag bit.
        (do_alias): Hande decc$ functions.
        (get_vms_time): New function.
        (ia64_vms_note): New function.
        * gas/config/tc-ia64.h (ia64_elf_section_letter): Now returns a bfd_vma.
        (ia64_elf_section_flags): Arg attr now a bfd_vma.
        (tc_init_after_args): Define for VMS.
        * gas/config/tc-alpha.c (alpha_elf_section_letter): Return a bfd_vma.
        (alpha_elf_section_flags): Change type of arg attr to bfd_vma.
        * gas/config/tc-alpha.h: Likewise.
        * gas/config/tc-i386.c (x86_64_section_letter): Return a bfd_vma.
        (x86_64_section_word): Return a bfd_vma.
        * gas/config/tc-i386.h: Likewise.
        * gas/config/tc-ip2k.c (ip2k_elf_section_flags): Change type of arg
        attr to bfd_vma.
        * gas/config/tc-ip2k.h: Likewise.
        * gas/config/tc-mep.c (mep_elf_section_letter): Return a bfd_vma.
        (mep_elf_section_flags): Change type of arg attr to bfd_vma.
        * gas/config/tc-mep.h: Likewise.
        * gas/config/tc-ppc.c  (ppc_section_letter): Return a bfd_vma.
        (ppc_section_word): Return a bfd_vma.
        (ppc_section_flags): Change type of arg attr to bfd_vma.
        * gas/config/tc-ppc.h: Likewise.
        * gas/config/te-vms.h (DWARF2_DIR_SHOULD_END_WITH_SEPARATOR,
        DWAR2_FILE_TIME_NAME, DWARF2_FILE_SIZE_NAME, DWARF2_FILEN_NAME):
        New file with new macros
        * gas/dwarf2dbg.c (get_filenum, out_file_list): Default and call new
        macros.
2009-01-15 12:42:52 +00:00
Nick Clifton 0f88be7a13 Remove STT_IFUNC support. 2008-12-23 09:01:51 +00:00
Nick Clifton e7c3341679 include/elf/
* common.h (STT_IFUNC): Define.
elfcpp/
            * elfcpp.h (enum STT): Add STT_IFUNC.
bfd/
            * syms.c (struct bfd_symbol): Add new flag BSF_INDIRECT_FUNCTION.
            Remove redundant flag BFD_FORT_COMM_DEFAULT_VALUE.  Renumber flags
            to remove gaps.
            (bfd_print_symbol_vandf): Return 'i' for BSF_INDIRECT_FUNCTION.
            (bfd_decode_symclass): Likewise.
            * elf.c (swap_out_syms): Translate BSF_INDIRECT_FUNCTION into
            STT_IFUNC.
            (elf_find_function): Treat STT_IFUNC in the same way as STT_FUNC.
            (_bfd_elf_is_function_type): Likewise.
            * elf32-arm.c (arm_elf_find_function): Likewise.
            (elf32_arm_adjust_dynamic_symbol): Likewise.
            (elf32_arm_swap_symbol_in): Likewise.
            (elf32_arm_additional_program_headers): Likewise.
            * elf32-i386.c (is_indirect_symbol): New function.
            (elf_i386_check_relocs): Also generate dynamic relocs for
            relocations against STT_IFUNC symbols.
            (allocate_dynrelocs): Likewise.
            (elf_i386_relocate_section): Likewise.
            * elf64-x86-64.c (is_indirect_symbol): New function.
            (elf64_x86_64_check_relocs): Also generate dynamic relocs for
            relocations against STT_IFUNC symbols.
            (allocate_dynrelocs): Likewise.
            (elf64_x86_64_relocate_section): Likewise.
            * elfcode.h (elf_slurp_symbol_table): Translate STT_IFUNC into
            BSF_INDIRECT_FUNCTION.
            * elflink.c (_bfd_elf_adjust_dynamic_reloc_section): Add support
            for STT_IFUNC symbols.
            (get_ifunc_reloc_section_name): New function.
            (_bfd_elf_make_ifunc_reloc_section): New function.
            * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs field.
            * bfd-in2.h: Regenerate.
gas/
            * config/obj-elf.c (obj_elf_type): Add support for STT_IFUNC type.
            * doc/as.texinfo: Document new feature.
            * NEWS: Mention new feature.
gas/testsuite/
            * gas/elf/type.s: Add test of STT_IFUNC symbol type.
            * gas/elf/type.e: Update expected disassembly.
            * gas/elf/elf.exp: Update grep of symbol types.
ld/
            * NEWS: Mention new feature.
            * pe-dll.c (process_def_file): Replace use of redundant
            BFD_FORT_COMM_DEFAULT_VALUE with 0.
            * scripttempl/elf.sc: Add .rel.ifunc.dyn and .rela.ifunc.dyn
            sections.
ld/testsuite/
            * ld-mips-elf/reloc-1-n32.d: Updated expected output for reloc
            descriptions.
            * ld-mips-elf/reloc-1-n64.d: Likewise.
            * ld-i386/ifunc.d: New test.
            * ld-i386/ifunc.s: Source file for the new test.
            * ld-i386/i386.exp: Run the new test.
2008-12-03 14:51:00 +00:00
Nick Clifton c91e322a29 * elf.c (swap_out_syms) [USE_STT_COMMON]: Fix syntax error. 2008-11-19 10:09:21 +00:00
Nick Clifton 2b0bc0884c bfd/
* elf.c (assign_file_positions_for_load_sections): Use header_size
        to avoid moving the load address of file headers.
        (assign_file_positions_for_load_sections): Set header_size for
        segments containing the file header.

        include/elf/
        * internal.h (struct elf_segment_map): Add header_size field.
2008-11-14 14:44:09 +00:00
Hans-Peter Nilsson 5726889422 PR ld/7028
* elf.c (assign_file_positions_for_load_sections): Allocate phrds
	with bfd_zalloc2 instead of bfd_alloc2.  For the amount, use
	the possibly-preset header-size, not the computed one.
2008-11-13 03:01:15 +00:00
Alan Modra 3337c1e561 PR 7023
* elf.c (bfd_section_from_shdr <SHT_SYMTAB>): Fail on invalid sh_info.
2008-11-12 22:04:04 +00:00
Alan Modra b84a33b5df * elf.c (assign_file_positions_for_non_load_sections): Consolidate
PT_GNU_RELRO handling.
2008-11-11 04:26:13 +00:00
Andreas Schwab 129af99fb5 PR 7011
* elf.c (assign_file_positions_for_non_load_sections): Handle
	PT_GNU_RELRO specially.
2008-11-10 22:47:58 +00:00
Alan Modra aea274d3a7 * elf.c (assign_file_positions_for_load_sections): When checking
a segment for contents, don't assume that a non-TLS nobits section
	must only be followed by nobits sections.
2008-10-08 08:30:27 +00:00
Alan Modra bcacc0f587 bfd/
* elf.c (bfd_elf_set_group_contents): Assign sh_info for ld -r when
	the signature symbol is global.
	* elflink.c (elf_link_input_bfd): Ensure group signature symbol
	is output when ld -r.  Set group sh_info when local.
	* linker.c (default_indirect_link_order): Handle group sections
	specially.
ld/
	* ldemul.c (ldemul_place_orphan): Add "name" param.
	* ldemul.h (ldemul_place_orphan): Update prototype.
	(struct ld_emulation_xfer_struct <place_orphan>): Likewise.
	* ldlang.c (lang_place_orphans): Generate unique section names here..
	* emultempl/elf32.em (place_orphan): ..rather than here.  Don't
	directly use an existing output section statement that has no
	bfd section.
	* emultempl/pe.em (place_orphan): Likewise.
	* emultempl/pep.em (place_orphan): Likewise.
	* emultempl/beos.em (place_orphan): Adjust.
	* emultempl/spuelf.em (spu_place_special_section): Adjust
	place_orphan call.
	* emultempl/genelf.em (gld${EMULATION_NAME}_after_open): New function.
	(LDEMUL_AFTER_OPEN): Define.
2008-10-03 09:40:49 +00:00
Alan Modra ceae84aacf bfd/
PR 6789
	* elf.c (assign_file_positions_for_load_sections): Call
	_bfd_elf_map_sections_to_segments, not elf_modify_segment_map.
	(get_program_header_size): Protect against NULL info.
	(_bfd_elf_map_sections_to_segments): Likewise.
	* elf32-spu.c (spu_elf_additional_program_headers): Likewise.
ld/testsuite/
	* ld-elf/extract-symbol-1sec.d: Correct section lma.
2008-09-29 14:12:02 +00:00
Alan Modra 9659de1cb3 * elf.c (_bfd_elf_init_private_section_data): Tweak union copy.
(bfd_section_from_shdr): Don't change SHT_GROUP section name.
	* elflink.c (section_signature): New function.
	(_bfd_elf_section_already_linked): Use it.
2008-09-28 13:30:35 +00:00
Alan Modra 4dd07732f2 * elf.c (bfd_elf_get_elf_syms): Don't leak memory on error.
* elflink.c (_bfd_elf_link_read_relocs): bfd_release on error.
	(elf_link_add_object_symbols): Don't leak memory on error.
	(bfd_elf_size_dynsym_hash_dynstr): Likewise.
	(elf_fixup_link_order): Free sections.
2008-08-08 08:00:14 +00:00
Richard Sandiford d35fd65983 bfd/
* elf-bfd.h (elf_backend_data): Add a "rela_plts_and_copies_p" field.
	* elfxx-target.h (elf_backend_rela_plts_and_copies_p): New macro.
	(elfNN_bed): Use it.
	* elf.c (_bfd_elf_get_synthetic_symtab): Use rela_plts_and_copies_p
	instead of default_use_rela_p to choose between ".rel.plt" and
	".rela.plt".
	* elflink.c (_bfd_elf_create_dynamic_sections): Use
	rela_plts_and_copies_p instead of default_use_rela_p to choose
	between ".rel.plt" and ".rela.plt", and between ".rel.bss" and
	".rela.bss".
2008-08-07 20:04:32 +00:00
Alan Modra 010c8431b0 * elf.c (rewrite_elf_program_header): Don't wrap p_paddr to
include file or program headers.
2008-08-01 06:39:04 +00:00
Alan Modra 0af1713e7c Silence gcc printf warnings 2008-07-30 04:34:58 +00:00
Alan Modra baea7ef144 * elf.c (_bfd_elf_make_section_from_shdr): Ignore return from
elf_parse_notes.  Use bfd_malloc_and_get_section.
	(elf_parse_notes): Validate note namesz and descsz.
2008-07-27 03:43:51 +00:00
Nick Clifton 4ff738568a * elf.c (_bfd_elf_map_sections_to_segments): Catch off by one
error assigning sections to segments.
2008-07-24 07:51:25 +00:00
Nick Clifton 39948a609d * elf.c (_bfd_elf_map_sections_to_segments): Allow sections in
adjoining pages to be included in the same segment.
2008-07-22 11:19:01 +00:00
Nick Clifton 37c43c558f * elf.c (assign_file_positions_for_load_sections): Print vma in
error message about overlapping section vmas.
2008-07-21 16:01:01 +00:00
Luis Machado 89eeb0bc23 * bfd/elf-bfd.h: Declare elfcore_write_ppc_vsx.
* bfd/elf.c (elfcore_grok_ppc_vsx): New function.
	(elfcore_write_ppc_vsx): New function
	(elfcore_grok_note): Handle VSX notes.
	(elfcore_write_register_note): Handle VSX notes.
	* include/elf/common.h: Define NT_PPC_VSX.
	* binutils/readelf.c (get_note_type): Handle VSX notes.
2008-07-21 05:33:37 +00:00
Jie Zhang 1bac266e85 Revert my last change since it has not been approved. 2008-07-12 08:54:13 +00:00
Jie Zhang 8c68457827 bfd/
* elf.c (_bfd_elf_map_sections_to_segments): Don't put
	executable sections into the same segment with other
	read only sections if --sep-code.
	* elf32-bfin.c (elf32_bfin_code_in_l1): New variable.
	(elf32_bfin_data_in_l1): New variable.
	(elf32_bfin_final_write_processing): New.
	(elf32_bfin_special_sections[]): New.
	(elf_backend_final_write_processing): Define.
	(elf_backend_special_sections): Define.

	binutils/
	* readelf.c (get_machine_flags): Deal with Blackfin specific
	flags.

	include/
	* bfdlink.h (struct bfd_link_info): Add sep_code member
	variable.
	* elf/bfin.h (EF_BFIN_CODE_IN_L1): Define.
	(EF_BFIN_DATA_IN_L1): Define.

	ld/
	* Makefile.am (eelf32bfin.c): Depend on bfin.em.
	(eelf32bfinfd.c): Likewise.
	* Makefile.in: Regenerate.
	* gen-doc.texi: Set Blackfin.
	* ld.texinfo: Document --sep-code and Blackfin specific
	options.
	* ldmain.c (main): Initialize link_info.sep_code.
	* lexsup.c (enum option_values): Add OPTION_SEP_CODE.
	(ld_options[]): Add --sep-code.
	(parse_args): Deal with --sep-code.
	* emulparams/bfin.sh (EXTRA_EM_FILE): Define.
	* emulparams/elf32bfinfd.sh (OTHER_SECTIONS): Define.
	* emultempl/bfin.em: New file.
2008-07-11 19:24:39 +00:00
Craig Silverstein 1b31505692 bfd/
* Makefile.am (BFD32_LIBS): Add compress.lo.
	(BFD32_LIBS_CFILES): Add compress.c.
	(BFD_H_FILES): Likewise.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Regenerate.
	* config.in: Add HAVE_ZLIB_H
	* configure.in: Add test for libz and zlib.h
	* configure: Regenerate.
	* dwarf2.c (read_section): New function.
	(read_indirect_string): Call new function read_section.
	(read_abbrevs): Likewise.
	(decode_line_info): Likewise.
	(read_debug_ranges): Likewise.
	(find_line): Call new function read_section when just one
	.zdebug_info section is found, otherwise read and compress
	multiple sections.
	(_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr.
	* elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix.
	(special_sections_z): New struct.
	(special_sections): Refer to special_sections_z.
	* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize
	sections named .zdebug_*.
	(_bfd_mips_elf_fake_sections): Likewise.
	* compress.c: New file.
	(bfd_uncompress_section_contents): New function.
bfd/doc/
	* Makefile.am (BFD_H_DEP): Add ../compress.c.
	* Makefile.in: Regenerate.
binutils/
	* config.in: Add HAVE_ZLIB_H
	* configure.in: Add test for libz and zlib.h
	* configure: Regenerate.
	* dwarf.c (debug_displays): Add .zdebug_* strings.
	* dwarf.h (struct dwarf_section): Add fields uncompressed_namd
	and compressed_name.
	* objdump.c (load_debug_section): Call
	bfd_uncompress_section_contents when loading a compressed
	section.
	(dump_dwarf_section): Recognize compressed section name.
	(mach_o_dwarf_sections): Rename as
	mach_o_uncompressed_dwarf_sections.
	(mach_o_compressed_dwarf_sections): New variable.
	(generic_dwarf_section): Rename as
	generic_uncompressed_dwarf_sections.
	(generic_compressed_dwarf_sections): New variable.
	(check_mach_o_dwarf): Save and restore
	mach_o_compressed_dwarf_sections.
	* readelf.c: Add #include for config.h and zlib.h
	(process_section_headers): Recognize compressed section name.
	(uncompress_section_contents): New function.
	(load_debug_section): Call uncompress_section_contents when
	loading a compressed section.
	(display_debug_section): Recognize compressed section name.
binutils/testsuite:
	* binutils-all/objdump.exp: Add test for objdump -s on a file
	with a compressed debug section.  Add test for objdump -W on a
	file that contains a compressed debug section.
	* binutils-all/readelf.exp: Call readelf_compressed_wa_test.
	(readelf_compressed_wa_test): New function.
	* binutils-all/dw2-compressed.S: New file.
	* binutils-all/objdump.W: New file.
	* binutils-all/objdump.s: New file.
	* binutils-all/readelf.wa: New file.
2008-07-10 01:32:23 +00:00
Richard Sandiford cb53bf42a0 bfd/
* elf.c (_bfd_elf_get_synthetic_symtab): Increment p by
	bed->s->int_rels_per_ext_rel.
2008-06-30 20:53:06 +00:00
Richard Sandiford 6ba2a41553 bfd/
* syms.c (BSF_SYNTHETIC): New flag.
	* elf.c (_bfd_elf_get_synthetic_symtab): Set it.
	* elf32-ppc.c (ppc_elf_get_synthetic_symtab): Likewise.
	* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise.
	* bfd-in.h (bfd_asymbol_flavour): Return bfd_target_unknown_flavour
	for synthetic symbols.
	* bfd-in2.h: Regenerate.

opcodes/
	* mips-dis.c (_print_insn_mips): Use bfd_asymbol_flavour to check
	for ELF symbols.
2008-06-30 20:51:58 +00:00
Alan Modra 0f0a5e5880 * elf.c (ignore_section_sym): Don't test section sym value here.
(elf_map_symbols): Instead check zero value here as was done prior
	to 2006-05-26 change.
2008-06-04 14:24:05 +00:00
Jan Kratochvil 11701589a8 bfd/
* elf.c (assign_file_positions_for_load_sections): Adjust pre-section
	gaps based on VMA and P_VADDR instead of LMA and P_PADDR addresses.
binutils/testsuite/
	* binutils-all/objcopy.exp: Call KEEP_DEBUG_SYMBOLS_AND_TEST_COPY.
	(keep_debug_symbols_and_test_copy): New function.
	(test5, test6): New variables.
2008-05-29 07:07:21 +00:00
Carlos Eduardo Seo bb864ac122 * elf.c (elfcore_write_register_note): New function.
* elf-bfd.h (elfcore_write_register_note): New prototype.
2008-05-24 16:14:59 +00:00