[cfe-dev] LLVM EH and PIC

Bill Wendling wendling at apple.com
Fri Mar 12 12:53:11 PST 2010


On Jan 24, 2010, at 10:40 AM, David Chisnall wrote:

> Hi all,
> 
> At the moment, clang is generating code that crashes in the unwind library if you use the GNU runtime and use -fPIC.  The problem is that the relevant entry in the type table looks like this:
> 
> 	.long	.L.str
> 
> Where .L.str is defined elsewhere as:
> 
> .L.str:
>    .asciz  "Object"
> 
> This is fine in non-PIC code, but when the EH personality function loads this value after relocation has taken place, it gets the offset within the module, rather than the real address, dereferences a random bit of memory, and crashes.
> 
> I think this is an LLVM bug, and it should be generating PIC-aware code for pointers passed to llvm_eh_selector(), but possibly I am doing something wrong in clang.  Are you meant to do anything magic to make the pointers that you pass to llvm_eh_selector() PIC-aware?  The code works if I modify the generated assembly and changing that line to:
> 
> 	.long	.L.str-.
> 
I don't know if any one has answered this yet...

It looks like you may have a conflict between absolute pointers and indirect pointers in PIC mode. Do you have a .bc file that shows the problem? It's quite possibly an LLVM problem, because that's the code that determines what the encoding of pointers in the LSDA etc. are.

-bw





More information about the cfe-dev mailing list