How to port this GCC assembly to gdc?
Iain Buclaw
ibuclaw at gdcproject.org
Thu Oct 24 17:01:06 UTC 2019
On Thu, 24 Oct 2019 at 16:50, drug via D.gnu <d.gnu at puremagic.com> wrote:
>
> On 10/24/19 5:41 PM, Iain Buclaw wrote:
> >
> > It looks like this is a top-level inline asslembler declaration? D
> > doesn't support top-level inline assembler, however I think this would
> > be a useful feature to allow.
> >
> > As for the syntax, it's `asm { ... }`
> >
>
> This is in fact DTrace probe generated by using
> ```
> DTRACE_PROBE2(myapp, func_call, a, b);
> ```
> I would like to generate this code by myself without C macros by obvious
> reason. I need ability to insert nop operation (that is trivial) and
> then add a note to specific section with the description of this probe
> (the address of this nop operation first of all and some other information)
>
> But as I understand it is impossible?
You can do the following:
void somefunc()
{
asm {
"990: nop" ~
".pushsection .note.stapsdt,\"?\",\"note\"" ~
".balign 4" ~
".4byte 992f-991f, 994f-993f, 3" ~
"991: .asciz \"stapsdt\"" ~
"992: .balign 4" ~
"993: .8byte 990b" ~
".8byte _.stapsdt.base" ~
".8byte 0" ~
".asciz \"myapp\"" ~
".asciz \"func_call\"" ~
".asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2]\"" ~
"994: .balign 4" ~
".popsection\n"
:: [_SDT_S1] "n" (4),
[_SDT_A1] "nor" ((a)),
[_SDT_S2] "n" (4),
[_SDT_A2] "nor" ((b))
}
}
The instruction string can be generated at CTFE.
--
Iain
More information about the D.gnu
mailing list