This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[GAS PATCH]: Recognize sparc %pc22 and %pc10


There is this ugly hack in the GAS sparc backend that takes
sequences of the form:

	sethi	%hi(_GLOBAL_OFFSET_TABLE_), %reg
	or	%reg, %lo(_GLOBAL_OFFSET_TABLE_), %reg

and emits PC22 and PC10 relocations when -PIC since it notices this is
against _GLOBAL_OFFSET_TABLE_.

That's awful (what if you really did want an absolute reference to the
GOT base from PIC code?).  What you're supposed to do is:

	sethi	%pc22(_GLOBAL_OFFSET_TABLE_), %reg
	or	%reg, %pc10(_GLOBAL_OFFSET_TABLE_), %reg

The following patch adds support for these sparc mnemonics, but
unfortunately we have to keep the -PIC hack in there.

Ok to commit?

2008-04-17  David S. Miller  <davem@davemloft.net>

	* config/tc-sparc.c (sparc_ip): Recognize %pc22 and %pc10.

Index: config/tc-sparc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sparc.c,v
retrieving revision 1.70
diff -u -p -r1.70 tc-sparc.c
--- config/tc-sparc.c	16 Apr 2008 08:51:18 -0000	1.70
+++ config/tc-sparc.c	17 Apr 2008 22:56:57 -0000
@@ -2309,6 +2309,8 @@ sparc_ip (str, pinsn)
 		      { "lox", 3, BFD_RELOC_SPARC_LOX10, 1, 0 },
 		      { "hi", 2, BFD_RELOC_HI22, 0, 1 },
 		      { "lo", 2, BFD_RELOC_LO10, 0, 1 },
+		      { "pc22", 4, BFD_RELOC_SPARC_PC22, 0, 1 },
+		      { "pc10", 4, BFD_RELOC_SPARC_PC10, 0, 1 },
 		      { "hh", 2, BFD_RELOC_SPARC_HH22, 1, 1 },
 		      { "hm", 2, BFD_RELOC_SPARC_HM10, 1, 1 },
 		      { "lm", 2, BFD_RELOC_SPARC_LM22, 1, 1 },


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]