<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 - R_386_GOTPC relocations unnecessarily turned into textrels"
   href="https://bugs.llvm.org/show_bug.cgi?id=33243">33243</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>R_386_GOTPC relocations unnecessarily turned into textrels
          </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>hi@shiz.me
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I've encountered an issue when attempting to cross-compile Go 1.8.1 to i586
using clang and LLD 4.0.0:
it will refuse to process a bunch of R_386_GOTPC unless -z notext (patch
backported from SVN) is specified, at which point it will create .text
relocations.

However, BFD LD and Gold do not seem to have this requirement, and no textrels
are created:

c581a024c2d7:/aports# # BFD ld
c581a024c2d7:/aports# ld --version
GNU ld (GNU Binutils) 2.28
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
c581a024c2d7:/aports# clang -target i586-alpine-linux-musl -resource-dir
~/sysroot-x86/usr/lib/clang/4.0.0 --rtlib=compiler-rt --sysroot ~/sysroot-x86
-m32 -gdwarf-2 -Wl,-z,relro -pie -rdynamic /tmp/nice/go-link-597453838/go.o -o
a.out
c581a024c2d7:/aports# scanelf --textrel a.out
 TYPE   TEXTREL FILE 
ET_DYN    -    a.out 

c581a024c2d7:/aports# # gold
c581a024c2d7:/aports# ld.gold --version
GNU gold (GNU Binutils 2.28) 1.14
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
c581a024c2d7:/aports# clang -fuse-ld=gold -target i586-alpine-linux-musl
-resource-dir ~/sysroot-x86/usr/lib/clang/4.0.0 --rtlib=compiler-rt --sysroot
~/sysroot-x86 -m32 -gdwarf-2 -Wl,-z,relro -pie -rdynamic
/tmp/nice/go-link-597453838/go.o -o a.out
c581a024c2d7:/aports# scanelf --textrel a.out 
 TYPE   TEXTREL FILE 
ET_DYN    -    a.out 

c581a024c2d7:/aports# # lld
c581a024c2d7:/aports# ld.lld --version
LLD 4.0.0 (compatible with GNU linkers)
c581a024c2d7:/aports# clang -fuse-ld=lld -target i586-alpine-linux-musl
-resource-dir ~/sysroot-x86/usr/lib/clang/4.0.0 --rtlib=compiler-rt --sysroot
~/sysroot-x86 -m32 -gdwarf-2 -Wl,-z,relro -pie -rdynamic
/tmp/nice/go-link-597453838/go.o -o a.out
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:47: can't create dynamic
relocation R_386_GOTPC against local symbol in readonly segment defined in
/tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:50: can't create dynamic
relocation R_386_GOTPC against local symbol in readonly segment defined in
/tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:53: can't create dynamic
relocation R_386_GOTPC against local symbol in readonly segment defined in
/tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:56: can't create dynamic
relocation R_386_GOTPC against local symbol in readonly segment defined in
/tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:59: can't create dynamic
relocation R_386_GOTPC against local symbol in readonly segment defined in
/tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:62: can't create dynamic
relocation R_386_GOTPC against local symbol in readonly segment defined in
/tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:96: can't create dynamic
relocation R_386_GOTPC against local symbol in readonly segment defined in
/tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:106: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:118: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:130: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:135: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:140: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:158: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:175: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:178: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:181: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:184: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:187: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:190: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: /usr/lib/go/src/runtime/alg.go:193: can't create
dynamic relocation R_386_GOTPC against local symbol in readonly segment defined
in /tmp/nice/go-link-597453838/go.o
/usr/bin/ld.lld: error: too many errors emitted, stopping now (use
-error-limit=0 to see all errors)
clang-4.0: error: linker command failed with exit code 1 (use -v to see
invocation)

c581a024c2d7:/aports# # lld with -z notext
c581a024c2d7:/aports# clang -target i586-alpine-linux-musl -resource-dir
~/sysroot-x86/usr/lib/clang/4.0.0 --rtlib=compiler-rt --sysroot ~/sysroot-x86
-fuse-ld=lld -m32 -gdwarf-2 -Wl,-z,relro -pie -rdynamic
/tmp/nice/go-link-597453838/go.o -o a.out -Wl,-z,notext
c581a024c2d7:/aports# scanelf --textrel a.out
 TYPE   TEXTREL FILE 
ET_DYN TEXTREL a.out 

I have attached the relevant object file in question, as I'm not entirely sure
how to further debug the matter. If there's anything I can do, please let me
know!</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>