From 1781a9d0f3d0319abeeae73b1f1f78fbf3778739 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 15 Feb 2021 09:48:50 +1030 Subject: nds32_elf_get_relocated_section_contents nds32_elf_get_relocated_section_contents uses nds32_get_section_contents to read sections contents, but nds32_get_section_contents has the wrong behaviour as it calls bfd_malloc_and_get_section. That function always mallocs its output buffer, whereas get_relocated_section_contents must support an already allocated buffer. bfd/ * elf32-nds32.c (nds32_get_section_contents): Replace bfd_malloc_and_get_section with bfd_get_full_section_contents. (nds32_elf_relax_delete_blanks): Init contents. (nds32_elf_relax_section, nds32_relax_fp_as_gp): Likewise. binutils/ * testsuite/binutils-all/compress.exp: Remove nds32 xfails. * testsuite/binutils-all/objdump.exp: Likewise. --- bfd/ChangeLog | 7 +++++++ bfd/elf32-nds32.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 7ff7eb0..cd018fe 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,12 @@ 2021-02-15 Alan Modra + * elf32-nds32.c (nds32_get_section_contents): Replace + bfd_malloc_and_get_section with bfd_get_full_section_contents. + (nds32_elf_relax_delete_blanks): Init contents. + (nds32_elf_relax_section, nds32_relax_fp_as_gp): Likewise. + +2021-02-15 Alan Modra + * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Use bfd_get_full_section_contents. diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 59ed470..01d0702 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -9201,6 +9201,7 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec, if (!(sect->flags & SEC_RELOC)) continue; + contents = NULL; nds32_get_section_contents (abfd, sect, &contents, TRUE); for (irel = internal_relocs; irel < irelend; irel++) @@ -9457,7 +9458,7 @@ nds32_get_section_contents (bfd *abfd, asection *sec, *contents_p = elf_section_data (sec)->this_hdr.contents; else { - if (!bfd_malloc_and_get_section (abfd, sec, contents_p)) + if (!bfd_get_full_section_contents (abfd, sec, contents_p)) return FALSE; if (cache) elf_section_data (sec)->this_hdr.contents = *contents_p; @@ -12157,6 +12158,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec, load_store_relax = table->load_store_relax; /* Get symbol table and section content. */ + contents = NULL; if (!nds32_get_section_contents (abfd, sec, &contents, TRUE) || !nds32_get_local_syms (abfd, sec, &isymbuf)) goto error_return; @@ -12814,6 +12816,7 @@ nds32_relax_fp_as_gp (struct bfd_link_info *link_info, symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + contents = NULL; if (!nds32_get_section_contents (abfd, sec, &contents, TRUE) || !nds32_get_local_syms (abfd, sec, &isymbuf)) return FALSE; -- cgit v1.1