[llvm-commits] [llvm] r173007 - /llvm/trunk/include/llvm/Object/ELF.h
Kaylor, Andrew
andrew.kaylor at intel.com
Mon Jan 21 12:52:21 PST 2013
You probably already found this, but it looks like this code in RuntimeDyld.cpp is probably the cause:
Check(i->getFileOffset(FileOffset));
Check(i->getSection(si));
if (si == obj->end_sections()) continue;
Check(si->getContents(SectionData));
Check(si->isText(IsCode));
const uint8_t* SymPtr = (const uint8_t*)InputBuffer->getBufferStart() +
(uintptr_t)FileOffset;
uintptr_t SectOffset = (uintptr_t)(SymPtr -
(const uint8_t*)SectionData.begin());
This code is trying to calculate the offset into the section where the symbol belongs. For ELF objects I think we could avoid this by using SymbolRef::getValue to grab the symbol's section offset directly, but I'm not sure how that would work for other object formats.
-Andy
-----Original Message-----
From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Michael Spencer
Sent: Sunday, January 20, 2013 11:58 PM
To: llvm-commits
Subject: Re: [llvm-commits] [llvm] r173007 - /llvm/trunk/include/llvm/Object/ELF.h
On Sun, Jan 20, 2013 at 10:46 PM, Michael J. Spencer <bigcheesegs at gmail.com> wrote:
> Author: mspencer
> Date: Mon Jan 21 00:46:11 2013
> New Revision: 173007
>
> URL: http://llvm.org/viewvc/llvm-project?rev=173007&view=rev
> Log:
> [Object] .bss sections have no content. PR15005.
>
> Modified:
> llvm/trunk/include/llvm/Object/ELF.h
>
> Modified: llvm/trunk/include/llvm/Object/ELF.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF
> .h?rev=173007&r1=173006&r2=173007&view=diff
> ======================================================================
> ========
> --- llvm/trunk/include/llvm/Object/ELF.h (original)
> +++ llvm/trunk/include/llvm/Object/ELF.h Mon Jan 21 00:46:11 2013
> @@ -1260,16 +1260,18 @@
> error_code ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
> StringRef &Result) const {
> const Elf_Shdr *sec = reinterpret_cast<const Elf_Shdr *>(Sec.p);
> - const char *start = (const char*)base() + sec->sh_offset;
> - Result = StringRef(start, sec->sh_size);
> - return object_error::success;
> + return getSectionContents(sec, Result);
> }
>
> template<class ELFT>
> error_code ELFObjectFile<ELFT>::getSectionContents(const Elf_Shdr *Sec,
> StringRef &Result)
> const {
> - const char *start = (const char*)base() + Sec->sh_offset;
> - Result = StringRef(start, Sec->sh_size);
> + if (Sec->sh_type == ELF::SHT_NOBITS)
> + Result = StringRef();
> + else {
> + const char *start = (const char*)base() + Sec->sh_offset;
> + Result = StringRef(start, Sec->sh_size); }
> return object_error::success;
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
This broke some of the JIT tests. I'm working on figuring out why.
- Michael Spencer
_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list