[llvm] r178677 - Implement sectionContainsSymbol for ELF.
Eric Christopher
echristo at gmail.com
Wed Apr 3 11:31:19 PDT 2013
Author: echristo
Date: Wed Apr 3 13:31:19 2013
New Revision: 178677
URL: http://llvm.org/viewvc/llvm-project?rev=178677&view=rev
Log:
Implement sectionContainsSymbol for ELF.
Patch by Nico Rieck!
Modified:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/test/Object/Mips/feature.test
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=178677&r1=178676&r2=178677&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Wed Apr 3 13:31:19 2013
@@ -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;
}
Modified: llvm/trunk/test/Object/Mips/feature.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Mips/feature.test?rev=178677&r1=178676&r2=178677&view=diff
==============================================================================
--- llvm/trunk/test/Object/Mips/feature.test (original)
+++ llvm/trunk/test/Object/Mips/feature.test Wed Apr 3 13:31:19 2013
@@ -2,10 +2,12 @@ RUN: llvm-objdump -disassemble -triple m
RUN: | FileCheck %s
CHECK: Disassembly of section .text:
-CHECK: .text:
+CHECK: dext:
CHECK: 0: 08 00 e0 03 jr $ra
CHECK: 4: 43 49 82 7c dext $2, $4, 5, 10
+CHECK: dextu:
CHECK: 8: 08 00 e0 03 jr $ra
CHECK: c: 83 28 82 7c dext $2, $4, 2, 6
+CHECK: dextm:
CHECK: 10: 08 00 e0 03 jr $ra
CHECK: 14: 43 09 82 7c dext $2, $4, 5, 2
More information about the llvm-commits
mailing list