[cfe-dev] LLVM EH and PIC

David Chisnall csdavec at swan.ac.uk
Sun Jan 24 10:40:36 PST 2010


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-.

David

--
This email complies with ISO 3103





More information about the cfe-dev mailing list