[LLVMdev] gcc bug?..segfault problem with getElfArchType.

Sid Manning sidneym at codeaurora.org
Sat Jun 30 17:40:36 PDT 2012


On 06/30/2012 07:16 PM, Michael Spencer wrote:
> On Sat, Jun 30, 2012 at 7:58 AM, Sid Manning<sidneym at codeaurora.org>  wrote:
>>
>> I've been debugging a segfault issue with the elfreader and I would like to
>> point out something that I have noticed.
>>
>> ELF.h declares an inline function, getElfArchType (MemoryBuffer *Object).
>>   When this function is called from ObjectFile::createELFObjectFile the
>> pointer to Object was getting corrupted.  The only thing that distinguished
>> this pointer was that it was declared as a unique_ptr.  The flow from when
>> it was created to getElfArchType is pretty direct.
>>
>> The segfault only happens only at optimization level -O0.
>> The segfault doesn't happen if getElfArchType is declared as, "static
>> inline"
>
> Is this occurring with ELF.h in lld? If so this sounds like your
> compiling llvm and lld with different standard libraries and because
> -O0 doesn't inline, the linkonce linkage is picking the wrong one.

Yes, this is happening with ELF.h in lld; so that may be what is 
happening.  I'm testing ReaderELF.h with a version of lld-core that 
reads objects rather than YAML.

What is the fix, build everything with std=c++0x?

Thanks,




More information about the llvm-dev mailing list