aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2021-09-02SHT_SYMTAB_SHNDX handlingAlan Modra3-30/+13
.symtab_shndx section contents is an array, one entry for each symbol in .symtab, present when the number of symbols exceeds a little less than 64k. Since the mapping is 1-1 with symbols there is no need to keep both dest_index and destshndx_index in elf_sym_strtab. Instead, just make sure that the shndx pointers to the swap functions are kept NULL when .symtab_shndx does not exist. Also, strtabcount in the linker's elf hash table is incremented in lock-step with the output symcount, so that can disappear too.
2021-09-02PTR_ADD and NPTR_ADD for bfd.hAlan Modra4-25/+38
This defines a couple of macros used to avoid ubsan complaints about calculations involving NULL pointers. PTR_ADD should be used in the case where it is known that the offset is always zero with a NULL pointer, and you'd like to know if a non-zero offset is ever used. NPTR_ADD should be rarely used, but is defined for cases where a non-zero offset is expected and should be ignored if the pointer is NULL. bfd/ * bfd-in.h (PTR_ADD, NPTR_ADD): Define. * bfd-in2.h: Regenerate. * elf-eh-frame.c (adjust_eh_frame_local_symbols): Avoid NULL pointer calculations. * elflink.c (_bfd_elf_strip_zero_sized_dynamic_sections): Likewise. (bfd_elf_add_dt_needed_tag, elf_finalize_dynstr): Likewise. (elf_link_add_object_symbols, elf_link_input_bfd): Likewise. (bfd_elf_final_link, bfd_elf_gc_record_vtinherit): Likewise. binutils/ * objdump.c (disassemble_section): Use PTR_ADD for rel_ppend.
2021-09-02Automatic date update in version.inGDB Administrator1-1/+1
2021-09-01Automatic date update in version.inGDB Administrator1-1/+1
2021-08-31Automatic date update in version.inGDB Administrator1-1/+1
2021-08-30RISC-V: PR27916, Support mapping symbols.Nelson Chu3-3/+34
Similar to ARM/AARCH64, we add mapping symbols in the symbol table, to mark the start addresses of data and instructions. The $d means data, and the $x means instruction. Then the disassembler uses these symbols to decide whether we should dump data or instruction. Consider the mapping-04 test case, $ cat tmp.s .text .option norelax .option norvc .fill 2, 4, 0x1001 .byte 1 .word 0 .balign 8 add a0, a0, a0 .fill 5, 2, 0x2002 add a1, a1, a1 .data .word 0x1 # No need to add mapping symbols. .word 0x2 $ riscv64-unknown-elf-as tmp.s -o tmp.o $ riscv64-unknown-elf-objdump -d tmp.o Disassembly of section .text: 0000000000000000 <.text>: 0: 00001001 .word 0x00001001 # Marked $d, .fill directive. 4: 00001001 .word 0x00001001 8: 00000001 .word 0x00000001 # .byte + part of .word. c: 00 .byte 0x00 # remaining .word. d: 00 .byte 0x00 # Marked $d, odd byte of alignment. e: 0001 nop # Marked $x, nops for alignment. 10: 00a50533 add a0,a0,a0 14: 20022002 .word 0x20022002 # Marked $d, .fill directive. 18: 20022002 .word 0x20022002 1c: 2002 .short 0x2002 1e: 00b585b3 add a1,a1,a1 # Marked $x. 22: 0001 nop # Section tail alignment. 24: 00000013 nop * Use $d and $x to mark the distribution of data and instructions. Alignments of code are recognized as instructions, since we usually fill nops for them. * If the alignment have odd bytes, then we cannot just fill the nops into the spaces. We always fill an odd byte 0x00 at the start of the spaces. Therefore, add a $d mapping symbol for the odd byte, to tell disassembler that it isn't an instruction. The behavior is same as Arm and Aarch64. The elf/linux toolchain regressions all passed. Besides, I also disable the mapping symbols internally, but use the new objudmp, the regressions passed, too. Therefore, the new objudmp should dump the objects corretly, even if they don't have any mapping symbols. bfd/ pr 27916 * cpu-riscv.c (riscv_elf_is_mapping_symbols): Define mapping symbols. * cpu-riscv.h: extern riscv_elf_is_mapping_symbols. * elfnn-riscv.c (riscv_maybe_function_sym): Do not choose mapping symbols as a function name. (riscv_elf_is_target_special_symbol): Add mapping symbols. binutils/ pr 27916 * testsuite/binutils-all/readelf.s: Updated. * testsuite/binutils-all/readelf.s-64: Likewise. * testsuite/binutils-all/readelf.s-64-unused: Likewise. * testsuite/binutils-all/readelf.ss: Likewise. * testsuite/binutils-all/readelf.ss-64: Likewise. * testsuite/binutils-all/readelf.ss-64-unused: Likewise. gas/ pr 27916 * config/tc-riscv.c (make_mapping_symbol): Create a new mapping symbol. (riscv_mapping_state): Decide whether to create mapping symbol for frag_now. Only add the mapping symbols to text sections. (riscv_add_odd_padding_symbol): Add the mapping symbols for the riscv_handle_align, which have odd bytes spaces. (riscv_check_mapping_symbols): Remove any excess mapping symbols. (md_assemble): Marked as MAP_INSN. (riscv_frag_align_code): Marked as MAP_INSN. (riscv_init_frag): Add mapping symbols for frag, it usually called by frag_var. Marked as MAP_DATA for rs_align and rs_fill, and marked as MAP_INSN for rs_align_code. (s_riscv_insn): Marked as MAP_INSN. (riscv_adjust_symtab): Call riscv_check_mapping_symbols. * config/tc-riscv.h (md_cons_align): Defined to riscv_mapping_state with MAP_DATA. (TC_SEGMENT_INFO_TYPE): Record mapping state for each segment. (TC_FRAG_TYPE): Record the first and last mapping symbols for the fragments. The first mapping symbol must be placed at the start of the fragment. (TC_FRAG_INIT): Defined to riscv_init_frag. * testsuite/gas/riscv/mapping-01.s: New testcase. * testsuite/gas/riscv/mapping-01a.d: Likewise. * testsuite/gas/riscv/mapping-01b.d: Likewise. * testsuite/gas/riscv/mapping-02.s: Likewise. * testsuite/gas/riscv/mapping-02a.d: Likewise. * testsuite/gas/riscv/mapping-02b.d: Likewise. * testsuite/gas/riscv/mapping-03.s: Likewise. * testsuite/gas/riscv/mapping-03a.d: Likewise. * testsuite/gas/riscv/mapping-03b.d: Likewise. * testsuite/gas/riscv/mapping-04.s: Likewise. * testsuite/gas/riscv/mapping-04a.d: Likewise. * testsuite/gas/riscv/mapping-04b.d: Likewise. * testsuite/gas/riscv/mapping-norelax-04a.d: Likewise. * testsuite/gas/riscv/mapping-norelax-04b.d: Likewise. * testsuite/gas/riscv/no-relax-align.d: Updated. * testsuite/gas/riscv/no-relax-align-2.d: Likewise. include/ pr 27916 * opcode/riscv.h (enum riscv_seg_mstate): Added. opcodes/ pr 27916 * riscv-dis.c (last_map_symbol, last_stop_offset, last_map_state): Added to dump sections with mapping symbols. (riscv_get_map_state): Get the mapping state from the symbol. (riscv_search_mapping_symbol): Check the sorted symbol table, and then find the suitable mapping symbol. (riscv_data_length): Decide which data size we should print. (riscv_disassemble_data): Dump the data contents. (print_insn_riscv): Handle the mapping symbols. (riscv_symbol_is_valid): Marked mapping symbols as invalid.
2021-08-30Automatic date update in version.inGDB Administrator1-1/+1
2021-08-29Automatic date update in version.inGDB Administrator1-1/+1
2021-08-27ld: Change indirect symbol from IR to undefinedH.J. Lu1-6/+17
bfd/ PR ld/28264 * elflink.c (_bfd_elf_merge_symbol): Change indirect symbol from IR to undefined. ld/ PR ld/28264 * testsuite/ld-plugin/lto.exp: Run PR ld/28264 test. * testsuite/ld-plugin/pr28264-1.d: New file. * testsuite/ld-plugin/pr28264-2.d: Likewise. * testsuite/ld-plugin/pr28264-3.d: Likewise. * testsuite/ld-plugin/pr28264-4.d: Likewise. * testsuite/ld-plugin/pr28264.c: Likewise. * testsuite/ld-plugin/pr28264.ver: Likewise.
2021-08-28PR28264, ld.bfd crash on linking efivar with LTOAlan Modra1-1/+1
PR 28264 PR 26978 * linker.c (_bfd_generic_link_add_one_symbol <MIND>): Check that string is non-NULL.
2021-08-28Automatic date update in version.inGDB Administrator1-1/+1
2021-08-27Automatic date update in version.inGDB Administrator1-1/+1
2021-08-26Automatic date update in version.inGDB Administrator1-1/+1
2021-08-25Automatic date update in version.inGDB Administrator1-1/+1
2021-08-24Automatic date update in version.inGDB Administrator1-1/+1
2021-08-23Automatic date update in version.inGDB Administrator1-1/+1
2021-08-22Automatic date update in version.inGDB Administrator1-1/+1
2021-08-21Automatic date update in version.inGDB Administrator1-1/+1
2021-08-20Automatic date update in version.inGDB Administrator1-1/+1
2021-08-19Automatic date update in version.inGDB Administrator1-1/+1
2021-08-18Automatic date update in version.inGDB Administrator1-1/+1
2021-08-17PATCH [4/4] arm: Add Tag_PACRET_use build attributeAndrea Corallo1-0/+1
bfd/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * elf32-arm.c (elf32_arm_merge_eabi_attributes): Add 'Tag_PACRET_use' case. binutils/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * readelf.c (arm_attr_tag_PAC_extension): Declare. (arm_attr_public_tags): Add 'PAC_extension' lookup. elfcpp/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * arm.h: Define 'Tag_PACRET_use' enum. gas/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * config/tc-arm.c (arm_convert_symbolic_attribute): Add 'Tag_PACRET_use' to the attribute_table. include/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * elf/arm.h (elf_arm_reloc_type): Add 'Tag_PACRET_use'.
2021-08-17PATCH [3/4] arm: Add Tag_BTI_use build attributeAndrea Corallo1-0/+1
bfd/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * elf32-arm.c (elf32_arm_merge_eabi_attributes): Add 'Tag_BTI_use' case. binutils/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * readelf.c (arm_attr_tag_PAC_extension): Declare. (arm_attr_public_tags): Add 'PAC_extension' lookup. elfcpp/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * arm.h: Define 'Tag_BTI_use' enum. gas/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * config/tc-arm.c (arm_convert_symbolic_attribute): Add 'Tag_BTI_use' to the attribute_table. include/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * elf/arm.h (elf_arm_reloc_type): Add 'Tag_BTI_use'.
2021-08-17PATCH [2/4] arm: Add Tag_BTI_extension build attributeAndrea Corallo1-0/+1
bfd/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * elf32-arm.c (elf32_arm_merge_eabi_attributes): Add 'Tag_BTI_extension' case. binutils/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * readelf.c (arm_attr_tag_PAC_extension): Declare. (arm_attr_public_tags): Add 'PAC_extension' lookup. elfcpp/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * arm.h: Define 'Tag_BTI_extension' enum. gas/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * config/tc-arm.c (arm_convert_symbolic_attribute): Add 'Tag_BTI_extension' to the attribute_table. include/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * elf/arm.h (elf_arm_reloc_type): Add 'Tag_BTI_extension'.
2021-08-17PATCH [1/4] arm: Add Tag_PAC_extension build attributeAndrea Corallo1-0/+1
bfd/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * elf32-arm.c (elf32_arm_merge_eabi_attributes): Add 'Tag_PAC_extension' case. binutils/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * readelf.c (arm_attr_tag_PAC_extension): Declare. (arm_attr_public_tags): Add 'PAC_extension' lookup. elfcpp/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * arm.h: Define 'Tag_PAC_extension' enum. gas/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * config/tc-arm.c (arm_convert_symbolic_attribute): Add 'Tag_PAC_extension' to the attribute_table. include/ 2021-07-06 Andrea Corallo <andrea.corallo@arm.com> * elf/arm.h (elf_arm_reloc_type): Add 'Tag_PAC_extension'.
2021-08-17Automatic date update in version.inGDB Administrator1-1/+1
2021-08-16Automatic date update in version.inGDB Administrator1-1/+1
2021-08-15Automatic date update in version.inGDB Administrator1-1/+1
2021-08-14Automatic date update in version.inGDB Administrator1-1/+1
2021-08-13ns32k configuryAlan Modra1-1/+4
Since ns32k-netbsd is as yet not removed, just marked obsolete, the target should still be accepted with --enable-obsolete. I also enabled ns32k-openbsd in ld since there doesn't seem to be a good reason why that target is not supported there but is elsewhere. bfd/ * config.bfd: Allow ns32k-netbsd. ld/ * configure.tgt: Allow ns32k-openbsd.
2021-08-13Automatic date update in version.inGDB Administrator1-1/+1
2021-08-12Automatic date update in version.inGDB Administrator1-1/+1
2021-08-11Deprecate a.out support for NetBSD targets.John Ericson4-932/+964
As discussed previously, a.out support is now quite deprecated, and in some cases removed, in both Binutils itself and NetBSD, so this legacy default makes little sense. `netbsdelf*` and `netbsdaout*` still work allowing the user to be explicit about there choice. Additionally, the configure script warns about the change as Nick Clifton requested. One possible concern was the status of NetBSD on NS32K, where only a.out was supported. But per [1] NetBSD has removed support, and if it were to come back, it would be with ELF. The binutils implementation is therefore marked obsolete, per the instructions in the last message. With that patch and this one applied, I have confirmed the following: --target=i686-unknown-netbsd --target=i686-unknown-netbsdelf builds completely --target=i686-unknown-netbsdaout properly fails because target is deprecated. --target=vax-unknown-netbsdaout builds completely except for gas, where the target is deprecated. [1]: https://mail-index.netbsd.org/tech-toolchain/2021/07/19/msg004025.html --- bfd/config.bfd | 43 +++++++++++++-------- bfd/configure.ac | 5 +-- binutils/testsuite/binutils-all/nm.exp | 2 +- binutils/testsuite/lib/binutils-common.exp | 7 +--- config/picflag.m4 | 4 +- gas/configure.tgt | 9 +++-- gas/testsuite/gas/arm/blx-bl-convert.d | 2 +- gas/testsuite/gas/arm/blx-local-thumb.d | 2 +- gas/testsuite/gas/sh/basic.exp | 2 +- gdb/configure.host | 34 +++++++---------- gdb/configure.tgt | 2 +- gdb/testsuite/gdb.asm/asm-source.exp | 6 +-- intl/configure | 2 +- ld/configure.tgt | 44 +++++++++++----------- ld/testsuite/ld-arm/arm-elf.exp | 4 +- ld/testsuite/ld-elf/elf.exp | 2 +- ld/testsuite/ld-elf/shared.exp | 4 +- libiberty/configure | 4 +-
2021-08-11PR28163, Segment fault in function rl78_special_relocAlan Modra1-365/+360
Relocation offset checks were completely missing in the rl78 backend, allowing a relocation to write over memory anywhere. This was true for rl78_special_reloc, a function primarily used when applying debug relocations, and in rl78_elf_relocate_section used by the linker. This patch fixes those problems by correcting inaccuracies in the relocation howtos, then uses those howtos to sanity check relocation offsets before applying relocations. In addition, the patch implements overflow checking using the howto information rather than the ad-hoc scheme implemented in relocate_section. I implemented the overflow checking in rl78_special_reloc too. * elf32-rl78.c (RL78REL, RL78_OP_REL): Add mask parameter. (rl78_elf_howto_table): Set destination masks. Correct size and bitsize of DIR32_REV. Correct complain_on_overflow for many relocs as per tests in relocate_section. Add RH_SFR. Correct bitsize for RH_SADDR. Set size to 3 and bitsize to 0 for all OP relocs. (check_overflow): New function. (rl78_special_reloc): Check that reloc address is within section. Apply relocations using reloc howto. Check for overflow. (RANGE): Delete. (rl78_elf_relocate_section): Sanity check r_offset. Perform overflow checking using reloc howto.
2021-08-11Automatic date update in version.inGDB Administrator1-1/+1
2021-08-10Updated Serbian and Russian translations for various sub-directoriesNick Clifton2-1582/+1556
2021-08-10Automatic date update in version.inGDB Administrator1-1/+1
2021-08-09Automatic date update in version.inGDB Administrator1-1/+1
2021-08-08Automatic date update in version.inGDB Administrator1-1/+1
2021-08-07PR28186, SEGV elf.c:7991:30 in _bfd_elf_fixup_group_sectionsAlan Modra1-1/+1
PR 28186 * elf.c (_bfd_elf_fixup_group_sections): Don't segfault on objcopy/strip with NULL output_section.
2021-08-07PR28176, rl78 complex reloc divide by zeroAlan Modra1-129/+154
This is a bit more than just preventing the divide by zero. Most of the patch is tidying up error reporting, so that for example, linking an object file with a reloc stack underflow produces a linker error rather than just displaying a message that might be ignored. PR 28176 * elf32-rl78.c (RL78_STACK_PUSH, RL78_STACK_POP): Delete. (rl78_stack_push, rl78_stack_pop): New inline functions. (rl78_compute_complex_reloc): Add status and error message params. Use new inline stack handling functions. Report stack overflow or underflow, and divide by zero. (rl78_special_reloc): Return status and error message from rl78_compute_complex_reloc. (rl78_elf_relocate_section): Similarly. Modernise reloc error reporting. Delete unused bfd_reloc_other case. Don't assume DIR24S_PCREL overflow is due to undefined function. (rl78_offset_for_reloc): Adjust to suit rl78_compute_complex_reloc.
2021-08-07Automatic date update in version.inGDB Administrator1-1/+1
2021-08-06chew ubsan warningAlan Modra1-2/+2
It matters not at all if pc is incremented from its initial NULL value, but avoid this silly runtime ubsan error. * doc/chew.c (perform): Avoid incrementing NULL pc.
2021-08-06bfd_reloc_offset_in_range overflowAlan Modra1-1/+1
This patch is more about the style of bounds checking we ought to use, rather than a real problem. An overflow of "octet + reloc_size" can only happen with huge sections which would certainly cause out of memory errors. * reloc.c (bfd_reloc_offset_in_range): Avoid possible overflow.
2021-08-06PR28175, Segment fault in coff-tic30.c reloc_processingAlan Modra3-9/+30
The obj_convert table shouldn't be accessed without first checking the index against the table size. PR 28175 * coff-tic30.c (reloc_processing): Sanity check reloc symbol index. * coff-z80.c (reloc_processing): Likewise. * coff-z8k.c (reloc_processing): Likewise.
2021-08-06PR28173, nds32_elf_howto_table index out of boundsAlan Modra1-30/+25
Indexing the howto table was seriously broken by a missing entry, and use of assertions about user input rather than testing the input. PR 28173 * elf32-nds32.c (nds32_elf_howto_table): Add missing empty howto. (bfd_elf32_bfd_reloc_type_table_lookup): Replace assertions with range checks. Return NULL if unsupported reloc type. Remove dead code. Take an unsigned int param. (nds32_info_to_howto_rel): Test for NULL howto or howto name return from lookup. Remove assertion. (nds32_info_to_howto): Remove unnecessary ATTRIBUTE_UNUSED. Test for NULL howto or howto name return from lookup.
2021-08-06PR28172, bfin_pcrel24_reloc heap-buffer-overflowAlan Modra1-5/+11
bfin pcrel24 relocs are weird, they apply to the reloc address minus two. That means reloc addresses of 0 and 1 are invalid. Check that, and fix other reloc range checking. PR 28172 * elf32-bfin.c (bfin_pcrel24_reloc): Correct reloc range check. (bfin_imm16_reloc, bfin_byte4_reloc, bfin_bfd_reloc): Likewise. (bfin_final_link_relocate): Likewise.
2021-08-06Automatic date update in version.inGDB Administrator1-1/+1
2021-08-05PR28167, vms-alpha build_module_listAlan Modra1-7/+4
PR 28167 * vms-alpha.c (build_module_list): Malloc and free section contents. Don't read past end of section.
2021-08-05PR28166, _bfd_elf_mips_get_relocated_section_contentsAlan Modra1-9/+2
Some of the code paths unpacking mips relocs left arelent->sym_ptr_ptr uninitialised. PR 28166 * elf64-mips.c (mips_elf64_slurp_one_reloc_table): Don't leave sym_ptr_ptr uninitialised.