<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - AddressSanitizer globals instrumentation causes ELF info to change size of symbol"
   href="https://bugs.llvm.org/show_bug.cgi?id=46300">46300</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AddressSanitizer globals instrumentation causes ELF info to change size of symbol
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>asan
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>elver@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When instrumenting globals, ASan adds redzones by replacing the globals with a
new one that has the redzones added to them. LLVM then, correctly, coveys this
information as-is and the global symbol will show up with the new size in ELF
(and likely other binary formats) symbol information.

This may cause problems for programs that somehow scan other binaries' symbol
information and rely on the usable (without redzone) size to be presented only.

This was first caught in: <a href="https://github.com/ClangBuiltLinux/linux/issues/1045">https://github.com/ClangBuiltLinux/linux/issues/1045</a>

To fix, we need to ensure that global variables' symbol information will show
up in ELF symbol tables like they would without ASan instrumentation, i.e.
hiding the fact that there is a redzone.

Evgenii Stepanov suggests:

<span class="quote">> target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-linux-gnu"

> @x_ = private global i64 0, align 8
> @y_ = private global i64 0, align 8

> @x = dso_local alias i32, bitcast (i64* @y_ to i32*)
> module asm ".size x, 4"
> @y = dso_local alias i32, bitcast (i64* @y_ to i32*)
> module asm ".size y, 4"

> Alternatively, we could build a way to communicate the desired symbol size to the MC layer. It could use metadata, or maybe we could even make aliases emit .size directives unconditionally.</span ></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>