This is the mail archive of the
mailing list for the binutils project.
Re: [CR16] Problem with TC_LINKRELAX_FIXUP
- From: Alan Modra <amodra at gmail dot com>
- To: "Jayant R. Sonar" <Jayant dot Sonar at kpitcummins dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>, "mr dot swami dot reddy at nsc dot com" <mr dot swami dot reddy at nsc dot com>
- Date: Wed, 4 Jul 2012 19:10:35 +0930
- Subject: Re: [CR16] Problem with TC_LINKRELAX_FIXUP
- References: <C013F7BFDC93F047B111833D343777BD3AAE613C@KCHJEXMB01.kpit.com> <20120630022504.GG3203@bubble.grove.modra.org> <C013F7BFDC93F047B111833D343777BD3AAE9745@KCHJEXMB01.kpit.com>
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
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
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.
Australia Development Lab, IBM