This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: The mips gas is broken
- To: "H . J . Lu" <hjl at lucon dot org>
- Subject: Re: The mips gas is broken
- From: Nick Clifton <nickc at cambridge dot redhat dot com>
- Date: 03 Jul 2001 16:03:31 +0100
- Cc: binutils at sourceware dot cygnus dot com
- References: <20010629130034.A25862@lucon.org>
Hi H.J.
> Your patch:
>
> http://sources.redhat.com/ml/binutils/2001-06/msg00741.html
>
> breaks mips.
*sigh* Yes it did. I have applied the patch below which basically
reverts my original patch and moves 'finalize_syms = 1' back before
size_seg is called.
This is all to do with md_convert_frag which gets called from
cvt_frag_to_fill which gets called from size_seg. It seems that MIPS
(and probably other ports) needs the symbols resolved so that it can
determine the distance betwen instructions and the symbols that they
reference. This is so that it can then work out exactly which kind of
instruction, and more importantly, what size of instruction, it needs
to use. This then means that it can then determine the size of the
frag containing the instruction, and hence the size of the section
containing the frag.
Other ports, however, need the frag information attached to local
symbols to be intact inside md_convert_frag, and this information is
lost if finalize_syms is true.
So what I have done is to create a new target configurable constant
which specifies the value that should be assigned to finalize_syms
just before size_segs is called. It defaults to 1, so that the MIPS
port will work as before, but it can be overridden by other ports if
necessary.
Cheers
Nick
2001-07-03 Nick Clifton <nickc@cambridge.redhat.com>
* write.c (TC_FINALIZE_SYMS_BEFORE_SIZE_SEG): Default to 1.
(write_object_file): Set finalize_syms to
TC_FINALIZE_SYMS_BEFORE_SIZE_SEG just before size_segs is
called.
* doc/internals.texi; Document
TC_FINALIZE_SYMS_BEFORE_SIZE_SEG.
Index: write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.40
diff -p -r1.40 write.c
*** write.c 2001/06/27 08:49:42 1.40
--- write.c 2001/07/03 14:48:08
***************
*** 52,57 ****
--- 52,61 ----
#define TC_FIX_ADJUSTABLE(fix) 1
#endif
+ #ifndef TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
+ #define TC_FINALIZE_SYMS_BEFORE_SIZE_SEG 1
+ #endif
+
#ifndef MD_PCREL_FROM_SECTION
#define MD_PCREL_FROM_SECTION(FIXP, SEC) md_pcrel_from(FIXP)
#endif
*************** write_object_file ()
*** 1574,1583 ****
if (!changed)
break;
}
- /* Note - we do not set finalize_syms here because some targets
- do not finish sizing all of their frags until after size_seg
- has completed. */
bfd_map_over_sections (stdoutput, size_seg, (char *) 0);
#else
relax_and_size_all_segments ();
--- 1578,1593 ----
if (!changed)
break;
}
+
+ /* Note - Most ports will use the default value of
+ TC_FINALIZE_SYMS_BEFORE_SIZE_SEG, which 1. This will force
+ local symbols to be resolved, removing their frag information.
+ Some ports however, will not have finished relaxing all of
+ their frags and will still need the local symbol frag
+ information. These ports can set
+ TC_FINALIZE_SYMS_BEFORE_SIZE_SEG to 0. */
+ finalize_syms = TC_FINALIZE_SYMS_BEFORE_SIZE_SEG;
bfd_map_over_sections (stdoutput, size_seg, (char *) 0);
#else
relax_and_size_all_segments ();
Index: doc/internals.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/internals.texi,v
retrieving revision 1.24
diff -p -r1.24 internals.texi
*** internals.texi 2001/06/22 09:32:09 1.24
--- internals.texi 2001/07/03 14:48:10
*************** The instruction is completed using the d
*** 1224,1229 ****
--- 1224,1240 ----
It may also create any necessary relocations.
@xref{Relaxation}.
+ @item TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
+ @cindex TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
+ Specifies the value to be assigned to @code{finalize_syms} before the function
+ @code{size_segs} is called. Since @code{size_segs} calls @code{cvt_frag_to_fill}
+ which can call @code{md_convert_frag}, this constant governs whether the symbols
+ accessed in @code{md_convert_frag} will be fully resolved. In particular it
+ governs whether local symbols will have been resolved, and had their frag
+ information removed. Depending upon the processing performed by
+ @code{md_convert_frag} the frag information may or may not be necessary, as may
+ the resolved values of the symbols. The default value is 1.
+
@item md_apply_fix
@cindex md_apply_fix
GAS will call this for each fixup. It should store the correct value in the