summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-04-03 18:31:19 +0000
committerEric Christopher <echristo@gmail.com>2013-04-03 18:31:19 +0000
commit19d7322170d6d07880055fe1152d6fe17125fb7e (patch)
tree92b055f16df671ba1eff091b2498ed958e41e889 /include
parenteac49f668a5461af4c408b13f328c9e370457200 (diff)
downloadllvm-19d7322170d6d07880055fe1152d6fe17125fb7e.tar.gz
llvm-19d7322170d6d07880055fe1152d6fe17125fb7e.tar.bz2
llvm-19d7322170d6d07880055fe1152d6fe17125fb7e.tar.xz
Implement sectionContainsSymbol for ELF.
Patch by Nico Rieck! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178677 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Object/ELF.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h
index fa75053f0a..719bc08915 100644
--- a/include/llvm/Object/ELF.h
+++ b/include/llvm/Object/ELF.h
@@ -1378,8 +1378,16 @@ template<class ELFT>
error_code ELFObjectFile<ELFT>::sectionContainsSymbol(DataRefImpl Sec,
DataRefImpl Symb,
bool &Result) const {
- // FIXME: Unimplemented.
- Result = false;
+ validateSymbol(Symb);
+
+ const Elf_Shdr *sec = reinterpret_cast<const Elf_Shdr *>(Sec.p);
+ const Elf_Sym *symb = getSymbol(Symb);
+
+ unsigned shndx = symb->st_shndx;
+ bool Reserved = shndx >= ELF::SHN_LORESERVE
+ && shndx <= ELF::SHN_HIRESERVE;
+
+ Result = !Reserved && (sec == getSection(symb->st_shndx));
return object_error::success;
}