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]
Other format: [Raw text]

mn10300 assembler fix for error in debugging info


On Oct  3, 2002, Alan Modra <amodra@bigpond.net.au> wrote:

> Indeed, the problem was introduced with my gas reloc changes.  I
> made a suggestion to Alex on a possible fix a few minutes before
> receiving your email, but on looking a little more closely, I
> think my suggestion was probably wrong.

> Instead, I think you want

> #define TC_VALIDATE_FIX_SUB(FIX) 1

> in tc-mn10300.h to disable the write.c check.  (Difference
> expressions will be checked later in tc-mn10300.c:tg_gen_reloc)

This fix works, indeed, and it produces the right results.  Even
though I'm not entirely happy about it, I'm checking in the first
patch below, at least as a stop-gap.

The second patch was an attempt to extend one of the
TC_FORCE_RELOCATION_SUB_ macros such that we could implement the plan
detailed in the comments I added before TC_LINKRELAX_FIXUP in the
first patch.  Does it sound like a reasonable plan?  Should the same
change be applied to other such macros so that we could implement it?

Index: gas/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>,
	Alan Modra  <amodra@bigpond.net.au>

	* config/tc-mn10300.h (TC_VALIDATE_FIX_SUB): Define.
	(TC_LINKRELAX_FIXUP): Add comments.

Index: gas/config/tc-mn10300.h
===================================================================
RCS file: /cvs/uberbaum/gas/config/tc-mn10300.h,v
retrieving revision 1.10
diff -u -p -r1.10 tc-mn10300.h
--- gas/config/tc-mn10300.h 30 Nov 2002 08:39:43 -0000 1.10
+++ gas/config/tc-mn10300.h 12 Dec 2002 04:27:50 -0000
@@ -47,7 +47,24 @@ extern int mn10300_force_relocation PARA
   (! SEG_NORMAL (SEG)				\
    || ((SEG)->flags & SEC_CODE) != 0)
 
-/* Fixup debug sections since we will never relax them.  */
+/* We validate subtract arguments within tc_gen_reloc(), so don't
+   report errors at this point.  */
+#define TC_VALIDATE_FIX_SUB(FIX) 1
+
+/* Fixup debug sections since we will never relax them.  Ideally, we
+   could do away with this and instead check every single fixup with
+   TC_FORCE_RELOCATION and TC_FORCE_RELOCATION_SUB_NAME, verifying
+   that the sections of the referenced symbols (and not the sections
+   in which the fixup appears) may be subject to relaxation.  We'd
+   still have to check the section in which the fixup appears, because
+   we want to do some simplifications in debugging info that might
+   break in real code.
+
+   Using the infrastructure in write.c to simplify subtraction fixups
+   would enable us to remove a lot of code from tc_gen_reloc(), but
+   this is simpler, faster, and produces almost the same effect.
+   Also, in the macros above, we can't check whether the fixup is in a
+   debugging section or not, so we have to use this for now.  */
 #define TC_LINKRELAX_FIXUP(seg) (seg->flags & SEC_ALLOC)
 
 #define md_operand(x)
Index: gas/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* write.c (TC_FORCE_RELOCATION_SUB_SAME): Add FIXSEG argument.
	(fixup_segment): Pass this_segment to it.
	* doc/internals.texi: Adjust.
	* config/tc-i960.h (TC_FORCE_RELOCATION_SUB_SAME): Adjust.
	* config/tc-mips.h (TC_FORCE_RELOCATION_SUB_SAME): Adjust.
	* config/tc-sh.h (TC_FORCE_RELOCATION_SUB_SAME): Adjust.
	* config/tc-sh64.h (TC_FORCE_RELOCATION_SUB_SAME): Adjust.
	* config/tc-mn10300.h (TC_FORCE_RELOCATION_SUB_SAME): Don't
	force it in non-alloc segments.

Index: gas/write.c
===================================================================
RCS file: /cvs/uberbaum/gas/write.c,v
retrieving revision 1.66
diff -u -p -r1.66 write.c
--- gas/write.c 30 Nov 2002 08:39:42 -0000 1.66
+++ gas/write.c 12 Dec 2002 02:51:58 -0000
@@ -50,7 +50,7 @@
 #endif
 
 #ifndef TC_FORCE_RELOCATION_SUB_SAME
-#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG)	\
+#define TC_FORCE_RELOCATION_SUB_SAME(FIX, FIXSEG, SEG)	\
   (! SEG_NORMAL (SEG))
 #endif
 
@@ -2623,7 +2623,8 @@ fixup_segment (fixP, this_segment)
 	  sub_symbol_segment = S_GET_SEGMENT (fixP->fx_subsy);
 	  if (fixP->fx_addsy != NULL
 	      && sub_symbol_segment == add_symbol_segment
-	      && !TC_FORCE_RELOCATION_SUB_SAME (fixP, add_symbol_segment))
+	      && !TC_FORCE_RELOCATION_SUB_SAME (fixP, this_segment,
+						add_symbol_segment))
 	    {
 	      add_number += S_GET_VALUE (fixP->fx_addsy);
 	      add_number -= S_GET_VALUE (fixP->fx_subsy);
Index: gas/doc/internals.texi
===================================================================
RCS file: /cvs/uberbaum/gas/doc/internals.texi,v
retrieving revision 1.32
diff -u -p -r1.32 internals.texi
--- gas/doc/internals.texi 18 Nov 2002 21:08:54 -0000 1.32
+++ gas/doc/internals.texi 12 Dec 2002 02:51:59 -0000
@@ -1293,13 +1293,13 @@ symbol in the current section.  If undef
 @code{fx_pcrel} or @code{fx_plt} or for which @code{TC_FORCE_RELOCATION}
 returns non-zero, will emit relocs.
 
-@item TC_FORCE_RELOCATION_SUB_SAME (@var{fix}, @var{seg})
+@item TC_FORCE_RELOCATION_SUB_SAME (@var{fix}, @var{fixseg}, @var{seg})
 @cindex TC_FORCE_RELOCATION_SUB
-This macro controls resolution of fixup expressions involving the
-difference of two symbols in the same section.  If this macro returns zero,
-the subtrahend will be resolved and @code{fx_subsy} set to @code{NULL} for
-@code{md_apply_fix3}.  If undefined, the default of
-@w{@code{! SEG_NORMAL (@var{seg})}} will be used.
+This macro controls resolution of a fixup expressions @var{fix} in section
+@var{fixseg} involving the difference of two symbols in the same section
+@var{seg}.  If this macro returns zero, the subtrahend will be resolved and
+@code{fx_subsy} set to @code{NULL} for @code{md_apply_fix3}.  If undefined, the
+default of @w{@code{! SEG_NORMAL (@var{seg})}} will be used.
 
 @item TC_FORCE_RELOCATION_SUB_ABS (@var{fix})
 @cindex TC_FORCE_RELOCATION_SUB_ABS
Index: gas/config/tc-mn10300.h
===================================================================
RCS file: /cvs/uberbaum/gas/config/tc-mn10300.h,v
retrieving revision 1.10
diff -u -p -r1.10 tc-mn10300.h
--- gas/config/tc-mn10300.h 30 Nov 2002 08:39:43 -0000 1.10
+++ gas/config/tc-mn10300.h 12 Dec 2002 02:52:08 -0000
@@ -42,10 +42,13 @@ extern int mn10300_force_relocation PARA
 /* Do not adjust relocations involving symbols in code sections,
    because it breaks linker relaxations.  This could be fixed in the
    linker, but this fix is simpler, and it pretty much only affects
-   object size a little bit.  */
-#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG)	\
-  (! SEG_NORMAL (SEG)				\
-   || ((SEG)->flags & SEC_CODE) != 0)
+   object size a little bit.  Enable simplification when generating
+   debugging info, such that we don't die when symbol offsets are
+   computed there.  */
+#define TC_FORCE_RELOCATION_SUB_SAME(FIX, FIXSEG, SEG)	\
+  ((! SEG_NORMAL (SEG)				\
+    || ((SEG)->flags & SEC_CODE) != 0) \
+   && ((FIXSEG) == (SEG) || TC_LINKRELAX_FIXUP (FIXSEG)))
 
 /* Fixup debug sections since we will never relax them.  */
 #define TC_LINKRELAX_FIXUP(seg) (seg->flags & SEC_ALLOC)
Index: gas/config/tc-i960.h
===================================================================
RCS file: /cvs/uberbaum/gas/config/tc-i960.h,v
retrieving revision 1.9
diff -u -p -r1.9 tc-i960.h
--- gas/config/tc-i960.h 5 Sep 2002 00:01:17 -0000 1.9
+++ gas/config/tc-i960.h 12 Dec 2002 02:52:00 -0000
@@ -132,7 +132,7 @@ struct relocation_info
 
 /* Makes no sense to use the difference of 2 arbitrary symbols
    as the target of a call instruction.  */
-#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG)	\
+#define TC_FORCE_RELOCATION_SUB_SAME(FIX, FIXSEG, SEG)	\
   ((FIX)->fx_tcbit				\
    || ! SEG_NORMAL (SEG))
 
Index: gas/config/tc-mips.h
===================================================================
RCS file: /cvs/uberbaum/gas/config/tc-mips.h,v
retrieving revision 1.20
diff -u -p -r1.20 tc-mips.h
--- gas/config/tc-mips.h 30 Nov 2002 08:39:43 -0000 1.20
+++ gas/config/tc-mips.h 12 Dec 2002 02:52:07 -0000
@@ -140,7 +140,7 @@ extern int mips_fix_adjustable PARAMS ((
 #define TC_FORCE_RELOCATION(FIX) mips_force_relocation (FIX)
 extern int mips_force_relocation PARAMS ((struct fix *));
 
-#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG)	\
+#define TC_FORCE_RELOCATION_SUB_SAME(FIX, FIXSEG, SEG)	\
   (mips_force_relocation (FIX)			\
    || !SEG_NORMAL (SEG))
 
Index: gas/config/tc-sh.h
===================================================================
RCS file: /cvs/uberbaum/gas/config/tc-sh.h,v
retrieving revision 1.23
diff -u -p -r1.23 tc-sh.h
--- gas/config/tc-sh.h 30 Nov 2002 08:39:44 -0000 1.23
+++ gas/config/tc-sh.h 12 Dec 2002 02:52:08 -0000
@@ -85,7 +85,7 @@ extern int sh_force_relocation PARAMS ((
        || (FIX)->fx_r_type == BFD_RELOC_8		\
        || SWITCH_TABLE_CONS (FIX)))
 
-#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG)		\
+#define TC_FORCE_RELOCATION_SUB_SAME(FIX, FIXSEG, SEG)	\
   (! SEG_NORMAL (SEG)					\
    || (sh_relax && SWITCH_TABLE (FIX)))
 
Index: gas/config/tc-sh64.h
===================================================================
RCS file: /cvs/uberbaum/gas/config/tc-sh64.h,v
retrieving revision 1.3
diff -u -p -r1.3 tc-sh64.h
--- gas/config/tc-sh64.h 5 Sep 2002 00:01:18 -0000 1.3
+++ gas/config/tc-sh64.h 12 Dec 2002 02:52:08 -0000
@@ -105,8 +105,8 @@ extern int sh64_target_mach PARAMS ((voi
    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_HI16	\
    || TC_FORCE_RELOCATION (FIX))
 
-#undef TC_FORCE_RELOCATION_SUB_SAME
-#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG)		\
+#undef TC_FORCE_RELOCATION_SUB_SAME
+#define TC_FORCE_RELOCATION_SUB_SAME(FIX, FIXSEG, SEG)	\
   (! SEG_NORMAL (SEG)					\
    || (sh_relax && SWITCH_TABLE (FIX))			\
    || *symbol_get_tc ((FIX)->fx_addsy) != NULL)
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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