<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - -fstack-protector fails to link on powerpc64le linux"
   href="https://llvm.org/bugs/show_bug.cgi?id=26226">26226</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-fstack-protector fails to link on powerpc64le linux
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: PowerPC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>timshen91@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Example:
  // clang++ -target powerpc64le-unknown-linux-gnu -fstack-protector a.cc
  int main() {
    char arr[2048];
    arr[2048+15] = 0;

    return 0;
  }

Linker complains undefined reference to `__stack_chk_guard'.

In fact, glibc stores stack_guard not as a global/TLS variable, but a data
member in TCB:
<a href="https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/nptl/tls.h;h=0e889bc122c9bf91bae1adf43977e9e04c1e5595;hb=HEAD#l99">https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/nptl/tls.h;h=0e889bc122c9bf91bae1adf43977e9e04c1e5595;hb=HEAD#l99</a>

x86 suffered from the same issue, and then was fixed by:
<a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20100705/103635.html">http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20100705/103635.html</a>

The fix specifies an address space (which finally turns into fs/gs access) and
hard code the offset to indicate the location of the stack guard.

How do we fix this? Do we use the same address space trick?

Thanks!</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>