Linker Relaxations in the CRIS

Hans-Peter Nilsson hp@bitrange.com
Thu Jan 20 02:47:00 GMT 2005


On Wed, 19 Jan 2005, Ravi Ramaseshan wrote:

> I have been trying to study linker relaxations. I've been trying to
> get the cris linker to relax with the following code:

The CRIS GNU AS/GAS port does assembly-time code relaxations.
However, the CRIS GNU LD port does *not* support linker code
relaxations.

A little of the reason is that IMHO linker relaxations are prone
to bugs: you manage to shrink code, but did you manage to
correctly adjust *all* the places that depend on the exact size
and shortened distance between labels on either side of the
removed code?  Have you tested all cases including ones that
straddle the different limits?  I guess most of the problem
cases may be "solved" by not doing linker relaxation when debug
information or exception tables are present.

Most of the reason though, is that CRIS does not have the type
of instructions that would benefit from linker relaxation for
normal use, as emitted by the GCC CRIS port (nor have I been
able to imagine related improvements; I'd be interested though).
You suggest conditional branches across object files, but GCC
doesn't emit such code.  Even unconditional branches are usually
within a function.

It can be argued that a counter-example is inter-section
branches, as in GCC hot/cold code partitioning, which may now or
in the not-too-distant future use conditional branches.  But
such branches are likely to anyway be separate by more than
32KiB, the largest branch reach for a CRIS conditional branch.
That is, such a branch is likely to be expanded anyway at link
time to a sequence that reaches 2GiB, as is already done at
assembly time for external or too-far-away symbols.

> Could you please help me by sending me some code which gets relaxed.

No, trivially because there is no such code.  For ports that do
support linker relaxation, look in their respective
target-specific linker test-suite.  If there are ports that do
support relaxation but do not have test-cases for it, ignore
them; they're likely broken.

For the CRIS assembly-time relaxation tests, grep for relax in
gas/testsuite/gas/cris.

brgds, H-P



More information about the Binutils mailing list