[RFC] [PATCH][AVR] Add linker relaxation support. Fix 64-Bit bootstrap failure

Björn Haase bjoern.m.haase@web.de
Mon Oct 3 20:09:00 GMT 2005


Hi,

The following patch adds support for linker relaxation for the avr port.
The most important issue is to choose the shorter variant of the two call/jump
alternatives if the displacement is sufficiently small. 
This small change alone results in up to 3 per cent code size reduction for 
the applications I have checked so far. The patch changes gas and bfd. 
When working on the patch I have stepped over a 64bit-system bug in gas. This 
one is fixed in a separate patch.

BFD:

The method is mainly a cut-and paste from the H8300 approach. Differing from 
the situation there, an additional correction for the relocation addend has 
been newly written.

In order to avoid problems in the interrupt vectors, these are protected from
relaxing as well as a ".jumptables" section that could be used in the (near)
future.

\begin{offtopic}

This ".jumptables" section is meant to be used for table-jump tables for the 
devices with three-byte program counter:
For these devices we will not be happy with 2-byte address tables and 
instead of them we could better use 4 bytes for storing a table of complete
22 bit jump instructions that we could jump to by an ijmp instruction.
For doing this we would need to make sure that relaxing does never change 
the relative offsets within this section.

\end{offtopic}

It would be helpful if someone could have a look at 
elf_avr_relax_delete_bytes.
I took this function from H8300 and it works, but I have no clue what it does
and why it is necessary.

GAS:

In order to make relaxation work, we need to make gas preserve more 
relocs than it used to preserve. The issue is that all the relative 
instruction
offsets no longer must be calculated at assembly time but at linke time.
For this purpose the patch disables the fixups for all of the program-space 
relative relocs.

Because there is no way to find out from the object file itself if it is
suitable for relaxing or not, I consider to be it best to make always the
linker make the fixups. Otherwise we would probably need an additional
tag in the object files that prevents undue use. I think the slightly larger
object files (more relocs than previously) are a small price to pay.

Legal issues:

I presently have a copyright assignment only for gcc. Could someone of the 
maintainers please ask the FSF to prepare papers for the other two important 
projects, both, binutils and gdb?

Bjoern.


2005-08-03  Bjoern Haase  <bjoern.m.haase@web.de>

	* gas/config/tc-avr.c:  include <inttypes.h>
	md_begin: replace typecast to int by typecast to intptr_t
	avr_ldi_expression: ditto.


2005-08-03  Bjoern Haase  <bjoern.m.haase@web.de>

	* gas/config/tc-avr.c:  include <inttypes.h>
	md_begin: replace typecast to int by typecast to intptr_t
	avr_ldi_expression: ditto.


2005-08-03  Bjoern Haase  <bjoern.m.haase@web.de>

	* gas/config/tc-avr.h
	TC_VALIDATE_FIX: Add. disable fixups for progmem related relocs.

	* bfd/elf32-avr.c
	elf32_avr_relax_section: add.
	elf32_avr_relax_delete_bytes: add.
	elf32_avr_get_relocated_section_contents: add.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gas_64bit.patch
Type: text/x-diff
Size: 3408 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20051003/23821198/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: relax_avr.patch
Type: text/x-diff
Size: 26729 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20051003/23821198/attachment-0001.bin>


More information about the Binutils mailing list