public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/26664]  New: use of rjmp on devices with more than 2kb flash
@ 2006-03-13 14:04 hochstein at algo dot informatik dot tu-darmstadt dot de
  2006-03-13 14:34 ` [Bug target/26664] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hochstein at algo dot informatik dot tu-darmstadt dot de @ 2006-03-13 14:04 UTC (permalink / raw)
  To: gcc-bugs

I compile the following program with

avr-gcc -mmcu=atmega8515 -o rjmp-test rjmp-test.c

program:

const char dummy[7000] __attribute__((__progmem__));
int main() {}

-----

Error:
The atmega8515 has 8Kb of flash memory. So gcc should not use
the rjmp/rcall instructions since they can only access 2Kb.
But avr-objdump shows this:

Disassembly of section .text:

00000000 <__vectors>:
       0:       bc cd           rjmp    .-1160          ; 0xfffffb7a
<__eeprom_e
       2:       d5 cd           rjmp    .-1110          ; 0xfffffbae
<__eeprom_e
       4:       d4 cd           rjmp    .-1112          ; 0xfffffbae
<__eeprom_e
       6:       d3 cd           rjmp    .-1114          ; 0xfffffbae
<__eeprom_e
       8:       d2 cd           rjmp    .-1116          ; 0xfffffbae
<__eeprom_e
       a:       d1 cd           rjmp    .-1118          ; 0xfffffbae
<__eeprom_e
       c:       d0 cd           rjmp    .-1120          ; 0xfffffbae
<__eeprom_e
...

Discussion:
All interrupt handlers are situated behind the 7000 byte array. Therefore
the jumps of the interrupt vectors have to span at least 7000 bytes.
That is not possible with the rjmp instruction which can span at most 2Kb.
This results in the strange negative offsets.

Solution:
Jumps which span more than 2Kb have to be encoded using "jmp" not "rjmp".


-- 
           Summary: use of rjmp on devices with more than 2kb flash
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hochstein at algo dot informatik dot tu-darmstadt dot de
 GCC build triplet: i686-pc-linux
  GCC host triplet: avr
GCC target triplet: avr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26664


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/26664] use of rjmp on devices with more than 2kb flash
  2006-03-13 14:04 [Bug target/26664] New: use of rjmp on devices with more than 2kb flash hochstein at algo dot informatik dot tu-darmstadt dot de
@ 2006-03-13 14:34 ` pinskia at gcc dot gnu dot org
  2006-03-13 14:37 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-13 14:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-03-13 14:34 -------
Why do you think this is a GCC bug and not a binutils one?  GCC does not
produce __vectors as far as I can tell.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26664


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/26664] use of rjmp on devices with more than 2kb flash
  2006-03-13 14:04 [Bug target/26664] New: use of rjmp on devices with more than 2kb flash hochstein at algo dot informatik dot tu-darmstadt dot de
  2006-03-13 14:34 ` [Bug target/26664] " pinskia at gcc dot gnu dot org
@ 2006-03-13 14:37 ` pinskia at gcc dot gnu dot org
  2006-03-13 14:54 ` hochstein at algo dot informatik dot tu-darmstadt dot de
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-13 14:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-03-13 14:37 -------
On second thought this should be closed as I did a grep for __vectors and found
nothing in the GCC source.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26664


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/26664] use of rjmp on devices with more than 2kb flash
  2006-03-13 14:04 [Bug target/26664] New: use of rjmp on devices with more than 2kb flash hochstein at algo dot informatik dot tu-darmstadt dot de
  2006-03-13 14:34 ` [Bug target/26664] " pinskia at gcc dot gnu dot org
  2006-03-13 14:37 ` pinskia at gcc dot gnu dot org
@ 2006-03-13 14:54 ` hochstein at algo dot informatik dot tu-darmstadt dot de
  2006-03-14  8:27 ` hochstein at algo dot informatik dot tu-darmstadt dot de
  2006-03-14 10:51 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: hochstein at algo dot informatik dot tu-darmstadt dot de @ 2006-03-13 14:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hochstein at algo dot informatik dot tu-darmstadt dot de  2006-03-13 14:54 -------
This is no gcc problem. The vectors are generated by avr-libc.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26664


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/26664] use of rjmp on devices with more than 2kb flash
  2006-03-13 14:04 [Bug target/26664] New: use of rjmp on devices with more than 2kb flash hochstein at algo dot informatik dot tu-darmstadt dot de
                   ` (2 preceding siblings ...)
  2006-03-13 14:54 ` hochstein at algo dot informatik dot tu-darmstadt dot de
@ 2006-03-14  8:27 ` hochstein at algo dot informatik dot tu-darmstadt dot de
  2006-03-14 10:51 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: hochstein at algo dot informatik dot tu-darmstadt dot de @ 2006-03-14  8:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hochstein at algo dot informatik dot tu-darmstadt dot de  2006-03-14 08:27 -------
This is a GCC bug although my first test program did not show this.
Consider this program:

void a() 
{
}

void b() 
{
  __asm("nop\n nop\n nop\n nop\n nop\n nop");
  // ...
  // (repeat this line 500 times)
}

int main(){
 a();
}

Compile with
avr-gcc -mmcu=atmega8515 -c jmp-test.c

Now avr-objdump shows this:

Disassembly of section .text:
00000000 <a>:
       0:       cf 93           push    r28
       2:       df 93           push    r29
       4:       cd b7           in      r28, 0x3d       ; 61
       6:       de b7           in      r29, 0x3e       ; 62
       8:       df 91           pop     r29
       a:       cf 91           pop     r28
       c:       08 95           ret

[...]

0000178c <main>:
    178c:       c0 e0           ldi     r28, 0x00       ; 0
    178e:       d0 e0           ldi     r29, 0x00       ; 0
    1790:       de bf           out     0x3e, r29       ; 62
    1792:       cd bf           out     0x3d, r28       ; 61
    1794:       35 d4           rcall   .+2154          ; 0x2000 <main+0x874>
    1796:       00 c0           rjmp    .+0             ; 0x1798 <main+0xc>

The call to a() goes into nirvana since a() cannot be reached by
"rcall". "call" must be used instead. 
I suppose there is an analogous example for "rjmp".


-- 

hochstein at algo dot informatik dot tu-darmstadt dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26664


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/26664] use of rjmp on devices with more than 2kb flash
  2006-03-13 14:04 [Bug target/26664] New: use of rjmp on devices with more than 2kb flash hochstein at algo dot informatik dot tu-darmstadt dot de
                   ` (3 preceding siblings ...)
  2006-03-14  8:27 ` hochstein at algo dot informatik dot tu-darmstadt dot de
@ 2006-03-14 10:51 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-03-14 10:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2006-03-14 10:51 -------
Usually these kind of "wrong" jumps get fixed up by the linker by inserting
trampolines.  So this looks like a binutils bug.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26664


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-14 10:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-13 14:04 [Bug target/26664] New: use of rjmp on devices with more than 2kb flash hochstein at algo dot informatik dot tu-darmstadt dot de
2006-03-13 14:34 ` [Bug target/26664] " pinskia at gcc dot gnu dot org
2006-03-13 14:37 ` pinskia at gcc dot gnu dot org
2006-03-13 14:54 ` hochstein at algo dot informatik dot tu-darmstadt dot de
2006-03-14  8:27 ` hochstein at algo dot informatik dot tu-darmstadt dot de
2006-03-14 10:51 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).