* C++: __asm on static method
@ 2019-08-01 9:45 Georg-Johann Lay
0 siblings, 0 replies; only message in thread
From: Georg-Johann Lay @ 2019-08-01 9:45 UTC (permalink / raw)
To: gcc-help
Hi,
suppose the following GNU C++ code:
class C
{
__attribute((used))
static void method() __asm ("__vector_1")
{
__asm ("; method1");
}
static void method2() __asm ("__vector_2");
};
void C::method2()
{
__asm ("; method2");
}
Similar code is used on bare metal when you want an interrupt
service routine (ISR) be defined as a class method that can
access private (static) members.
The generated assembly for method2 is as expected
(here with avr-g++ v8):
.text
.global __vector_2
.type __vector_2, @function
__vector_2:
/* #APP */
; method2
/* #NOAPP */
ret
The ISR must have this specific name to be recognized as
interrupt vector and to be inserted into the vector table.
method1 however reads as follows:
.text
.section .text._ZN1C7method1Ev,"axG",@progbits,_ZN1C7method1Ev,comdat
.weak _ZN1C7method1Ev
.type _ZN1C7method1Ev, @function
_ZN1C7method1Ev:
/* #APP */
; method1
/* #NOAPP */
ret
As far as I understand the semantics of __asm, the assembler
name of method1 should be __vector_1. For the comdat group
name, both __vector_1 and _ZN1C7method1Ev should be okay
provided it is consistent across units.
IMO method1 is not compiled correctly; it would be pointless
to specify __asm if it was supposed to have to effect.
Presumably, this is some glitch / bug in varasm.c?
Thanks,
Johann
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-08-01 9:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-01 9:45 C++: __asm on static method Georg-Johann Lay
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).