[PATCH] ld: Fix several 32-bit SPARC plugin tests

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] ld: Fix several 32-bit SPARC plugin tests

Rainer Orth-2
Several ld plugin tests currently FAIL on 32-bit Solaris/SPARC:

FAIL: load plugin with source
FAIL: plugin claimfile lost symbol with source
FAIL: plugin claimfile replace symbol with source
FAIL: plugin claimfile resolve symbol with source
FAIL: plugin claimfile replace file with source
FAIL: plugin set symbol visibility with source
FAIL: plugin ignore lib with source
FAIL: plugin claimfile replace lib with source
FAIL: plugin 2 with source lib
FAIL: load plugin 2 with source
FAIL: load plugin 2 with source and -r
FAIL: plugin 3 with source lib
FAIL: load plugin 3 with source
FAIL: load plugin 3 with source and -r
FAIL: PR ld/20070

all of them in the same way:

./ld-new: BFD (GNU Binutils) 2.34.50.20200328 internal error, aborting at /vol/src/gnu/binutils/hg/master/git/bfd/elf32-sparc.c:154 in sparc_final_write_processing

This happens when bfd_get_mach returns 0 when abfd refers to a source
file:

$11 = {
  filename = 0x28c358 "/vol/src/gnu/binutils/hg/master/local/ld/testsuite/ld-plugin/func.c (symbol from plugin)", xvec = 0x24ed6c <sparc_elf32_sol2_vec>,
[...]

While I could find no specfication what abfd's are allowed/expected in
*_final_write_processing, I could find no other target that behaved the
same.  And indeed just removing the abort fixes the failures.  64-bit
SPARC is not affected because it doesn't have a specific implementation
of elf_backend_final_write_processing.

Tested on sparc-sun-solaris2.11.

Ok for master?

        Rainer

--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2020-04-06  Rainer Orth  <[hidden email]>

        * elf32-sparc.c (sparc_final_write_processing) <default>: Don't
        abort.

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ld: Fix several 32-bit SPARC plugin tests

Rainer Orth-2
This time with the actual patch.

        Rainer


2020-04-06  Rainer Orth  <[hidden email]>

        * elf32-sparc.c (sparc_final_write_processing) <default>: Don't
        abort.


diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -151,7 +151,6 @@ sparc_final_write_processing (bfd *abfd)
       elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA;
       break;
     default :
-      abort ();
       break;
     }
 }
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ld: Fix several 32-bit SPARC plugin tests

Sourceware - binutils list mailing list
Hi Rainer,

My guess as to the reason for the abort() was that the writer wanted to
catch unhandled sparc machine values.  So please could you try changing
the patch to this:

diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 65c81ecccf..aba81fae1a 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -150,6 +150,8 @@ sparc_final_write_processing (bfd *abfd)
     case bfd_mach_sparc_sparclite_le :
       elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA;
       break;
+    case 0: /* A non-sparc architecture - ignore.  */
+      break;
     default :
       abort ();
       break;

Or, if like me you do not like calls to abort() inside a library,
then how about this:

diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 65c81ecccf..e6c873ddf1 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -150,8 +150,11 @@ sparc_final_write_processing (bfd *abfd)
     case bfd_mach_sparc_sparclite_le :
       elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA;
       break;
+    case 0: /* A non-sparc architecture - ignore.  */
+      break;
     default :
-      abort ();
+      _bfd_error_handler (_("%pB: unhandled spac machine value '%lu' detected during write processing"),
+                         abfd, (long) bfd_get_mach (abfd));
       break;
     }
 }

Either of these is pre-approved for committal if they work for you.

Cheers
  Nick

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ld: Fix several 32-bit SPARC plugin tests

Rainer Orth-2
Hi Nick,

> My guess as to the reason for the abort() was that the writer wanted to
> catch unhandled sparc machine values.  So please could you try changing
> the patch to this:
>
> diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
> index 65c81ecccf..aba81fae1a 100644
> --- a/bfd/elf32-sparc.c
> +++ b/bfd/elf32-sparc.c
> @@ -150,6 +150,8 @@ sparc_final_write_processing (bfd *abfd)
>      case bfd_mach_sparc_sparclite_le :
>        elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA;
>        break;
> +    case 0: /* A non-sparc architecture - ignore.  */
> +      break;
>      default :
>        abort ();
>        break;
>
> Or, if like me you do not like calls to abort() inside a library,
> then how about this:
>
> diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
> index 65c81ecccf..e6c873ddf1 100644
> --- a/bfd/elf32-sparc.c
> +++ b/bfd/elf32-sparc.c
> @@ -150,8 +150,11 @@ sparc_final_write_processing (bfd *abfd)
>      case bfd_mach_sparc_sparclite_le :
>        elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA;
>        break;
> +    case 0: /* A non-sparc architecture - ignore.  */
> +      break;
>      default :
> -      abort ();
> +      _bfd_error_handler (_("%pB: unhandled spac machine value '%lu' detected during write processing"),
> +                         abfd, (long) bfd_get_mach (abfd));
>        break;
>      }
>  }
>
> Either of these is pre-approved for committal if they work for you.
I strongly prefer the second variant, especially because I had to
recompile with -g3 -O0 to learn the problematic mach value in the first
place.

Here's what I've committed after testing.  Apart from a slight
reindentation and typo fixing, I've removed the blanks before the colons
in several case statements.  While I known you're not supposed to mix
code and whitespace/formatting changes in one commit, they're separate
enough here not do cause confusion.

Thanks.
        Rainer

--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2020-04-07  Rainer Orth  <[hidden email]>
            Nick Clifton  <[hidden email]>

        * elf32-sparc.c (sparc_final_write_processing): Fix whitespace.
        <0>: Ignore.
        <default>: Error rather than abort.


# HG changeset patch
# Parent  5f851b3a471abec37e25d52a8ac0d62be94a5447
ld: Fix several 32-bit SPARC plugin tests

diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -121,37 +121,41 @@ sparc_final_write_processing (bfd *abfd)
 {
   switch (bfd_get_mach (abfd))
     {
-    case bfd_mach_sparc :
-    case bfd_mach_sparc_sparclet :
-    case bfd_mach_sparc_sparclite :
+    case bfd_mach_sparc:
+    case bfd_mach_sparc_sparclet:
+    case bfd_mach_sparc_sparclite:
       break; /* nothing to do */
-    case bfd_mach_sparc_v8plus :
+    case bfd_mach_sparc_v8plus:
       elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
       elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
       elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS;
       break;
-    case bfd_mach_sparc_v8plusa :
+    case bfd_mach_sparc_v8plusa:
       elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
       elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
       elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS | EF_SPARC_SUN_US1;
       break;
-    case bfd_mach_sparc_v8plusb :
-    case bfd_mach_sparc_v8plusc :
-    case bfd_mach_sparc_v8plusd :
-    case bfd_mach_sparc_v8pluse :
-    case bfd_mach_sparc_v8plusv :
-    case bfd_mach_sparc_v8plusm :
-    case bfd_mach_sparc_v8plusm8 :
+    case bfd_mach_sparc_v8plusb:
+    case bfd_mach_sparc_v8plusc:
+    case bfd_mach_sparc_v8plusd:
+    case bfd_mach_sparc_v8pluse:
+    case bfd_mach_sparc_v8plusv:
+    case bfd_mach_sparc_v8plusm:
+    case bfd_mach_sparc_v8plusm8:
       elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
       elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
       elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS | EF_SPARC_SUN_US1
        | EF_SPARC_SUN_US3;
       break;
-    case bfd_mach_sparc_sparclite_le :
+    case bfd_mach_sparc_sparclite_le:
       elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA;
       break;
-    default :
-      abort ();
+    case 0: /* A non-sparc architecture - ignore.  */
+      break;
+    default:
+      _bfd_error_handler
+ (_("%pB: unhandled sparc machine value '%lu' detected during write processing"),
+ abfd, (long) bfd_get_mach (abfd));
       break;
     }
 }