aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2019-11-12Automatic date update in version.inGDB Administrator1-1/+1
2019-11-11Automatic date update in version.inGDB Administrator1-1/+1
2019-11-10Automatic date update in version.inGDB Administrator1-1/+1
2019-11-09Automatic date update in version.inGDB Administrator1-1/+1
2019-11-08Automatic date update in version.inGDB Administrator1-1/+1
2019-11-07Remove CR16C supportAlan Modra14-1195/+17
I think it is past time to remove CR16C support. CR16C was added in 2004, and only for ld. gas and binutils support is lacking, and there have been no commits to bfd/elf32-cr16c.c other than warning fixes or global maintainers making changes to all targets. I see no maintainer listed for CR16C, and no commits from anyone at NSC supporting the target. Furthermore, at the time the CR16 support was added in 2007, config.sub was changed upstream to no longer recognise cr16c as a valid cpu. That means the CR16C ld support is only available as a secondary target by configuring with, for example, --enable-targets=all or --enable-targets=cr16c-unknown-elf. No testing of the CR16C target is possible. include/ * elf/cr16c.h: Delete. bfd/ * cpu-cr16c.c: Delete. * elf32-cr16c.c: Delete. * Makefile.am, * archures.c, * config.bfd, * configure.ac, * reloc.c, * targets.c: Remove cr16c support. * Makefile.in, * bfd-in2.h, * configure, * libbfd.h, * po/SRC-POTFILES.in: Regenerate. ld/ * emulparams/elf32cr16c.sh: Delete. * scripttempl/elf32cr16c.sc: Delete. * Makefile.am, * configure.tgt: Remove cr16c support. * NEWS: Mention removal of cr16c. * Makefile.in, * po/BLD-POTFILES.in: Regenerate.
2019-11-07Automatic date update in version.inGDB Administrator1-1/+1
2019-11-06Automatic date update in version.inGDB Administrator1-1/+1
2019-11-05Fix memory allocation and release problems in the bfd documentation processor.Tim R?hsen2-6/+25
* doc/chew.c (add_to_definition): Use correct type when calculating size of array reallocation. (nextword): Always initialise the word return parameter. (compile): Check return value of nextword().
2019-11-05Automatic date update in version.inGDB Administrator1-1/+1
2019-11-04Automatic date update in version.inGDB Administrator1-1/+1
2019-11-03Automatic date update in version.inGDB Administrator1-1/+1
2019-11-02Automatic date update in version.inGDB Administrator1-1/+1
2019-11-01Automatic date update in version.inGDB Administrator1-1/+1
2019-10-31Automatic date update in version.inGDB Administrator1-1/+1
2019-10-30Add the ability to the BFD library to read build-ids from core flies.Keith Seitz5-5/+153
* elf-bfd.h (elf_backend_data) <elf_backend_core_find_build_id>: New field. (_bfd_elf32_core_find_build_id, _bfd_elf64_core_find_build_id): New functions. (elf_read_notes): Add declaration. * elf.c (elf_read_notes): Move elf-bfd.h. (_bfd_elf_core_find_build_id): New function. (bfd_section_from_phdr): Scan core file PT_LOAD segments for build-id if none is known. (elf_parse_notes): For core files, scan for notes. * elfcore.h (elf_core_file_matches_executable_p): If both BFDs have identical build-ids, then they match. (_bfd_elf_core_find_build_id): New function. * elfxx-target.h (elf_backend_core_find_build_id): Define. (elfNN_bed): Add elf_backend_core_find_build_id.
2019-10-30Automatic date update in version.inGDB Administrator1-1/+1
2019-10-29When copying pe format files, copy the dos_message array, rather than ↵Andrew Eikum5-16/+43
re-initiialising it. * libcoff-in.h (struct pe_tdata): Add dos_message field. * libcoff.h: Regenerate. * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Copy the dos_message field rather than initialising it. (_bfd_XX_bfd_copy_private_bfd_data_common): Copy the dos_message field. * peicode.h (pe_mkobject): Initialise the dos_message field. (pe_mkobject_hook): Copy the dos_message field. (pe_bfd_object_p): Copy the dos_message field.
2019-10-29Automatic date update in version.inGDB Administrator1-1/+1
2019-10-28Automatic date update in version.inGDB Administrator1-1/+1
2019-10-27Automatic date update in version.inGDB Administrator1-1/+1
2019-10-26Automatic date update in version.inGDB Administrator1-1/+1
2019-10-25PR4499, assign file positions assumes segment offsets increasingAlan Modra4-236/+285
This rewrites much of assign_file_positions_for_non_load_sections to allow objcopy and strip to handle cases like that in PR4499 where program headers were not in their usual position immediately after the ELF file header, and PT_LOAD headers were not sorted by paddr. PR 4499 include/ * elf/internal.h (struct elf_segment_map): Delete header_size. Add no_sort_lma and idx. bfd/ * elf-nacl.c (nacl_modify_segment_map): Set no_sort_lma for all PT_LOAD segments. * elf32-spu.c (spu_elf_modify_segment_map): Likewise on overlay PT_LOAD segments. * elf.c (elf_sort_segments): New function. (assign_file_positions_except_relocs): Use shortcuts to elfheader and elf_tdata. Seek to e_phoff not sizeof_ehdr to write program headers. Move PT_PHDR check.. (assign_file_positions_for_non_load_sections): ..and code setting PT_PHDR p_vaddr and p_paddr, and code setting __ehdr_start value.. (assign_file_positions_for_load_sections): ..to here. Sort PT_LOAD headers. Delete header_pad code. Use actual number of headers rather than allocated in calculating size for program headers. Don't assume program headers follow ELF file header. Simplify pt_load_count code. Only set "off" for PT_LOAD or PT_NOTE in cores. (rewrite_elf_program_header): Set p_vaddr_offset for segments that include file and program headers. (copy_elf_program_header): Likewise, replacing header_size code.
2019-10-25Automatic date update in version.inGDB Administrator1-1/+1
2019-10-24Automatic date update in version.inGDB Administrator1-1/+1
2019-10-23Automatic date update in version.inGDB Administrator1-1/+1
2019-10-22Automatic date update in version.inGDB Administrator1-1/+1
2019-10-21ar P supportAlan Modra4-6/+29
This patch extends "ar P" to allow creation of normal (as distinct from thin) archives with full path names. PR 452 PR 25104 bfd/ * archive.c (normalize): Return file unchanged when BFD_ARCHIVE_FULL_PATH. (_bfd_construct_extended_name_table): Pass abfd, the output bfd, to normalize. (_bfd_archive_bsd44_construct_extended_name_table): Likewise. * bfd.c (struct bfd): Make flags a full flagword. (BFD_ARCHIVE_FULL_PATH): Define. * bfd-in2.h: Regenerate. binutils/ * ar.c (write_archive): Set BFD_ARCHIVE_FULL_PATH. * doc/binutils.texi (extract from archive): Mention restrictions when extracting from archives with full paths. (ar P): Update to current P support. (ar -X32_64): Fix spelling.
2019-10-21Automatic date update in version.inGDB Administrator1-1/+1
2019-10-20 [bfd] Provide 8-byte minimum alignment for .plt sectionJohn David Anglin2-2/+8
This change increases the default alignment for the .plt section from 4 bytes to 8 bytes. When function descriptors are 8-byte aligned, they can be updated atomically on 32-bit hppa. This helps with ordering issues on SMP machines. It also ensures that descriptors reside on the same cache line. This reduces the probability of a double TLB miss in a call. 2019-10-20 John David Anglin <danglin@gcc.gnu.org> * elf32-hppa.c (elf32_hppa_size_dynamic_sections): Provide 8-byte minimum alignment for .plt section.
2019-10-20Automatic date update in version.inGDB Administrator1-1/+1
2019-10-19 [bfd] Revise import stubs on hppa.John David Anglin2-43/+66
This commit updates the import stubs to leave the pointer to the function descriptor in register %r22. This provides a backup mechanism for _dl_runtime_resolve to fixup descriptors during lazy binding. bfd/ChangeLog 2019-10-19 John David Anglin <danglin@gcc.gnu.org> * elf32-hppa.c: Revise import stub sequences. (LONG_BRANCH_STUB_SIZE): Define. (LONG_BRANCH_SHARED_STUB_SIZE): Define. (IMPORT_STUB_SIZE): Define. (IMPORT_SHARED_STUB_SIZE): Define. (EXPORT_STUB_SIZE): Define. (plt_stub): Revise to not use register %r22. (LDO_R1_R22): Define. (LDW_R22_R21): Define. (LDW_R22_R19): Define. (hppa_build_one_stub): Update stub generation and use new defines. (hppa_size_one_stub): Likewise.
2019-10-19Automatic date update in version.inGDB Administrator1-1/+1
2019-10-18Automatic date update in version.inGDB Administrator1-1/+1
2019-10-17RISC-V: Report unresolved relocation error via linker's callback function.Jim Wilson2-17/+59
Two patches from Nelson Chu. It is better to use the linker's callback functions to handle the link time error when relocating. The unresolved relocation error can be regarded as an unsupported relocation. To make user easier to understand different errors, we need to extend the current error message format of the callback function since the format is fixed. bfd/ * elfnn-riscv.c (riscv_elf_relocate_section): Use asprintf to extend the error message if needed, and then store the result into the `msg_buf`. Finally, remember to free the unused `msg_buf`. All error message for the dangerous relocation should be set before we call the callback function. If we miss the error message since linker runs out of memory, we should set the default error message for the error. ld/ * testsuite/ld-riscv-elf/lib-nopic-01a.s: Create the shared library lib-nopic-01a.so, it will be linked with lib-nopic-01b.s. * testsuite/ld-riscv-elf/lib-nopic-01b.s: Add new test for the unresolved relocation. Link the non-pic code into a shared library may cause the error. * testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run the new test only when the shared library is supported. R_RISCV_CALL, R_RISCV_JAL and R_RISCV_RVC_JUMP are pc-relative relocation. For now, we do not allow the object with these relocation links into a shared library since the referenced symbols may be loaded to the places that too far from the pc. We can improve the error message for these unsupported relocation to notice user that they should recompile their code with `fPIC`. bfd/ * elfnn-riscv.c (riscv_elf_relocate_section): Report the error message that user should recompile their code with `fPIC` when linking non-pic code into shared library. ld/ * testsuite/ld-riscv-elf/lib-nopic-01b.d: Update the error message. Change-Id: Ib3347a0a6fa1c2b20a9647c314d5bec2c322ff04
2019-10-17Automatic date update in version.inGDB Administrator1-1/+1
2019-10-16PR13616, linker should pad executable sections with nops, not zerosAlan Modra3-3/+48
This implements padding of orphan executable sections for PowerPC. Of course, the simple implementation of bfd_arch_ppc_nop_fill and removing the NOP definition didn't work, with powerpc64 hitting a testsuite failure linking to S-records. That's because the srec target is BFD_ENDIAN_UNKNOWN so the test of bfd_big_endian (abfd) in default_data_link_order therefore returned false, resulting in a little-endian nop pattern. The rest of the patch fixes that problem by adding a new field to bfd_link_info that can be used to determine actual endianness on targets like srec. PR 13616 include/ * bfdlink.h (struct bfd_link_info <big_endian>): New field. bfd/ * cpu-powerpc.c (bfd_arch_ppc_nop_fill): New function, use it for all ppc arch info. * linker.c (default_data_link_order): Pass info->big_endian to arch_info->fill function. ld/ * emulparams/elf64lppc.sh (NOP): Don't define. * emulparams/elf64ppc.sh (NOP): Don't define. * ldwrite.c (build_link_order): Use link_info.big_endian. Move code determining endian to use for data_statement to.. * ldemul.c (after_open_default): ..here. Set link_info.big_endian.
2019-10-16Automatic date update in version.inGDB Administrator1-1/+1
2019-10-15m68hc1x: better arg checking for reloc_warningAlan Modra2-21/+26
* elf32-m68hc1x.c (reloc_warning): Add printf attribute. (elf32_m68hc11_relocate_section): Don't use a variable for format strings. Delete some unnecessary xgettext:c-format comments.
2019-10-15remove more xmalloc in bfdAlan Modra4-44/+67
Also fixes m68hc1x printf arguments which would have bombed when compiling on a 32-bit host with --enable-64-bit-bfd. bfd/ PR 24955 * elf32-arm.c (set_cmse_veneer_addr_from_implib): Use bfd_malloc rather than xmalloc. * elf32-m68hc1x.c (reloc_warning): New function. (elf32_m68hc11_relocate_section): Use it here. Cast bfd_vma values corresponding to %lx in format strings. * elf32-nds32.c (nds32_insertion_sort): Use a stack temporary. gas/ * config/tc-nds32.c (nds32_set_section_relocs): Use relocs and n parameters rather than equivalent sec->orelocation and sec->reloc_count. Don't sort for n <= 1. Tidy.
2019-10-15PR25100, Compile fails in elf64-ppc.c because of single equal sign instead ↵Alan Modra2-3/+6
of double equal for comparison PR 25100 * elf64-ppc.c (sfpr_define): Delete dead code that triggered a warning.
2019-10-15Simplify power of two testAlan Modra2-1/+6
* bfd.c (bfd_check_compression_header): Check for powers of two with x == (x & -x).
2019-10-15Automatic date update in version.inGDB Administrator1-1/+1
2019-10-14qsort: syms.c stab sortingAlan Modra2-3/+13
* syms.c (struct indexentry): Add idx field. (cmpindexentry): Final sort on idx. (_bfd_stab_section_find_nearest_line): Set idx.
2019-10-14qsort: dwarf2.cAlan Modra2-5/+24
This patch ensures qsort stability in line and function sorting done in dwarf2.c. For the line sequences we make use of an existing field that isn't used until later, as a monotonic counter for the qsort. * dwarf2.c (struct lookup_funcinfo): Add idx field. (compare_lookup_funcinfos): Perform final sort on idx. (build_lookup_funcinfo_table): Set idx. (compare_sequences): Perform final sort on num_lines. (build_line_info_table): Set num_lines and line_info_lookup earlier. (sort_line_sequences): Set num_lines for sort.
2019-10-14qsort: elf_link_add_object_symbols weak aliasesAlan Modra2-12/+49
This particular sort almost certainly does not need to be stable for the ELF linker to work correctly. However it is conceivable that an unstable sort could affect linker output, and thus different output be seen with differing qsort implementations. The argument goes like this: Given more than one strong alias symbol of equal section, value, and size, the aliases will compare equal by elf_sort_symbol and thus which one is chosen as the "real" symbol to be made dynamic depends on qsort. Why would anyone define two symbols at the same address? Well, sometimes the fact that there are more than one strong alias symbol is due to linker script symbols like __bss_start being made dynamic. This will match the first symbol defined in .bss if it doesn't have correct size, and forgetting to properly set size and type of symbols isn't as rare as it should be. This patch adds some more heuristics to elf_sort_symbol. * elflink.c (elf_sort_symbol): Sort on type and name as well. (elf_link_add_object_symbols): Style fix.
2019-10-14qsort: elf_sort_sections use of target_indexAlan Modra3-10/+23
elf_sort_sections tried to ensure a stable qsort by using target_index as the final comparison, but target_index hasn't been set by anything at the time elf_sort_sections was run. This patch arrange to have target_index set. * elf.c (_bfd_elf_map_sections_to_segments): Init target_index for sections about to be sorted. (assign_file_positions_for_load_sections): Likewise. (elf_sort_sections): Don't bother optimising both TOEND case. * elflink.c (bfd_elf_final_link): Reset target_index.
2019-10-14qsort: SHF_LINK_ORDER section sortAlan Modra2-61/+51
The linker SHF_LINK_ORDER section sorting had a number of defects. 1) The ordering was by VMA, which won't work with overlays. LMA is better. 2) Zero size sections can result in two sections at the same LMA/VMA. When only one of the two sections at the same LMA is zero size, that one must be first. 3) Warnings given by elf_get_linked_section_vma won't ever be emitted since elf_object_p warns and excludes objects with zero sh_link on a SHF_LINK_ORDER section. 4) Section offset was adjusted down rather than up by section alignment, possibly creating overlapping sections. 5) Finding the linked section did so the hard way, rather than simply using elf_linked_to_section. * elflink.c (elf_get_linked_section_vma): Delete. (compare_link_order): Use elf_linked_to_section and sort by lma, size, and id. (elf_fixup_link_order): Use size_t variables where appropriate. Make use of elf_linked_to_section. Formatting. Properly align sections.
2019-10-14qsort issuesAlan Modra5-8/+60
qsort isn't guaranteed to be a stable sort, that is, elements comparing equal according to the comparison function may be reordered relative to their original ordering. Of course sometimes you may not care, but even in those cases it is good to force some ordering (ie. not have the comparison function return 0) so that linker output is reproducible over different libc qsort implementations. One way to make qsort stable (which the glibc manual incorrectly says is the only way) is to augment the elements being sorted with a monotonic counter of some kind, and use that counter as the final arbiter of ordering in the comparison function. Another way is to set up an array of pointers into the array of elements, first pointer to first element, second pointer to second element and so so, and sort the pointer array rather than the element array. Final arbiter in the comparison function then is the pointer difference. This works well with, for example, the symbol pointers returned by _bfd_elf_canonicalize_symtab which point into a symbol array. This patch fixes a few places where sorting by symbol pointers is appropriate, and adds comments where qsort stability is a non-issue. * elf-strtab.c (strrevcmp): Comment. * merge.c (strrevcmp): Likewise. * elf64-ppc.c (compare_symbols): Correct final pointer comparison. Comment on why comparing pointers ensures a stable sort. * elflink.c (struct elf_symbol): Add void* to union. (elf_sort_elf_symbol): Ensure a stable sort with pointer comparison. (elf_sym_name_compare): Likewise. (bfd_elf_match_symbols_in_sections): Style fix. (elf_link_sort_cmp1): Comment.
2019-10-14PR24955, libbfd terminating program on out of memory (part2)Alan Modra5-10/+37
PR 24955 * elflink.c (elf_output_implib): Don't use xmalloc. Don't ignore return value of bfd_alloc2. * peXXigen.c (_bfd_XXi_write_codeview_record): Don't use xmalloc. * pef.c (bfd_pef_print_symbol): Likewise. Don't ignore return value of bfd_get_section_contents. * som.c (som_write_space_strings): Don't use xmalloc. (som_write_symbol_strings): Likewise.