This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


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

Re: Possible reloc patch (2/2)



I didn't make it clear that I was talking about the gas port for cgen,
mostly gas/cgen.c.

On Tue, 23 Jan 2001, Doug Evans wrote:

> Richard Sandiford writes:
>  > Following up on my previous message about fixups.  When you don't provide
>  > a custom operand parser, CGEN generates standard relocs like BFD_RELOC_16
>  > and BFD_RELOC_32 for external addresses.

Also, this was wrong, sorry.  My implementation of md_cgen_lookup_reloc()
was selecting standard reloc types, assuming that gas would output a reloc
for the operand itself.  But even so...

>  > But the associated fixup regions seem to describe the whole instruction
>  > rather than the operand itself.
>
> Correct.  All else being equal, this is what you want.
>
> What should happen is that a different reloc gets used,
> BFD_RELOC_2ND_32_BITS_OF_64_BIT_VALUE or some such.
>
> I'd ask the binutils list, but IMO you want the reloc to refer
> to the insn.  Taking shortcuts like having just one 32 bit reloc
> (BFD_RELOC_32) and using it everywhere, including situations like
> the 2nd 32 bits of a 64 bit value, is asking for future trouble.

Am I right in thinking this is a special requirement of the gas port for
cgen?  I've just double checked on the gas output for i386 and m68hc11
targets, and there the relocs point to the start of the address that needs
to be modified, rather than the start of the containing instruction. E.g.

	.extern foo
	.text
	mov	%eax,foo

Gives:

# objdump -r a.out

a.out:     file format elf32-i386

RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
00000001 R_386_32          foo

Couldn't there at least be an option for gas/cgen.c to generate relocs
like this as well?  Maybe some macro?  E.g.

>  > --- 590,601 ----
>  >         reloc_type = md_cgen_lookup_reloc (insn, operand, fixP);
>  >         if (reloc_type != BFD_RELOC_NONE)
>  >   	{
#ifdef CGEN_OPERAND_RELOCS
>  > + 	  const CGEN_IFLD *field;
>  > +
>  > + 	  field = cgen_ifield_lookup_by_num (gas_cgen_cpu_desc,
>  > + 					     operand->ifield);
>  > + 	  fixP->fx_where += field->word_offset / 8;
>  > + 	  fixP->fx_size = field->length / 8;
#endif
>  >   	  fixP->fx_r_type = reloc_type;
>  >   	}
>  >         else
>


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