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]

Re: [patch] gas: MIPS64/ELF: Another RELA problem


On Thu, Jun 13, 2002 at 12:56:33PM +0200, Maciej W. Rozycki wrote:
> On 12 Jun 2002, Ian Lance Taylor wrote:
> 
> > I certainly agree that it should be fixed.  It's just that fixing it
> > would be a real pain, and so far nobody has been willing to undergo
> > the suffering (including me).  My brief suggestions on how to fix it
> > are in bfd/doc/bfdint.texi.
> 
>  OK, I've added it to my to-do list.  I'll look at the problem once I have
> my MIPS64/Linux work done.

Note that there are really two problems involved in unraveling the
mess, as the backend md_apply_fix3 routines have fudges to cope with
deficiencies in write.c:fixup_segment as well as other fudges to
correct bfd_install_relocation problems.  I have a patchset addressing
fixup_segment, which I intend to apply after we branch for 2.13.  If
people want to see it now, just ask.  Here's the doco change:

Index: gas/doc/internals.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/internals.texi,v
retrieving revision 1.29
diff -u -p -r1.29 internals.texi
--- gas/doc/internals.texi	11 Apr 2002 11:11:35 -0000	1.29
+++ gas/doc/internals.texi	8 Jun 2002 08:39:09 -0000
@@ -1250,18 +1250,70 @@ information removed.  Depending upon the
 @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_fix3
+@item md_apply_fix3 (@var{fixP}, @var{valP}, @var{seg})
 @cindex md_apply_fix3
 GAS will call this for each fixup.  It should store the correct value in the
-object file.  @code{fixup_segment} performs a generic overflow check on the
-@code{valueT *val} argument after @code{md_apply_fix3} returns.  If the overflow
-check is relevant for the target machine, then @code{md_apply_fix3} should
-modify @code{valueT *val}, typically to the value stored in the object file.
+object file.  @code{struct fix *@var{fixP}} is the fixup @code{md_apply_fix3}
+is operating on.  @code{valueT *@var{valP}} is the value to store into the
+object files, or at least is the generic code's best guess!  Specifically,
+*@var{valP} is the value of the fixup symbol, perhaps modified by
+@samp{TC_FIX_ADJUSTABLE}, plus @code{@var{fixP}->fx_offset} (symbol addend),
+less MD_PCREL_FROM_SECTION for pc-relative fixups.  @code{segT @var{seg}} is
+the section the fix is in.
+@code{fixup_segment} performs a generic overflow check on *@var{valP} after
+@code{md_apply_fix3} returns.  If the overflow check is relevant for the target
+machine, then @code{md_apply_fix3} should modify *@var{valP}, typically to the
+value stored in the object file.
 
 @item TC_HANDLES_FX_DONE
 @cindex TC_HANDLES_FX_DONE
 If this macro is defined, it means that @code{md_apply_fix3} correctly sets the
 @code{fx_done} field in the fixup.
+
+@item TC_FORCE_RELOCATION (@var{fixP})
+@cindex TC_FORCE_RELOCATION
+@code{fixup_segment} tries to reduce the number of relocation emitted.
+For example, a fixup expression involving the difference of two symbols in one
+section, or a fixup against an absolute symbol, will normally not require a
+reloc.  This macro allows a target machine to override the default behaviour.
+
+@item TC_FORCE_RELOCATION_ABS (@var{fixP})
+@cindex TC_FORCE_RELOCATION_ABS
+Like TC_FORCE_RELOCATION, but used only for fixup expressions against an
+absolute symbol.  If undefined, TC_FORCE_RELOCATION will be used instead.
+
+@item TC_FORCE_RELOCATION_LOCAL (@var{fixP})
+@cindex TC_FORCE_RELOCATION_LOCAL
+Like TC_FORCE_RELOCATION, but used only for pc-relative, non-plt fixup
+expressions against a symbol in the current section.  If undefined,
+TC_FORCE_RELOCATION will be used instead.
+
+@item TC_FORCE_RELOCATION_SUB_SAME (@var{fixP})
+@cindex TC_FORCE_RELOCATION_SUB
+Like TC_FORCE_RELOCATION, but used only for fixup expressions involving the
+difference of two symbols in one section.  If undefined, TC_FORCE_RELOCATION
+will be used instead.
+
+@item TC_FORCE_RELOCATION_SUB_ABS (@var{fixP})
+@cindex TC_FORCE_RELOCATION_SUB_ABS
+Like TC_FORCE_RELOCATION, but used only for fixup expressions involving the
+difference of two symbols, with the subtrahend an absolute symbol.  If the
+macro is undefined or returns zero, the subtrahend will be resolved.
+
+@item TC_FORCE_RELOCATION_SUB_LOCAL (@var{fixP})
+@cindex TC_FORCE_RELOCATION_SUB_LOCAL
+Like TC_FORCE_RELOCATION_SUB_ABS, but the subtrahend is a symbol in the same
+section as the fixup.
+
+@item TC_FIX_ADJUSTABLE (@var{fixP})
+@cindex TC_FIX_ADJUSTABLE
+This macro controls whether the symbol value becomes part of the value passed
+to @code{md_apply_fix3}.  If the macro is undefined, or returns non-zero, the
+symbol value will be included.  Adjusting the applied value like this is
+important on REL targets where the addend is stored by @code{md_apply_fix3}.
+RELA targets generally ignore the section contents when applying a relocation.
+For ELF, a suitable definition might be
+@code{@w{!symbol_used_in_reloc_p ((@var{fixP})->fx_addsy)}}.
 
 @item tc_gen_reloc
 @cindex tc_gen_reloc

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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