[LLVMdev] Re: RE:RE: Question about inserting instructions
Qiuyu Zhang
qiuyu at ucla.edu
Wed May 11 20:24:39 PDT 2005
Hi,
One more thing I just realized for the method Chris mentioned.
>Actually that's not true. You can make instructions with an asmstring of:
>
> ".byte 123\n .byte 56\n .byte 86" and those bytes will get emitted to
>the code stream.
It seems to work on generating binary file since it uses asmstring, right?
There are two steps related with binary file operation,
1) opt -load passname < *.bc > *.bc which is the first one.
2) the second one is 'as' or 'gcc'
as -o *.o *.s
gcc -c *.s -o *.o
Is it true the method you mention should work on the first one?
Another question, when emitting the asmstring to the code stream ( binary code string,right), we need adjust some instruction operation like jmp jne call, for example
jmp/jne 0xxxx ( address of memory or offset). If we put asmstring in code stream, we should adjust the value/offset of such instruction, it makes complicated. So that is why I am trying find a way to insert meaningless code when generating assemble code by llc. ( assemble code generated work on label for those instruction).
Actually, I think I can write a code which read assemble file generated by 'LLC' and find the tag of the dummy BB and put some meanless assemble code like 'push %eax' etc. I am supposed that it should work well. However, I prefer to implement the whole thing within LLVM.
Anyway, I do appreciate if you can give me some hint about how to emit asmstring to code
Thanks
----- Original Message -----
From: Qiuyu Zhang
To: llvmdev at cs.uiuc.edu
Sent: Wednesday, May 11, 2005 7:32 PM
Subject: RE:RE: Question about inserting instructions
Hi,
Thanks again.
>>> during step 2, we read *.bc code and find dummy BB and put some
>>> meaningless machinecode, here, we cannot put some illegal machince
>>> code, otherwise, step 3 goes to fail.
>>
>> Yes, you are correct -- if you want to create illegal code you need to
>> not use system as. What you need is the ability for llc to create
>> object files with native code directly, without using the system
>> assembler. I think someone is working on it, but I'm not sure as to the
>> status. Otherwise, you will just have some random one-byte
>> instructions.
>
>Actually that's not true. You can make instructions with an asmstring of:
>
> ".byte 123\n .byte 56\n .byte 86" and those bytes will get emitted to
>the code stream.
Yes, you are right. The way is like buffer overflow code in which the instructions exist as asm string in memory
\x123\x35\86......However, I have no idea how to make it . Would you like giving me idea? Is there any way I can follow?
CodeEmitGen.cpp MachineCodeEmitter.cpp ... which one is response for it?
Thanks.
Qiuyu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050511/8abbc935/attachment.html>
More information about the llvm-dev
mailing list