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: A question about ld relaxation.


Hi Qinwei,

I see it is reliable to relax pc-relative instructions,
like bl-32bits relax to bl-16bits (for function call) for the
pc-relative offset can be calculated correctly?

This is possible for *some* architectures, not all.


1, Can ld relax direct jump instructions?

During a final link, for architectures that have different sized direct jump instructions, then yes it is possible. (Note: Just because it is possible, this does not mean that the code to perform this relaxation has actually been written).


Such as jump-32bits relax to jump-16bits. It is not the final link,
and all global symbol address is not fixed. In the relaxation stage,
can i directly use the global symbol address as the final address?

If you are not in the final link stage, then no, you cannot use the current address of the global symbol as the final address of the jump.
The address of the symbol might change during the final link (if it is not an absolute symbol) and the address of the jump instruction itself cannot be known until the final link stage.



2, Does ld handle pc-relative relaxation and direct jump relaxation the same way?

In general yes. Obviously the instructions will have different opcodes and may have different binary layouts, so there will be some differences in how they are handled.


3, Almost all the targets shrink the instruction size during relaxation.
Can i enlarge the instruction? like bl32-bits relax to bl-48bits?

In theory you could do this, although I do not know of any port of the GNU linker that currently supports this feature.


Cheers
  Nick


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