Subject: Re: -current MIPS ld.elf_so fix/workaround
To: Christopher SEKIYA <wileyc@rezrov.net>
From: Rafal Boni <rafal@attbi.com>
List: port-mips
Date: 04/13/2003 12:55:27
In message <200304131642.h3DGfxc21012@fearless-vampire-killer.waterside.net>, 
I had just written:

-> In message <20030413092157.GA29678@rezrov.net>, you write: 
-> 
-> -> On Sat, Apr 12, 2003 at 06:10:55PM -0400, Rafal Boni wrote:
-> -> 
-> -> > the following small patch makes my ld.elf_so behave correctly
-> -> 
-> -> I confirm that this patch makes bash/perl do the right thing.
-> 
-> Yeah, I tested this with a perl (which didn't even build with the in-tree
-> ld.elf_so) and tcsh before I sent that email but it is good to have that
-> seconded 8-)
-> 
-> -> A couple of comments (aside from the SUPPORT_BROKEN_LD define, which 
-> -> provides support that might not be necessary anymore):
-> 
-> Well, this isn't really true... There's still the "local, section relative"
-> stuff which gets fixed up by the SUPPORT_BROKEN_LD, and AFAICT, this was
-> the worse of the two things (in fact, for the case I eliminated, I'm not
-> sure which binutils versions generate the correct output according to the
-> comment and which ones don't -- other than the fact that it appears that
-> the current in-tree one does not).
-> 
-> -> >  		if (ELF_ST_TYPE(sym->st_info) == STT_FUNC &&
-> -> > -		    sym->st_value != 0) {
-> -> > +		    *got != sym->st_value) {
-> -> 
-> -> This bit I understand ...
-> -> 
-> -> > +			 * 
-> -> > +			 * XXXrkb: this can't be right?!?
-> -> >  			 */
-> -> > -			*got = sym->st_value + (Elf_Addr)obj->relocbase
-> ;
-> -> > +			*got += (Elf_Addr)obj->relocbase;
-> -> 
-> -> ... this is sort of confusing.  Why does this work, oh holy MIPS gurus?
-> 
-> I just tried to restore things to how they worked before Charles' changes.
-> I think the key here is "if we don't need to do anything else, at least
-> we have to adjust the address by the relocbase".  I'm not quite sure which
-> cases fall into this code, though...

Heh, taking a look at LD_DEBUG output (and adding an rdbg() for that case),
it's never actually hit because it seems that in all the cases I found, the
GOT value was exactly equal to sym->st_value... This wasn't an exhaustive
study by any means, but that does suggest it could be wrong, too..

--rafal

----
Rafal Boni                                                     rafal@attbi.com
  We are all worms.  But I do believe I am a glowworm.  -- Winston Churchill