tags:

views:

43

answers:

1

I'm generating AT&T-syntax assembly files. I want to encode some data in the generated instruction stream. (I want to embed a register pointer mask that I can lookup using a fixed offset to the PC.)

I can simply use the .byte or .ascii directive and jmp over embedded data:

movq _label6@GOTPCREL(%rip), %rax
jmp _skip0
.ascii "garbage instructions; scares GDB\0"
_skip0:
movq %rax, -8(%r15)

However, this seems a little absurd. Is there a cleaner way to do this? The Intel manuals say there are multi-byte NOP instructions. Is there any way to encode data in a NOP? If so, can I do it using assembly? (I don't want to generate binaries myself.)

Thanks.

+1  A: 

My guess is that it's plausible - http://www.asmpedia.org/index.php?title=NOP

You might be able to use different register values to encode different stuff.

Anon.