<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/97649>97649</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            AddesssSanitizer cannot intercept stat when linking against glibc
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ccotter
      </td>
    </tr>
</table>

<pre>
    [`stat`, `fstat`, and a few others are provided as static symbols](https://stackoverflow.com/questions/66701091/what-is-the-purpose-of-libc-nonshared-a) on glibc based builds, rather than in the libc shared object. This means AddressSanitizer's interceptor cannot intercept `stat`. E.g., I'd expect for https://godbolt.org/z/EMcxfh8qn to bail out upon `stat` being passed a freed pointer, but the program does not crash since `stat` is statically linked. `-static-libasan` does not change the situation.

Are there are any techniques to get `stat` and friends to be intercepted properly when linking against glibc (or any other toolchains/libraries that link against a static `stat`? If not, what can we do to improve this situation?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U82S4yYQfhp86ZJKxj-SDjo4mVXVHnJKXqCBliCLQUuj8XqfPoU8EztJVS52CZru76-R2c2BaBCnX8TpbYdrtjENWsecKe1UNPft6txwxizOjZC_gjg308snBgMIE90gZkuJARPBkuK7M2QAGUqt08D3q4qexelNyM7mvLA4XIQchRw5o_4W3ylNPt5qHa9Cjt9X4uxiYCHH87lt9k2_F3K8WcyV4ypbqpY1LZGpilPlndJViIEtJjIVCtlDDDCXc1DIZECtzhsuiBMWoJAtBnABsiXY6h6PIao_Seca_rCO4UoYGC7GJGL-HYPL7iclIVsGFzIlTUuOCTSGEPPzCJ6S1fClnusy96uQrQH6sZDOMMUE_1RhjkZFn-uYZiHHn0KOX37TPybbfQ-QIyh0HuKaYV1ieOkPilyYYUEuLBGmRGRgiRuWMlateeO4pDgnvIKJxFDQ6oRsgV3Q9NrPfVqG3t_Bu_CNTF0KqsdxERsZQ6l99rIYZtrmsMsrFutq0byJ5vL4vaTtNtGWDwx3yKRtcMXnQm-mV9G2VE3JUTDbraKntoVdigslf4ebpbBBLBLgjC5w_nBdyC6mbVB82B2j17ZUCDl6pxImV0ZbzFuHv5_jZ2JfYn8Y4etUiBZBSwaL43AjMLHAc9cS-EKwiPfJXxzGnRkOpj_0uKNh38qmOZ7a02FnB9TNvj2avlF66vTpRH3XqQYn2U1HUu155wbZyGPTNgcpZb8_1ERaS3XsJ01Gdh2JY0NXdL72_v1aQrNzzCsNfXs-9juPijxvyytloBtsl0LKsuZpKG8qtc4sjo13nPnZJbvsabgYQ_yS-P8mvEjzP_rv1uSHfwXcZbuqj_0u8z7-qiXFsnJCjhvKYtCDxfsg_woAAP__qUmSCw">