public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ld: Fix several 32-bit SPARC plugin tests
@ 2020-04-06 11:31 Rainer Orth
  2020-04-06 13:27 ` Rainer Orth
  0 siblings, 1 reply; 4+ messages in thread
From: Rainer Orth @ 2020-04-06 11:31 UTC (permalink / raw)
  To: binutils

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  <ro@CeBiTec.Uni-Bielefeld.DE>

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ld: Fix several 32-bit SPARC plugin tests
  2020-04-06 11:31 [PATCH] ld: Fix several 32-bit SPARC plugin tests Rainer Orth
@ 2020-04-06 13:27 ` Rainer Orth
  2020-04-06 14:57   ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Rainer Orth @ 2020-04-06 13:27 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 174 bytes --]

This time with the actual patch.

	Rainer


2020-04-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: e32s.patch --]
[-- Type: text/x-patch, Size: 287 bytes --]

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;
     }
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ld: Fix several 32-bit SPARC plugin tests
  2020-04-06 13:27 ` Rainer Orth
@ 2020-04-06 14:57   ` Nick Clifton
  2020-04-07 14:58     ` Rainer Orth
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2020-04-06 14:57 UTC (permalink / raw)
  To: Rainer Orth, binutils

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ld: Fix several 32-bit SPARC plugin tests
  2020-04-06 14:57   ` Nick Clifton
@ 2020-04-07 14:58     ` Rainer Orth
  0 siblings, 0 replies; 4+ messages in thread
From: Rainer Orth @ 2020-04-07 14:58 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 2263 bytes --]

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  <ro@CeBiTec.Uni-Bielefeld.DE>
	    Nick Clifton  <nickc@redhat.com>

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ld-sol2-sparc-plugin-abort.patch --]
[-- Type: text/x-patch, Size: 2249 bytes --]

# 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;
     }
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-07 14:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 11:31 [PATCH] ld: Fix several 32-bit SPARC plugin tests Rainer Orth
2020-04-06 13:27 ` Rainer Orth
2020-04-06 14:57   ` Nick Clifton
2020-04-07 14:58     ` Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).