aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
AgeCommit message (Collapse)AuthorFilesLines
2014-10-31Avoid allocating over-large buffers when parsing corrupt binaries.Nick Clifton1-0/+5
PR binutils/17512 * coffgen.c (_bfd_coff_get_external_symbols): Do not try to load a symbol table bigger than the file. * elf.c (bfd_elf_get_str_section): Do not try to load a string table bigger than the file. * readelf.c (process_program_headers): Avoid memory exhaustion due to corrupt values in a dynamis segment header. (get_32bit_elf_symbols): Do not attempt to read an over-large section. (get_64bit_elf_symbols): Likewise.
2014-10-29Fixes another memory corruption bug introduced by patches for PR 17512.Nick Clifton1-1/+1
* elf.c (bfd_section_from_shdr): Fix heap use after free memory leak.
2014-10-29Thix fixes an obvious coding error that led to a GDB crash on AIX or HPUX.Dennis Brueni1-1/+1
* elf.c (elfcore_write_lwpstatus): fix typo in call to memcpy
2014-10-28More fixes for corrupt binaries crashing the binutils.Nick Clifton1-3/+13
PR binutils/17512 * elf.c (bfd_section_from_shdr): Allocate and free the recursion detection table on a per-bfd basis. * peXXigen.c (pe_print_edata): Handle binaries with a truncated export table.
2014-10-28This patch fixes a flaw in the SREC parser which could cause a stack overflowNick Clifton1-1/+1
and potential secuiryt breach. PR binutils/17510 * srec.c (srec_bad_byte): Increase size of buf to allow for negative values. (srec_scan): Use an unsigned char buffer to hold header bytes.
2014-10-27This fixes more seg-faults in tools like "strings" and "objdump" whenNick Clifton1-65/+129
presented with corrupt binaries. PR binutils/17512 * elf.c (bfd_section_from_shdr): Detect and warn about ELF binaries with a group of sections linked by the string table indicies. * peXXigen.c (pe_print_edata): Detect out of range rvas and entry counts for the Export Address table, Name Pointer table and Ordinal table.
2014-10-27This patch closes a potential security hole in applications that useNick Clifton1-4/+30
the bfd library to parse binaries containing maliciously corrupt section group headers. PR binutils/17510 * elf.c (setup_group): Improve handling of corrupt group sections.
2014-10-15Merge bfd_find_nearest_line variantsAlan Modra1-44/+17
When bfd_find_nearest_line_discriminator was added, not enough care was taken to ensure all targets had a proper definition of the function. This patch cures that by merging bfd_find_nearest_line_discriminator and bfd_find_nearest_line target implementations. PR 17481 * aoutx.h (NAME (aout, find_nearest_line)): Add "discriminator_ptr" param, group "section" and "offset" params. Zero discriminator. * bfd.c (bfd_find_nearest_line): Implement with new _bfd_find_nearest_line. (bfd_find_nearest_line_discriminator): Likewise. * coff-i386.c (_bfd_generic_find_nearest_line_discriminator): Don't define. * coff-rs6000.c (xcoff_find_nearest_line, xcoff_find_nearest_line_discriminator): Delete. (_bfd_xcoff_find_nearest_line): Don't define. (_bfd_xcoff_find_nearest_line): Define as coff_find_nearest_line. * coff-x86_64.c (_bfd_generic_find_nearest_line_discriminator): Don't define. * coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Adjust. * coffgen.c (coff_find_nearest_line_with_names): Reorder params, adjust _bfd_dwarf2_find_nearest_line call. (coff_find_nearest_line): Add "discriminator_ptr" param, reorder others. Set discriminator. Adjust call. (coff_find_nearest_line_discriminator): Delete. * dwarf1.c (_bfd_dwarf1_find_nearest_line): Reorder params. * dwarf2.c (find_line): Rename to.. (_bfd_dwarf2_find_nearest_line): ..this, reordering params. Simplify setting of do_line. Delete old function. (_bfd_dwarf2_find_line): Delete. * ecoff.c (_bfd_ecoff_find_nearest_line): Reorder params, add discriminator_ptr and set it. * elf-bfd.h (_bfd_elf_find_nearest_line): Update prototype. (_bfd_elf_find_nearest_line_discriminator): Delete. (_bfd_elf_find_line_discriminator): Delete. (_bfd_generic_find_nearest_line_discriminator): Don't define. * elf.c (elf_find_function): Reorder params. (_bfd_elf_find_nearest_line): Reorder params, add discriminator_ptr. Adjust calls. (_bfd_elf_find_nearest_line_discriminator): Delete. (_bfd_elf_find_line): Adjust call. * elf32-arm.c (arm_elf_find_function): Reorder params. (elf32_arm_find_nearest_line): Reorder params, add discriminator_ptr. Adjust calls. * elf64-alpha.c (elf64_alpha_find_nearest_line): Similarly. * elfnn-aarch64.c (aarch64_elf_find_function): Reorder params. (elfNN_aarch64_find_nearest_line): Reorder params, add discriminator_ptr. Adjust calls. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Similarly. * elfxx-mips.h (_bfd_mips_elf_find_nearest_line): Update prototype. * libaout.h (NAME (aout, find_nearest_line)): Update prototype. * libbfd-in.h (_bfd_nosymbols_find_nearest_line): Update. (_bfd_dwarf1_find_nearest_line): Likewise. (_bfd_dwarf2_find_nearest_line): Likewise. (_bfd_dwarf2_find_line): Delete. (_bfd_generic_find_nearest_line_discriminator): Delete. * libbfd.c (_bfd_generic_find_nearest_line_discriminator): Delete. * libcoff-in.h (coff_find_nearest_line): Update prototype. (coff_find_nearest_line_discriminator): Delete. (coff_find_nearest_line_with_names): Update prototype. * libecoff.h (_bfd_ecoff_find_nearest_line): Update prototype. * mach-o.c (bfd_mach_o_find_nearest_line): Reorder params, add discriminator_ptr. Adjust calls. * mach-o.h (bfd_mach_o_find_nearest_line): Update prototype. * pdp11.c (NAME (aout, find_nearest_line)): Reorder params, add discriminator_ptr and set. * som.c (som_find_nearest_line): Similarly. * targets.c (BFD_JUMP_TABLE_SYMBOLS): Delete entry for _bfd_find_nearest_line_discriminator. (struct bfd_target <_bfd_find_nearest_line>): Adjust prototype. (struct bfd_target <_bfd_find_nearest_line_discriminator>): Delete. * vms-alpha.c (_bfd_vms_find_nearest_dst_line): Rename to.. (_bfd_vms_find_nearest_line): ..this. Reorder params, add "discriminator" and set. (_bfd_vms_find_nearest_line_discriminator): Delete. (_bfd_generic_find_nearest_line_discriminator): Don't define. (alpha_vms_find_nearest_line): Update define. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * libcoff.h: Regenerate.
2014-09-11Move ELF section headers to end of object fileAlan Modra1-12/+13
Currently, section ordering differs a little for non-loaded reloc sections output by ld -emit-relocs or ld -r and that after passing such objects through objcopy. Not that it really matters, but it would be better for a simple objcopy to produce an unchanged output object file. Also, section headers are put somewhere in the middle of the non-loaded sections, again slightly differently for ld and objcopy. This patch fixes these discrepancies and puts section headers last, which is where gold puts them, and is where bfd_from_remote_memory wrongly assumed they will be found. bfd/ * elf.c (assign_file_positions_except_relocs): Move section header placement to.. (_bfd_elf_assign_file_positions_for_relocs): ..here. Make static. * elf-bfd.h (_bfd_elf_assign_file_positions_for_relocs): Delete. * elflink.c (bfd_elf_final_link): Don't call above function. gas/testsuite/ * gas/arm/got_prel.d: Adjust for changed section header placement. * gas/i386/ilp32/x86-64-size-1.d: Likewise. * gas/i386/ilp32/x86-64-size-3.d: Likewise. * gas/i386/ilp32/x86-64-size-5.d: Likewise. * gas/i386/ilp32/x86-64-unwind.d: Likewise. * gas/i386/size-1.d: Likewise. * gas/i386/size-3.d: Likewise. * gas/i386/x86-64-size-1.d: Likewise. * gas/i386/x86-64-size-3.d: Likewise. * gas/i386/x86-64-size-5.d: Likewise. * gas/i386/x86-64-unwind.d: Likewise. * gas/ia64/alias-ilp32.d: Likewise. * gas/ia64/alias.d: Likewise. * gas/ia64/group-1.d: Likewise. * gas/ia64/group-2.d: Likewise. * gas/ia64/secname-ilp32.d: Likewise. * gas/ia64/secname.d: Likewise. * gas/ia64/unwind-ilp32.d: Likewise. * gas/ia64/unwind.d: Likewise. * gas/mmix/bspec-1.d: Likewise. * gas/mmix/bspec-2.d: Likewise. * gas/mmix/byte-1.d: Likewise. * gas/mmix/loc-1.d: Likewise. * gas/mmix/loc-2.d: Likewise. * gas/mmix/loc-3.d: Likewise. * gas/mmix/loc-4.d: Likewise. * gas/mmix/loc-5.d: Likewise. * gas/tic6x/scomm-directive-4.d: Likewise. ld/testsuite/ * ld-aarch64/emit-relocs-local-addend.d: Adjust for changed section header placement. * ld-aarch64/local-addend-r.d: Likewise. * ld-mmix/bspec1.d: Likewise. * ld-mmix/bspec2.d: Likewise. * ld-mmix/local1.d: Likewise. * ld-mmix/local3.d: Likewise. * ld-mmix/local5.d: Likewise. * ld-mmix/local7.d: Likewise. * ld-mmix/undef-3.d: Likewise. * ld-sh/sh64/crange3-cmpct.rd: Likewise. * ld-sh/sh64/crange3-media.rd: Likewise. * ld-sh/sh64/crangerel1.rd: Likewise. * ld-sh/sh64/crangerel2.rd: Likewise. * ld-tic6x/common.d: Likewise. * ld-tic6x/shlib-1.rd: Likewise. * ld-tic6x/shlib-1b.rd: Likewise. * ld-tic6x/shlib-1r.rd: Likewise. * ld-tic6x/shlib-1rb.rd: Likewise. * ld-tic6x/shlib-app-1.rd: Likewise. * ld-tic6x/shlib-app-1b.rd: Likewise. * ld-tic6x/shlib-app-1r.rd: Likewise. * ld-tic6x/shlib-app-1rb.rd: Likewise. * ld-tic6x/shlib-noindex.rd: Likewise. * ld-tic6x/static-app-1.rd: Likewise. * ld-tic6x/static-app-1b.rd: Likewise. * ld-tic6x/static-app-1r.rd: Likewise. * ld-tic6x/static-app-1rb.rd: Likewise. * ld-x86-64/ilp32-4.d: Likewise. * ld-x86-64/split-by-file-nacl.rd: Likewise. * ld-x86-64/split-by-file.rd: Likewise.
2014-07-12Fix typo in _bfd_elf_strtab_addMaks Naumov1-1/+1
PR 17141 * elf.c (_bfd_elf_strtab_add): Check strtab name for failure.
2014-04-03This fixes a problem building large (> 2Gb) binaries on 32-bit hosts. Using aMaria Guseva1-1/+1
long type instead of long long meant that bfd_seek (SET) could be called with a negative offset. PR ld/16803 * elf.c (_bfd_elf_set_section_contents): Use correct type to hold file position.
2014-04-03Fix sim breakageAlan Modra1-1/+1
* elf-bfd.h (struct elf_backend_data <elf_backend_bfd_from_remote_memory>): Replace "size_t size" with "bfd_size_type size". (_bfd_elf32_bfd_from_remote_memory): Likewise. (_bfd_elf64_bfd_from_remote_memory): Likewise. * elf.c (bfd_elf_bfd_from_remote_memory): Likewise. * elfcode.h (bfd_from_remote_memory): Likewise.
2014-04-02Handle VDSO section headers past end of pageAlan Modra1-1/+2
When a VDSO gets large enough that it doesn't entirely fit in one page, but not so large that the part described by the program header exceeds one page, then gdb/BFD doesn't read the section headers and symbol table information. This patch cures that by passing the size of the vdso to BFD, and fixes a number of other issues in the BFD code. bfd/ * elfcode.h (bfd_from_remote_memory): Add "size" parameter. Consolidate code handling possible section headers past end of segment. Don't use p_align for page size guess, instead use minpagesize. Take note of ld.so clearing section headers when p_memsz > p_filesz. Handle file header specifying no section headers. Handle zero p_align throughout. Default loadbase to zero. Add comments. Rename contents_size to high_offset, and make it a bfd_vma. Delete unnecessary bfd_set_error calls. * bfd-in.h (bfd_elf_bfd_from_remote_memory): Update prototpe. * elf-bfd.h (struct elf_backend_data <elf_backend_from_remote_memory>): Likewise. (_bfd_elf32_bfd_from_remote_memory): Likewise. (_bfd_elf64_bfd_from_remote_memory): Likewise. * elf.c (bfd_elf_bfd_from_remote_memory): Adjust. * bfd-in2.h: Regnerate. gdb/ * symfile-mem.c (symbol_file_add_from_memory): Add size parameter. Pass to bfd_elf_bfd_from_remote_memory. Adjust all callers. (struct symbol_file_add_from_memory_args): Add size field. (find_vdso_size): New function. (add_vsyscall_page): Attempt to find vdso size.
2014-03-12objcopy/strip ELF program header p_vaddr confusionAlan Modra1-2/+3
copy_elf_program_header has logic to reject non-alloc sections when calculating p_vaddr offset for padding, but blithely assumed the first section in a segment was allocated. PR 16690 * elf.c (copy_elf_program_header): Ignore first section lma if non-alloc.
2014-03-05Update copyright yearsAlan Modra1-1/+1
2014-01-23Issue a linker error if TLS sections are not adjacentH.J. Lu1-3/+23
Bad linker script may lead to TLS sections separated by non-TLS sections in output. This patch changes linker assert to a linker error to provide better linker diagnosis. PR ld/16498 * elf.c (_bfd_elf_map_sections_to_segments): Issue a linker error if TLS sections are not adjacent.
2014-01-10Don't adjust LOAD segment to match GNU_RELRO segmentAlan Modra1-37/+0
Instead, fix Jakub's original code setting up the PR_GNU_RELRO header from the PT_LOAD header. PR ld/14207 PR ld/16322 PR binutils/16323 bfd/ * elf.c (assign_file_positions_for_load_sections): Revert last change. (assign_file_positions_for_non_load_sections): When setting up PT_GNU_RELRO header, don't require a corresponding PT_LOAD header that completely covers the relro region. ld/ * ldlang.c (lang_size_sections): Remove unneeded RELRO base adjust. Tidy comments. * ld.texinfo (DATA_SEGMENT_RELRO_END): Correct description. ld/testsuite/ * ld-x86-64/pr14207.d: Adjust
2014-01-08Adjust LOAD segment to generate GNU_RELRO segmentH.J. Lu1-5/+36
This patch fixes 2 GNU_RELRO segment bugs: 1. lang_size_sections didn't properly align base to the maximum alignment power of sections between DATA_SEGMENT_ALIGN and DATA_SEGMENT_RELRO_END. 2. ld failed to adjust LOAD segment to generate GNU_RELRO segment when LOAD segment doesn't fit GNU_RELRO segment. This is https://sourceware.org/bugzilla/show_bug.cgi?id=14207 We "fixed" ld by not generating GNU_RELRO segment. This patch adjusts LOAD segment to generate GNU_RELRO segment. It fixes PR ld/16322 and at the same time it also fixes PR binutils/16323 since now we can adjust LOAD segment if it is too small. bfd/ PR ld/14207 PR ld/16322 PR binutils/16323 * elf.c (_bfd_elf_map_sections_to_segments): Don't check section size for PT_GNU_RELRO segment. (assign_file_positions_for_load_sections): If PT_LOAD segment doesn't fit PT_GNU_RELRO segment, adjust its p_filesz and p_memsz. ld/ PR ld/14207 PR ld/16322 PR binutils/16323 * ldlang.c (lang_size_sections): Properly align RELRO base. ld/testsuite/ PR ld/14207 PR ld/16322 PR binutils/16323 * ld-elf/pr16322.d: New file. * ld-elf/pr16322.s: Likewise. * ld-x86-64/pr14207.d: Expect PT_GNU_RELRO segment.
2014-01-03 PR binutils/16199Nick Clifton1-1/+4
* elf.c (vma_page_aligned_bias): Handle a maxpagesize value of zero.
2013-12-19Set SHF_INFO_LINK bit for SHT_REL/SHT_RELA sectionsH.J. Lu1-1/+6
It is a good pratice to set the SHF_INFO_LINK bit when the sh_info field represents a section header index. bfd/ PR binutils/16317 * elf.c (assign_section_numbers): Set the SHF_INFO_LINK bit for SHT_REL/SHT_RELA sections when setting the sh_info field. binutils/testsuite/ PR binutils/16317 * binutils-all/readelf.s: Updated. * binutils-all/readelf.s-64: Likewise. ld/testsuite/ PR binutils/16317 * ld-elf/linkinfo1.s: New file. * ld-elf/linkinfo1a.d: Likewise. * ld-elf/linkinfo1b.d: Likewise.
2013-12-17Default elf_backend_post_process_headers to set OSABIH.J. Lu1-4/+3
* elf-bfd.h (_bfd_elf_set_osabi): Renamed to ... (_bfd_elf_post_process_headers): This. * elf.c (_bfd_elf_compute_section_file_positions): Always call elf_backend_post_process_headers. (_bfd_elf_set_osabi): Renamed to ... (_bfd_elf_post_process_headers): This. * elf32-hppa.c (elf_backend_post_process_headers): Removed. * elf32-i370.c (elf_backend_post_process_headers): Likewise. * elf32-msp430.c (elf_backend_post_process_headers): Likewise. * elf32-ppc.c (elf_backend_post_process_headers): Likewise. * elf32-sparc.c (elf_backend_post_process_headers): Likewise. * elf64-hppa.c (elf_backend_post_process_headers): Likewise. * elf64-ppc.c (elf_backend_post_process_headers): Likewise. * elf64-sparc.c (elf_backend_post_process_headers): Likewise. * elf64-x86-64.c (elf_backend_post_process_headers): Likewise. * (elf_backend_post_process_headers): Likewise. * (elf_backend_post_process_headers): Likewise. * elf32-i386.c (elf_backend_post_process_headers): Don't define as _bfd_elf_set_osabi. (elf_i386_fbsd_post_process_headers): Updated. * elf32-mips.c (elf_fbsd_post_process_headers): Removed. (elf_backend_post_process_headers): Likewise. * elf32-tic6x.c (elf32_tic6x_set_osabi): Removed. (elf_backend_post_process_headers): Likewise. * elf64-mips.c (elf_fbsd_post_process_headers): Removed. (elf_backend_post_process_headers): Likewise. * elfn32-mips.c (elf_fbsd_post_process_headers): Removed. (elf_backend_post_process_headers): Likewise. * elfnn-aarch64.c (elfNN_aarch64_post_process_headers): Updated. * elfxx-target.h (elf_backend_post_process_headers): Default to _bfd_elf_post_process_headers.
2013-12-12Also copy EI_OSABI fieldH.J. Lu1-5/+9
bfd/ PR binutils/16318 * elf.c (_bfd_elf_copy_private_bfd_data): Remove BFD_ASSERT. Set e_flags only if elf_flags_init is FALSE. Copy EI_OSABI field. binutils/testsuite/ PR binutils/16318 * binutils-all/strip-10.d: Check OS/ABI.
2013-12-12Set ET_EXEC for -pie -Ttext-segment=H.J. Lu1-0/+21
bfd/ * elf.c (assign_file_positions_except_relocs): Set e_type in ELF header to ET_EXEC for -pie -Ttext-segment=. 2013-12-10 H.J. Lu <hongjiu.lu@intel.com> * ld-pie/vaddr-0.d: New file. * ld-pie/vaddr-1.d: Likewise. * ld-pie/vaddr.s: Likewise.
2013-10-17 PR 16056Alan Modra1-2/+3
* elf.c (copy_elf_program_header): Only consider SEC_ALLOC sections when finding lowest_section.
2013-03-27 * elf-bfd.h (enum elf_reloc_type_class): Add reloc_class_ifunc.Alan Modra1-1/+3
(struct elf_backend_data <elf_backed_reloc_type_class>): Add bfd_link_info* and asection* params. (_bfd_elf_reloc_type_class): Likewise. * elf.c (_bfd_elf_reloc_type_class): Likewise. * elflink.c (elf_link_sort_cmp2): Sort first on reloc class. (elf_link_sort_relocs): Update elf_backed_reloc_type_class call. * elf32-ppc.c (ppc_elf_reloc_type_class): Return reloc_class_ifunc for any reliplt reloc. Don't return reloc_class_plt for R_PPC_REL24 and R_PPC_ADDR24. * elf64-ppc.c (allocate_got): Formatting. (ppc64_elf_reloc_type_class): Return reloc_class_ifunc for any reliplt reloc. * elf-m10300.c, * elf32-arm.c, * elf32-bfin.c, * elf32-cr16.c, * elf32-cris.c, * elf32-hppa.c, * elf32-i386.c, * elf32-lm32.c, * elf32-m32r.c, * elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c, * elf32-s390.c, * elf32-sh.c, * elf32-sparc.c, * elf32-tilepro.c, * elf32-vax.c, * elf32-xtensa.c, * elf64-aarch64.c, * elf64-alpha.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c, * elfnn-ia64.c, * elfxx-tilegx.c, * elfxx-tilegx.h: Add extra params to the various reloc_type_class functions.
2013-03-25 * elf-bfd.h (struct elf_backend_data <merge_symbol>): Update proto.Alan Modra1-1/+1
(_bfd_elf_init_reloc_shdr): Delete. * elf.c (_bfd_elf_init_reloc_shdr): Make static. * elf64-x86-64.c (elf_x86_64_merge_symbol): Trim parameters to just what is needed. * elflink.c (_bfd_elf_merge_symbol): Update bed->merge_symbol call.
2013-03-08 * elf-bfd.h (elfcore_write_s390_tdb): Add prototype.Nick Clifton1-4/+28
* elf.c (elfcore_write_s390_tdb): New function. (elfcore_write_register_note): Call it. (elfcore_grok_s390_tdb): New function. (elfcore_grok_note): Call it. * readelf.c (get_note_type): Add NT_S390_TDB.
2013-02-21bfd/Alan Modra1-8/+14
* elf-bfd.h (struct elf_build_id): Extracted from.. (struct elf_build_id_info): ..here. Delete. (struct output_elf_obj_tdata): New, extracted from.. (struct elf_obj_tdata): ..here. Reorganize for better packing. Add "o" field. (elf_program_header_size): Reference tdata->o. (elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker, elf_stack_flags, elf_shstrtab, elf_strtab_sec, elf_shstrtab_sec, elf_section_syms, elf_num_section_syms, elf_flags_init): Likewise. * elf.c (bfd_elf_allocate_object): Allocate output_elf_obj_tdata when opening bfd in any mode that might write. (_bfd_elf_write_object_contents): Use build_id field in output_elf_obj_tdata. (_bfd_elf_close_and_cleanup): Tweak elf_shstrtab test. (elfobj_grok_gnu_build_id): Adjust for elf_tdata changes. gdb/ * elfread.c (build_id_bfd_get): Adjust for elf_tdata changes. ld/ * emultempl/elf32.em (write_build_id, setup_build_id): Adjust for elf_tdata changes.
2013-02-21 * elf-bfd.h (struct core_elf_obj_tdata): New.Alan Modra1-42/+45
(struct elf_obj_tdata): Delete core_signal, core_pid, core_lwpid, core_program, and core_command. Add "core". * elf.c (bfd_elf_mkcorefile): Allocate "core" struct. Update all refs to tdata core fields. * elf32-am33lin.c, * elf32-arm.c, * elf32-cris.c, * elf32-frv.c, * elf32-hppa.c, * elf32-i386.c, * elf32-m68k.c, * elf32-mips.c, * elf32-nios2.c, * elf32-ppc.c, * elf32-s390.c, * elf32-score.c, * elf32-score7.c, * elf32-sh.c, * elf32-sparc.c, * elf32-tilegx.c, * elf32-tilepro.c, * elf32-xtensa.c, * elf64-aarch64.c, * elf64-hppa.c, * elf64-mips.c, * elf64-ppc.c, * elf64-tilegx.c, * elf64-x86-64.c, * elfcore.h, * elfn32-mips.c: Update all refs to tdata core fields.
2013-02-21bfd/Alan Modra1-84/+78
* elf-bfd.h (struct elf_obj_tdata): Rename segment_map to seg_map. Delete num_locals and num_globals. (elf_num_locals, elf_num_globals): Don't define. (elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker, elf_stack_flags, elf_strtab_sec, elf_shstrtab_sec): Define. * bfd.c, * elf-eh-frame.c, * elf-nacl.c, * elf-vxworks.c, * elf.c, * elf32-arm.c, * elf32-lm32.c, * elf32-ppc.c, * elf32-rx.c, * elf32-spu.c, * elf64-hppa.c, * elfcode.h, * elflink.c, * elfnn-ia64.c, * elfxx-mips.c: Use newly defined elf_obj_tdata accessor macros. * elf.c (elf_map_symbols): Add pnum_locals param. Return number of locals syms via new param. (swap_out_syms): Adjust to suit elf_map_symbols change. ld/ * emultempl/elf-generic.em: Use newly defined elf_obj_tdata accessor macros.
2013-02-18include/Alan Modra1-9/+17
* bfdlink.h (struct bfd_link_info): Delete emit_note_gnu_build_id. bfd/ * configure.in: Bump version to 2.23.52. * elf-bfd.h (struct elf_build_id_info): New. (struct elf_obj_tdata): Delete after_write_object_contents, after_write_object_contents_info and build_id_size. Make build_id a pointer to struct elf_build_id_info. * elf.c (_bfd_elf_write_object_contents): Style. Update after_write_ibject_contents invocation. (elfobj_grok_gnu_build_id): Update for new build_id struct. Don't allow zero size notes. * configure: Regenerate. gdb/ * elfread.c (struct build_id): Delete. Use struct elf_build_id throughout file instead. (build_id_bfd_get): Update to use new elf_tdata build_id field. Don't xmalloc return value. (build_id_verify): Similarly. Don't xfree. (build_id_to_debug_filename): Update. (find_separate_debug_file_by_buildid): Update, don't xfree. ld/ * emultempl/elf32.em (emit_note_gnu_build_id): New static var. Replace all info->emit_note_gnu_build_id refs. (id_note_section_size): Rename from gld${EMULATION_NAME}_id_note_section_size. (struct build_id_info): Delete. (write_build_id): Rename from gld${EMULATION_NAME}_write_build_id_section. Update elf_tdata usage. Style, formatting. (setup_build_id): New function. (gld${EMULATION_NAME}_after_open): Use setup_build_id.
2013-02-08 PR binutils/15106Alan Modra1-23/+31
* elf-bfd.h (struct elf_obj_tdata): Add elf_find_function_cache. * elf.c (elf_find_function): Revert last change. Use new tdata field rather than static vars for cache.
2013-02-07 PR binutils/15106Alan Modra1-0/+3
* elf.c (elf_find_function): Don't cache if symbols change.
2013-02-042013-02-04 Sergio Durigan Junior <sergiodj@redhat.com>Sergio Durigan Junior1-0/+29
Pedro Alves <palves@redhat.com> * Makefile.in (SOURCE_HFILES): Add `elf-linux-psinfo.h'. * elf-bfd.h (elf_internal_linux_prpsinfo): New structure declaration. (elfcore_write_linux_prpsinfo32, elfcore_write_linux_prpsinfo64) (elfcore_write_ppc32_linux_prpsinfo32): New declarations. * elf-linux-psinfo.h: New file. * elf.c: Include elf-linux-psinfo.h. (elfcore_write_linux_prpsinfo32, elfcore_write_linux_prpsinfo64): New functions. * elf32-ppc.c: Include `elf-linux-psinfo.h'. (elf_external_ppc_linux_prpsinfo32): New structure declaration. (PPC_LINUX_PRPSINFO32_SWAP_FIELDS): New macro. (elfcore_write_ppc_linux_prpsinfo32): New function.
2013-01-08include/elf/Yufeng Zhang1-1/+83
2013-01-08 Yufeng Zhang <yufeng.zhang@arm.com> * common.h (NT_ARM_TLS, NT_ARM_HW_BREAK, NT_ARM_HW_WATCH): New macro definitions. bfd/ 2013-01-08 Yufeng Zhang <yufeng.zhang@arm.com> * elf-bfd.h (elfcore_write_aarch_tls): Add prototype. (elfcore_write_aarch_hw_break): Likewise. (elfcore_write_aarch_hw_watch): Likewise. * elf.c (elfcore_grok_aarch_tls): New function. (elfcore_grok_aarch_hw_break): Likewise. (elfcore_grok_aarch_hw_watch): Likewise. (elfcore_grok_note): Call the new functions to handle the corresponding notes. (elfcore_write_aarch_tls): New function. (elfcore_write_aarch_hw_break): Likewise. (elfcore_write_aarch_hw_watch): Likewise. (elfcore_write_register_note): Call the new functions to handle the corresponding pseudo sections. binutils/ 2013-01-08 Yufeng Zhang <yufeng.zhang@arm.com> * readelf.c (get_note_type): Handle NT_ARM_TLS, NT_ARM_HW_BREAK and NT_ARM_HW_WATCH.
2012-12-18 * elf.c (swap_out_syms): Set shndx to SHN_ABS when not one ofAlan Modra1-0/+1
the special MAP_* values.
2012-12-14gdbTom Tromey1-0/+4
* NEWS: Mention "info proc" and core files. * corelow.c (core_info_proc): New function. (init_core_ops): Set to_info_proc. * gdbarch.c, gdbarch.h: Rebuild. * gdbarch.sh (core_info_proc): New method. * infcmd.c (info_proc_cmd_1): Invoke target_info_proc first. * linux-tdep.c (linux_core_info_proc_mappings) (linux_core_info_proc): New functions. (linux_find_memory_region_ftype): New typedef. (linux_find_memory_regions_full): New function, from linux_find_memory_regions. (struct linux_find_memory_regions_data): New. (linux_find_memory_regions_thunk): New function. (linux_find_memory_regions): Rewrite. (struct linux_make_mappings_data): New. (linux_make_mappings_callback) (linux_make_mappings_corefile_notes): New functions. (linux_make_corefile_notes): Call linux_make_mappings_corefile_notes. (linux_init_abi): Call set_gdbarch_core_info_proc. * target.c (target_info_proc): Return 'int'. * target.h (target_info_proc): Update. gdb/doc * gdb.texinfo (SVR4 Process Information): Mention core files. gdb/testsuite * gdb.base/info-proc.exp: Add core file tests. bfd * elf.c (elfcore_grok_note) <NT_FILE>: New case.
2012-12-07 PR ld/14926Alan Modra1-0/+1
* elf.c (_bfd_elf_map_sections_to_segments): Include elf header size when determining phdr_in_segment.
2012-11-21Set output maxpagesize when rewriting program headerH.J. Lu1-0/+20
bfd/ PR binutils/14493 * elf.c (copy_elf_program_header): When rewriting program header, set the output maxpagesize to the maximum alignment of input PT_LOAD segments. 2012-11-21 H.J. Lu <hongjiu.lu@intel.com> PR binutils/14493 * ld-elf/maxpage5.d: New file. * ld-elf/maxpage5.s: Likewise. * ld-elf/maxpage5.t: Likewise.
2012-11-13Allocate elf_segment_map with bfd_zallocH.J. Lu1-1/+1
* elf.c (rewrite_elf_program_header): Allocate elf_segment_map with bfd_zalloc, instead of bfd_alloc.
2012-11-09Remove trailing redundant `;'H.J. Lu1-1/+1
bfd/ * aout-tic30.c (MY_final_link_callback): Remove trailing redundant `;'. * coff-h8500.c (extra_case): Likewise. (bfd_coff_reloc16_get_value): Likewise. * dwarf2.c (_bfd_dwarf2_cleanup_debug_info): Likewise. * elf.c (_bfd_elf_slurp_version_tables): Likewise. * elf32-frv.c (elf32_frv_relocate_section): Likewise. * elf32-v850.c (v850_elf_perform_relocation): Likewise. * opncls.c (bfd_calc_gnu_debuglink_crc32): Likewise. * plugin.c (add_symbols): Likewise. * reloc.c (bfd_check_overflow): Likewise. * vms-lib.c (_bfd_vms_lib_archive_p): Likewise. binutils/ * coffgrok.c (coff_grok): Remove trailing redundant `;'. * resrc.c (open_input_stream): Likewise. gas/ * config/atof-ieee.c (gen_to_words): Remove trailing redundant `;'. * config/atof-vax.c (flonum_gen2vax): Likewise. * config/tc-d10v.c (write_2_short): Likewise. * config/tc-i386-intel.c (i386_intel_simplify): Likewise. * config/tc-s390.c (tc_s390_force_relocation): Likewise. * config/tc-v850.c (md_parse_option): Likewise. * config/tc-xtensa.c (find_address_of_next_align_frag): Likewise. * dwarf2dbg.c (out_header): Likewise. * symbols.c (dollar_label_name): Likewise. (fb_label_name): Likewise. ld/ * testplug.c (record_add_file): Remove trailing redundant `;'. opcodes/ * aarch64-opc.h (gen_mask): Remove trailing redundant `;'. * ia64-gen.c (fetch_insn_class): Likewise.
2012-11-08gdbTom Tromey1-0/+4
* linux-tdep.c (linux_make_siginfo_note): New function. (linux_make_corefile_notes): Use it. * corelow.c (get_core_siginfo): New function. (core_xfer_partial) <TARGET_OBJECT_SIGNAL_INFO>: New case. gdb/testsuite * gdb.base/siginfo-obj.exp: Create core file. Test siginfo from core files, if possible. * gdb.base/siginfo-thread.c: New file * gdb.base/siginfo-thread.exp: New file bfd * elf.c (elfcore_grok_note) <NT_SIGINFO>: New case; make pseudosection.
2012-10-23 bfd/Nathan Sidwell1-2/+17
* bfd-in.h (bfd_elf_stack_segment_size): Declare. * bfd-in2.h: Rebuilt. * elfxx-target.h (elf_backend_stack_align): New. (elfNN_bed): Add it. * elf-bfd.h (struct elf_backend_data): Add stack_align field. * elf.c (bfd_elf_map_sections_to_segments): Pay attention to stack_align and stacksize for PT_GNU_STACK segment. (assign_file_positions_for_non_load_sections): Set p_memsz for PT_GNU_STACK segment. (copy_elf_program_header): Copy PT_GNU_STACK size. * elflink.c (bfd_elf_stack_segment_size): New function, taken from uclinux backends. (bfd_elf_size_dynamic_sections): Determine PT_GNU_STACK requirements after calling backend. Pay attention to stacksize. * elf32-bfin.c (elf32_bfinfdpic_always_size_sections): Call bfd_elf_stack_segment_size. (elf32_bfinfdpic_modify_program_headers): Delete. (elf32_bfingfdpic_copy_private_bfd_data): Don't copy PT_GNU_STACK here. (elf_backend_stack_align): Override. (elf_backend_modify_program_headers): Don't override. * elf32-frv.c (frvfdpic_always_size_sections): Call bfd_elf_stack_segment_size. (elf32_frvfdpic_modify_program_headers): Delete. (elf32_frvfdpic_copy_private_bfd_data): Don't copy PT_GNU_STACK here. (elf_backend_stack_align): Override. (elf_backend_modify_program_headers): Don't override. * elf32-lm32.c (lm32_elf_always_size_sections): Leave PT_GNU_STACK creation to underlying elf support. Check __stacksize here for backwards compatibility, and set it if needed. (lm32_elf_modify_segment_map): Delete. (lm32_elf_modify_program_headers): Delete. (elf_backend_stack_align): Override. (elf_backend_modify_segment_map): Don't override. (elf_backend_modify_program_headers): Don't override. * elf32-sh.c (sh_elf_always_size_sections): Call bfd_elf_stack_segment_size. (sh_elf_modify_program_headers): Delete. (sh_elf_copy_private_data): Don't copy PT_GNU_STACK here. (elf_backend_stack_align): Override. (elf_backend_modify_program_headers): Don't override. * elf32-tic6x.c (elf32_tic6x_always_size_sections): Call bfd_elf_stack_segment_size. (elf32_tic6x_modify_program_headers): Delete. (elf32_tic6x_copy_private_data): Delete. (elf_backend_stack_align): Override. (bfd_elf32_bfd_copy_private_bfd_data): Don't override. (elf_backend_modify_program_headers): Don't override. include/ * bfdlink.h (struct bfd_link_info): Add stacksize option. ld/ * ld.texinfo (stack-size): New option. * emultempl/elf32.em: Add stack-size option. ld/testsuite/ * ld-elf/binutils.exp: Add -z stack-size=0. * ld-elf/elf.exp: Add stack-exec and stack-size tests. * ld-elf/orphan-region.d: Add stack-size option. Remove xfail. * ld-elf/stack-exec.rd: New. * ld-elf/stack-size.rd: New. * ld-elf/stack.s: New. * ld-scripts/empty-aligned.d: Add stack-size option. * ld-sh/fdpic-stack-set.d: New. * ld-tic6x/shlib-1.rd: Remove __stacksize symbol. * ld-tic6x/shlib-1b.rd: Likewise. * ld-tic6x/shlib-1r.rd: Likewise. * ld-tic6x/shlib-1rb.rd: Likewise. * ld-tic6x/shlib-app-1.rd: Likewise. * ld-tic6x/shlib-app-1b.rd: Likewise. * ld-tic6x/shlib-app-1r.rd: Likewise. * ld-tic6x/shlib-app-1rb.rd: Likewise. * ld-tic6x/shlib-noindex.rd: Likewise. * ld-tic6x/static-app-1.rd: Likewise. * ld-tic6x/static-app-1b.rd: Likewise. * ld-tic6x/static-app-1r.rd: Likewise. * ld-tic6x/static-app-1rb.rd: Likewise.
2012-10-15 * elf.c (special_sections_d): Add comment.Doug Evans1-0/+3
2012-10-07 PR binutils/14662Alan Modra1-37/+17
* elf.c (_bfd_elf_make_section_from_shdr): Treat .gdb_index as SEC_DEBUGGING.
2012-09-04Ignore section symbols without a BFD sectionH.J. Lu1-3/+11
bfd/ PR binutils/14493 * elf.c (ignore_section_sym): Also ignore section symbols without a BFD section. binutils/ PR binutils/14493 * readelf.c (get_symbol_index_type): Check bad section index.
2012-08-10 PR binutils/14444Alan Modra1-5/+5
* elf.c (IS_VALID_GROUP_SECTION_HEADER) Add minsize param. (setup_group): Adjust uses. (bfd_section_from_shdr): Allow SHT_GROUP sections with just a flag word.
2012-07-242012-07-24 Teresa Johnson <tejohnson@google.com>Cary Coutant1-2/+30
bfd/ * bfd.c (bfd_find_nearest_line_discriminator): New macro. * coff-rs6000.c: Init _bfd_find_nearest_line_discriminator. * coff64-rs6000.c: Likewise. * dwarf2.c (struct line_info): Add discriminator field. (add_line_info): Fill in new discriminator field. (decode_line_info): Record discriminator information instead of ignoring it. (lookup_address_in_line_info_table): Return discriminator field if requested. (comp_unit_find_nearest_line): Add discriminator argument. (find_line): Likewise. (_bfd_dwarf2_find_nearest_line): Likewise. (_bfd_dwarf2_find_line): Likewise. * elf-bfd.h (_bfd_elf_find_nearest_line_discriminator): New. (_bfd_elf_find_line_discriminator): Likewise. (_bfd_generic_find_nearest_line_discriminator): Likewise. Defined. * elf.c (_bfd_elf_find_nearest_line): Change to a wrapper that invokes _bfd_elf_find_nearest_line_discriminator with correct arguments. (_bfd_elf_find_nearest_line_discriminator): New. (_bfd_elf_find_line): Change to a wrapper that invokes _bfd_elf_find_line_discriminator with correct arguments. (_bfd_elf_find_line_discriminator): New. * coffgen.c (coff_find_nearest_line_with_names): Handle new discriminator argument. * elf32-arm.c (elf32_arm_find_nearest_line): Likewise. * elf64-alpha.c (elf64_alpha_find_nearest_line): Likewise. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise. * mach-o.c (bfd_mach_o_find_nearest_line): Likewise. * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Add discriminator argument. (_bfd_dwarf2_find_line): Likewise. (_bfd_generic_find_nearest_line_discriminator): New. * libbfd.c (_bfd_generic_find_nearest_line_discriminator): New. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. * targets.c (BFD_JUMP_TABLE_SYMBOLS): Initialize _bfd_find_nearest_line_discriminator with _bfd_generic_find_nearest_line_discriminator. (bfd_target): Add _bfd_find_nearest_line_discriminator. binutils/ * addr2line.c (find_address_in_section): Invoke bfd_find_nearest_line_discriminator to get the discriminator. (find_offset_in_section): Likewise. (translate_addresses): Print discriminator if it is non-zero. * objdump.c (show_line): Invoke bfd_find_nearest_line_discriminator to get the discriminator, and keep track of prev_discriminator. Print discriminator if it is non-zero. (disassemble_data): Initialize prev_discriminator. (dump_reloc_set): Invoke bfd_find_nearest_line_discriminator to get the discriminator, and keep track of last_discriminator. Print discriminator if it is non-zero.
2012-07-04Check number of sections overflowH.J. Lu1-0/+7
* elf.c (assign_section_numbers): Check if number of sections >= SHN_LORESERVE. * elfcode.h (elf_object_p): Likewise.
2012-07-03Don't compress empty debug sectionH.J. Lu1-1/+1
2012-07-03 H.J. Lu <hongjiu.lu@intel.com> PR binutils/14319 * elf.c (_bfd_elf_make_section_from_shdr): Don't compress empty debug section. 2012-07-03 H.J. Lu <hongjiu.lu@intel.com> PR binutils/14319 * binutils-all/compress.exp: Test compress empty debug sections. * binutils-all/dw2-empty.S: New file.