public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RFC: Patch to fix MIPS -mno-shared with multi-got...
@ 2005-03-03 21:05 David Daney
  2005-03-03 21:48 ` Richard Sandiford
  0 siblings, 1 reply; 18+ messages in thread
From: David Daney @ 2005-03-03 21:05 UTC (permalink / raw)
  To: binutils

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

This patch added by Ian Lance Taylor:

http://sourceware.org/ml/binutils/2004-12/msg00094.html

Added a new option for the MIPS assembler -mno-shared which as he stated 
in the message referenced above:


-------------8<-----------------
This patch adds a new option to the MIPS assembler: -mno-shared.
Normally the .cpload pseudo-op generates code which looks like this:

	lui	$gp,%hi(_gp_disp)
	addiu	$gp,$gp,%lo(_gp_disp)
	addu	$gp,$gp,.cpload argument

With -mno-shared, the .cpload pseudo-op will generate code that looks
like this:

	lui	$gp,%hi(_gp)
	addiu	$gp,$gp,%lo(_gp)
------------8<-------------------


When doing a multi-got link the "_gp_disp" virtual symbol refers to one 
of the several GOTs in the output.

The problem is that "_gp" points to the primary GOT but the relocations 
need to be done against which ever GOT is used by the module being linked

The attached patch adds special handling for "_gp" so that it is treated 
in a manner similar to "_gp_disp"

It allows my large (multi-got) application to be compiled with 
-Wa,-mno-shared which is good.

One thing I am not sure about is if there is existing code somewhere 
that that will break with the patch.

Possible problems are code that use relocations other than R_MIPS_HI16, 
R_MIPS_LO16, R_MIPS16_HI16 and R_MIPS16_LO16 against "_gp" as they would 
now be illegal.  Also multi-got code that for some reason needed to 
refer to the "real _gp" instead of the GOT corresponding to the module.

Thoughts?

If it is thought to be a good patch, I could probably create some test 
cases for it.

David Daney


[-- Attachment #2: no-shared-multi-got.diff --]
[-- Type: text/plain, Size: 2669 bytes --]

--- /home/daney/binutils-050218/bfd/elfxx-mips.c	2005-02-15 20:45:23.000000000 -0800
+++ bfd/elfxx-mips.c	2005-03-03 12:19:30.000000000 -0800
@@ -3039,6 +3039,8 @@ mips_elf_calculate_relocation (bfd *abfd
   bfd_boolean local_p, was_local_p;
   /* TRUE if the symbol referred to by this relocation is "_gp_disp".  */
   bfd_boolean gp_disp_p = FALSE;
+  /* TRUE if the symbol referred to by this relocation is "_gp".  */
+  bfd_boolean gp_p = FALSE;
   Elf_Internal_Shdr *symtab_hdr;
   size_t extsymoff;
   unsigned long r_symndx;
@@ -3135,6 +3137,20 @@ mips_elf_calculate_relocation (bfd *abfd
 
 	  gp_disp_p = TRUE;
 	}
+      /* See if this is the special _gp symbol.  Note that such a
+	 symbol must always be a global symbol.  */
+      else if (strcmp (*namep, "_gp") == 0
+	  && ! NEWABI_P (input_bfd))
+	{
+	  /* Relocations against _gp are permitted only with
+	     R_MIPS_HI16 and R_MIPS_LO16 relocations.  */
+	  if (r_type != R_MIPS_HI16 && r_type != R_MIPS_LO16
+	      && r_type != R_MIPS16_HI16 && r_type != R_MIPS16_LO16)
+	    return bfd_reloc_notsupported;
+
+	  gp_p = TRUE;
+	}
+
       /* If this symbol is defined, calculate its address.  Note that
 	 _gp_disp is a magic symbol, always implicitly defined by the
 	 linker, so it's inappropriate to check to see whether or not
@@ -3415,12 +3431,7 @@ mips_elf_calculate_relocation (bfd *abfd
 
     case R_MIPS_HI16:
     case R_MIPS16_HI16:
-      if (!gp_disp_p)
-	{
-	  value = mips_elf_high (addend + symbol);
-	  value &= howto->dst_mask;
-	}
-      else
+      if (gp_disp_p)
 	{
 	  /* For MIPS16 ABI code we generate this sequence
 	        0: li      $v0,%hi(_gp_disp)
@@ -3437,13 +3448,21 @@ mips_elf_calculate_relocation (bfd *abfd
 	    value = mips_elf_high (addend + gp - p);
 	  overflowed_p = mips_elf_overflow_p (value, 16);
 	}
+      else if (gp_p)
+        {
+	  value = mips_elf_high (addend + gp);
+	  overflowed_p = mips_elf_overflow_p (value, 16);
+        }
+      else
+	{
+	  value = mips_elf_high (addend + symbol);
+	  value &= howto->dst_mask;
+	}
       break;
 
     case R_MIPS_LO16:
     case R_MIPS16_LO16:
-      if (!gp_disp_p)
-	value = (symbol + addend) & howto->dst_mask;
-      else
+      if (gp_disp_p)
 	{
 	  /* See the comment for R_MIPS16_HI16 above for the reason
 	     for this conditional.  */
@@ -3468,6 +3487,12 @@ mips_elf_calculate_relocation (bfd *abfd
 	     Therefore, we consider this a bug in the MIPS ABI, and do
 	     not check for overflow here.  */
 	}
+      else if (gp_p)
+        {
+          value = addend + gp;
+        }
+      else
+	value = (symbol + addend) & howto->dst_mask;
       break;
 
     case R_MIPS_LITERAL:

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 21:05 RFC: Patch to fix MIPS -mno-shared with multi-got David Daney
@ 2005-03-03 21:48 ` Richard Sandiford
  2005-03-03 22:34   ` David Daney
  0 siblings, 1 reply; 18+ messages in thread
From: Richard Sandiford @ 2005-03-03 21:48 UTC (permalink / raw)
  To: David Daney; +Cc: binutils

David Daney <ddaney@avtrex.com> writes:
> Possible problems are code that use relocations other than R_MIPS_HI16,
> R_MIPS_LO16, R_MIPS16_HI16 and R_MIPS16_LO16 against "_gp" as they would
> now be illegal.

Couldn't you get around that by:

> @@ -3135,6 +3137,20 @@ mips_elf_calculate_relocation (bfd *abfd
>  
>  	  gp_disp_p = TRUE;
>  	}
> +      /* See if this is the special _gp symbol.  Note that such a
> +	 symbol must always be a global symbol.  */
> +      else if (strcmp (*namep, "_gp") == 0
> +	  && ! NEWABI_P (input_bfd))
> +	{
> +	  /* Relocations against _gp are permitted only with
> +	     R_MIPS_HI16 and R_MIPS_LO16 relocations.  */
> +	  if (r_type != R_MIPS_HI16 && r_type != R_MIPS_LO16
> +	      && r_type != R_MIPS16_HI16 && r_type != R_MIPS16_LO16)
> +	    return bfd_reloc_notsupported;
> +
> +	  gp_p = TRUE;
> +	}

setting "symbol" to the local _gp value here?  There would then be
no need for the gp_p variable.

(Not tested of course.  Just wondering if you'd tried that and rejected
it for some reason.)

WRT possible breakge to things expecting the real "_gp": I agree that
might be a problem.  One possibility would be to define a new symbol,
something like __gnu_local_gp, and make -mno-shared use that instead
of plain _gp.  -mno-shared is a new option, so there's no backwards
compatiblity problem.

Richard

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 21:48 ` Richard Sandiford
@ 2005-03-03 22:34   ` David Daney
  2005-03-03 22:49     ` Thiemo Seufer
  2005-03-04  4:31     ` RFC: " Ian Lance Taylor
  0 siblings, 2 replies; 18+ messages in thread
From: David Daney @ 2005-03-03 22:34 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils

Richard Sandiford wrote:
> David Daney <ddaney@avtrex.com> writes:
> 
>>Possible problems are code that use relocations other than R_MIPS_HI16,
>>R_MIPS_LO16, R_MIPS16_HI16 and R_MIPS16_LO16 against "_gp" as they would
>>now be illegal.
> 
> 
> Couldn't you get around that by:
> 
> 
>>@@ -3135,6 +3137,20 @@ mips_elf_calculate_relocation (bfd *abfd
>> 
>> 	  gp_disp_p = TRUE;
>> 	}
>>+      /* See if this is the special _gp symbol.  Note that such a
>>+	 symbol must always be a global symbol.  */
>>+      else if (strcmp (*namep, "_gp") == 0
>>+	  && ! NEWABI_P (input_bfd))
>>+	{
>>+	  /* Relocations against _gp are permitted only with
>>+	     R_MIPS_HI16 and R_MIPS_LO16 relocations.  */
>>+	  if (r_type != R_MIPS_HI16 && r_type != R_MIPS_LO16
>>+	      && r_type != R_MIPS16_HI16 && r_type != R_MIPS16_LO16)
>>+	    return bfd_reloc_notsupported;
>>+
>>+	  gp_p = TRUE;
>>+	}
> 
> 
> setting "symbol" to the local _gp value here?  There would then be
> no need for the gp_p variable.
> 

That is a good idea in theory.  But the _gp value is calculated later, 
so in practice I would remove the checks against r_type and set the gp_p 
flag here.  Then right before the big switch on r_type where the 
relocations are calculated I would set "symbol = gp".


One thing I was wondering about is if a R_MIPS_HI16 or R_MIPS_LO16 
relocation overflows for '_gp_disp' and error is emmited, but for other 
symbols overflow is not checked and the value is just masked off to the 
appropiate number of bits (16).  Why different treatment for the 
_gp_disp case?


> 
> WRT possible breakge to things expecting the real "_gp": I agree that
> might be a problem.  One possibility would be to define a new symbol,
> something like __gnu_local_gp, and make -mno-shared use that instead
> of plain _gp.  -mno-shared is a new option, so there's no backwards
> compatiblity problem.

OK, I kind of like this idea.  But I am not an ABI authority.  I am 
assuming the the meaning of "_gp_disp" is defined somewhere in the ABI 
specs.  I know _gp is specified.  Does anybody have objections to adding 
the new magic __gnu_local_gp symbol?

I am working on a new patch...

David Daney.

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 22:34   ` David Daney
@ 2005-03-03 22:49     ` Thiemo Seufer
  2005-03-03 23:15       ` David Daney
  2005-03-03 23:57       ` David Daney
  2005-03-04  4:31     ` RFC: " Ian Lance Taylor
  1 sibling, 2 replies; 18+ messages in thread
From: Thiemo Seufer @ 2005-03-03 22:49 UTC (permalink / raw)
  To: David Daney; +Cc: binutils

David Daney wrote:
[snip]
> >WRT possible breakge to things expecting the real "_gp": I agree that
> >might be a problem.  One possibility would be to define a new symbol,
> >something like __gnu_local_gp, and make -mno-shared use that instead
> >of plain _gp.  -mno-shared is a new option, so there's no backwards
> >compatiblity problem.
> 
> OK, I kind of like this idea.  But I am not an ABI authority.  I am 
> assuming the the meaning of "_gp_disp" is defined somewhere in the ABI 
> specs.  I know _gp is specified.  Does anybody have objections to adding 
> the new magic __gnu_local_gp symbol?

I have the general (and still vague) idea to have multigot-capable object
files, with _gp _gp.1 .. _gp.n and _gp_disp _gp_disp.1 .. _gp_disp.n
depending on the GOT in use, and with the single got case staying binary
compatible. I think this would cover your case as well, but it's of
course much more work.


Thiemo

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 22:49     ` Thiemo Seufer
@ 2005-03-03 23:15       ` David Daney
  2005-03-03 23:27         ` Thiemo Seufer
  2005-03-03 23:57       ` David Daney
  1 sibling, 1 reply; 18+ messages in thread
From: David Daney @ 2005-03-03 23:15 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: binutils

Thiemo Seufer wrote:
> David Daney wrote:
> [snip]
> 
>>>WRT possible breakge to things expecting the real "_gp": I agree that
>>>might be a problem.  One possibility would be to define a new symbol,
>>>something like __gnu_local_gp, and make -mno-shared use that instead
>>>of plain _gp.  -mno-shared is a new option, so there's no backwards
>>>compatiblity problem.
>>
>>OK, I kind of like this idea.  But I am not an ABI authority.  I am 
>>assuming the the meaning of "_gp_disp" is defined somewhere in the ABI 
>>specs.  I know _gp is specified.  Does anybody have objections to adding 
>>the new magic __gnu_local_gp symbol?
> 
> 
> I have the general (and still vague) idea to have multigot-capable object
> files, with _gp _gp.1 .. _gp.n and _gp_disp _gp_disp.1 .. _gp_disp.n
> depending on the GOT in use, and with the single got case staying binary
> compatible. I think this would cover your case as well, but it's of
> course much more work.
> 

I don't think that solves the problem we are talking about.

The main problem is that with -mno-shared you get object files with this:

     lui    $gp,%hi(_gp)
     addiu    $gp,$gp,%lo(_gp)

Where _gp refers to which ever GOT that the linker assignes to the module.

But it is possible to have C code like this:

extern int _gp;


int
foo()
{
   int *bar = &_gp;
/* Do something with the primary GOT */
}

In this case the existing semantics are clear.  It is the primary GOT.


My original patch changed the semantics of the above C program. 
Richard's suggestion to use __gnu_local_gp lets us have the desired 
semantics for .cpload with out changing those of the C program.

David Daney.


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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 23:15       ` David Daney
@ 2005-03-03 23:27         ` Thiemo Seufer
  2005-03-04  0:41           ` Daniel Jacobowitz
  0 siblings, 1 reply; 18+ messages in thread
From: Thiemo Seufer @ 2005-03-03 23:27 UTC (permalink / raw)
  To: David Daney; +Cc: binutils

David Daney wrote:
> Thiemo Seufer wrote:
> >David Daney wrote:
> >[snip]
> >
> >>>WRT possible breakge to things expecting the real "_gp": I agree that
> >>>might be a problem.  One possibility would be to define a new symbol,
> >>>something like __gnu_local_gp, and make -mno-shared use that instead
> >>>of plain _gp.  -mno-shared is a new option, so there's no backwards
> >>>compatiblity problem.
> >>
> >>OK, I kind of like this idea.  But I am not an ABI authority.  I am 
> >>assuming the the meaning of "_gp_disp" is defined somewhere in the ABI 
> >>specs.  I know _gp is specified.  Does anybody have objections to adding 
> >>the new magic __gnu_local_gp symbol?
> >
> >
> >I have the general (and still vague) idea to have multigot-capable object
> >files, with _gp _gp.1 .. _gp.n and _gp_disp _gp_disp.1 .. _gp_disp.n
> >depending on the GOT in use, and with the single got case staying binary
> >compatible. I think this would cover your case as well, but it's of
> >course much more work.
> >
> 
> I don't think that solves the problem we are talking about.
> 
> The main problem is that with -mno-shared you get object files with this:
> 
>     lui    $gp,%hi(_gp)
>     addiu    $gp,$gp,%lo(_gp)
> 
> Where _gp refers to which ever GOT that the linker assignes to the module.

With the proposed scheme it could be _gp.n, with a renumbering from the
intermediate object to the final module (and _gp for the primary GOT).

> But it is possible to have C code like this:
> 
> extern int _gp;
> 
> 
> int
> foo()
> {
>   int *bar = &_gp;
> /* Do something with the primary GOT */
> }
> 
> In this case the existing semantics are clear.  It is the primary GOT.

Whithout having looked it up, I doubt the ABI gives the program any
guarantee about the contents of the GOT.


Thiemo

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 22:49     ` Thiemo Seufer
  2005-03-03 23:15       ` David Daney
@ 2005-03-03 23:57       ` David Daney
  2005-03-04  0:43         ` Daniel Jacobowitz
  2005-03-04  9:36         ` Richard Sandiford
  1 sibling, 2 replies; 18+ messages in thread
From: David Daney @ 2005-03-03 23:57 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: binutils

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

Thiemo Seufer wrote:
> David Daney wrote:
> [snip]
> 
>>>WRT possible breakge to things expecting the real "_gp": I agree that
>>>might be a problem.  One possibility would be to define a new symbol,
>>>something like __gnu_local_gp, and make -mno-shared use that instead
>>>of plain _gp.  -mno-shared is a new option, so there's no backwards
>>>compatiblity problem.
>>
>>OK, I kind of like this idea.  But I am not an ABI authority.  I am 
>>assuming the the meaning of "_gp_disp" is defined somewhere in the ABI 
>>specs.  I know _gp is specified.  Does anybody have objections to adding 
>>the new magic __gnu_local_gp symbol?
> 
> 
> I have the general (and still vague) idea to have multigot-capable object
> files, with _gp _gp.1 .. _gp.n and _gp_disp _gp_disp.1 .. _gp_disp.n
> depending on the GOT in use, and with the single got case staying binary
> compatible. I think this would cover your case as well, but it's of
> course much more work.
> 
Yes, it makes my head hurt just to think about it.

In lieu of doing that I present the attached patch.

The main question being:  Use _gp or __gnu_local_gp ?

The pros of using _gp are that Thiemo's plan to magically rename _gp 
would be binary compatible.

The pros of using __gnu_local_gp are that existing code using _gp 
outside of .cpload would continue to work.

I am inclined to use _gp as it does not create a gnu specific ABI 
extension, but I am apprehensive about what will happen when I try to 
build glibc.

David Daney.

[-- Attachment #2: mno-shared-multi-got2.diff --]
[-- Type: text/plain, Size: 5108 bytes --]

Only in /home/daney/binutils_reference/binutils-050218/bfd/doc: bfd.info-1
Only in /home/daney/binutils_reference/binutils-050218/bfd/doc: bfd.info-2
diff -rcp --exclude='*.info' /home/daney/binutils_reference/binutils-050218/bfd/elfxx-mips.c binutils-050218/bfd/elfxx-mips.c
*** /home/daney/binutils_reference/binutils-050218/bfd/elfxx-mips.c	2005-02-15 20:45:23.000000000 -0800
--- binutils-050218/bfd/elfxx-mips.c	2005-03-03 14:41:04.000000000 -0800
*************** mips_elf_calculate_relocation (bfd *abfd
*** 3039,3044 ****
--- 3039,3046 ----
    bfd_boolean local_p, was_local_p;
    /* TRUE if the symbol referred to by this relocation is "_gp_disp".  */
    bfd_boolean gp_disp_p = FALSE;
+   /* TRUE if the symbol referred to by this relocation is "__gnu_local_gp".  */
+   bfd_boolean gnu_local_gp_p = FALSE;
    Elf_Internal_Shdr *symtab_hdr;
    size_t extsymoff;
    unsigned long r_symndx;
*************** mips_elf_calculate_relocation (bfd *abfd
*** 3135,3140 ****
--- 3137,3148 ----
  
  	  gp_disp_p = TRUE;
  	}
+       /* See if this is the special _gp symbol.  Note that such a
+ 	 symbol must always be a global symbol.  */
+       else if (strcmp (*namep, "__gnu_local_gp") == 0)
+ 	gnu_local_gp_p = TRUE;
+ 
+ 
        /* If this symbol is defined, calculate its address.  Note that
  	 _gp_disp is a magic symbol, always implicitly defined by the
  	 linker, so it's inappropriate to check to see whether or not
*************** mips_elf_calculate_relocation (bfd *abfd
*** 3336,3341 ****
--- 3344,3352 ----
        break;
      }
  
+   if (gnu_local_gp_p)
+     symbol = gp;
+   
    /* Figure out what kind of relocation is being performed.  */
    switch (r_type)
      {
Only in binutils-050218/bfd: elfxx-mips.c~
diff -rcp --exclude='*.info' /home/daney/binutils_reference/binutils-050218/gas/config/tc-mips.c binutils-050218/gas/config/tc-mips.c
*** /home/daney/binutils_reference/binutils-050218/gas/config/tc-mips.c	2005-02-17 05:46:04.000000000 -0800
--- binutils-050218/gas/config/tc-mips.c	2005-03-03 15:33:20.000000000 -0800
*************** macro_build_lui (expressionS *ep, int re
*** 3395,3407 ****
    else
      {
        assert (ep->X_op == O_symbol);
!       /* _gp_disp is a special case, used from s_cpload.  _gp is used
  	 if mips_no_shared.  */
        assert (mips_pic == NO_PIC
  	      || (! HAVE_NEWABI
  		  && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp_disp") == 0)
  	      || (! mips_in_shared
! 		  && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp") == 0));
        *r = BFD_RELOC_HI16_S;
      }
  
--- 3395,3407 ----
    else
      {
        assert (ep->X_op == O_symbol);
!       /* _gp_disp is a special case, used from s_cpload.  __gnu_local_gp is used
  	 if mips_no_shared.  */
        assert (mips_pic == NO_PIC
  	      || (! HAVE_NEWABI
  		  && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp_disp") == 0)
  	      || (! mips_in_shared
! 		  && strcmp (S_GET_NAME (ep->X_add_symbol), "__gnu_local_gp") == 0));
        *r = BFD_RELOC_HI16_S;
      }
  
*************** s_abicalls (int ignore ATTRIBUTE_UNUSED)
*** 11797,11808 ****
     The .cpload argument is normally $25 == $t9.
  
     The -mno-shared option changes this to:
! 	lui	$gp,%hi(_gp)
! 	addiu	$gp,$gp,%lo(_gp)
     and the argument is ignored.  This saves an instruction, but the
     resulting code is not position independent; it uses an absolute
!    address for _gp.  Thus code assembled with -mno-shared can go into
!    an ordinary executable, but not into a shared library.  */
  
  static void
  s_cpload (int ignore ATTRIBUTE_UNUSED)
--- 11797,11808 ----
     The .cpload argument is normally $25 == $t9.
  
     The -mno-shared option changes this to:
! 	lui	$gp,%hi(__gnu_local_gp)
! 	addiu	$gp,$gp,%lo(__gnu_local_gp)
     and the argument is ignored.  This saves an instruction, but the
     resulting code is not position independent; it uses an absolute
!    address for __gnu_local_gp.  Thus code assembled with -mno-shared
!    can go into an ordinary executable, but not into a shared library.  */
  
  static void
  s_cpload (int ignore ATTRIBUTE_UNUSED)
*************** s_cpload (int ignore ATTRIBUTE_UNUSED)
*** 11830,11836 ****
    in_shared = mips_in_shared || HAVE_64BIT_ADDRESSES;
  
    ex.X_op = O_symbol;
!   ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" : "_gp");
    ex.X_op_symbol = NULL;
    ex.X_add_number = 0;
  
--- 11830,11836 ----
    in_shared = mips_in_shared || HAVE_64BIT_ADDRESSES;
  
    ex.X_op = O_symbol;
!   ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" : "__gnu_local_gp");
    ex.X_op_symbol = NULL;
    ex.X_add_number = 0;
  
*************** MIPS options:\n\
*** 14078,14083 ****
--- 14078,14085 ----
  -non_shared		do not generate position independent code\n\
  -xgot			assume a 32 bit GOT\n\
  -mpdr, -mno-pdr		enable/disable creation of .pdr sections\n\
+ -mshared, -mno-shared   disable/enable .cpload optimization for\n\
+                         non-shared code\n\
  -mabi=ABI		create ABI conformant object file for:\n"));
  
    first = 1;
Only in binutils-050218/gas/config: tc-mips.c.orig

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 23:27         ` Thiemo Seufer
@ 2005-03-04  0:41           ` Daniel Jacobowitz
  0 siblings, 0 replies; 18+ messages in thread
From: Daniel Jacobowitz @ 2005-03-04  0:41 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: David Daney, binutils

On Fri, Mar 04, 2005 at 12:27:29AM +0100, Thiemo Seufer wrote:
> David Daney wrote:
> > But it is possible to have C code like this:
> > 
> > extern int _gp;
> > 
> > 
> > int
> > foo()
> > {
> >   int *bar = &_gp;
> > /* Do something with the primary GOT */
> > }
> > 
> > In this case the existing semantics are clear.  It is the primary GOT.
> 
> Whithout having looked it up, I doubt the ABI gives the program any
> guarantee about the contents of the GOT.

I know at least one dynamic linker that works this way.  Of course, it
uses the symbol _GLOBAL_OFFSET_TABLE_ for consistency with other
platforms, so it won't be directly affected; but there may be others.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 23:57       ` David Daney
@ 2005-03-04  0:43         ` Daniel Jacobowitz
  2005-03-04  9:36         ` Richard Sandiford
  1 sibling, 0 replies; 18+ messages in thread
From: Daniel Jacobowitz @ 2005-03-04  0:43 UTC (permalink / raw)
  To: David Daney; +Cc: Thiemo Seufer, binutils

On Thu, Mar 03, 2005 at 03:57:04PM -0800, David Daney wrote:
> Thiemo Seufer wrote:
> >David Daney wrote:
> >[snip]
> >
> >>>WRT possible breakge to things expecting the real "_gp": I agree that
> >>>might be a problem.  One possibility would be to define a new symbol,
> >>>something like __gnu_local_gp, and make -mno-shared use that instead
> >>>of plain _gp.  -mno-shared is a new option, so there's no backwards
> >>>compatiblity problem.
> >>
> >>OK, I kind of like this idea.  But I am not an ABI authority.  I am 
> >>assuming the the meaning of "_gp_disp" is defined somewhere in the ABI 
> >>specs.  I know _gp is specified.  Does anybody have objections to adding 
> >>the new magic __gnu_local_gp symbol?
> >
> >
> >I have the general (and still vague) idea to have multigot-capable object
> >files, with _gp _gp.1 .. _gp.n and _gp_disp _gp_disp.1 .. _gp_disp.n
> >depending on the GOT in use, and with the single got case staying binary
> >compatible. I think this would cover your case as well, but it's of
> >course much more work.

As David said, I think this solves a different problem.

> Yes, it makes my head hurt just to think about it.
> 
> In lieu of doing that I present the attached patch.
> 
> The main question being:  Use _gp or __gnu_local_gp ?
> 
> The pros of using _gp are that Thiemo's plan to magically rename _gp 
> would be binary compatible.
> 
> The pros of using __gnu_local_gp are that existing code using _gp 
> outside of .cpload would continue to work.
> 
> I am inclined to use _gp as it does not create a gnu specific ABI 
> extension, but I am apprehensive about what will happen when I try to 
> build glibc.

We can handle __gnu_local_gp.1 just as easily as _gp.1, once someone
does the work :-)  I don't have much of a preference.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 22:34   ` David Daney
  2005-03-03 22:49     ` Thiemo Seufer
@ 2005-03-04  4:31     ` Ian Lance Taylor
  1 sibling, 0 replies; 18+ messages in thread
From: Ian Lance Taylor @ 2005-03-04  4:31 UTC (permalink / raw)
  To: David Daney; +Cc: Richard Sandiford, binutils

David Daney <ddaney@avtrex.com> writes:

Thanks for fixing this issue.

> OK, I kind of like this idea.  But I am not an ABI authority.  I am
> assuming the the meaning of "_gp_disp" is defined somewhere in the ABI
> specs.  I know _gp is specified.  Does anybody have objections to
> adding the new magic __gnu_local_gp symbol?

The ABI defines _gp_disp.  It does not define _gp.

I used _gp because the GNU linker has historically defined it in the
linker script.  Programs which tried to use _gp as anything other than
an offset into the GOT have historically not worked with the GNU
linker.  And as an offset into the GOT it has not always had the same
value.  Therefore I expect that it is safe to use _gp.  I also think
it would be safe to use __gnu_local_gp instead.

Ian

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

* Re: RFC: Patch to fix MIPS -mno-shared with multi-got...
  2005-03-03 23:57       ` David Daney
  2005-03-04  0:43         ` Daniel Jacobowitz
@ 2005-03-04  9:36         ` Richard Sandiford
  2005-03-04 19:43           ` New " David Daney
  1 sibling, 1 reply; 18+ messages in thread
From: Richard Sandiford @ 2005-03-04  9:36 UTC (permalink / raw)
  To: David Daney; +Cc: Thiemo Seufer, binutils

David Daney <ddaney@avtrex.com> writes:
> The main question being:  Use _gp or __gnu_local_gp ?
>
> The pros of using _gp are that Thiemo's plan to magically rename _gp
> would be binary compatible.
>
> The pros of using __gnu_local_gp are that existing code using _gp
> outside of .cpload would continue to work.
>
> I am inclined to use _gp as it does not create a gnu specific ABI
> extension, but I am apprehensive about what will happen when I try to
> build glibc.

Well, I think Thiemo was suggesting that the assembler use _gp.N
instead of _gp, so that would need a GNU-specific extension as well.

Other arguments in favour of __gnu_local_gp:

  - What -mno-shared does is already a GNU-specific ABI extension,
    in that no existing MIPS tools do it as far as I'm aware.  So in
    a way, it seems natural to use a GNU-specific extension for the
    symbol as well.

  - -mno-shared isn't implied by other options.  You have to ask for
    it explicitly.  It seems reasonable to ask that you only use
    -mno-shared with a linker that would support it.

  - Simply adding a "__gnu_local_gp = _gp;" assignment to a linker
    script would make it work with existing linkers.

FWIW, I like your patch (but I can't approve it).  One very minor
nit though:

> !   ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" : "__gnu_local_gp");

...watch the long lines.

Richard

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

* New Patch to fix MIPS -mno-shared with multi-got...
  2005-03-04  9:36         ` Richard Sandiford
@ 2005-03-04 19:43           ` David Daney
  2005-03-04 19:45             ` Daniel Jacobowitz
  0 siblings, 1 reply; 18+ messages in thread
From: David Daney @ 2005-03-04 19:43 UTC (permalink / raw)
  To: binutils; +Cc: Richard Sandiford, Thiemo Seufer

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

Richard Sandiford wrote:
> David Daney <ddaney@avtrex.com> writes:
> 
>>The main question being:  Use _gp or __gnu_local_gp ?
>>
>>The pros of using _gp are that Thiemo's plan to magically rename _gp
>>would be binary compatible.
>>
>>The pros of using __gnu_local_gp are that existing code using _gp
>>outside of .cpload would continue to work.
>>
>>I am inclined to use _gp as it does not create a gnu specific ABI
>>extension, but I am apprehensive about what will happen when I try to
>>build glibc.
> 
> 
> Well, I think Thiemo was suggesting that the assembler use _gp.N
> instead of _gp, so that would need a GNU-specific extension as well.
> 
> Other arguments in favour of __gnu_local_gp:
> 
>   - What -mno-shared does is already a GNU-specific ABI extension,
>     in that no existing MIPS tools do it as far as I'm aware.  So in
>     a way, it seems natural to use a GNU-specific extension for the
>     symbol as well.
> 
>   - -mno-shared isn't implied by other options.  You have to ask for
>     it explicitly.  It seems reasonable to ask that you only use
>     -mno-shared with a linker that would support it.
> 
>   - Simply adding a "__gnu_local_gp = _gp;" assignment to a linker
>     script would make it work with existing linkers.
> 
> FWIW, I like your patch (but I can't approve it).  One very minor
> nit though:
> 
> 
>>!   ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" : "__gnu_local_gp");
> 
> 
> ...watch the long lines.

Done.

Attached is what I hope is the final version of the patch.  I had to 
bzip2 it because the testcase is a bit large.

Comments from Richard Sandiford and Daniel Jacobowitz convinced me that 
we should use "__gnu_local_gp" as the symbol referenced in the 
-mno-shared .cpload optimization.

Tested on i686-linux -> mipsel-linux cross with make -k check no 
regressions found.

bfd ChangeLog:
2005-03-04  David Daney <ddaney@avtrex.com>

	* elfxx-mips.c (mips_elf_calculate_relocation): Handle special
	'__gnu_local_gp' symbol used by gas -mno-shared.

gas ChangeLog:
2005-03-04  David Daney <ddaney@avtrex.com>

	* config/tc-mips.c (macro_build_lui): Use '__gnu_local_gp' instead
	of '_gp' for -mno-shared optimization.
	(s_cpload): Ditto.
	(s_abicalls): Document it in the comment.
	(md_show_usage): Document the -mno-shared option.


gas/testsuite ChangeLog:
2005-03-04  David Daney <ddaney@avtrex.com>

	* gas/mips/elf-rel23b.d: Use '__gnu_local_gp' instead
	of '_gp' for -mno-shared optimization.
	* gas/mips/elf-rel25a.d: Ditto.

ld/testsuite ChangeLog:
2005-03-04  David Daney <ddaney@avtrex.com>

	* ld-mips-elf/multi-got-no-shared{-1.s, -2.s, .d}: New test.
	* ld-mips-elf/mips-elf.exp: Run it.

If O.K.  I can try to commit as it appears that I have CVS write access 
(although never tested with binutils).

David Daney.



[-- Attachment #2: binutils.d.bz2 --]
[-- Type: application/x-tar, Size: 165261 bytes --]

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

* Re: New Patch to fix MIPS -mno-shared with multi-got...
  2005-03-04 19:43           ` New " David Daney
@ 2005-03-04 19:45             ` Daniel Jacobowitz
  2005-03-04 21:53               ` David Daney
  0 siblings, 1 reply; 18+ messages in thread
From: Daniel Jacobowitz @ 2005-03-04 19:45 UTC (permalink / raw)
  To: David Daney; +Cc: binutils, Richard Sandiford, Thiemo Seufer

On Fri, Mar 04, 2005 at 11:42:33AM -0800, David Daney wrote:
> Attached is what I hope is the final version of the patch.  I had to 
> bzip2 it because the testcase is a bit large.

If you don't mind, could you try to do something like the multi-GOT
test for TLS?  It's smaller, easier to edit and proofread, and requires
less constant maintenance.

I don't really dig 100k linker tests.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

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

* Re: New Patch to fix MIPS -mno-shared with multi-got...
  2005-03-04 19:45             ` Daniel Jacobowitz
@ 2005-03-04 21:53               ` David Daney
  2005-03-04 22:12                 ` Thiemo Seufer
  0 siblings, 1 reply; 18+ messages in thread
From: David Daney @ 2005-03-04 21:53 UTC (permalink / raw)
  To: binutils; +Cc: Daniel Jacobowitz, Richard Sandiford, Thiemo Seufer

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

Daniel Jacobowitz wrote:
> On Fri, Mar 04, 2005 at 11:42:33AM -0800, David Daney wrote:
> 
>>Attached is what I hope is the final version of the patch.  I had to 
>>bzip2 it because the testcase is a bit large.
> 
> 
> If you don't mind, could you try to do something like the multi-GOT
> test for TLS?  It's smaller, easier to edit and proofread, and requires
> less constant maintenance.
> 
> I don't really dig 100k linker tests.
> 

Thanks for the pointer.  You shamed me into creating a more compact 
version of the test case.


Tested on i686-linux -> mipsel-linux cross with make -k check no 
regressions found.

bfd ChangeLog:
2005-03-04  David Daney <ddaney@avtrex.com>

     * elfxx-mips.c (mips_elf_calculate_relocation): Handle special
     '__gnu_local_gp' symbol used by gas -mno-shared.

gas ChangeLog:
2005-03-04  David Daney <ddaney@avtrex.com>

     * config/tc-mips.c (macro_build_lui): Use '__gnu_local_gp' instead
     of '_gp' for -mno-shared optimization.
     (s_cpload): Ditto.
     (s_abicalls): Document it in the comment.
     (md_show_usage): Document the -mno-shared option.


gas/testsuite ChangeLog:
2005-03-04  David Daney <ddaney@avtrex.com>

     * gas/mips/elf-rel23b.d: Use '__gnu_local_gp' instead
     of '_gp' for -mno-shared optimization.
     * gas/mips/elf-rel25a.d: Ditto.

ld/testsuite ChangeLog:
2005-03-04  David Daney <ddaney@avtrex.com>

     * ld-mips-elf/multi-got-no-shared{-1.s, -2.s, .d}: New test.
     * ld-mips-elf/mips-elf.exp: Run it.

If O.K.  I can try to commit as it appears that I have CVS write access 
(although never tested with binutils).


David Daney.

[-- Attachment #2: binutils.d --]
[-- Type: text/plain, Size: 9909 bytes --]

? bfd/doc/bfd.info
? gas/doc/as.info
? ld/testsuite/ld-mips-elf/t
? ld/testsuite/ld-mips-elf/t.dump
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.125
diff -c -p -r1.125 elfxx-mips.c
*** bfd/elfxx-mips.c	2 Mar 2005 21:23:20 -0000	1.125
--- bfd/elfxx-mips.c	4 Mar 2005 21:49:54 -0000
*************** mips_elf_calculate_relocation (bfd *abfd
*** 3646,3651 ****
--- 3646,3654 ----
    bfd_boolean local_p, was_local_p;
    /* TRUE if the symbol referred to by this relocation is "_gp_disp".  */
    bfd_boolean gp_disp_p = FALSE;
+   /* TRUE if the symbol referred to by this relocation is
+      "__gnu_local_gp".  */
+   bfd_boolean gnu_local_gp_p = FALSE;
    Elf_Internal_Shdr *symtab_hdr;
    size_t extsymoff;
    unsigned long r_symndx;
*************** mips_elf_calculate_relocation (bfd *abfd
*** 3742,3747 ****
--- 3745,3756 ----
  
  	  gp_disp_p = TRUE;
  	}
+       /* See if this is the special _gp symbol.  Note that such a
+ 	 symbol must always be a global symbol.  */
+       else if (strcmp (*namep, "__gnu_local_gp") == 0)
+ 	gnu_local_gp_p = TRUE;
+ 
+ 
        /* If this symbol is defined, calculate its address.  Note that
  	 _gp_disp is a magic symbol, always implicitly defined by the
  	 linker, so it's inappropriate to check to see whether or not
*************** mips_elf_calculate_relocation (bfd *abfd
*** 3956,3961 ****
--- 3965,3973 ----
        break;
      }
  
+   if (gnu_local_gp_p)
+     symbol = gp;
+   
    /* Figure out what kind of relocation is being performed.  */
    switch (r_type)
      {
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.290
diff -c -p -r1.290 tc-mips.c
*** gas/config/tc-mips.c	4 Mar 2005 09:51:07 -0000	1.290
--- gas/config/tc-mips.c	4 Mar 2005 21:49:56 -0000
*************** macro_build_lui (expressionS *ep, int re
*** 3393,3405 ****
    else
      {
        assert (ep->X_op == O_symbol);
!       /* _gp_disp is a special case, used from s_cpload.  _gp is used
! 	 if mips_no_shared.  */
        assert (mips_pic == NO_PIC
  	      || (! HAVE_NEWABI
  		  && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp_disp") == 0)
  	      || (! mips_in_shared
! 		  && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp") == 0));
        *r = BFD_RELOC_HI16_S;
      }
  
--- 3393,3406 ----
    else
      {
        assert (ep->X_op == O_symbol);
!       /* _gp_disp is a special case, used from s_cpload.
! 	 __gnu_local_gp is used if mips_no_shared.  */
        assert (mips_pic == NO_PIC
  	      || (! HAVE_NEWABI
  		  && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp_disp") == 0)
  	      || (! mips_in_shared
! 		  && strcmp (S_GET_NAME (ep->X_add_symbol),
!                              "__gnu_local_gp") == 0));
        *r = BFD_RELOC_HI16_S;
      }
  
*************** s_abicalls (int ignore ATTRIBUTE_UNUSED)
*** 11819,11830 ****
     The .cpload argument is normally $25 == $t9.
  
     The -mno-shared option changes this to:
! 	lui	$gp,%hi(_gp)
! 	addiu	$gp,$gp,%lo(_gp)
     and the argument is ignored.  This saves an instruction, but the
     resulting code is not position independent; it uses an absolute
!    address for _gp.  Thus code assembled with -mno-shared can go into
!    an ordinary executable, but not into a shared library.  */
  
  static void
  s_cpload (int ignore ATTRIBUTE_UNUSED)
--- 11820,11831 ----
     The .cpload argument is normally $25 == $t9.
  
     The -mno-shared option changes this to:
! 	lui	$gp,%hi(__gnu_local_gp)
! 	addiu	$gp,$gp,%lo(__gnu_local_gp)
     and the argument is ignored.  This saves an instruction, but the
     resulting code is not position independent; it uses an absolute
!    address for __gnu_local_gp.  Thus code assembled with -mno-shared
!    can go into an ordinary executable, but not into a shared library.  */
  
  static void
  s_cpload (int ignore ATTRIBUTE_UNUSED)
*************** s_cpload (int ignore ATTRIBUTE_UNUSED)
*** 11852,11858 ****
    in_shared = mips_in_shared || HAVE_64BIT_SYMBOLS;
  
    ex.X_op = O_symbol;
!   ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" : "_gp");
    ex.X_op_symbol = NULL;
    ex.X_add_number = 0;
  
--- 11853,11860 ----
    in_shared = mips_in_shared || HAVE_64BIT_SYMBOLS;
  
    ex.X_op = O_symbol;
!   ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" :
!                                          "__gnu_local_gp");
    ex.X_op_symbol = NULL;
    ex.X_add_number = 0;
  
*************** MIPS options:\n\
*** 14118,14123 ****
--- 14120,14127 ----
  -non_shared		do not generate position independent code\n\
  -xgot			assume a 32 bit GOT\n\
  -mpdr, -mno-pdr		enable/disable creation of .pdr sections\n\
+ -mshared, -mno-shared   disable/enable .cpload optimization for\n\
+                         non-shared code\n\
  -mabi=ABI		create ABI conformant object file for:\n"));
  
    first = 1;
Index: gas/testsuite/gas/mips/elf-rel23b.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/elf-rel23b.d,v
retrieving revision 1.1
diff -c -p -r1.1 elf-rel23b.d
*** gas/testsuite/gas/mips/elf-rel23b.d	10 Dec 2004 19:48:42 -0000	1.1
--- gas/testsuite/gas/mips/elf-rel23b.d	4 Mar 2005 21:49:56 -0000
*************** Disassembly of section \.text:
*** 10,16 ****
  0+00 <.*>:
  .*:	0380282d 	move	\$5,\$28
  .*:	3c1c0000 	lui	\$28,0x0
! 			.*: R_MIPS_HI16	_gp
  .*:	279c0000 	addiu	\$28,\$28,0
! 			.*: R_MIPS_LO16	_gp
  .*:	00000000 	nop
--- 10,16 ----
  0+00 <.*>:
  .*:	0380282d 	move	\$5,\$28
  .*:	3c1c0000 	lui	\$28,0x0
! 			.*: R_MIPS_HI16	__gnu_local_gp
  .*:	279c0000 	addiu	\$28,\$28,0
! 			.*: R_MIPS_LO16	__gnu_local_gp
  .*:	00000000 	nop
Index: gas/testsuite/gas/mips/elf-rel25a.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/elf-rel25a.d,v
retrieving revision 1.2
diff -c -p -r1.2 elf-rel25a.d
*** gas/testsuite/gas/mips/elf-rel25a.d	13 Dec 2004 13:02:10 -0000	1.2
--- gas/testsuite/gas/mips/elf-rel25a.d	4 Mar 2005 21:49:56 -0000
*************** Disassembly of section \.text:
*** 9,15 ****
  
  0+00 <.*>:
  .*:	3c1c0000 	lui	\$28,0x0
! 			.*: R_MIPS_HI16	_gp
  .*:	279c0000 	addiu	\$28,\$28,0
! 			.*: R_MIPS_LO16	_gp
  #pass
--- 9,15 ----
  
  0+00 <.*>:
  .*:	3c1c0000 	lui	\$28,0x0
! 			.*: R_MIPS_HI16	__gnu_local_gp
  .*:	279c0000 	addiu	\$28,\$28,0
! 			.*: R_MIPS_LO16	__gnu_local_gp
  #pass
Index: ld/testsuite/ld-mips-elf/mips-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/mips-elf.exp,v
retrieving revision 1.28
diff -c -p -r1.28 mips-elf.exp
*** ld/testsuite/ld-mips-elf/mips-elf.exp	2 Mar 2005 21:22:57 -0000	1.28
--- ld/testsuite/ld-mips-elf/mips-elf.exp	4 Mar 2005 21:49:57 -0000
*************** run_dump_test "branch-misc-1"
*** 35,40 ****
--- 35,41 ----
  # the "traditional" emulations.
  if { $linux_gnu } {
      run_dump_test "multi-got-1"
+     run_dump_test "multi-got-no-shared"
  }
  
  if $has_newabi {
Index: ld/testsuite/ld-mips-elf/multi-got-no-shared-1.s
===================================================================
RCS file: ld/testsuite/ld-mips-elf/multi-got-no-shared-1.s
diff -N ld/testsuite/ld-mips-elf/multi-got-no-shared-1.s
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-mips-elf/multi-got-no-shared-1.s	4 Mar 2005 21:49:57 -0000
***************
*** 0 ****
--- 1,29 ----
+ 	.macro  one_sym count
+ 	.globl  sym_1_\count
+ sym_1_\count:
+         la      $2, sym_1_\count
+ 	.endm
+ 
+ 	
+ 	.text
+ 	.globl	func1
+ 	.ent	func1
+ func1:
+ 	.frame	$sp,0,$31
+ 	.set noreorder
+ 	.cpload	$25
+ 	.set reorder
+ 	.cprestore 8
+ 	.set noreorder
+ 
+ 	.irp    thou,0,1,2,3,4,5,6,7,8
+ 	.irp    hund,0,1,2,3,4,5,6,7,8,9
+ 	.irp    tens,0,1,2,3,4,5,6,7,8,9
+ 	.irp    ones,0,1,2,3,4,5,6,7,8,9
+ 	one_sym \thou\hund\tens\ones
+ 	.endr
+ 	.endr
+ 	.endr
+ 	.endr
+ 
+ 	.end	func1
Index: ld/testsuite/ld-mips-elf/multi-got-no-shared-2.s
===================================================================
RCS file: ld/testsuite/ld-mips-elf/multi-got-no-shared-2.s
diff -N ld/testsuite/ld-mips-elf/multi-got-no-shared-2.s
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-mips-elf/multi-got-no-shared-2.s	4 Mar 2005 21:49:57 -0000
***************
*** 0 ****
--- 1,27 ----
+ 	.macro  one_sym count
+ 	.globl  sym_2_\count
+ sym_2_\count:
+         la      $2, sym_2_\count
+ 	.endm
+ 
+ 	.text
+ 	.ent	func2
+ func2:
+ 	.frame	$sp,0,$31
+ 	.set noreorder
+ 	.cpload	$25
+ 	.set reorder
+ 	.cprestore 8
+ 	.set noreorder
+ 
+ 	.irp    thou,0,1,2,3,4,5,6,7,8
+ 	.irp    hund,0,1,2,3,4,5,6,7,8,9
+ 	.irp    tens,0,1,2,3,4,5,6,7,8,9
+ 	.irp    ones,0,1,2,3,4,5,6,7,8,9
+ 	one_sym \thou\hund\tens\ones
+ 	.endr
+ 	.endr
+ 	.endr
+ 	.endr
+ 
+ 	.end	func2
Index: ld/testsuite/ld-mips-elf/multi-got-no-shared.d
===================================================================
RCS file: ld/testsuite/ld-mips-elf/multi-got-no-shared.d
diff -N ld/testsuite/ld-mips-elf/multi-got-no-shared.d
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-mips-elf/multi-got-no-shared.d	4 Mar 2005 21:49:57 -0000
***************
*** 0 ****
--- 1,18 ----
+ #name: MIPS multi-got-no-shared
+ #as: -EB -32 -KPIC -mno-shared
+ #source: multi-got-no-shared-1.s
+ #source: multi-got-no-shared-2.s
+ #ld: -melf32btsmip --entry func1
+ #objdump: -D -j .text --prefix-addresses --show-raw-insn
+ 
+ .*: +file format.*
+ 
+ Disassembly of section \.text:
+ 004000b0 <[^>]*> 3c1c1000 	lui	gp,0x1000
+ 004000b4 <[^>]*> 279c7ff0 	addiu	gp,gp,32752
+ 004000b8 <[^>]*> afbc0008 	sw	gp,8\(sp\)
+ #...
+ 00408d60 <[^>]*> 3c1c1002 	lui	gp,0x1002
+ 00408d64 <[^>]*> 279c9960 	addiu	gp,gp,-26272
+ 00408d68 <[^>]*> afbc0008 	sw	gp,8\(sp\)
+ #pass

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

* Re: New Patch to fix MIPS -mno-shared with multi-got...
  2005-03-04 21:53               ` David Daney
@ 2005-03-04 22:12                 ` Thiemo Seufer
  2005-03-04 22:21                   ` David Daney
  0 siblings, 1 reply; 18+ messages in thread
From: Thiemo Seufer @ 2005-03-04 22:12 UTC (permalink / raw)
  To: David Daney; +Cc: binutils, Daniel Jacobowitz, Richard Sandiford

David Daney wrote:
[snip]
> bfd ChangeLog:
> 2005-03-04  David Daney <ddaney@avtrex.com>
> 
>     * elfxx-mips.c (mips_elf_calculate_relocation): Handle special
>     '__gnu_local_gp' symbol used by gas -mno-shared.
> 
> gas ChangeLog:
> 2005-03-04  David Daney <ddaney@avtrex.com>
> 
>     * config/tc-mips.c (macro_build_lui): Use '__gnu_local_gp' instead
>     of '_gp' for -mno-shared optimization.
>     (s_cpload): Ditto.
>     (s_abicalls): Document it in the comment.
>     (md_show_usage): Document the -mno-shared option.
> 
> 
> gas/testsuite ChangeLog:
> 2005-03-04  David Daney <ddaney@avtrex.com>
> 
>     * gas/mips/elf-rel23b.d: Use '__gnu_local_gp' instead
>     of '_gp' for -mno-shared optimization.
>     * gas/mips/elf-rel25a.d: Ditto.
> 
> ld/testsuite ChangeLog:
> 2005-03-04  David Daney <ddaney@avtrex.com>
> 
>     * ld-mips-elf/multi-got-no-shared{-1.s, -2.s, .d}: New test.
>     * ld-mips-elf/mips-elf.exp: Run it.

Ok.


Thiemo

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

* Re: New Patch to fix MIPS -mno-shared with multi-got...
  2005-03-04 22:12                 ` Thiemo Seufer
@ 2005-03-04 22:21                   ` David Daney
  2005-03-04 23:40                     ` Eric Christopher
  2005-03-05  0:03                     ` Thiemo Seufer
  0 siblings, 2 replies; 18+ messages in thread
From: David Daney @ 2005-03-04 22:21 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: binutils, Daniel Jacobowitz, Richard Sandiford

Thiemo Seufer wrote:
> David Daney wrote:
> [snip]
> 
>>bfd ChangeLog:
>>2005-03-04  David Daney <ddaney@avtrex.com>
>>
>>    * elfxx-mips.c (mips_elf_calculate_relocation): Handle special
>>    '__gnu_local_gp' symbol used by gas -mno-shared.
>>
>>gas ChangeLog:
>>2005-03-04  David Daney <ddaney@avtrex.com>
>>
>>    * config/tc-mips.c (macro_build_lui): Use '__gnu_local_gp' instead
>>    of '_gp' for -mno-shared optimization.
>>    (s_cpload): Ditto.
>>    (s_abicalls): Document it in the comment.
>>    (md_show_usage): Document the -mno-shared option.
>>
>>
>>gas/testsuite ChangeLog:
>>2005-03-04  David Daney <ddaney@avtrex.com>
>>
>>    * gas/mips/elf-rel23b.d: Use '__gnu_local_gp' instead
>>    of '_gp' for -mno-shared optimization.
>>    * gas/mips/elf-rel25a.d: Ditto.
>>
>>ld/testsuite ChangeLog:
>>2005-03-04  David Daney <ddaney@avtrex.com>
>>
>>    * ld-mips-elf/multi-got-no-shared{-1.s, -2.s, .d}: New test.
>>    * ld-mips-elf/mips-elf.exp: Run it.
> 
> 
> Ok.
> 

Oh no!  I guess I do not have write access.

I just got:
Checking in bfd/ChangeLog;
/cvs/src/src/bfd/ChangeLog,v  <--  ChangeLog
new revision: 1.2949; previous revision: 1.2948
cvs [commit aborted]: could not open lock file 
`/cvs/src/src/bfd/,ChangeLog,': Permission denied

Can someone do the checkin for me?

David Daney.

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

* Re: New Patch to fix MIPS -mno-shared with multi-got...
  2005-03-04 22:21                   ` David Daney
@ 2005-03-04 23:40                     ` Eric Christopher
  2005-03-05  0:03                     ` Thiemo Seufer
  1 sibling, 0 replies; 18+ messages in thread
From: Eric Christopher @ 2005-03-04 23:40 UTC (permalink / raw)
  To: David Daney; +Cc: Thiemo Seufer, binutils, Daniel Jacobowitz, Richard Sandiford


> Oh no!  I guess I do not have write access.
> 
> I just got:
> Checking in bfd/ChangeLog;
> /cvs/src/src/bfd/ChangeLog,v  <--  ChangeLog
> new revision: 1.2949; previous revision: 1.2948
> cvs [commit aborted]: could not open lock file 
> `/cvs/src/src/bfd/,ChangeLog,': Permission denied
> 

I'll sponsor your write access for binutils.

-eric

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

* Re: New Patch to fix MIPS -mno-shared with multi-got...
  2005-03-04 22:21                   ` David Daney
  2005-03-04 23:40                     ` Eric Christopher
@ 2005-03-05  0:03                     ` Thiemo Seufer
  1 sibling, 0 replies; 18+ messages in thread
From: Thiemo Seufer @ 2005-03-05  0:03 UTC (permalink / raw)
  To: David Daney; +Cc: binutils, Daniel Jacobowitz, Richard Sandiford

David Daney wrote:
[snip]
> >Ok.
> >
> 
> Oh no!  I guess I do not have write access.

Applied, with small formatting fixes for the ChangeLog entries.


Thiemo

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

end of thread, other threads:[~2005-03-05  0:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-03 21:05 RFC: Patch to fix MIPS -mno-shared with multi-got David Daney
2005-03-03 21:48 ` Richard Sandiford
2005-03-03 22:34   ` David Daney
2005-03-03 22:49     ` Thiemo Seufer
2005-03-03 23:15       ` David Daney
2005-03-03 23:27         ` Thiemo Seufer
2005-03-04  0:41           ` Daniel Jacobowitz
2005-03-03 23:57       ` David Daney
2005-03-04  0:43         ` Daniel Jacobowitz
2005-03-04  9:36         ` Richard Sandiford
2005-03-04 19:43           ` New " David Daney
2005-03-04 19:45             ` Daniel Jacobowitz
2005-03-04 21:53               ` David Daney
2005-03-04 22:12                 ` Thiemo Seufer
2005-03-04 22:21                   ` David Daney
2005-03-04 23:40                     ` Eric Christopher
2005-03-05  0:03                     ` Thiemo Seufer
2005-03-04  4:31     ` RFC: " Ian Lance Taylor

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).