www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16702] New: DMD emit PIC relocation when it isn't

https://issues.dlang.org/show_bug.cgi?id=16702

          Issue ID: 16702
           Summary: DMD emit PIC relocation when it isn't appropriate,
                    program won't link.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: deadalnix gmail.com

$ dmd -c -ofobj/libd.o allmyfiles.d -m64 -w -debug -g -unittest -Ilibd/src
$ ar rcs lib/libd.a obj/libd.o
$ gcc -o bin/sdc obj/driver.o -m64  -Llib -lsdc -ld-llvm -ld -lphobos2
`llvm-config-3.9 --ldflags` `llvm-config-3.9 --libs` `llvm-config-3.9
--system-libs` -fuse-ld=gold -lstdc++ -export-dynamic

And I get many relocation error. Nothing is PIC in there, all is statically
linked.

I get a ton of

relocation R_X86_64_PC32 against symbol «
_D6object8opEqualsFxC6ObjectxC6ObjectZb » can't be used when making shared
object;recompile with -fPIC

$ readelf --relocs obj/libd.o | egrep '(GOT|PLT|JU?MP_SLOT)'
00000000001c  32af00000016 R_X86_64_GOTTPOFF 0000000000000000
_D4util9condition59__T - 4
00000000001c  32af00000016 R_X86_64_GOTTPOFF 0000000000000000
_D4util9condition59__T - 4
000000000038  32af00000016 R_X86_64_GOTTPOFF 0000000000000000
_D4util9condition59__T - 4
00000000006b  32af00000016 R_X86_64_GOTTPOFF 0000000000000000
_D4util9condition59__T - 4
00000000001c  32af00000016 R_X86_64_GOTTPOFF 0000000000000000
_D4util9condition59__T - 4
000000000038  32af00000016 R_X86_64_GOTTPOFF 0000000000000000
_D4util9condition59__T - 4
00000000006b  32af00000016 R_X86_64_GOTTPOFF 0000000000000000
_D4util9condition59__T - 4
000000000028  4b4b00000004 R_X86_64_PLT32    0000000000000000 _d_dso_registry -
4

This seems to be the offending relocations (or is it ?).

--
Nov 18 2016