Bug 12132 - AVR gs() operator does not work directly on jmp or rjmp
Summary: AVR gs() operator does not work directly on jmp or rjmp
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-18 18:37 UTC by mschulze
Modified: 2012-02-02 15:14 UTC (History)
2 users (show)

See Also:
Host:
Target: avr-*-*
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mschulze 2010-10-18 18:37:48 UTC
The following code compiled with avr-gcc 4.5 results in an assembler file that gas is not able translate correctly.

void function() {}

int main(void) {
    asm volatile (
        "rjmp %[Function]\n"
        :
        : [Function] "i" (function)
    );
}

The rjmp could be also a jmp, call or something similar. The compiler translates this to

rjmp gs(_Z8functionv)

which is in my eyes correct. However, this line is rejected by gas with the message

/tmp/cc6RG14B.s: Assembler messages:
/tmp/cc6RG14B.s:39: Error: garbage at end of line

Maybe it is a bug in the parser component of gas and the bug may be related to Bug #11102.
Comment 1 Georg-Johann Lay 2012-01-29 18:29:31 UTC
(In reply to comment #0)
> The following code compiled with avr-gcc 4.5 results in an assembler file that
> gas is not able translate correctly.
> 
> void function() {}
> 
> int main(void) {
>     asm volatile (
>         "rjmp %[Function]\n"
>         :
>         : [Function] "i" (function)
>     );
> }
> 
> The rjmp could be also a jmp, call or something similar. The compiler
> translates this to
> 
> rjmp gs(_Z8functionv)

A gs() makes no sense here. Write "rjmp %x[Function]"
Comment 2 mschulze 2012-02-02 09:13:24 UTC
(In reply to comment #1)
> A gs() makes no sense here. Write "rjmp %x[Function]"
Yes, you are right. The %x does what I had in mind. Where is this %x modifier documented. I could not find it. Are there other/further modifiers with special meanings?
Comment 3 Georg-Johann Lay 2012-02-02 10:58:54 UTC
The modifiers are described at top of GCC's AVR machine description file located at

./gcc/config/avr/avr.md
http://gcc.gnu.org/viewcvs/trunk/gcc/config/avr/avr.md?content-type=text%2Fplain&view=co

The function to print assembler code template is

./gcc/config/avr/avr.c:avr_print_operand()
./gcc/final.c:output_asm_insn()

The first is avr-specific output like %A and the second is machine independent like %n.
Comment 4 mschulze 2012-02-02 15:14:12 UTC
Aha, thank you. Apropos, that is the reason why I had not find it, because I looked only in the documentation of the avr part. Maybe such information should be even integrated in the documentation or at least giving a note as a pointer to that file.