<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 - AArch64 ifunc broken: can't create dynamic relocation R_AARCH64_ADR_GOT_PAGE"
   href="https://bugs.llvm.org/show_bug.cgi?id=40250">40250</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AArch64 ifunc broken: can't create dynamic relocation R_AARCH64_ADR_GOT_PAGE
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </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>ELF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>eugeni.stepanov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre># cat 1.cc
static void fff_impl() {}

extern "C"
void *fff_resolver() {
  return (void *)&fff_impl;
}

__attribute__((ifunc("fff_resolver")))
void fff();

int use() {
  long z = reinterpret_cast<long>(&fff);
  if (z & 0xa)
    return true;
  else
    return false;
}

# bin/clang++  ../llvm-project/1.cc -target aarch64-linux-android -fPIC 
-shared -fuse-ld=lld -B ~/build/android-ndk-r18b/standalone-arm64-api24/
--sysroot ~/build/android-ndk-r18b/standalone-arm64-api24/sysroot/
-stdlib=libstdc++

ld.lld: error: can't create dynamic relocation R_AARCH64_ADR_GOT_PAGE against
symbol: fff() in readonly segment; recompile object files with -fPIC or pass
'-Wl,-z,notext' to allow text relocations in the output
<span class="quote">>>> defined in /tmp/1-c41c9b.o
>>> referenced by 1.cc
>>>               /tmp/1-c41c9b.o:(use())</span >

ld.lld: error: can't create dynamic relocation R_AARCH64_LD64_GOT_LO12_NC
against symbol: fff() in readonly segment; recompile object files with -fPIC or
pass '-Wl,-z,notext' to allow text relocations in the output
<span class="quote">>>> defined in /tmp/1-c41c9b.o
>>> referenced by 1.cc
>>>               /tmp/1-c41c9b.o:(use())</span >
clang-8: error: linker command failed with exit code 1 (use -v to see
invocation)</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>