]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
nds32_elf_get_relocated_section_contents
authorAlan Modra <amodra@gmail.com>
Sun, 14 Feb 2021 23:18:50 +0000 (09:48 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 15 Feb 2021 03:04:08 +0000 (13:34 +1030)
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
bfd/elf32-nds32.c
binutils/ChangeLog
binutils/testsuite/binutils-all/compress.exp
binutils/testsuite/binutils-all/objdump.exp

index 7ff7eb0f26cd212f6e8bd006e89ec8569c41b001..cd018fec3b7d1fc603ec89b115d7815541f95685 100644 (file)
@@ -1,3 +1,10 @@
+2021-02-15  Alan Modra  <amodra@gmail.com>
+
+       * 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  <amodra@gmail.com>
 
        * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Use
index 59ed470648252b8b56d3c6995722ca55ecb01606..01d0702255a84f8aefcd099795f53d65317651e3 100644 (file)
@@ -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;
index 12ff93dc53abe3060dbc70289b414e1de4bbb36c..a7a9cae080e17a20d1b9c092d234b42be7ca45db 100644 (file)
@@ -1,3 +1,8 @@
+2021-02-15  Alan Modra  <amodra@gmail.com>
+
+       * testsuite/binutils-all/compress.exp: Remove nds32 xfails.
+       * testsuite/binutils-all/objdump.exp: Likewise.
+
 2021-02-14  Alan Modra  <amodra@gmail.com>
 
        * objdump.c (slurp_symtab): Don't add an extra entry for NULL
index 5801f6b7c64a1fb7c8ffd196c808b6d9d9ab328d..98daf67155222500b7358793a6b4aee2fcf02277 100644 (file)
@@ -162,7 +162,6 @@ if ![string match "" $got] then {
     }
 }
 
-setup_xfail "nds32*-*-*"
 set testname "objdump compress debug sections"
 set got [remote_exec host "$OBJDUMP -W ${compressedfile}.o" "" "/dev/null" "objdump.out"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
@@ -175,7 +174,6 @@ if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
     pass "$testname"
 }
 
-setup_xfail "nds32*-*-*"
 set testname "objdump compress debug sections 3"
 set got [remote_exec host "$OBJDUMP -W ${compressedfile3}.o" "" "/dev/null" "objdump.out"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
@@ -546,7 +544,6 @@ if ![string match "" $got] then {
     }
 }
 
-setup_xfail "nds32*-*-*"
 set testname "objcopy compress debug sections in archive with zlib-gabi"
 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${copyfile}gabi.a ${compressedcopyfile}gabi.a"]
 if ![string match "" $got] then {
@@ -567,7 +564,6 @@ if ![string match "" $got] then {
     }
 }
 
-setup_xfail "nds32*-*-*"
 set testname "objdump compress debug sections 3 with zlib-gabi"
 set got [remote_exec host "$OBJDUMP -W ${compressedfile3}gabi.o" "" "/dev/null" "objdump.out"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
index 6f95d4039f55a6d3e6c8a31c16831ce0ba41df92..9a0720f95aa879f06c5482cd8fe3b7a37ce575cf 100644 (file)
@@ -503,7 +503,7 @@ if { ![is_elf_format] } then {
        send_log "\n"
     }
 
-    setup_xfail "msp430-*-*" "nds32*-*-*"
+    setup_xfail "msp430-*-*"
     if { [regexp_diff objdump.out $srcdir/$subdir/dw2-ranges.W] } then {
        fail "objdump -W for debug_ranges"
     } else {