This is the mail archive of the binutils@sources.redhat.com 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]

Re: Better handling of PIC suffixes in GAS expression parser


Here's the infrastructure patch I've got that makes it possible to do
this fast matching of @GOT, @PLT, etc.  I can't contribute the port
I'm working on yet, but I can already give you a feel of how it's
going to look like.  Given the patch below:

Index: gas/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* expr.c (operand): Call new hook md_parse_name_and_continuation.
	* struc-symbol.h (struct local_symbol): New TC_LOCAL_SYMFIELD_TYPE.

Index: gas/expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.31
diff -u -p -r1.31 expr.c
--- gas/expr.c 2001/03/30 07:07:09 1.31
+++ gas/expr.c 2001/04/09 05:39:39
@@ -1226,6 +1226,14 @@ operand (expressionP)
 	  name = --input_line_pointer;
 	  c = get_symbol_end ();
 
+#ifdef md_parse_name_and_continuation
+	  /* This is a hook for the backend to parse certain names
+	     followed by suffixes. */
+	  if (md_parse_name_and_continuation (name, c, input_line_pointer,
+					      expressionP))
+	    break;
+#endif
+
 #ifdef md_parse_name
 	  /* This is a hook for the backend to parse certain names
              specially in certain contexts.  If a name always has a
Index: gas/struc-symbol.h
===================================================================
RCS file: /cvs/src/src/gas/struc-symbol.h,v
retrieving revision 1.6
diff -u -p -r1.6 struc-symbol.h
--- gas/struc-symbol.h 2001/03/08 23:24:22 1.6
+++ gas/struc-symbol.h 2001/04/09 05:39:39
@@ -139,6 +139,10 @@ struct local_symbol
 
   /* The offset within the frag.  */
   valueT lsy_offset;
+
+#ifdef TC_LOCAL_SYMFIELD_TYPE
+  TC_LOCAL_SYMFIELD_TYPE lsy_tc;
+#endif
 };
 
 #define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)

I set TC_SYMFIELD_TYPE and TC_LOCAL_SYMFIELD_TYPE to a struct
sym_pic_notes, with an enum indicating whether the symbol is a regular
symbol, a @GOT, @PLT or @GOTOFF reference, or _GLOBAL_OFFSET_TABLE_.
The struct would also contain pointers to the GOT, PLT and GOTOFF
(local) symbols associated with a regular symbol, or a pointer to the
regular symbol, in case of GOT, PLT and GOTOFF references.

md_parse_name_and_continuation() is defined to a function that
sets the enum to indicate the symbol is _GLOBAL_OFFSET_TABLE_, or
looks for one of the @GOT, @PLT or @GOTOFF suffixes setting the enum
accordingly, setting up the back-pointer to the regular symbol and the
pointer to the suffixed local symbol.

Then, when deciding which relocation(s) to generate for an expression,
a function is called that looks for non-regular symbols in the
expression, noting and validating the particular relocation type that
should be generated, replacing the symbols with their regular
counterparts.

I haven't got to the early validation of expressions.  I'm not sure
I'll have time for that at this moment, so I thought I'd post this
right now.

Ok to install?

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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