[Issue 3226] New: -fPIC flag doesn't seem to work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 4 07:40:45 PDT 2009


           Summary: -fPIC flag doesn't seem to work
           Product: D
           Version: 1.046
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Keywords: link-failure
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: snake.scaly at gmail.com

Here is a test case:

$ cat test.d
module test; // file "test.d"
export int testMe() { return 1; }
export class Test
    private int n;
    this(int i) { n = i; }
    int get() { return n; }
$ dmd -c -fPIC test.d
$ gcc -shared test.o -o libtest.so
warning: creating a DT_TEXTREL in object.

Note the warning above.  This is how GCC complains about relocations found in
an object file.  Linking with this shared object consequently fails:

$ cat prog.d
module prog; // file "prog.d"
import std.stdio;
import test;
void main()
   writefln("testMe: %d", testMe());
   writefln("Test class: %d", (new Test(3)).get());
$ dmd prog.d -L-L. -L-ltest
dynamic variable `_D4test4Test7__ClassZ' is zero size
prog.o(.text._Dmain+0x22): unresolvable R_386_32 relocation against symbol
final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

The tools used:

$ dmd | head -n1
Digital Mars D Compiler v1.046
$ gcc --version | head -n1
gcc (Gentoo 4.3.3-r2 p1.1, pie-10.1.5) 4.3.3
$ uname -a
Linux mordor-gen #1 PREEMPT Sat May 24 22:27:30 UTC 2008
i686 Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz GenuineIntel GNU/Linux

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

More information about the Digitalmars-d-bugs mailing list