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]

Newbie questions about relaxation in binutils port


I'm in the process of porting binutils to a new target CPU, and have
some questions to ask regarding relaxation, that I have been unable to
find clear answers to in the documentation and mailing list archives.
Also, the source code of different ports seem to say very different
things.

What is the difference in purpose between
md_estimate_size_before_relax and md_relax_frag? In most ports I've
looked at, they both seem to do pretty much the same thing, ie.
determine the size of the instruction. Is "estimate size before relax"
supposed to be interpreted as "estimate the size of the instruction as
it is before it is relaxed", or "estimate the size that the
instruction will get after relaxation, but do the estimation
before-hand"?

Also, what is the actual interpretation of the frag_var and
frag_variant functions? I understand that they set the fr_subtype
field, but what does "variable part" of instructions really mean? Does
the third argument "var" (and fragP->fr_var) say how many of the
already allocated bytes that might not be needed, or does it say how
many more bytes we might allocate eventually? If it is the latter, why
do we need to specify this in advance?

I am looking to implement a mechanism that can choose which one of two
instructions (of different length) to output depending on the size of
the immediate value, and I believe that putting the correct opcode
into the frag is best done in md_convert_frag. Should I do anything
about the frag length here, too?

Say that the original opcode has length 2, and I have created a frag
with frag_var using max_chars=2 and var=2. On realizing that the
immediate won't fit, I want to change it into an instruction with an
opcode of length 4. In md_convert_frag, do I need to call frag_more?
Do I need to change fragP->fr_fix or fr_var?

If any of this is obvious from some documentation that I've
overlooked, please point me to it!

Regards,
Tomas


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