I'm reading through how pointer guard works, and looking at the glibc macro that does it:
# define PTR_MANGLE(var) asm ("xor %%fs:%c2, %0\n" \
"rol $2*" LP_SIZE "+1, %0" \
: "=r" (var) \
: "0" (var), \
"i" (offsetof (tcbhead_t, \
# define PTR_DEMANGLE(var) asm ("ror $2*" LP_SIZE "+1, %0\n" \
"xor %%fs:%c2, %0" \
: "=r" (var) \
: "0" (var), \
"i" (offsetof (tcbhead_t, \
pointer_guard)))
The syntax is a little cryptic so I'm having a hard time understanding how PTR_DEMANGLE
eventually produces assembly code like this:
ror rdx,0x11
xor rdx,QWORD PTR fs:0x30
call rdx
How is string substitution working here?
What is the meaning of :
in this context? (I don't see a conditional assignment?)