aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2022-11-01Automatic date update in version.inGDB Administrator1-1/+1
2022-10-31Automatic date update in version.inGDB Administrator1-1/+1
2022-10-30Automatic date update in version.inGDB Administrator1-1/+1
2022-10-29pef: sanity check before mallocAlan Modra1-5/+7
And do the sanity check in a way that can't overflow. * pef.c (bfd_pef_parse_function_stubs): Sanity check header imported_library_count and total_imported_symbol_count before allocating memory.
2022-10-29NULL dereference read in som_write_object_contentsAlan Modra1-2/+3
objcopy copy_object may omit the call to bfd_copy_private_bfd_data for various conditions deemed non-fatal, in which case obj_som_exec_data will be NULL for the output file. * som.c (som_finish_writing): Don't dereference NULL obj_som_exec_data.
2022-10-29Automatic date update in version.inGDB Administrator1-1/+1
2022-10-28RISC-V: Output mapping symbols with ISA string.Nelson Chu2-0/+8
RISC-V Psabi pr196, https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/196 bfd/ * elfxx-riscv.c (riscv_release_subset_list): Free arch_str if needed. (riscv_copy_subset_list): Copy arch_str as well. * elfxx-riscv.h (riscv_subset_list_t): Store arch_str for each subset list. gas/ * config/tc-riscv.c (riscv_reset_subsets_list_arch_str): Update the architecture string in the subset_list. (riscv_set_arch): Call riscv_reset_subsets_list_arch_str after parsing new architecture string. (s_riscv_option): Likewise. (need_arch_map_symbol): New boolean, used to indicate if .option directives do affect instructions. (make_mapping_symbol): New boolean parameter reset_seg_arch_str. Need to generate $x+arch for MAP_INSN, and then store it into tc_segment_info_data if reset_seg_arch_str is true. (riscv_mapping_state): Decide if we need to add $x+arch for MAP_INSN. For now, only add $x+arch if the architecture strings in subset list and segment are different. Besides, always add $x+arch at the start of section, and do not add $x+arch for code alignment, since rvc for alignment can be judged from addend of R_RISCV_ALIGN. (riscv_remove_mapping_symbol): If current and previous mapping symbol have same value, then remove the current $x only if the previous is $x+arch; Otherwise, always remove previous. (riscv_add_odd_padding_symbol): Updated. (riscv_check_mapping_symbols): Don't need to add any $x+arch if need_arch_map_symbol is false, so changed them to $x. (riscv_frag_align_code): Updated since riscv_mapping_state is changed. (riscv_init_frag): Likewise. (s_riscv_insn): Likewise. (riscv_elf_final_processing): Call riscv_release_subset_list to release subset_list of riscv_rps_as, rather than only release arch_str in the riscv_write_out_attrs. (riscv_write_out_attrs): No need to call riscv_arch_str, just get arch_str from subset_list of riscv_rps_as. * config/tc-riscv.h (riscv_segment_info_type): Record current $x+arch mapping symbol of each segment. * testsuite/gas/riscv/mapping-0*: Merged and replaced by mapping.s. * testsuite/gas/riscv/mapping.s: New testcase, to test most of the cases in one file. * testsuite/gas/riscv/mapping-symbols.d: Likewise. * testsuite/gas/riscv/mapping-dis.d: Likewise. * testsuite/gas/riscv/mapping-non-arch.s: New testcase for the case that does need any $x+arch. * testsuite/gas/riscv/mapping-non-arch.d: Likewise. * testsuite/gas/riscv/option-arch-01a.d: Updated. opcodes/ * riscv-dis.c (riscv_disassemble_insn): Set riscv_fpr_names back to riscv_fpr_names_abi or riscv_fpr_names_numeric when zfinx is disabled for some specfic code region. (riscv_get_map_state): Recognized mapping symbols $x+arch, and then reset the architecture string once the ISA is different.
2022-10-28Automatic date update in version.inGDB Administrator1-1/+1
2022-10-27RISC-V: Fix build failures for -Werror=sign-compare.Nelson Chu1-2/+6
elfnn-riscv.c: In function ‘riscv_relax_resolve_delete_relocs’: elfnn-riscv.c:4256:30: error: operand of ‘?:’ changes signedness from ‘int’ to ‘unsigned int’ due to unsignedness of other operand [-Werror=sign-compare] So make the operands unsigned could resolve problem. bfd/ * elfnn-riscv.c (riscv_relax_resolve_delete_relocs): Fixed build failures for -Werror=sign-compare.
2022-10-27Automatic date update in version.inGDB Administrator1-1/+1
2022-10-26buffer overflow in _bfd_XX_print_ce_compressed_pdataAlan Modra1-0/+2
More fuzzed fun. * peXXigen.c (_bfd_XX_print_ce_compressed_pdata): Use smaller of virt_size and bfd section size as limit of function table.
2022-10-26Correct ELF reloc size sanity checkAlan Modra1-6/+11
The external reloc size check was wrong. Here asect is the code/data section, not the reloc section. So using this_hdr gave the size of the code/data section. * elf.c (_bfd_elf_get_reloc_upper_bound): Properly get external size from reloc headers.
2022-10-26som.c reloc sanity checkingAlan Modra1-295/+287
This patch checks that relocations emitted in som_write_fixups have offsets that are monotonic and within a section. To do that properly using bfd_reloc_offset_in_range it is necessary to set the reloc howto size field, which isn't used otherwise by the som backend. Note that the sizes used are not exactly those in the old sizing switch statement deleted from som_write_fixups, but all relocs handled by the main switch statement there get the same size. Most unhandled relocs get a zero size (exceptions being R_RELOCATION, R_SPACE_REF, R_MILLI_REL, R_BREAKPOINT which all involve writing one word according to my SOM reference). I figure it doesn't matter since any unhandled reloc is converted to 0xff R_RESERVED, and a default of zero is better for a "don't know" reloc. Besides tidying the code, stringizing name from type in SOM_HOWTO fixes R_REPEATED_INIT name. * som.c (SOM_HOWTO): Add SIZE arg, delete NAME. Stringize type to name. (som_hppa_howto_table): Update with sizes. (som_write_fixups): Delete sizing switch statement. Sanity check bfd_reloc address against subsection size.
2022-10-26som.c buffer overflowAlan Modra1-4/+6
Fuzzed object files can put random values in bfd_reloc->address, leading to large som_reloc_skip output. * som.c (som_write_fixups): Allow for maximal som_reloc_skip.
2022-10-26Automatic date update in version.inGDB Administrator1-1/+1
2022-10-25x86-64: Use only one default max-page-sizeMichael Matz1-5/+1
On x86-64 the default ELF_MAXPAGESIZE depends on a configure option (--disable-separate-code). Since 9833b775 ("PR28824, relro security issues") we use max-page-size for relro alignment (with a short interval, from 31b4d3a ("PR28824, relro security issues, x86 keep COMMONPAGESIZE relro") to its revert a1faa5ea, where x86-64 only used COMMONPAGESIZE as relro alignment target). But that means that a linker configured with --disable-separate-code behaves different from one configured with --enable-separate-code (the default), _even if using "-z {no,}separate-code" option to use the non-configured behaviour_ . In particular it means that when configuring with --disable-separate-code the linker will produce binaries aligned to 2MB pages on disk, and hence generate 2MB executables for a hello world (and even 6MB when linked with "-z separate-code"). Generally we can't have constants that ultimately land in static variables be depending on configure options if those only influence behaviour that is overridable by command line options. So, do away with that, make the default MAXPAGESIZE be 4k (as is default for most x86-64 configs anyway, as most people won't configure with --disable-separate-code). If people need more they can use the "-z max-page-size" (with would have been required right now for a default configure binutils). bfd/ * elf64-x86-64.c (ELF_MAXPAGESIZE): Don't depend on DEFAULT_LD_Z_SEPARATE_CODE.
2022-10-25RISC-V: Should reset `again' flag for _bfd_riscv_relax_pc.Nelson Chu1-1/+2
The R_RISCV_DELETE relocations are no longer deleted at another relax pass, so we should reset 'again' flag to true for _bfd_riscv_relax_pc, while the deleted bytes are marked as R_RISCV_DELETE. bfd/ * elfnn-riscv.c (_bfd_riscv_relax_pc): Set `again' to true while the deleted bytes are marked as R_RISCV_DELETE.
2022-10-25RISC-V: Improve link time complexity.Patrick O'Neill1-49/+131
The riscv port does deletion and symbol table update for each relocation while relaxing, so we are moving section bytes and scanning symbol table once for each relocation. Compared to microblaze port, they record the relaxation changes into a table, then do the deletion and symbol table update once per section, rather than per relocation. Therefore, they should have better link time complexity than us. To improve the link time complexity, this patch try to make the deletion in linear time. Compared to record the relaxation changes into a table, we replace the unused relocation with R_RISCV_DELETE for the deleted bytes, and then resolve them at the end of the section. Assuming the number of R_RISCV_DELETE is m, and the number of symbols is n, the total link complexity should be O(m) for moving section bytes, and O(m*n^2) for symbol table update. If we record the relaxation changes into the table, and then sort the symbol table by values, then probably can reduce the time complexity to O(m*n*log(n)) for updating symbol table, but it doesn't seem worth it for now. bfd/ * elfnn-riscv.c (_riscv_relax_delete_bytes): Renamed from riscv_relax_delete_bytes, updated to reduce the tiem complexity to O(m) for memmove. (typedef relax_delete_t): Function pointer declaration of delete functions. (riscv_relax_delete_bytes): Can choose to use _riscv_relax_delete_piecewise or _riscv_relax_delete_immediate for deletion. (_riscv_relax_delete_piecewise): Just mark the deleted bytes as R_RISCV_DELETE. (_riscv_relax_delete_immediate): Delete some bytes from a section while relaxing. (riscv_relax_resolve_delete_relocs): Delete the bytes for R_RISCV_DELETE relocations from a section, at the end of _bfd_riscv_relax_section. (_bfd_riscv_relax_call): Mark deleted bytes as R_RISCV_DELETE by reusing R_RISCV_RELAX. (_bfd_riscv_relax_lui): Likewise, but reuse R_RISCV_HI20 for lui, and reuse R_RISCV_RELAX for c.lui. (_bfd_riscv_relax_tls_le): Likewise, but resue R_RISCV_TPREL_HI20 and R_RISCV_TPREL_ADD. (_bfd_riscv_relax_pc): Likewise, but resue R_RISCV_PCREL_HI20 for auipc. (_bfd_riscv_relax_align): Updated, don't need to resue relocation since calling _riscv_relax_delete_immediate. (_bfd_riscv_relax_delete): Removed. (_bfd_riscv_relax_section): Set riscv_relax_delete_bytes for each relax_func, to delete bytes immediately or later. Call riscv_relax_resolve_delete_relocs to delete bytes for DELETE relocations from a section.
2022-10-25Automatic date update in version.inGDB Administrator1-1/+1
2022-10-24Automatic date update in version.inGDB Administrator1-1/+1
2022-10-23Automatic date update in version.inGDB Administrator1-1/+1
2022-10-22Automatic date update in version.inGDB Administrator1-1/+1
2022-10-21Automatic date update in version.inGDB Administrator1-1/+1
2022-10-20ld: Add --pdb optionMark Harmstone3-10/+28
Second patch incorporates fixes for endian and UB issues in calc_hash, as per https://sourceware.org/pipermail/binutils/2022-October/123514.html.
2022-10-20Automatic date update in version.inGDB Administrator1-1/+1
2022-10-20Obsolete beosAlan Modra1-1/+2
* config.bfd: Obsolete *-*-beos*. Simplify x86 beos match.
2022-10-19Fix an illegal memory access when parsing an ELF file containing corrupt ↵Nick Clifton2-1/+9
symbol version information. PR 29699 * elf.c (_bfd_elf_slurp_version_tables): Fail if the sh_info field of the section header is zero.
2022-10-19bfd: fix undefined references to aarch64_pe_le_vecAndrew Burgess2-1/+3
After commit: commit c60b3806799abf1d7f6cf5108a1b0e733a950b13 Date: Wed Oct 19 10:57:12 2022 +0200 aarch64-pe support for LD, GAS and BFD It appears that bfd/Makefile.in and bfd/configure were not regenerated correctly. The differences in the configure file are only whitespace, but in Makefile.in a critical reference to pe-aarch64.lo was missing.
2022-10-19aarch64-pe support for LD, GAS and BFDJedidiah Thompson15-44/+272
Allows aarch64-pe to be targeted natively, not having to use objcopy to convert it from ELF to PE. Based on initial work by Jedidiah Thompson Co-authored-by: Jedidiah Thompson <wej22007@outlook.com> Co-authored-by: Zac Walker <zac.walker@linaro.org>
2022-10-19IBM zSystems: Issue error for *DBL relocs on misaligned symbolsAndreas Krebbel1-0/+18
Relocs like PC32DBL require a right shift of the symbol value. There is no situation where dropping symbol value bits with the right shift is a good thing. Hence we now issue an error to detect such problems.
2022-10-19Automatic date update in version.inGDB Administrator1-1/+1
2022-10-18Automatic date update in version.inGDB Administrator1-1/+1
2022-10-17Automatic date update in version.inGDB Administrator1-1/+1
2022-10-16zlib-gabi to zstd woesAlan Modra4-31/+11
So we had a zlib-gabi .debug_info section that increased in size with zstd, so much so that it was better to leave the section uncompressed. Things went horribly wrong when the section was read again later. The section was read again off disk using the uncompressed size. So you get the zlib section again with some garbage at the end. Fix that particular problem by setting the section flag SEC_IN_MEMORY. Any future read will get sec->contents. Also, if the section is to be left uncompressed, the input SHF_COMPRESSED flag needs to be reset otherwise objcopy will copy it to output. Finally, bfd_convert_section_contents needed a small update to handle zstd compressed sections, and I've deleted bfd_cache_section_contents. * bfd.c (bfd_convert_section_contents): Handle zstd. * compress.c (bfd_compress_section_contents): When section contents are uncompressed set SEC_IN_MEMORY flag, compress_status to COMRESS_SECTION_NONE, and clear SHF_COMPRESSED. Set SEC_IN_MEMORY for compressed contents. (bfd_get_full_section_contents): Don't check section size against file size when SEC_IN_MEMORY. (bfd_cache_section_contents): Delete function. * elf32-arm.c (elf32_arm_get_synthetic_symtab): Expand bfd_cache_section_contents here. * bfd-in2.h: Regenerate.
2022-10-16Automatic date update in version.inGDB Administrator1-1/+1
2022-10-15Automatic date update in version.inGDB Administrator1-1/+1
2022-10-14PR29677, Field `the_bfd` of `asymbol` is uninitialisedAlan Modra1-41/+31
Besides not initialising the_bfd of synthetic symbols, counting symbols when sizing didn't match symbols created if there were any dynsyms named "". We don't want synthetic symbols without names anyway, so get rid of them. Also, simplify and correct sanity checks. PR 29677 * mach-o.c (bfd_mach_o_get_synthetic_symtab): Rewrite.
2022-10-14RISC-V: Zicbo{m,p,z} adjustments to riscv_multi_subset_supports_ext()Jan Beulich1-0/+6
The lack thereof did caused gas to issue "internal: unreachable INSN_CLASS_*" errors when trying to assemble respective insns without the feature(s) enabled via e.g. ".option arch, ...". Of course a proper hint towards the missing extension then wasn't given either.
2022-10-14RISC-V: Imply 'Zicsr' from privileged extensions with CSRsTsukasa OI1-0/+5
'H', 'Smstateen', 'Sscofpmf' and 'Sstc' are four privileged extensions with their CSR definitions and 'Smepmp' is a privileged extension with additional CSR bits. Volume II: Privileged Architecture of the RISC-V ISA Manual states that the privileged architecture requires the 'Zicsr' extension. However, current GNU Binutils has no direct way whether the program has dependency to the privileged architecture itself. As a workaround, we should add implications from privileged extensions that either add new CSRs, extend existing CSRs or depends on using CSRs. This commit adds such implications for existing privileged extensions that satisfy this condition. gas/ChangeLog: * testsuite/gas/riscv/march-imply-h.d: New test, at least for 'H'. bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets): Add 'Zicsr' implicications for privileged extensions 'H', 'Smstateen', 'Sscofpmf', 'Sstc' and 'Smepmp'.
2022-10-14Automatic date update in version.inGDB Administrator1-1/+1
2022-10-13Automatic date update in version.inGDB Administrator1-1/+1
2022-10-12Automatic date update in version.inGDB Administrator1-1/+1
2022-10-11fix compressed_debug_section_names definition for "zlib"Martin Liska1-1/+1
bfd/ChangeLog: * libbfd.c: Set COMPRESS_DEBUG_GABI_ZLIB for "zlib" value.
2022-10-11refactor usage of compressed_debug_section_typeMartin Liska3-6/+70
bfd/ChangeLog: * bfd-in.h (bfd_hash_set_default_size): Add COMPRESS_UNKNOWN enum value. (struct compressed_type_tuple): New. * bfd-in2.h (bfd_hash_set_default_size): Regenerate. (struct compressed_type_tuple): Likewise. * libbfd.c (ARRAY_SIZE): New macro. (bfd_get_compression_algorithm): New function. (bfd_get_compression_algorithm_name): Likewise. gas/ChangeLog: * as.c: Do not special-case, use the new functions. ld/ChangeLog: * emultempl/elf.em: Do not special-case, use the new functions. * lexsup.c (elf_static_list_options): Likewise.
2022-10-11Automatic date update in version.inGDB Administrator1-1/+1
2022-10-10Automatic date update in version.inGDB Administrator1-1/+1
2022-10-09Automatic date update in version.inGDB Administrator1-1/+1
2022-10-08Automatic date update in version.inGDB Administrator1-1/+1
2022-10-07PR29653, objcopy/strip: fuzzed small input file induces large output fileAlan Modra2-43/+46
_bfd_check_format functions should not print errors or warnings if they return NULL. A NULL return means the particular target under test does not match, so there isn't any reason to make a complaint about the target. In fact there isn't a good reason to warn even if the target matches, except via the _bfd_per_xvec_warn mechanism; Some other target might be a better match. This patch tidies pe_bfd_object_p with the above in mind, and restricts the PE optional header SectionAlignment and FileAlignment fields somewhat. I chose to warn on nonsense values rather than refusing to match. Refusing to match would be OK too. PR 29653 * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Don't emit error about invalid NumberOfRvaAndSizes here. Limit loop copying data directory to IMAGE_NUMBEROF_DIRECTORY_ENTRIES. * peicode.h (pe_bfd_object_p): Don't clear and test bfd_error around bfd_coff_swap_aouthdr_in. Warn on invalid SectionAlignment, FileAlignment and NumberOfRvaAndSizes. Don't return NULL on invalid NumberOfRvaAndSizes.
2022-10-07Automatic date update in version.inGDB Administrator1-1/+1