This is the mail archive of the binutils@sourceware.org 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: [CR16] Problem with TC_LINKRELAX_FIXUP


On Wed, Jul 04, 2012 at 04:27:28AM +0000, Jayant R. Sonar wrote:
> Please guide how should I proceed.

You should first find a copy of the cr16 ABI, read and understand how
the cr16 relocations are supposed to work.

Next you need to understand the gas concept of fixups.  These are
expressions that gas could not resolve at the time an instruction or
directive was parsed, typically generated by fix_new_exp.  See struct
fix.  Some fixups can be resolved later, for instance if you wrote

	.word table_end - table
table:
	.byte ..
	...
	.byte ..
table_end:

At the time the first word holding the table size was parsed, gas
would need to emit a fixup since it doesn't know values for the
symbols in the expression.  Later, at any time after gas has parsed
the table_end label, it would be possible to evaluate the fixup to an
absolute value, and write that value.  md_apply_fix is the usual place
where this evaluation is applied, and the fixup is marked done.  For
those that can't be applied, tc_gen_reloc is responsible for
generating a relocation.

However, targets like cr16 that set linkrelax bypass the call to
md_apply_fix at least for fixups in some sections.  That means
tc_gen_reloc now has the job of resolving some fixups as well as
generating relocations, but if you look at the cr16 tc_gen_reloc I see
no support for resolving fixups and writing their values.  Not
resolving fixups in tc_gen_reloc might even be correct, but I see a
comment about "no relocation needed" and no code to write out the
value!  That can't work unless the value is written out earlier and I
see no evidence of that happening.  So your first job is to correct
tc_gen_reloc.

Next you need to rewrite md_apply_fix.  I can't give you anything but
general details since I'm not familiar with the cr16 ABI or cr16 code
in general.  Nor am I particularly interested in learning about cr16.
As I said earlier, md_apply_fix should resolve and apply some fixups,
setting fx_done for those it applies.  It should leave the fixup alone
in other cases, except where some change is needed in reloc type or,
in special cases, where some adjustment in addend is needed.  Please
take up any future discussions with Swami.

-- 
Alan Modra
Australia Development Lab, IBM


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