aboutsummaryrefslogtreecommitdiff
path: root/bfd/ChangeLog
AgeCommit message (Collapse)AuthorFilesLines
2022-02-09This is the 2.38 GNU Binutils releasebinutils-2_38Nick Clifton1-0/+11
2022-02-02Stop the BFD library from complaining that dwarf debug string sections are ↵Nick Clifton1-0/+6
too big. PR 28834 * dwarf2.c (read_section): Change the heuristic that checks for overlarge dwarf debug info sections.
2022-01-24Update Bulgarian, French, Romaniam and Ukranian translation for some of the ↵Nick Clifton1-0/+6
sub-directories
2022-01-22CHange version number to 2.37.90 and regenerate filesNick Clifton1-0/+6
2022-01-22Add markers for 2.38 branchNick Clifton1-0/+4
2022-01-17Update the config.guess and config.sub files from the master repository and ↵Nick Clifton1-0/+7
regenerate files.
2022-01-02Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
2021-12-15Fix an undefined behaviour in the BFD library's DWARF parser.Nikita Popov1-0/+5
PR 28687 * dwarf1.c (parse_die): Fix undefined behaviour in range tests.
2021-11-17Fix the linker script parser so that it will recognise the PT_GNU_RELRO ↵Nick Clifton1-0/+6
segment type, and the linker itself so that it will gracefully handle being unable to assign any sections to such a segment. PR 28452 bfd * elf.c (assign_file_positions_for_non_load_sections): Replace assertion with a warning message. ld * ldgram.y: Add support for PT_GNU_RELRO and PT_GNU_PROPERTY. * ldgram.c: Regenerate.
2021-10-19Fix a potential illegal memory access when testing for a special LTO symbol ↵Nick Clifton1-0/+6
name. bfd * linker.c (_bfd_generic_link_add_one_symbol): Test for a NULL name before checking to see if the symbol is __gnu_lto_slim. * archive.c (_bfd_compute_and_write_armap): Likewise. binutils * nm.c (filter_symbols): Test for a NULL name before checking to see if the symbol is __gnu_lto_slim. * objcopy.c (filter_symbols): Likewise.
2021-09-27configure: regenerate in all projects that use libtool.m4Nick Alcock1-0/+4
(including sim/, which has no changelog.) bfd/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. binutils/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. gas/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. gprof/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. ld/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. libctf/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. * Makefile.in: Regenerate. opcodes/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. zlib/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate.
2021-09-15bfd: fix incorrect type used in sizeofAndrew Burgess1-0/+5
Noticed in passing that we used 'sizeof (char **)' when calculating the size of a list of 'char *' pointers. Of course, this isn't really going to make a difference anywhere, but we may as well be correct. There should be no user visible changes after this commit. bfd/ChangeLog: * archures.c (bfd_arch_list): Use 'char *' instead of 'char **' when calculating space for a string list.
2021-09-14arc: Fix potential invalid pointer access when fixing got symbols.Claudiu Zissulescu1-0/+9
When statically linking, it can arrive to an undefined weak symbol of which its value cannot be determined. However, we are having pieces of code which doesn't take this situation into account, leading to access a structure which may not be initialized. Fix this situation and add a test. bfd/ xxxx-xx-xx Cupertino Miranda <cmiranda@synopsys.com> Claudiu Zissulescu <claziss@synopsys.com> * arc-got.h (arc_static_sym_data): New structure. (get_static_sym_data): New function. (relocate_fix_got_relocs_for_got_info): Move the computation fo symbol value and section to above introduced function, and use this new function. ld/testsuite/ xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com> * ld-arc/got-weak.d: New file. * ld-arc/got-weak.s: Likewise. Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com> fix
2021-09-07Revert: [AArch64] MTE corefile supportLuis Machado1-0/+9
bfd * elf.c (elfcore_make_memtag_note_section): New function. (elfcore_grok_note): Handle NT_MEMTAG note types. binutils* readelf.c (get_note_type): Handle NT_MEMTAG note types. include * elf/common.h (NT_MEMTAG): New constant. (NT_MEMTAG_TYPE_AARCH_MTE): New constant.
2021-09-07Fix an illegal memory access triggered by an atempt to disassemble a corrupt ↵Nick Clifton1-0/+4
xtensa binary. PR 28305 * elf32-xtensa.c (elf_xtensa_do_reloc): Add check for put of range reloc.
2021-09-07Fix illegal memory access triggered by an attempt to disassemble a corrupt ↵Nick Clifton1-0/+6
RISC-V binary. PR 28303 * elfxx-riscv.c (riscv_elf_add_sub_reloc): Add check for out of range relocs.
2021-08-10Updated Serbian and Russian translations for various sub-directoriesNick Clifton1-0/+4
2021-07-18Move pending-obsolesence targets onto the obsolete list.Nick Clifton1-0/+4
* config.bfd: Move pending obsoletion targets to obsolete list.
2021-07-16or1k: fix pc-relative relocation against dynamic on PC relative 26 bit ↵Giulio Benetti1-0/+6
relocation. bfd * elf32-or1k.c (or1k_elf_relocate_section): Use a separate entry in switch case R_OR1K_INSN_REL_26 where we need to check for !SYMBOL_CALLS_LOCAL() instead of !SYMBOL_REFERENCES_LOCAL().
2021-07-14objdump: add DWARF support for AIXClément Chigot1-0/+7
DWARF sections have special names on AIX which need be handled by objdump in order to correctly print them. This patch also adds the correlation in bfd for future uses. bfd/ * libxcoff.h (struct xcoff_dwsect_name): Add DWARF name. * coff-rs6000.c (xcoff_dwsect_names): Update. * coffcode.h (sec_to_styp_flags): Likewise. (coff_new_section_hook): Likewise. binutils/ * dwarf.h (struct dwarf_section): Add XCOFF name. * dwarf.c (struct dwarf_section_display): Update. * objdump.c (load_debug_section): Add XCOFF name handler. (dump_dwarf_section): Likewise. gas/ * config/tc-ppc.c (ppc_change_debug_section): Update to match new name's field.
2021-07-10Tidy commit 49910fd88dcdAlan Modra1-0/+5
Pointer range checking is UB if the values compared are outside the underlying array elements (plus one). * dwarf2.c (read_address): Remove accidental commit. (read_ranges): Compare offset rather than pointers.
2021-07-08Updated Portuguese translation for the BFD sub-directoryNick Clifton1-0/+4
2021-07-07Remove an accidental change to elfcode.h included as part of commit 6e0dfbf420.Nick Clifton1-0/+5
PR 27659 * elfcode.h (elf_swap_symbol_out): Revert accidental change that removed an abort if the shndx pointer is NULL.
2021-07-07Fix Solaris gprof build with --disable-nlsRainer Orth1-0/+5
gprof fails to compile on Solaris 10 and 11.3 with --disable-nls: In file included from /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/gprof/gprof.h:33, from /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/gprof/basic_blocks.c:24: /usr/include/libintl.h:45:14: error: expected identifier or '(' before 'const' 45 | extern char *dcgettext(const char *, const char *, const int); | ^~~~~~~~~ /usr/include/libintl.h:46:14: error: expected identifier or '(' before 'const' 46 | extern char *dgettext(const char *, const char *); | ^~~~~~~~ /usr/include/libintl.h:47:14: error: expected identifier or '(' before 'const' 47 | extern char *gettext(const char *); | ^~~~~~~ /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/gprof/../bfd/sysdep.h:165:33: error: expected identifier or '(' before 'do' 165 | # define textdomain(Domainname) do {} while (0) | ^~ /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/gprof/../bfd/sysdep.h:165:39: error: expected identifier or '(' before 'while' 165 | # define textdomain(Domainname) do {} while (0) | ^~~~~ /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/gprof/../bfd/sysdep.h:166:46: error: expected identifier or '(' before 'do' 166 | # define bindtextdomain(Domainname, Dirname) do {} while (0) | ^~ /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/gprof/../bfd/sysdep.h:166:52: error: expected identifier or '(' before 'while' 166 | # define bindtextdomain(Domainname, Dirname) do {} while (0) | ^~~~~ /usr/include/libintl.h:55:14: error: expected identifier or '(' before 'unsigned' 55 | extern char *dcngettext(const char *, const char *, | ^~~~~~~~~~ /usr/include/libintl.h:57:14: error: expected identifier or '(' before 'unsigned' 57 | extern char *dngettext(const char *, const char *, | ^~~~~~~~~ /usr/include/libintl.h:59:14: error: expected identifier or '(' before 'unsigned' 59 | extern char *ngettext(const char *, const char *, unsigned long int); | ^~~~~~~~ This is a known issue already partially fixed in binutils/sysdep.h. For gprof, the same fix needs to be applied in bfd/sysdep.h, as the following patch does. Tested on i386-pc-solaris2.10 and i386-pc-solaris2.11. 2021-07-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> bfd: * sysdep.h [!ENABLE_NLS]: Prevent inclusion of <libintl.h> on Solaris.
2021-07-07Check for strnlen declaration to fix Solaris 10 buildRainer Orth1-0/+5
binutils currently fails to compile on Solaris 10: /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c: In function 'bfd_get_debug_link_info_1': /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1231:16: error: implicit declaration of function 'strnlen' [-Werror=implicit-function-declaration] 1231 | crc_offset = strnlen (name, size) + 1; | ^~~~~~~ /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1231:16: error: incompatible implicit declaration of built-in function 'strnlen' [-Werror] /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c: In function 'bfd_get_alt_debug_link_info': /vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1319:20: error: incompatible implicit declaration of built-in function 'strnlen' [-Werror] 1319 | buildid_offset = strnlen (name, size) + 1; | ^~~~~~~ and in a couple of other places. The platform lacks strnlen, and while libiberty.h can provide a fallback declaration, the necessary configure test isn't run. Fixed with the following patch. Tested on i386-pc-solaris2.10. 2021-07-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> bfd: * configure.ac: Check for strnlen declaration. * configure, config.in: Regenerate. binutils: * configure.ac: Check for strnlen declaration. * configure, config.in: Regenerate.
2021-07-07Fix problems translating messages when a percentage sign appears at the end ↵Nick Clifton1-0/+10
of a string. PR 28051 gas * config/tc-i386.c (offset_in_range): Reformat error messages in order to fix problems when translating. (md_assemble): Likewise. * messages.c (as_internal_value_out_of_range): Likewise. * read.c (emit_expr_with_reloc): Likewise. * testsuite/gas/all/overflow.l Change expected output format. * po/gas.pot: Regenerate. bfd * coff-rs6000.c (xcoff_reloc_type_tls): Reformat error messages in order to fix problems when translating. * cofflink.c (_bfd_coff_write_global_sym): Likewise. * elfnn-aarch64.c (_bfd_aarch64_erratum_843419_branch_to_stub): Likewise. * po/bfd.pot: Regenerate.
2021-07-06elf/riscv: Fix relaxation with aliases [PR28021]Michael Matz1-0/+6
the fix for PR22756 only changed behaviour for hidden aliases, but the same situation exists for non-hidden aliases: sym_hashes[] can contain multiple entries pointing to the same symbol structure leading to relaxation adjustment to be applied twice. Fix this by testing for duplicates for everything that looks like it has a version. PR ld/28021 bfd/ * elfnn-riscv.c (riscv_relax_delete_bytes): Check for any versioning. ld/ * testsuite/ld-riscv-elf/relax-twice.ver: New. * testsuite/ld-riscv-elf/relax-twice-1.s: New. * testsuite/ld-riscv-elf/relax-twice-2.s: New. * testsuite/ld-riscv-elf/ld-riscv-elf.exp (run_relax_twice_test): New, and call it.
2021-07-06Re: PR28055, segfault in bpf special reloc functionAlan Modra1-0/+5
PR 28055 * elf64-bpf.c (bpf_elf_generic_reloc): Add missing ATTRIBUTE_UNUSED.
2021-07-05PR28055, segfault in bpf special reloc functionAlan Modra1-0/+6
The testcase in this PR tickled two bugs fixed here. output_bfd is NULL when a reloc special_function is called for final linking and when called from bfd_generic_get_relocated_section_contents. Clearly using output_bfd is wrong as it results in segfaults. Not only that, the endianness of the reloc field really should be that of the input. The second bug was not checking that the entire reloc field was contained in the section contents. PR 28055 * elf64-bpf.c (bpf_elf_generic_reloc): Use correct bfd for bfd_put and bfd_put_32 calls. Correct section limit checks.
2021-07-03Update version number and regenerate filesNick Clifton1-0/+6
2021-07-03Add markers for 2.37 branchNick Clifton1-0/+4
2021-07-02Fix an illegal memory access triggered by an attempt to parse a corrupt ↵Nick Clifton1-0/+6
input file. PR 28046 * dwarf2.c (read_ranges): Check that range_ptr does not exceed range_end.
2021-06-30Mark .gnu.debuglto_.debug_* as SHT_MIPS_DWARFYunQiang Su1-0/+7
PR mips/28009 * bfd/elfxx-mips.c (_bfd_mips_elf_section_from_shdr, _bfd_mips_elf_fake_sections): Mark LTO debug info as SHT_MIPS_DWARF.
2021-06-29Add the netbsdpe configuration to the list of obsolete targets.Nick Clifton1-0/+4
* config.bfd (obsolete configurations): Add netbsdpe.
2021-06-22RISC-V: Clarify the addends of pc-relative access.Nelson Chu1-0/+17
The original discussion was here, https://github.com/riscv/riscv-elf-psabi-doc/issues/184 After discussing with Kito Cheng, I think the addends of %pcrel_hi and %pcrel_lo are both allowed in GNU toolchain. However, both of the them mean the offset of symbols, rather than the pc address. But the addends of %got_pcrel_hi and it's %pcrel_lo do not look reasonable. I believe gcc won't generate the got patterns with addends, so linker should report dangerous relocation errors, in case the assembly code use them. Another issue was here, https://sourceware.org/pipermail/binutils/2021-June/116983.html At the beginnig, I suppose %pcrel_hi and %pcrel_lo are valid only when they are in the same input section. But Jim Wilson points out that gcc may generate %hi and %lo in the different input sections, when -freorder-blocks-and-partition option is used. So that a memory references for a loop may have the %hi outside the loop, but the %lo remain in the loop. However, it is hard to create the testcases, to see if %pcrel_hi and %pcrel_lo have the same behavior. Unfortunately, I notice that the current pcrel resolver cannot work for the above case. For now we build a hash table for pcrel at the start of riscv_elf_relocate_section, and then free the hash at the end. But riscv_elf_relocate_section only handles an input section at a time, so that means we can only resolve the %pcrel_hi and %pcrel_lo which are in the same input section. Otherwise, like the above case, we will report "%pcrel_lo missing matching %pcrel_hi" for them. I have no plan to improve this in the short-term, so maybe we can wait until someone meets the problem before we deal with it. bfd/ * elfnn-riscv.c (riscv_pcrel_hi_reloc): Added field to store the original relocation type, in case the type is converted to R_RISCV_HI20. (riscv_pcrel_lo_reloc): Removed unused name field. (riscv_pcrel_relocs): Added comments. (riscv_zero_pcrel_hi_reloc): Removed unused input_bfd. (riscv_record_pcrel_hi_reloc): Updated. (riscv_record_pcrel_lo_reloc): Likewise. (riscv_resolve_pcrel_lo_relocs): Likewise. Check the original type of auipc, to make sure the %pcrel_lo without any addends. Otherwise, report dangerous relocation error. (riscv_elf_relocate_section): Updated above functions are changed. For R_RISCV_GOT_HI20, report dangerous relocation error when addend isn't zero. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/pcrel-lo-addend-3a.d: New testcase. * testsuite/ld-riscv-elf/pcrel-lo-addend-3a.s: Likewise. * testsuite/ld-riscv-elf/pcrel-lo-addend-3b.d: New testcase. Should report error since the %pcrel_lo with addend refers to %got_pcrel_hi. * testsuite/ld-riscv-elf/pcrel-lo-addend-3b.s: Likewise. * testsuite/ld-riscv-elf/pcrel-lo-addend-3c.d: New testcase. Should report error since the %got_pcrel_hi with addend. * testsuite/ld-riscv-elf/pcrel-lo-addend-3c.s: Likewise. * testsuite/ld-riscv-elf/pcrel-lo-addend-3.ld: Likewise.
2021-06-19x86: Count PLT for GOTOFF relocation against IFUNC symbolH.J. Lu1-0/+7
Since GOTOFF relocations against IFUNC symbols must go through PLT, set PLT reference count to 1 for GOTOFF relocation. bfd/ PR ld/27998 * elfxx-x86.c (elf_x86_allocate_dynrelocs): Count PLT for GOTOFF relocation against IFUNC symbols. (_bfd_x86_elf_adjust_dynamic_symbol): Likewise. ld/ PR ld/27998 * testsuite/ld-i386/i386.exp: Run PR ld/27998 tests. * testsuite/ld-i386/pr27998a.d: New file. * testsuite/ld-i386/pr27998a.s: Likewise. * testsuite/ld-i386/pr27998b.d: Likewise. * testsuite/ld-i386/pr27998b.s: Likewise.
2021-06-19elf: Correct DT_TEXTREL warning in PDEH.J. Lu1-0/+5
Change ld: warning: creating DT_TEXTREL in a PIE to ld: warning: creating DT_TEXTREL in a PDE on PDE. bfd/ * elflink.c (bfd_elf_final_link): Correct DT_TEXTREL warning in PDE. ld/ * testsuite/ld-x86-64/textrel-1.err: New file. * testsuite/ld-x86-64/textrel-1a.s: Likewise. * testsuite/ld-x86-64/textrel-1b.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run textrel-1 tests.
2021-06-18elf: Add GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXXH.J. Lu1-0/+7
Implement GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX: https://sourceware.org/pipermail/gnu-gabi/2021q1/000467.html 1. GNU_PROPERTY_UINT32_AND_LO..GNU_PROPERTY_UINT32_AND_HI #define GNU_PROPERTY_UINT32_AND_LO 0xb0000000 #define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff A bit in the output pr_data field is set only if it is set in all relocatable input pr_data fields. If all bits in the the output pr_data field are zero, this property should be removed from output. If the bit is 1, all input relocatables have the feature. If the bit is 0 or the property is missing, the info is unknown. 2. GNU_PROPERTY_UINT32_OR_LO..GNU_PROPERTY_UINT32_OR_HI #define GNU_PROPERTY_UINT32_OR_LO 0xb0008000 #define GNU_PROPERTY_UINT32_OR_HI 0xb000ffff A bit in the output pr_data field is set if it is set in any relocatable input pr_data fields. If all bits in the the output pr_data field are zero, this property should be removed from output. If the bit is 1, some input relocatables have the feature. If the bit is 0 or the property is missing, the info is unknown. bfd/ * elf-properties.c (_bfd_elf_parse_gnu_properties): Handle GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI, GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI. (elf_merge_gnu_properties): Likewise. binutils/ * readelf.c (print_gnu_property_note): Handle GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI, GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI. include/ * elf/common.h (GNU_PROPERTY_UINT32_AND_LO): New. (GNU_PROPERTY_UINT32_AND_HI): Likewise. (GNU_PROPERTY_UINT32_OR_LO): Likewise. (GNU_PROPERTY_UINT32_OR_HI): Likewise. ld/ * testsuite/ld-elf/property-and-1.d: New file. * testsuite/ld-elf/property-and-1.s: Likewise. * testsuite/ld-elf/property-and-2.d: Likewise. * testsuite/ld-elf/property-and-2.s: Likewise. * testsuite/ld-elf/property-and-3.d: Likewise. * testsuite/ld-elf/property-and-3.s: Likewise. * testsuite/ld-elf/property-and-4.d: Likewise. * testsuite/ld-elf/property-and-empty.s: Likewise. * testsuite/ld-elf/property-or-1.d: Likewise. * testsuite/ld-elf/property-or-1.s: Likewise. * testsuite/ld-elf/property-or-2.d: Likewise. * testsuite/ld-elf/property-or-2.s: Likewise. * testsuite/ld-elf/property-or-3.d: Likewise. * testsuite/ld-elf/property-or-3.s: Likewise. * testsuite/ld-elf/property-or-4.d: Likewise. * testsuite/ld-elf/property-or-empty.s: Likewise.
2021-06-11PR27952, Disallow ET_DYN DF_1_PIE linker inputAlan Modra1-0/+6
This patch adds a new elf_tdata flag, is_pie, set during the linker's open_input_bfds processing. The flag is then used to reject attempts to link a PIE as if it were a shared library. bfd/ PR 27952 * elf-bfd.h (struct elf_obj_tdata): Add is_pie. * elflink.c (elf_link_add_object_symbols): Set is_pie. ld/ PR 27952 * ldelf.c (ldelf_after_open): Error on input PIEs too.
2021-06-09Fix the creation of archives for Sparc Solaris2 targets by eliminating the ↵Nick Clifton1-0/+6
support for generic SPARC ELF files. PR 27666 bfd * config.bfd: Do not add the sparc_elf32_vec or sparc_elf64_vec vectors to Sparc Solaris2 targets. ld * testsuite/ld-sparc/sparc.exp: Do not run the sparctests or sparc64tests for Solaris2 targets.
2021-06-08bfd/elf: Don't read non-existing secondary relocsMichael Matz1-0/+5
I forgot the ChangeLog commit :-/
2021-06-07fix Dwarf2 build with certain gcc versionsJan Beulich1-0/+4
Older gcc reports: .../bfd/dwarf2.c: In function 'read_ranges': .../bfd/dwarf2.c:3107: error: comparison between signed and unsigned .../bfd/dwarf2.c: In function 'read_rnglists': .../bfd/dwarf2.c:3189: error: comparison between signed and unsigned Similarly for binutils/dwarf.c. Arrange for the left sides of the > to also be unsigned quantities.
2021-06-02asan: heap buffer overflow in _bfd_elf_parse_attributesAlan Modra1-0/+5
* elf-attrs.c (_bfd_elf_parse_attributes): Break out of loop if subsection length is too small to cover tag and length field.
2021-05-31RISC-V: PR27566, Do not relax when data segment phase is exp_seg_relro_adjust.Nelson Chu1-0/+13
2021-05-31 Nelson Chu <nelson.chu@sifive.com> Lifang Xia <lifang_xia@c-sky.com> The data segment phase exp_seg_relro_adjust means we are still adjusting the relro segments, so we will get the symbol values which havn't consider the relro. It is dangerous and we shouldn't do the relaxations at this stage. Otherwise, we may get the truncated fails when the relax range crossing the data segment. One of the solution is that, we use a pointer to monitor the data segment phase while relaxing, to know whether the relro has been handled or not. Once we check the phase is exp_seg_relro_adjust, we should skip this round of relaxations, since the incorrect symbol values will affect the correctness of relaxations. I think we probably need to record more information about data segment or alignments in the future, to make sure it is safe to doing relaxations. For the two new testcases, relro-relax-lui and relro-relax-pcrel, we get the following truncated errors when using toolchains, which enable relro: (.text+0x0): relocation truncated to fit: R_RISCV_GPREL_I against symbol `SymbolRodata' defined in .rodata section in test1.o After applying this patch, the truncated errors should be resolved. However, only linux toolchains support -z relro, so we only test these two testcases when supporting shared library. bfd/ PR 27566 * elfnn-riscv.c (struct riscv_elf_link_hash_table): New integer pointer to monitor the data segment phase. (bfd_elfNN_riscv_set_data_segment_info): New function called by after_allocation, to set the data_segment_phase from expld.dataseg. (_bfd_riscv_relax_section): Don't relax when data_segment_phase is exp_seg_relro_adjust (0x4). * elfxx-riscv.h (bfd_elf32_riscv_set_data_segment_info): New extern. (bfd_elf64_riscv_set_data_segment_info): Likewise. ld/ PR 27566 * emultempl/riscvelf.em (after_allocation): Call riscv_set_data_segment_info to set data segment phase before relaxing. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/relro-relax-lui.d: New testcase. * testsuite/ld-riscv-elf/relro-relax-lui.s: Likewise. * testsuite/ld-riscv-elf/relro-relax-pcrel.d: Likewise. * testsuite/ld-riscv-elf/relro-relax-pcrel.s: Likewise.
2021-05-28x86: Restore PC16 relocation overflow checkH.J. Lu1-0/+16
The x86-64 psABI has --- A program or object file using R_X86_64_8, R_X86_64_16, R_X86_64_PC16 or R_X86_64_PC8 relocations is not conformant to this ABI, these relocations are only added for documentation purposes. --- Since x86 PC16 relocations have been used for 16-bit programs in an ELF32 or ELF64 container, PC16 relocation should wrap-around in 16-bit address space. Revert commit a7664973b24a242cd9ea17deb5eaf503065fc0bd Author: Jan Beulich <jbeulich@suse.com> Date: Mon Apr 26 10:41:35 2021 +0200 x86: correct overflow checking for 16-bit PC-relative relocs and xfail the related tests. Also revert commit 50c95a739c91ae70cf8481936611aa1f5397a384 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed May 26 12:13:13 2021 -0700 x86: Propery check PC16 reloc overflow in 16-bit mode instructions while keeping PR ld/27905 tests for PC16 relocation in 16-bit programs. bfd/ PR ld/27905 * elf32-i386.c: Don't include "libiberty.h". (elf_howto_table): Revert commits a7664973b24 and 50c95a739c9. (elf_i386_rtype_to_howto): Revert commit 50c95a739c9. (elf_i386_info_to_howto_rel): Likewise. (elf_i386_tls_transition): Likewise. (elf_i386_relocate_section): Likewise. * elf64-x86-64.c (x86_64_elf_howto_table): Revert commits a7664973b24 and 50c95a739c9. (elf_x86_64_rtype_to_howto): Revert commit 50c95a739c9. * elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Likewise. * elfxx-x86.h (elf_x86_obj_tdata): Likewise. (elf_x86_has_code16): Likewise. binutils/ PR ld/27905 * readelf.c (decode_x86_feature_2): Revert commit 50c95a739c9. gas/ PR ld/27905 * config/tc-i386.c (set_code_flag): Revert commit 50c95a739c9. (set_16bit_gcc_code_flag): Likewise. (x86_cleanup): Likewise. * testsuite/gas/i386/code16-2.d: Updated. * testsuite/gas/i386/x86-64-code16-2.d: Likewise. include/ PR ld/27905 * elf/common.h (GNU_PROPERTY_X86_FEATURE_2_CODE16): Removed. ld/ PR ld/27905 * testsuite/ld-i386/pcrel16-2.d: xfail. * testsuite/ld-x86-64/pcrel16-2.d: Likewise.
2021-05-26x86: Propery check PC16 reloc overflow in 16-bit mode instructionsH.J. Lu1-0/+21
commit a7664973b24a242cd9ea17deb5eaf503065fc0bd Author: Jan Beulich <jbeulich@suse.com> Date: Mon Apr 26 10:41:35 2021 +0200 x86: correct overflow checking for 16-bit PC-relative relocs caused linker failure when building 16-bit program in a 32-bit ELF container. Update GNU_PROPERTY_X86_FEATURE_2_USED with #define GNU_PROPERTY_X86_FEATURE_2_CODE16 (1U << 12) to indicate that 16-bit mode instructions are used in the input object: https://groups.google.com/g/x86-64-abi/c/UvvXWeHIGMA to indicate that 16-bit mode instructions are used in the object to allow linker to properly perform relocation overflow check for 16-bit PC-relative relocations in 16-bit mode instructions. 1. Update x86 assembler to always generate the GNU property note with GNU_PROPERTY_X86_FEATURE_2_CODE16 for .code16 in ELF object. 2. Update i386 and x86-64 linkers to use 16-bit PC16 relocations if input object is marked with GNU_PROPERTY_X86_FEATURE_2_CODE16. bfd/ PR ld/27905 * elf32-i386.c: Include "libiberty.h". (elf_howto_table): Add 16-bit R_386_PC16 entry. (elf_i386_rtype_to_howto): Add a BFD argument. Use 16-bit R_386_PC16 if input has 16-bit mode instructions. (elf_i386_info_to_howto_rel): Update elf_i386_rtype_to_howto call. (elf_i386_tls_transition): Likewise. (elf_i386_relocate_section): Likewise. * elf64-x86-64.c (x86_64_elf_howto_table): Add 16-bit R_X86_64_PC16 entry. (elf_x86_64_rtype_to_howto): Use 16-bit R_X86_64_PC16 if input has 16-bit mode instructions. * elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Set elf_x86_has_code16 if relocatable input is marked with GNU_PROPERTY_X86_FEATURE_2_CODE16. * elfxx-x86.h (elf_x86_obj_tdata): Add has_code16. (elf_x86_has_code16): New. binutils/ PR ld/27905 * readelf.c (decode_x86_feature_2): Support GNU_PROPERTY_X86_FEATURE_2_CODE16. gas/ PR ld/27905 * config/tc-i386.c (set_code_flag): Update x86_feature_2_used with GNU_PROPERTY_X86_FEATURE_2_CODE16 for .code16 in ELF object. (set_16bit_gcc_code_flag): Likewise. (x86_cleanup): Always generate the GNU property note if x86_feature_2_used isn't 0. * testsuite/gas/i386/code16-2.d: New file. * testsuite/gas/i386/code16-2.s: Likewise. * testsuite/gas/i386/x86-64-code16-2.d: Likewise. * testsuite/gas/i386/i386.exp: Run code16-2 and x86-64-code16-2. include/ PR ld/27905 * elf/common.h (GNU_PROPERTY_X86_FEATURE_2_CODE16): New. ld/ PR ld/27905 * testsuite/ld-i386/code16.d: New file. * testsuite/ld-i386/code16.t: Likewise. * testsuite/ld-x86-64/code16.d: Likewise. * testsuite/ld-x86-64/code16.t: Likewise. * testsuite/ld-i386/i386.exp: Run code16. * testsuite/ld-x86-64/x86-64.exp: Likewise.
2021-05-26RISC-V: Allow to link the objects with unknown prefixed extensions.Nelson Chu1-0/+8
Since the policies of GNU and llvm toolchain are different for now, current binutils mainline cannot accept any draft extensions, including rvv, zfh, .... The Clang/LLVM allows these draft stuff on mainline, but the GNU ld might be used with them, so this causes the link time problems. The patch allows ld to link the objects with unknown prefixed extensions, which are probably generated by LLVM or customized toolchains. bfd/ * elfxx-riscv.h (check_unknown_prefixed_ext): New bool. * elfxx-riscv.c (riscv_parse_prefixed_ext): Do not check the prefixed extension name if check_unknown_prefixed_ext is false. * elfnn-riscv.c (riscv_merge_arch_attr_info): Set check_unknown_prefixed_ext to false for linker. gas/ * config/tc-riscv.c (riscv_set_arch): Set check_unknown_prefixed_ext to true for assembler.
2021-05-25Add range checks to local array accesses in elf32-arm.c.Nick Clifton1-0/+14
bfd * elf32-arn.c (struct elf_arm_obj_tdata): Add num_entries field. (elf32_arm_num_entries): New macro. (elf32_arm_allocate_local_sym_info): Initialise the new field. Allocate arrays individually so that buffer overruns can be detected by memory checkers. (elf32_arm_create_local_iplt): Check num_entries. (elf32_arm_get_plt_info): Likewise. (elf32_arm_final_link_relocate): Likewise. (elf32_arm_check_relocs): Likewise. (elf32_arm_size_dynamic_sections): Likewise. (elf32_arm_output_arch_local_syms): Likewise.
2021-05-25Fix formatting in elf32-arm.cNick Clifton1-0/+4
2021-05-25asan: _bfd_elf_parse_attributes heap buffer overflowAlan Modra1-0/+12
I exposed a problem with the change in commit 574ec1084d to the outer loop of _bfd_elf_parse_attributes. "p_end - p >= 4" is better than "p < p_end - 4" as far as pointer UB is concerned if the size of the attritbute section is say, 3 bytes. However you do need to ensure p never exceeds p_end, and that length remaining is kept consistent with the pointer. * elf-attrs.c (elf_attr_strdup): New function. (_bfd_elf_attr_strdup): Use it here. (elf_add_obj_attr_string): New function, extracted from.. (bfd_elf_add_obj_attr_string): ..here. (elf_add_obj_attr_int_string): New function, extracted from.. (bfd_elf_add_obj_attr_int_string): ..here. (_bfd_elf_parse_attributes): Don't allocate an extra byte for a string terminator. Instead ensure parsing doesn't go past end of sub-section. Use size_t variables for lengths.