[LLVMbugs] [Bug 4533] New: relocation problem with shared libraries on x86-64

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Jul 10 19:02:52 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=4533

           Summary: relocation problem with shared libraries on x86-64
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: rafael.espindola at gmail.com, llvmbugs at cs.uiuc.edu


The problem is that the address of a function shows up differently in two
different translation units. One TU is compiled to a shared library with -fPIC,
the other has neither. This works with GCC but not LLVM:

$ g++ -O2 -fPIC x.cc -shared -o x.so
$ g++ -O2 y.cc -o y x.so
$ ./y
y: 0x400570
x: 0x400570

$ llvm-g++ -O2 -fPIC x.cc -shared -o x.so
$ llvm-g++ -O2 y.cc -o y x.so
$ ./y
y: 0x4004c8
x: 0x7f07903b2240

The testcase is two very small files:

x.cc:
  #include <cstdio>

  void trouble() {}

  void func() {
    printf("x: %p\n", trouble);
  }

y.cc:
  #include <cstdio>

  void trouble();
  extern void func();

  int main(void) {
    printf("y: %p\n", trouble);
    func();
  }


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list