[llvm-commits] [llvm] r141774 - /llvm/trunk/lib/Object/ELFObjectFile.cpp
Nick Lewycky
nlewycky at google.com
Wed Oct 12 10:23:56 PDT 2011
On 12 October 2011 03:28, NAKAMURA Takumi <geek4civic at gmail.com> wrote:
> Author: chapuni
> Date: Wed Oct 12 05:28:55 2011
> New Revision: 141774
>
> URL: http://llvm.org/viewvc/llvm-project?rev=141774&view=rev
> Log:
> lib/Object/ELFObjectFile.cpp: Fix undefined behavior for
> MC/ELF/many-section.s not to fail (on msvc).
>
> DenseMap::lookup(k) would return "default constructor value" when k was not
> met. It would be useless when value type were POD.
>
Maybe I'm forgetting something important, but I thought that a
default-initialized value was guaranteed to be zero? ie "int a; // random"
vs. "int b = int(); // zero". DenseMap::lookup() should always return zero
here if the value isn't found. Is there a bug in DenseMap instead? (or in
MSVC?)
Besides that, I wish this could be written without doing two lookups into
the DenseMap. :) Anyways, I can try to see if I can do that. Thanks for the
fix!!
Nick
Modified:
> llvm/trunk/lib/Object/ELFObjectFile.cpp
>
> Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=141774&r1=141773&r2=141774&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/ELFObjectFile.cpp Wed Oct 12 05:28:55 2011
> @@ -444,8 +444,11 @@
> const typename ELFObjectFile<target_endianness, is64Bits>::Elf_Shdr *
> ELFObjectFile<target_endianness, is64Bits>
> ::getSection(const Elf_Sym *symb) const {
> - if (symb->st_shndx == ELF::SHN_XINDEX)
> + if (symb->st_shndx == ELF::SHN_XINDEX) {
> + if (!ExtendedSymbolTable.count(symb))
> + return 0;
> return getSection(ExtendedSymbolTable.lookup(symb));
> + }
> if (symb->st_shndx >= ELF::SHN_LORESERVE)
> return 0;
> return getSection(symb->st_shndx);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111012/8f8e2b7f/attachment.html>
More information about the llvm-commits
mailing list