Fix CRIS bug exposed by "MIPS/BFD: Don't make debug section relocs dynamic"

Tristan Gingold gingold@adacore.com
Fri Dec 2 08:12:00 GMT 2011


On Dec 1, 2011, at 11:46 AM, Mikael Pettersson wrote:

> Hans-Peter Nilsson writes:
>>> From: "Maciej W. Rozycki" <macro@codesourcery.com>
>>> Date: Mon, 31 Oct 2011 13:21:52 +0100
>> 
>>> 2011-10-31  Maciej W. Rozycki  <macro@codesourcery.com>
>>> 
>>>        PR ld/10144
>>>        * lib/ld-lib.exp (run_ld_link_tests): Handle sources from other
>>>        directories.
>>>        (run_ld_link_exec_tests): Likewise.
>>>        (run_cc_link_tests): Likewise.
>>>        * ld-elf/comm-data1.sd: New test.
>>>        * ld-elf/comm-data1.s: Source for the new test.
>>>        * ld-elf/comm-data2.sd: New test.
>>>        * ld-elf/comm-data2.rd: Likewise.
>>>        * ld-elf/comm-data2.xd: Likewise.
>>>        * ld-elf/comm-data2.s: Source for the new tests.
>>>        * ld-elf/comm-data.exp: Run the new tests.
>>>        * ld-mips-elf/comm-data.exp: Likewise.
>> 
>> This new test caused the following failure to appear for
>> cris-axis-linux-gnu:
>> 
>> Running /tmp/hpautotest-binutils/bsrc/src/ld/testsuite/ld-elf/comm-data.exp ...
>> FAIL: Common symbol override test
>> 
>> ...but it turned out to be a target bug, so...thanks, I guess. :)
>> 
>> I see this test fails for m68k-linux too, if someone feels pity
>> (no listed maintainer).
>> 
>> No regressions tested cris-elf cris-linux.
>> Can I put this on the 2.22 branch too?

Yes.

>> 
>> bfd:
>> 	* elf32-cris.c (cris_elf_check_relocs) <plt accounting for
>> 	R_CRIS_8, R_CRIS_16, and R_CRIS_32>: Move early break for
>> 	non-SEC_ALLOC sections before GOT and PLT accounting.
>> 
>> Index: elf32-cris.c
>> ===================================================================
>> RCS file: /cvs/src/src/bfd/elf32-cris.c,v
>> retrieving revision 1.117
>> diff -p -u -r1.117 elf32-cris.c
>> --- elf32-cris.c	19 Oct 2011 07:17:13 -0000	1.117
>> +++ elf32-cris.c	1 Dec 2011 02:47:49 -0000
>> @@ -3583,6 +3583,12 @@ cris_elf_check_relocs (bfd *abfd,
>> 		 sec,
>> 		 cris_elf_howto_table[r_type].name);
>> 	    }
>> +
>> +	  /* We don't need to handle relocs into sections not going into
>> +	     the "real" output.  */
>> +	  if ((sec->flags & SEC_ALLOC) == 0)
>> +	    break;
>> +
>> 	  if (h != NULL)
>> 	    {
>> 	      h->non_got_ref = 1;
>> @@ -3612,11 +3618,6 @@ cris_elf_check_relocs (bfd *abfd,
>> 	  if (! info->shared)
>> 	    break;
>> 
>> -	  /* We don't need to handle relocs into sections not going into
>> -	     the "real" output.  */
>> -	  if ((sec->flags & SEC_ALLOC) == 0)
>> -	    break;
>> -
>> 	  /* We may need to create a reloc section in the dynobj and made room
>> 	     for this reloc.  */
>> 	  if (sreloc == NULL)
>> 
>> brgds, H-P
> 
> I've implemented a similar change for elf32-m68k.c which fixes
> ld-elf/comm-data.exp for m68k-linux, with no testsuite regressions
> on head or the 2.22 release.
> 
> As for m68k maintainers, I looked around in recent ChangeLogs,
> and both Andreas Schwab and Maxim Kuvyrkov seem likely candidates
> so I've added them to the Cc: list.
> 
> Ok for head and 2.22 branch?
> 
> (If approved I'll need for someone else to do the commits.)
> 
> /Mikael
> 
> 
> bfd/
> 
> 2011-12-01  Mikael Pettersson  <mikpe@it.uu.se>
> 
> 	* elf32-m68k.c (elf_m68k_check_relocs) <R_68K_8, R68K_16, R_68K_32>: For
> 	non-SEC_ALLOC sections break before GOT and PLT accounting.
> 
> --- binutils-2.22.51/bfd/elf32-m68k.c.~1~	2011-10-19 09:17:14.000000000 +0200
> +++ binutils-2.22.51/bfd/elf32-m68k.c	2011-12-01 10:41:31.000000000 +0100
> @@ -2816,6 +2816,11 @@ elf_m68k_check_relocs (abfd, info, sec, 
> 	case R_68K_8:
> 	case R_68K_16:
> 	case R_68K_32:
> +	  /* We don't need to handle relocs into sections not going into
> +	     the "real" output.  */
> +	  if ((sec->flags & SEC_ALLOC) == 0)
> +	      break;
> +
> 	  if (h != NULL)
> 	    {
> 	      /* Make sure a plt entry is created for this symbol if it
> @@ -2829,8 +2834,7 @@ elf_m68k_check_relocs (abfd, info, sec, 
> 
> 	  /* If we are creating a shared library, we need to copy the
> 	     reloc into the shared library.  */
> -	  if (info->shared
> -	      && (sec->flags & SEC_ALLOC) != 0)
> +	  if (info->shared)
> 	    {
> 	      /* When creating a shared object, we must copy these
> 		 reloc types into the output file.  We create a reloc



More information about the Binutils mailing list