I'm working on instrumenting a piece of assembly code and I noted the following interesting phenomena:
The original assembly:
64 .loc 1 22 0 is_stmt 0 discriminator 1
65 cmpl $31, -4(%rbp) #, i
66 jg .L2 #,
Instrumented assembly:
64 .loc 1 22 0 is_stmt 0 discriminator 1
65 cmpl $31, -4(%rbp) #, i
66 addq $15, %r15
67 jg .L2 #,
First, r15
is not used by any other part of the assembly (ensured by gcc --fixed-r15
).
After adding a single addq
, the program hangs (like there is a dead loop). I didn't understand what's the significance with that add
so I tried to put it at other places. Interestingly, I found that whenever it's added after a section with discriminator 1
, then some errors would occur. Any idea? I couldn't fully understand the discriminator
after a reading of this. Will keep reading.
Any idea?