- }
-
- if (distance_short_enough)
- {
- unsigned char code_msb;
- unsigned char code_lsb;
-
- if (debug_relax)
- printf ("shrinking jump/call instruction at address 0x%x"
- " in section %s\n\n",
- (int) dot, sec->name);
-
- /* Note that we've changed the relocs, section contents,
- etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
- symtab_hdr->contents = (unsigned char *) isymbuf;
-
- /* Get the instruction code for relaxing. */
- code_lsb = bfd_get_8 (abfd, contents + irel->r_offset);
- code_msb = bfd_get_8 (abfd, contents + irel->r_offset + 1);
-
- /* Mask out the relocation bits. */
- code_msb &= 0x94;
- code_lsb &= 0x0E;
- if (code_msb == 0x94 && code_lsb == 0x0E)
- {
- /* we are changing call -> rcall . */
- bfd_put_8 (abfd, 0x00, contents + irel->r_offset);
- bfd_put_8 (abfd, 0xD0, contents + irel->r_offset + 1);
- }
- else if (code_msb == 0x94 && code_lsb == 0x0C)
- {
- /* we are changeing jump -> rjmp. */
- bfd_put_8 (abfd, 0x00, contents + irel->r_offset);
- bfd_put_8 (abfd, 0xC0, contents + irel->r_offset + 1);
- }
- else
- abort ();
-
- /* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
- R_AVR_13_PCREL);
-
- /* We should not modify the ordering if 'shrinkable' is
- FALSE. */
- if (!shrinkable)
- {
- /* Let's insert a nop. */
- bfd_put_8 (abfd, 0x00, contents + irel->r_offset + 2);
- bfd_put_8 (abfd, 0x00, contents + irel->r_offset + 3);
- }
- else
- {
- /* Delete two bytes of data. */
- if (!elf32_avr_relax_delete_bytes (abfd, sec,
- irel->r_offset + 2, 2))
- goto error_return;
-
- /* That will change things, so, we should relax again.
- Note that this is not required, and it may be slow. */
- *again = TRUE;
- }
- }
- }
-
- default:
- {
- unsigned char code_msb;
- unsigned char code_lsb;
- bfd_vma dot;
-
- code_msb = bfd_get_8 (abfd, contents + irel->r_offset + 1);
- code_lsb = bfd_get_8 (abfd, contents + irel->r_offset + 0);
-
- /* Get the address of this instruction. */
- dot = (sec->output_section->vma
- + sec->output_offset + irel->r_offset);
-
- /* Here we look for rcall/ret or call/ret sequences that could be
- safely replaced by rjmp/ret or jmp/ret. */
- if (((code_msb & 0xf0) == 0xd0)
- && avr_replace_call_ret_sequences)
- {
- /* This insn is a rcall. */
- unsigned char next_insn_msb = 0;
- unsigned char next_insn_lsb = 0;
-
- if (irel->r_offset + 3 < sec->size)
- {
- next_insn_msb =
+ }
+
+ if (distance_short_enough)
+ {
+ unsigned char code_msb;
+ unsigned char code_lsb;
+
+ if (debug_relax)
+ printf ("shrinking jump/call instruction at address 0x%x"
+ " in section %s\n\n",
+ (int) dot, sec->name);
+
+ /* Note that we've changed the relocs, section contents,
+ etc. */
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
+ symtab_hdr->contents = (unsigned char *) isymbuf;
+
+ /* Get the instruction code for relaxing. */
+ code_lsb = bfd_get_8 (abfd, contents + irel->r_offset);
+ code_msb = bfd_get_8 (abfd, contents + irel->r_offset + 1);
+
+ /* Mask out the relocation bits. */
+ code_msb &= 0x94;
+ code_lsb &= 0x0E;
+ if (code_msb == 0x94 && code_lsb == 0x0E)
+ {
+ /* we are changing call -> rcall . */
+ bfd_put_8 (abfd, 0x00, contents + irel->r_offset);
+ bfd_put_8 (abfd, 0xD0, contents + irel->r_offset + 1);
+ }
+ else if (code_msb == 0x94 && code_lsb == 0x0C)
+ {
+ /* we are changeing jump -> rjmp. */
+ bfd_put_8 (abfd, 0x00, contents + irel->r_offset);
+ bfd_put_8 (abfd, 0xC0, contents + irel->r_offset + 1);
+ }
+ else
+ abort ();
+
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ R_AVR_13_PCREL);
+
+ /* We should not modify the ordering if 'shrinkable' is
+ FALSE. */
+ if (!shrinkable)
+ {
+ /* Let's insert a nop. */
+ bfd_put_8 (abfd, 0x00, contents + irel->r_offset + 2);
+ bfd_put_8 (abfd, 0x00, contents + irel->r_offset + 3);
+ }
+ else
+ {
+ /* Delete two bytes of data. */
+ if (!elf32_avr_relax_delete_bytes (abfd, sec,
+ irel->r_offset + 2, 2,
+ TRUE))
+ goto error_return;
+
+ /* That will change things, so, we should relax again.
+ Note that this is not required, and it may be slow. */
+ *again = TRUE;
+ }
+ }
+ }
+ /* Fall through. */
+
+ default:
+ {
+ unsigned char code_msb;
+ unsigned char code_lsb;
+ bfd_vma dot;
+
+ code_msb = bfd_get_8 (abfd, contents + irel->r_offset + 1);
+ code_lsb = bfd_get_8 (abfd, contents + irel->r_offset + 0);
+
+ /* Get the address of this instruction. */
+ dot = (sec->output_section->vma
+ + sec->output_offset + irel->r_offset);
+
+ /* Here we look for rcall/ret or call/ret sequences that could be
+ safely replaced by rjmp/ret or jmp/ret. */
+ if (((code_msb & 0xf0) == 0xd0)
+ && avr_replace_call_ret_sequences)
+ {
+ /* This insn is a rcall. */
+ unsigned char next_insn_msb = 0;
+ unsigned char next_insn_lsb = 0;
+
+ if (irel->r_offset + 3 < sec->size)
+ {
+ next_insn_msb =