public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* relocations in gas
@ 2005-01-18 15:48 Jean-Philippe Bernardy
  2005-01-19  5:25 ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: Jean-Philippe Bernardy @ 2005-01-18 15:48 UTC (permalink / raw)
  To: binutils

Greetings,

I'm trying to bring an old port of binutils to the current version.
The port is for the calmrisc16 architecture. It uses cgen and 
--version says "2.10-calmrisc16-010518".


All seems well except that I'm currently facing a problem with
relocation in gas: when a global symbol is referenced inside its
defining module, the relocation table contains a wrong entry. From an
external point of view it seems that the relocation is done twice.

This problem didn't manifest itself with old binutils.

Maybe this rings a bell? Any help would be greatly appreciated.

Details follow...
Assembling:

.text
	.globl fct2
fct1:
	jmp fct2
	jmp fct3
	jmp fct4
fct2:
	nop
fct3:
	nop


objdump -r says:

RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
00000000 R_CALMRISC16_IMM22  fct2+0x0000000c
00000004 R_CALMRISC16_IMM22  .text+0x0000000e
00000008 R_CALMRISC16_IMM22  fct4

whereas the correct table would be

00000000 R_CALMRISC16_IMM22  fct2
00000004 R_CALMRISC16_IMM22  .text+0x0000000e
00000008 R_CALMRISC16_IMM22  fct4

Note that the problem occurs only for the fct2 symbol (global).

Thanks in advance,
JP.

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

* Re: relocations in gas
  2005-01-18 15:48 relocations in gas Jean-Philippe Bernardy
@ 2005-01-19  5:25 ` Alan Modra
  2005-01-19 13:28   ` Jean-Philippe Bernardy
  2005-01-21 13:28   ` Jean-Philippe Bernardy
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Modra @ 2005-01-19  5:25 UTC (permalink / raw)
  To: Jean-Philippe Bernardy; +Cc: binutils

Adding the following line to your tc-*.h file will probably cure the
problem.

#define EXTERN_FORCE_RELOC 0

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: relocations in gas
  2005-01-19  5:25 ` Alan Modra
@ 2005-01-19 13:28   ` Jean-Philippe Bernardy
  2005-01-21 13:28   ` Jean-Philippe Bernardy
  1 sibling, 0 replies; 5+ messages in thread
From: Jean-Philippe Bernardy @ 2005-01-19 13:28 UTC (permalink / raw)
  To: binutils

On Wed, 19 Jan 2005 15:55:07 +1030, Alan Modra <amodra@bigpond.net.au> wrote:
> Adding the following line to your tc-*.h file will probably cure the
> problem.
> 
> #define EXTERN_FORCE_RELOC 0


This works perfectly.
Thanks alot,

JP.

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

* Re: relocations in gas
  2005-01-19  5:25 ` Alan Modra
  2005-01-19 13:28   ` Jean-Philippe Bernardy
@ 2005-01-21 13:28   ` Jean-Philippe Bernardy
  2005-01-21 22:48     ` Alan Modra
  1 sibling, 1 reply; 5+ messages in thread
From: Jean-Philippe Bernardy @ 2005-01-21 13:28 UTC (permalink / raw)
  To: binutils

Hello,

Still on the calmrisc16 port, I encountered the problem that gas
adjusted fixups in a mergeable section. This results in incorrect
relocations when merge occurs at link time.

In found this fix:
in write.c, replace 

if ((symsec->flags & SEC_MERGE) != 0
	    && (fixp->fx_offset != 0 || fixp->fx_subsy != NULL))
	  continue;

by

if ((symsec->flags & SEC_MERGE) != 0
	    && (fixp->fx_offset != 0 || fixp->fx_subsy != NULL ||
fixp->fx_addsy != NULL))
	  continue;

Effectively taking in account the 'add symbol'. Maybe there is a
better way to handle this?

Cheers,
JP.

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

* Re: relocations in gas
  2005-01-21 13:28   ` Jean-Philippe Bernardy
@ 2005-01-21 22:48     ` Alan Modra
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2005-01-21 22:48 UTC (permalink / raw)
  To: Jean-Philippe Bernardy; +Cc: binutils

On Fri, Jan 21, 2005 at 02:27:32PM +0100, Jean-Philippe Bernardy wrote:
> Still on the calmrisc16 port, I encountered the problem that gas
> adjusted fixups in a mergeable section. This results in incorrect
> relocations when merge occurs at link time.
> 
> In found this fix:
> in write.c, replace 
> 
> if ((symsec->flags & SEC_MERGE) != 0
> 	    && (fixp->fx_offset != 0 || fixp->fx_subsy != NULL))
> 	  continue;

No, that code is correct.  If you need to keep the original symbol in
SEC_MERGE sections for some reason, then do so by returning zero in your
target tc_fix_adjustable function.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

end of thread, other threads:[~2005-01-21 22:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-18 15:48 relocations in gas Jean-Philippe Bernardy
2005-01-19  5:25 ` Alan Modra
2005-01-19 13:28   ` Jean-Philippe Bernardy
2005-01-21 13:28   ` Jean-Philippe Bernardy
2005-01-21 22:48     ` Alan Modra

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).