[LLVMdev] -fPIC troubles on Linux x86 (32 bit)

Anton Korobeynikov anton at korobeynikov.info
Tue May 19 06:03:46 PDT 2009


Hello, Everyone

> Note that -fPIC is *not* required to build shared libraries on 32 bit
> x86, in fact AFAICT it's recommended to *not* use -fPIC there. The
> workaround is obvious: we just tell users to build LLVM with
> --disable-pic on x86 systems (and to avoid broken binary x86 packages
> like the one in Jaunty).
The problem is pretty easy: nobody cared about loading GOT pointer to
ebx before doing a call via PLT. The initial patch for this was x86-64
only (and I explicitly mentioned that it won't work on x86-32 due to
this issue). Unfortunately, it was commited as-is and later when PIC
was enabled by default this subtle bug appeared...

The proper solution will be to conditionalize for x86-32 linux and
assemble a proper call sequence via PLT.

-- 
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University



More information about the llvm-dev mailing list