summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2013-01-21 06:46:11 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2013-01-21 06:46:11 +0000
commit07d5617ca88fdc20f4acbaf0d302eeca959ff1b8 (patch)
tree0d93cccc82350112c3ba2ac5738ee81201727658 /include
parentb99bafe36d0c63b9febc7c620cde3663f9f7792f (diff)
downloadllvm-07d5617ca88fdc20f4acbaf0d302eeca959ff1b8.tar.gz
llvm-07d5617ca88fdc20f4acbaf0d302eeca959ff1b8.tar.bz2
llvm-07d5617ca88fdc20f4acbaf0d302eeca959ff1b8.tar.xz
[Object] .bss sections have no content. PR15005.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173007 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Object/ELF.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h
index 136fdf5e5e..5409fc3ae5 100644
--- a/include/llvm/Object/ELF.h
+++ b/include/llvm/Object/ELF.h
@@ -1260,16 +1260,18 @@ template<class ELFT>
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;
}