Revert "[Object] .bss sections have no content. PR15005."
authorMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 21 Jan 2013 08:13:04 +0000 (08:13 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 21 Jan 2013 08:13:04 +0000 (08:13 +0000)
This reverts commit r173007.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173012 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/ELF.h

index 5409fc3ae59da0b36a4903b250599f008c88d9bc..136fdf5e5e78146f759d8c304d95f9b51b148a93 100644 (file)
@@ -1260,18 +1260,16 @@ template<class ELFT>
 error_code ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
                                                    StringRef &Result) const {
   const Elf_Shdr *sec = reinterpret_cast<const Elf_Shdr *>(Sec.p);
-  return getSectionContents(sec, Result);
+  const char *start = (const char*)base() + sec->sh_offset;
+  Result = StringRef(start, sec->sh_size);
+  return object_error::success;
 }
 
 template<class ELFT>
 error_code ELFObjectFile<ELFT>::getSectionContents(const Elf_Shdr *Sec,
                                                    StringRef &Result) const {
-  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);
-  }
+  const char *start = (const char*)base() + Sec->sh_offset;
+  Result = StringRef(start, Sec->sh_size);
   return object_error::success;
 }