Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since the question is really about those odd labels and data and not really about the code itself, I'm only going to shed some light on them.</p> <p>If an instruction of the program causes an execution error (such as division by 0 or access to an inaccessible memory region or an attempt to execute a privileged instruction), it results in an exception (not a C++ kind of exception, rather an interrupt kind of it) and forces the CPU to execute the appropriate exception handler in the OS kernel. If we were to totally disallow these exceptions, the story would be very short, the OS would simply terminate the program.</p> <p>However, there are advantages of letting programs handle their own exceptions and so the primary exception handler in the OS handler reflects some of exceptions back into the program for handling. For example, a program could attempt to recover from the exception or it could save a meaningful crash report before terminating.</p> <p>In either case, it is useful to know the following:</p> <ul> <li>the function, where the exception has occurred, not just the offending instruction in it</li> <li>the function that called that function, the function that called that one and so on</li> </ul> <p>and possibly (mainly for debugging):</p> <ul> <li>the line of the source code file, from which this instruction was generated</li> <li>the lines where these function calls were made</li> <li>the function parameters</li> </ul> <p>Why do we need to know the call tree?</p> <p>Well, if the program registers its own exception handlers, it usually does it something like the C++ <code>try</code> and <code>catch</code> blocks:</p> <pre><code>fxn() { try { // do something potentially harmful } catch() { // catch and handle attempts to do something harmful } catch() { // catch and handle attempts to do something harmful } } </code></pre> <p>If neither of those <code>catches</code> catches, the exception propagates to the caller of <code>fxn</code> and potentially to the caller of the caller of <code>fxn</code>, until there's a <code>catch</code> that catches the exception or until the default exception handler that simply terminates the program.</p> <p>So, you need to know the code regions that each <code>try</code> covers and you need to know how to get to the next closest <code>try</code> (in the caller of <code>fxn</code>, for example) if the immediate <code>try</code>/<code>catch</code> doesn't catch the exception and it has to bubble up.</p> <p>The ranges for <code>try</code> and locations of <code>catch</code> blocks are easy to encode in a special section of the executable and they are easy to work with (just do a binary search for the offending instruction addresses in those ranges). But figuring out the next outer <code>try</code> block is harder because you may need to find out the return address from the function, where the exception occurred.</p> <p>And you may not always rely on <code>rbp+8</code> pointing to the return address on the stack, because the compiler may optimize the code in such a way that <code>rbp</code> is no longer involved in accessing function parameters and local variables. You can access them through <code>rsp+something</code> as well and save a register and a few instructions, but given the fact that different functions allocate different number of bytes on the stack for the locals and the parameters passed to other functions and adjust <code>rsp</code> differently, just the value of <code>rsp</code> isn't enough to find out the return address and the calling function. <code>rsp</code> can be an arbitrary number of bytes away from where the return address is on the stack.</p> <p>For such scenarios the compiler includes additional information about functions and their stack usage in a dedicated section of the executable. The exception-handling code examines this information and properly unwinds the stack when exceptions have to propagate to the calling functions and their <code>try</code>/<code>catch</code> blocks.</p> <p>So, the data following <code>_main.eh</code> contains that additional information. Note that it explicitly encodes the beginning and the size of <code>main()</code> by referring to <code>Leh_func_begin1</code> and <code>Leh_func_end1-Leh_func_begin1</code>. This piece of info allows the exception-handling code to identify <code>main()'s</code> instructions as <code>main()'s</code>.</p> <p>It also appears that <code>main()</code> isn't very unique and some of its stack/exception info is the same as in other functions and it makes sense to share it between them. And so there's a reference to <code>Leh_frame_common</code>.</p> <p>I can't comment further on the structure of <code>_main.eh</code> and the exact meaning of those constants like <code>144</code> and <code>13</code> as I don't know the format of this data. But generally one doesn't need to know these details unless they are the compiler or the debugger developers.</p> <p>I hope this give you an idea of what those labels and constants are for.</p>
    singulars
    1. This table or related slice is empty.
    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.
    3. 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