[llvm-bugs] [Bug 33243] New: R_386_GOTPC relocations unnecessarily turned into textrels

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 31 00:31:22 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33243

            Bug ID: 33243
           Summary: R_386_GOTPC relocations unnecessarily turned into
                    textrels
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: hi at shiz.me
                CC: llvm-bugs at lists.llvm.org

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!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170531/c6ea7cb2/attachment.html>


More information about the llvm-bugs mailing list