RFC: Patch to fix MIPS -mno-shared with multi-got...

David Daney ddaney@avtrex.com
Thu Mar 3 21:05:00 GMT 2005


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

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: no-shared-multi-got.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20050303/b6d5a103/attachment.ksh>


More information about the Binutils mailing list