This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: LSDA and PIC compilation, getting the wrong pointer


On Fri, Oct 18, 2013 at 11:21 AM, edA-qa mort-ora-y <eda-qa@disemia.com> wrote:
> I'm writing a compiler, using LLVM, that includes exception handling. I
> link the results via gcc (convenient option). If I produce static
> executables all is well, but my LSDA in a shared module (with PIC), is
> incorrect.
>
> I've traced through the libgcc personality function but can't figure out
> where I've gone wrong. My LSDA parser seems valid: static builds work,
> and I do get the correct number of action records, and the type offsets
> seem okay. But the type table is pointing to an invalid location, a
> really small address. It's as though it isn't getting its relocated address.
>
> Does this sound like a common problem? Am I missing something simple,
> like linker flags? Perhaps an init function of some kind must be called
> in the shared library (I define my own init/fini functions).
>
> Platform is GNU/Linux x86_64.
> gcc/ld flags: --eh-frame-hdr --build-id --export-dynamic -shared
>
> Sorry if my question isn't strictly gcc related, but I'm not sure where
> else somebody might know the answer. I also realize it may be very hard
> to assist, since the effect is a combination of my personality code,
> LLVM EH generation, the linker, and gcc unwinding.

What is generating the exception frames?  That is, the data that
appears in the .eh_frame and (possibly) .gcc_except sections?

What you are describing does not sound like a common problem.  That
said, seeing a low number in the LSDA suggests that there is a missing
relocation, and that you are seeing the offset from the start of the
section when you should be seeing an address.

Or, are you sure that you are handling the LSDA encoding correctly?
If you are seeing DW_EH_PE_absptr then you should see an address
there.  But if the LSDA encoding is DW_EH_PE_textrel then you need to
add in the text segment offset yourself.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]