<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I generated LLVM bytecode for a "hello world!" program just to get the
basic bytecode structure.  I have a few questions about the global info
module and the global constants module where there have apparently been
changes since 1.4.  I would be happy to collect these differences and
do an edit pass of the bytecode spec once my decoder is fully
up-to-snuff again.  I've put an annotated bytecode file after my
questions to illustrate what I'm trying to sort out about the bytecode.<br>
<br>
1) In the global info module, it looks like an extra bit has been added
to global and function definitions.  I'm just guessing this because it
appears to make the type slot info work out.  What is the extra bit
for?  In this simple example, it appears to always be 1.<br>
<br>
2) There are only two function calls in this little file, and the first
one decodes fine, but the second one appears to have the wrong type
slot information.  Just a guess: is this type slot info maybe always
the actual function type slot minus 1 instead of the slot of the
pointer to the function?<br>
<br>
3) Looks like library dependencies section is empty even though I would
be expecting libc to be here.  Unused?<br>
<br>
4) Looks like constant strings are initialized in the constants section
now, since it looks like this section ID stuff in the globals module is
not used or has changed?  Also, I'm finding my constant string is
definitely in the constants section when I expected to find just a type
slot number.<br>
<br>
5) Again looks like the function pointer type wants to be 0x12 instead
of 0x11 here?<br>
<br>
6) After this my decode of the last few bytes of the constants section
just started to break down.  Any insight you can give me re the meaning
of these last few bytes in the constants module would be appreciated.<br>
<br>
Here's the bytecode file I'm looking at (annotated).  Interesting bits
are marked with five question marks:<br>
<br>
<font face="Courier New, Courier, monospace" size="-1">Signature = llvc0<br>
00000000  6c 6c 76 63 30<br>
<br>
Module block ID = 0x01 and size = 0x0a3<br>
 01 00 00  00 a3 00 00 00<br>
<br>
Format information<br>
 50 = 01010000<br>
             ^ Target is little endian<br>
            ^- Target pointers are 32-bit<br>
           ^-- Target has endianess<br>
          ^--- Target has pointer size<br>
      ^^^^---- Bytecode format 5<br>
<br>
***********************************************************<br>
<br>
Global type pool ID = 0x06 and size = 0x014<br>
 86 02  |llvc0........P..|<br>
00000010  00 00<br>
<br>
Global type pool<br>
<br>
Number of definitions = 7<br>
 07<br>
<br>
0x0d = Pointer to array of sbyte[18]<br>
 10 0e<br>
<br>
0x0e = Array of sbyte[18]<br>
 0f 03 12<br>
<br>
0x0f = Pointer to function int ()<br>
  10 10<br>
<br>
0x10 = Function int ()<br>
 0d 07 00<br>
<br>
0x11 = Pointer to function int ( sbyte*, ... )<br>
 10 13<br>
<br>
0x12 = Pointer to sbyte<br>
 10  |................|<br>
00000020  03<br>
<br>
0x13 = Function int ( sbyte*, ... )<br>
 0d 07 02 12 00<br>
<br>
***********************************************************<br>
<br>
Module globals info ID = 0x05 and size = 0x01e<br>
 c5 03  00 00<br>
<br>
Global definition<br>
 af 03 = 0000001110101111<br>
                        ^ Is a constant<br>
                       ^- Has an initializer<br>
                    ^^^-- Linkage = internal<br>
                   ^----- ????? <--- see question #1<br>
         ^^^^^^^^^^------ Type slot = sbyte[18]<br>
 01 = Value slot number of the initializer <br>
<br>
End of globals<br>
 00<br>
<br>
Function definition<br>
 e1 03  |................| = 0000001111100001<br>
                                         ^^^^ Calling convention = 1<br>
                                        ^---- Internal<br>
                                       ^----- ????? <--- see
question #1<br>
                             ^^^^^^^^^^------ Type slot = int (*)()<br>
<br>
Function definition<br>
00000030  b1 04 = 0000010010110001<br>
                              ^^^^ Calling convention = 1<br>
                             ^---- External<br>
                            ^----- ????? <--- see question #1<br>
                  ^^^^^^^^^^------ Type slot = 0x012 = sbyte*?????
<--- see question #2<br>
<br>
End of functions<br>
 00<br>
<br>
Depends on no libraries????? <--- see question #3<br>
 00<br>
<br>
Target triple = "i686-pc-linux-gnu"<br>
 11 69 36 38  36 2d 70 63 2d 6c 69 6e  |.....i686-pc-lin|<br>
00000040  75 78 2d 67 6e 75<br>
<br>
Section strings for globals: none????? <----- see question #4<br>
 00<br>
<br>
Inline asm block: none<br>
 00<br>
<br>
***********************************************************<br>
<br>
Module constant pool ID = 0x03 and size = 0x01f<br>
  e3 03 00 00<br>
<br>
Module constant pool<br>
<br>
One constant string sbyte[18] = "Hello RKM world!\n" ????? <--- see
question #4<br>
 01 00 0e 48  |ux-gnu.........H|<br>
00000050  65 6c 6c 6f 20 52 4b 4d  20 77 6f 72 6c 64 21 0a  |ello RKM
world!.|<br>
00000060  00<br>
<br>
One constant sbyte*????? <--- see question #5<br>
 01 12 04 1a<br>
<br>
One constant pointer to array of sbyte[18] = NULL????? <--- see
question #6<br>
 01 0d 00<br>
<br>
????? <--- see question #6<br>
  07 00 06<br>
<br>
***********************************************************<br>
<br>
Function definition ID = 0x02 and size = 0x023<br>
 62 04 00 00<br>
<br>
Function definition<br>
 00  |...........b....|<br>
00000070  27 01 00 00 74 11 02 01  01 05 07 00 00 24 02 00 
|'...t........$..|<br>
00000080  00 00 01 0c 00 05 65 6e  74 72 79 01 07 01 03 74 
|......entry....t|<br>
00000090  6d 70<br>
<br>
***********************************************************<br>
<br>
Symbol table ID = 0x04 and size = 0x1a<br>
 44 03 00 00 00 01  11 01 06 70 72 69 6e 74  |mpD........print|<br>
000000a0  66 01 0f 01 04 6d 61 69  6e 01 0d 01 03 73 74 72 
|f....main....str|<br>
000000b0<br>
<br>
</font>
<pre class="moz-signature" cols="72">-- 
Robert Mykland               Voice: (831) 462-6725
Founder/CTO                   Ascenium Corporation
"A new world of computing fulfilling people's lives"</pre>
</body>
</html>