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

    <tr>
        <th>Summary</th>
        <td>
            [ASAN] [RFC] For Asan instrumented global, emit two symbols, one with actual size and other with instrumented size.
        </td>
    </tr>

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

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

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

<pre>
    Asan instrumented global variable size includes actual size plus redzone size. Symbol table entry for the instrumented global would report the padded size (actual size+ redzone size) but has the name of actual global variable.

AMD language runtimes provide queries for the size of device global symbols and functions to copy data to and from device global variables. Runtime gets the needed information form the ELF symbol table. So, when it querires the size of device global variable, it gets the padded size rather than actual size.

To fix this, https://github.com/llvm/llvm-project/pull/66666 was created, where actual size of global was emitted for the symbol. But @hctim pointed out that the approach would have issue with relinkers.

**As a solution, we are proposing the below approach in #70166** 

- Identify instrumented global variable by attaching "asan_instrumented" attribute to the global. (https://github.com/llvm/llvm-project/pull/68865 under review).

- For the instrumented global, emit two symbols at the same offset but with different sizes. One with actual global variable name and actual size. Other symbol will have different name and size of instrumented variable.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVFmP2zYQ_jX0yyCCRFla-0EP3mwNFGgbINv3YiSOLDYUqfKw6vz6gpTPxWaBxjB8iJzrOwadkwdN1LDqmVUvKwx-MLZx37qnVWvEqdk51CC18zaMpD0JOCjTooIjWomtInDyO4HUnQqCHGDnA6rl4aSCA0viu9HLtQxeT2NrFPgUSdrbE_TGgh_o3SKzCUqApclYny5NKASJJT3jm7tqjD8_1GJ8C23wMKBLkRpHAtNfGnwzRcbyF5bvls_d7y-gUB8CHghs0F6O5GCy5igFwT-BrCR37Tv1YnoQdJQdXRK7NKgD1AL6oDsvjXbgDXRmOoFAj_FPOrVmfBN86cpl8HUpDwfy5zmII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