On 12 October 2011 03:28, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com">geek4civic@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Author: chapuni<br>
Date: Wed Oct 12 05:28:55 2011<br>
New Revision: 141774<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=141774&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=141774&view=rev</a><br>
Log:<br>
lib/Object/ELFObjectFile.cpp: Fix undefined behavior for MC/ELF/many-section.s not to fail (on msvc).<br>
<br>
DenseMap::lookup(k) would return "default constructor value" when k was not met. It would be useless when value type were POD.<br></blockquote><div><br></div><div>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?)</div>

<div><br></div><div>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!!</div><div><br></div><div>Nick</div><div><br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Modified:<br>
    llvm/trunk/lib/Object/ELFObjectFile.cpp<br>
<br>
Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=141774&r1=141773&r2=141774&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=141774&r1=141773&r2=141774&view=diff</a><br>


==============================================================================<br>
--- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)<br>
+++ llvm/trunk/lib/Object/ELFObjectFile.cpp Wed Oct 12 05:28:55 2011<br>
@@ -444,8 +444,11 @@<br>
 const typename ELFObjectFile<target_endianness, is64Bits>::Elf_Shdr *<br>
 ELFObjectFile<target_endianness, is64Bits><br>
                              ::getSection(const Elf_Sym *symb) const {<br>
-  if (symb->st_shndx == ELF::SHN_XINDEX)<br>
+  if (symb->st_shndx == ELF::SHN_XINDEX) {<br>
+    if (!ExtendedSymbolTable.count(symb))<br>
+      return 0;<br>
     return getSection(ExtendedSymbolTable.lookup(symb));<br>
+  }<br>
   if (symb->st_shndx >= ELF::SHN_LORESERVE)<br>
     return 0;<br>
   return getSection(symb->st_shndx);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br>