public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* fix for fixup_segment / MD_PCREL_FROM_SECTION
@ 2001-08-28 13:07 Joern Rennecke
  2001-08-28 16:38 ` law
  2001-08-28 22:34 ` Alan Modra
  0 siblings, 2 replies; 6+ messages in thread
From: Joern Rennecke @ 2001-08-28 13:07 UTC (permalink / raw)
  To: binutils; +Cc: law, amylaar

Currently, it is impossible to write a port with a correct definition of
MD_PCREL_FROM that works, because fixup_segment neglects to subtract the
address of the relocation.

Tue Aug 28 20:37:06 2001  J"orn Rennecke <amylaar@redhat.com>

	* write.c (fixup_segment): When resolving pcrel addresses,
	properly subtract the address of the relocation if
	TC_MD_PCREL_FROM_SECTION_FIXED is defined.

Index: write.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/write.c,v
retrieving revision 1.239
diff -p -r1.239 write.c
*** write.c	2001/08/11 18:27:01	1.239
--- write.c	2001/08/28 19:33:11
*************** fixup_segment (fixP, this_segment_type)
*** 2772,2777 ****
--- 2781,2789 ----
  
  	      add_number += S_GET_VALUE (add_symbolP);
  	      add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment_type);
+ #ifdef TC_MD_PCREL_FROM_SECTION_FIXED
+ 	      add_number -= fixP->fx_frag->fr_address + fixP->fx_where;
+ #endif
  	      /* Lie.  Don't want further pcrel processing.  */
  	      pcrel = 0;
  
Index: doc/internals.texi
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/doc/internals.texi,v
retrieving revision 1.42
diff -p -r1.42 internals.texi
*** internals.texi	2001/07/14 15:56:19	1.42
--- internals.texi	2001/08/28 19:33:11
*************** If you define this macro, it should retu
*** 1280,1285 ****
--- 1280,1291 ----
  PC relative fixup and the position from which the PC relative adjustment should
  be made.  On many processors, the base of a PC relative instruction is the next
  instruction, so this macro would return the length of an instruction.
+ @item TC_MD_PCREL_FROM_SECTION_FIXED
+ @cindexTC_MD_PCREL_FROM_SECTION_FIXED
+ You also need to define @code{TC_MD_PCREL_FROM_SECTION_FIXED} to make this
+ work right, because a large number of old ports papered over a bug in
+ fixup_segment by making the reverse error in their definition of
+ @code{MD_PCREL_FROM_SECTION}.
  
  @item md_pcrel_from
  @cindex md_pcrel_from

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fix for fixup_segment / MD_PCREL_FROM_SECTION
  2001-08-28 13:07 fix for fixup_segment / MD_PCREL_FROM_SECTION Joern Rennecke
@ 2001-08-28 16:38 ` law
  2001-08-28 22:34 ` Alan Modra
  1 sibling, 0 replies; 6+ messages in thread
From: law @ 2001-08-28 16:38 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: binutils, amylaar

  In message < 200108282007.f7SK7rG02021@phal.cambridge.redhat.com >you write:
  > Currently, it is impossible to write a port with a correct definition of
  > MD_PCREL_FROM that works, because fixup_segment neglects to subtract the
  > address of the relocation.
  > 
  > Tue Aug 28 20:37:06 2001  J"orn Rennecke <amylaar@redhat.com>
  > 
  > 	* write.c (fixup_segment): When resolving pcrel addresses,
  > 	properly subtract the address of the relocation if
  > 	TC_MD_PCREL_FROM_SECTION_FIXED is defined.
Please show me the path through fixup_segment that you're taking.  It also
seems to me that you don't need to define MD_PCREL_FROM for the port you're
working on, but that's a separate issue.

jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fix for fixup_segment / MD_PCREL_FROM_SECTION
  2001-08-28 13:07 fix for fixup_segment / MD_PCREL_FROM_SECTION Joern Rennecke
  2001-08-28 16:38 ` law
@ 2001-08-28 22:34 ` Alan Modra
  2001-08-29  4:09   ` Joern Rennecke
  2001-08-29  8:11   ` law
  1 sibling, 2 replies; 6+ messages in thread
From: Alan Modra @ 2001-08-28 22:34 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: binutils, law, amylaar

On Tue, Aug 28, 2001 at 09:07:53PM +0100, Joern Rennecke wrote:
>   be made.  On many processors, the base of a PC relative instruction is the next
>   instruction, so this macro would return the length of an instruction.
> + @item TC_MD_PCREL_FROM_SECTION_FIXED
> + @cindexTC_MD_PCREL_FROM_SECTION_FIXED
> + You also need to define @code{TC_MD_PCREL_FROM_SECTION_FIXED} to make this
> + work right, because a large number of old ports papered over a bug in
> + fixup_segment by making the reverse error in their definition of
> + @code{MD_PCREL_FROM_SECTION}.

Hmm, alternatively, just modify the doco for MD_PCREL_FROM_SECTION to
reflect reality.  Note also that your patch misses a number of other
places where MD_PCREL_FROM_SECTION is used.

Alan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fix for fixup_segment / MD_PCREL_FROM_SECTION
  2001-08-28 22:34 ` Alan Modra
@ 2001-08-29  4:09   ` Joern Rennecke
  2001-08-29  5:05     ` Alan Modra
  2001-08-29  8:11   ` law
  1 sibling, 1 reply; 6+ messages in thread
From: Joern Rennecke @ 2001-08-29  4:09 UTC (permalink / raw)
  To: Alan Modra; +Cc: Joern Rennecke, binutils, law, amylaar

> Hmm, alternatively, just modify the doco for MD_PCREL_FROM_SECTION to
> reflect reality.  Note also that your patch misses a number of other
> places where MD_PCREL_FROM_SECTION is used.

I've seen these too, but I wasn't sure that was life code, or if it actually
did have the same problem/feature/whatever.

Anyways, here is a doc patch.

Wed Aug 29 12:05:13 2001  J"orn Rennecke <amylaar@redhat.com>

	* doc/internals.texi (MD_PCREL_FROM_SECTION): Change
	docuemntation to reflect reality.

Index: internals.texi
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/doc/internals.texi,v
retrieving revision 1.42
diff -p -r1.42 internals.texi
*** internals.texi	2001/07/14 15:56:19	1.42
--- internals.texi	2001/08/29 11:04:35
*************** You may define this macro to indicate wh
*** 1274,1285 ****
  symbol should be adjusted to be against the section symbol.  It should return a
  non-zero value if the adjustment is acceptable.
  
! @item MD_PCREL_FROM_SECTION
  @cindex MD_PCREL_FROM_SECTION
! If you define this macro, it should return the offset between the address of a
! PC relative fixup and the position from which the PC relative adjustment should
! be made.  On many processors, the base of a PC relative instruction is the next
! instruction, so this macro would return the length of an instruction.
  
  @item md_pcrel_from
  @cindex md_pcrel_from
--- 1274,1287 ----
  symbol should be adjusted to be against the section symbol.  It should return a
  non-zero value if the adjustment is acceptable.
  
! @item MD_PCREL_FROM_SECTION (@var{fixp}, @var{section})
  @cindex MD_PCREL_FROM_SECTION
! If you define this macro, it should return the position from which the PC
! relative adjustment for a PC relative fixup should be made.  On many
! processors, the base of a PC relative instruction is the next instruction,
! so this macro would return the length of an instruction, plus the address of
! the PC relative fixup.  The latter can be calculated as
! @var{fixp}->fx_where + @var{fixp}->fx_frag->fr_address .
  
  @item md_pcrel_from
  @cindex md_pcrel_from

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fix for fixup_segment / MD_PCREL_FROM_SECTION
  2001-08-29  4:09   ` Joern Rennecke
@ 2001-08-29  5:05     ` Alan Modra
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Modra @ 2001-08-29  5:05 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: binutils, law, amylaar

On Wed, Aug 29, 2001 at 12:09:01PM +0100, Joern Rennecke wrote:
> 	* doc/internals.texi (MD_PCREL_FROM_SECTION): Change
> 	docuemntation to reflect reality.

Thanks!  Please apply.

-- 
Alan Modra

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fix for fixup_segment / MD_PCREL_FROM_SECTION
  2001-08-28 22:34 ` Alan Modra
  2001-08-29  4:09   ` Joern Rennecke
@ 2001-08-29  8:11   ` law
  1 sibling, 0 replies; 6+ messages in thread
From: law @ 2001-08-29  8:11 UTC (permalink / raw)
  To: Alan Modra; +Cc: Joern Rennecke, binutils, amylaar

  In message < 20010829150419.G26936@bubble.sa.bigpond.net.au >you write:
  > On Tue, Aug 28, 2001 at 09:07:53PM +0100, Joern Rennecke wrote:
  > >   be made.  On many processors, the base of a PC relative instruction is 
  > the next
  > >   instruction, so this macro would return the length of an instruction.
  > > + @item TC_MD_PCREL_FROM_SECTION_FIXED
  > > + @cindexTC_MD_PCREL_FROM_SECTION_FIXED
  > > + You also need to define @code{TC_MD_PCREL_FROM_SECTION_FIXED} to make t
  > his
  > > + work right, because a large number of old ports papered over a bug in
  > > + fixup_segment by making the reverse error in their definition of
  > > + @code{MD_PCREL_FROM_SECTION}.
  > 
  > Hmm, alternatively, just modify the doco for MD_PCREL_FROM_SECTION to
  > reflect reality.  Note also that your patch misses a number of other
  > places where MD_PCREL_FROM_SECTION is used.
Ironic -- this is what I suggested to Joern privately when he indicated
that every port which uses MD_PCREL_FROM_SECTION was wrong according
to the documentation.

jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-08-29  8:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-28 13:07 fix for fixup_segment / MD_PCREL_FROM_SECTION Joern Rennecke
2001-08-28 16:38 ` law
2001-08-28 22:34 ` Alan Modra
2001-08-29  4:09   ` Joern Rennecke
2001-08-29  5:05     ` Alan Modra
2001-08-29  8:11   ` law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).