<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 25, 2015 at 3:19 PM, Wim Lewis <span dir="ltr"><<a href="mailto:wiml@omnigroup.com" target="_blank">wiml@omnigroup.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><div><br></div></span><div>FYI, I submitted a patch a few years ago to do this for many of the x86-32 assembly files. The perlasm preprocessor already tries to track the stack offset, which means that a lot of those .cfi directives can be generated automatically, without requiring the programmer to keep track of them.</div><div><br></div><div>The patches are here:</div><div>   <a href="http://rt.openssl.org/Ticket/Display.html?id=2562" target="_blank">http://rt.openssl.org/Ticket/Display.html?id=2562</a></div><div><br></div><div>As you point out, this is pretty useful to allow profiling and/or debugging code that spends a lot of its time in OpenSSL.</div></div></div></blockquote><div><br></div><div>That's an interesting approach, much more maintainable going forward.  As you noted in your bug report, there is some code in the sha1 implementation that does something like this:</div><div><br></div><div>    mov %rsp,%rax</div><div>    and $-64,%rsp</div><div>    mov %rax,64(%rsp)</div><div>    [more code that trashes rax]</div><div><br></div><div>Then, in the epilogue it does something like this:<br></div><div>    mov 64(%rsp),%rsi</div><div>    [restore callee-saved variables]</div><div>    mov %rsi,%rsp</div><div><br></div><div>This is done to align %rsp to a 64 byte boundary, and the original %rsp is stored on the stack; so the only way to get the actual frame pointer is to read 64(%rsp) and add an offset to that.  I managed to do that by inserting a raw DWARF expression.  It's not clear to me that the perlasm preprocessor could (or should) do this; but perhaps it makes sense to add some directives for the perlasm preprocessor and let it generate the raw DWARF expression.</div><div><br></div><div>If I understand correctly, your patch was not folded in.  Do you recall why?</div><div><br></div><div>    -Matt</div><div><br></div></div></div></div>