Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer your first question, of course it contains your program's instructions: you can only execute what you can access. To get at the address of your instructions, you can take the address of a function and start printing from there. You can then use a library like <a href="http://udis86.sourceforge.net/" rel="nofollow">udis86</a> to disassemble them. Note however, that your compiler isn't required to order the functions in any specific way, so starting at <code>main</code> and reading from there isn't guaranteed to get everything, might trample on un-allocated memory.</p> <p>To get at the entire instruction memory range (you're looking for the <code>.text</code> segment), you can look up the address+size from your operating system (In Linux, that info will be in <code>/proc/[pid]/maps</code>, in OS X you can either use <code>vmmap</code> or ask the kernel via the <code>mach_vm_region()</code> kernel trap), and then just read the memory directly. You can also use <code>nm</code> to dump the symbols of your program, isolate all that point to the <code>.text</code> segment (They should be marked with <code>T</code> in <code>nm</code> output) and dump those. This is not a good method, since you'd have to disassemble everything to determine where they end in the case there's padding between them.</p> <p>All the mapped memory is accessible, but not all of it will be writeable (The <code>.text</code> segment wouldn't be). One thing to keep in mind, the addresses will probably not be stable invocation to invocation if your operating system implements ASLR.</p> <p>To address your second question, yes you can print your own stack and symbolicate it with the help of third-party libraries, but not the way you're trying to do it. Stack typically grows <em>down</em> (i.e. Starts at a high address and moves towards lower addresses. As an exercise to the reader, disassemble one of your functions via <code>gdb</code> or another disassembler and look how memory on the stack gets allocated during your function prolog), so your for-loop will never run as <code>BASE</code> will probably always be larger than the address of <code>sentinel</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload