bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/24571] New: [avr] Relaxation does not shorten jmp or call to tar


From: saaadhu at gcc dot gnu.org
Subject: [Bug ld/24571] New: [avr] Relaxation does not shorten jmp or call to target at pc-relative range boundary
Date: Fri, 17 May 2019 11:27:24 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=24571

            Bug ID: 24571
           Summary: [avr] Relaxation does not shorten jmp or call to
                    target at pc-relative range boundary
           Product: binutils
           Version: 2.31
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: saaadhu at gcc dot gnu.org
  Target Milestone: ---

For the following piece of code, linker relaxation does not transform the jmp 
to forward_target into an rjmp, even though the target label is within range of
a pc-relative jump.

$ cat relax-insn-at-range-boundary.s
.section ".text", "ax",@progbits
.global main
main:
backward_target:                ; Exactly -4094 bytes from jmp
  .ds.b 4094, 0
  jmp backward_target
  jmp forward_target
  .ds.b 4094, 0
forward_target:                 ; Exactly 4098 bytes before relax, 4096 bytes
after relax
  nop

$ avr-as -m avr51 relax-insn-at-range-boundary.s -o tmp.o
$ avr-ld -m avr51 --relax tmp.o 
$ avr-objdump -d a.out

a.out:     file format elf32-avr


Disassembly of section .text:

00000000 <__ctors_end>:
        ...
     ffc:       00 00           nop
     ffe:       00 c8           rjmp    .-4096          ; 0x0 <__ctors_end>
    1000:       0c 94 01 10     jmp     0x2002  ; 0x2002 <forward_target>
        ...

00002002 <forward_target>:
        ...

The forward_target label is at a distance of 4098 bytes - if the jmp is relaxed
to rjmp, the distance gets reduced to 4096, and with the implicit PC increment
of 2, that address is reachable via rjmp .+4094

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]