<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.3826.2400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face="Times New Roman" size=2>Hi,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" size=2>One more thing I just realized for the
method Chris mentioned.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" size=2>>Actually that's not true. You
can make instructions with an asmstring of:<BR>><BR>> ".byte
123\n .byte 56\n .byte 86" and those bytes will get emitted to <BR>>the code
stream.<BR></FONT></DIV>
<DIV><FONT face="Times New Roman" size=2>It seems to work on generating binary
file since it uses asmstring, right?</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=2>There are two steps related with binary
file operation,</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=2>1) opt -load passname < *.bc >
*.bc which is the first one.</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2>2) the second one is 'as' or
'gcc' </FONT></DIV>
<DIV><FONT face="Times New Roman" size=2> as -o *.o
*.s</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2> gcc -c *.s -o
*.o</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2> </FONT></DIV>
<DIV><FONT face="Times New Roman" size=2>Is it true the method you mention
should work on the first one?</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=2>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</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=2>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).</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" size=2>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.
</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" size=2>Anyway, I do appreciate if you can give
me some hint about how to emit asmstring to code</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" size=2>Thanks</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" size=2></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=2> </DIV></FONT>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<DIV style="FONT: 9pt 宋体">----- Original Message ----- </DIV>
<DIV style="BACKGROUND: #e4e4e4; FONT: 9pt 宋体; font-color: black"><B>From:</B>
<A href="mailto:qiuyu@ucla.edu" title=qiuyu@ucla.edu>Qiuyu Zhang</A> </DIV>
<DIV style="FONT: 9pt 宋体"><B>To:</B> <A href="mailto:llvmdev@cs.uiuc.edu"
title=llvmdev@cs.uiuc.edu>llvmdev@cs.uiuc.edu</A> </DIV>
<DIV style="FONT: 9pt 宋体"><B>Sent:</B> Wednesday, May 11, 2005 7:32 PM</DIV>
<DIV style="FONT: 9pt 宋体"><B>Subject:</B> RE:RE: Question about inserting
instructions</DIV>
<DIV><BR></DIV>
<DIV><FONT face="Times New Roman" size=2>Hi,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Times New Roman" size=2>Thanks again.</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=2>>>> during step 2, we read
*.bc code and find dummy BB and put some<BR>>>> meaningless
machinecode, here, we cannot put some illegal machince<BR>>>> code,
otherwise, step 3 goes to fail.<BR>>><BR>>> Yes, you are correct
-- if you want to create illegal code you need to<BR>>> not use system
as. What you need is the ability for llc to create<BR>>> object
files with native code directly, without using the system<BR>>>
assembler. I think someone is working on it, but I'm not sure as to
the<BR>>> status. Otherwise, you will just have some random
one-byte<BR>>> instructions.<BR>><BR>>Actually that's not
true. You can make instructions with an asmstring
of:<BR>><BR>> ".byte 123\n .byte 56\n .byte 86" and those
bytes will get emitted to <BR>>the code stream.<BR></FONT></DIV>
<DIV><FONT face="Times New Roman" size=2>Yes, you are right. The way is like
buffer overflow code in which the instructions exist as asm string in
memory</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2>\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?</FONT></DIV>
<DIV><FONT face="Times New Roman" size=2></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=2>CodeEmitGen.cpp
MachineCodeEmitter.cpp ... which one is response for it? </FONT></DIV>
<DIV><FONT face="Times New Roman" size=2></FONT> </DIV>
<DIV><FONT face="Times New Roman" size=2>Thanks.</FONT></DIV>
<DIV><FONT face="Times New Roman"
size=2>Qiuyu<BR></DIV></BLOCKQUOTE></FONT></BODY></HTML>