From 19d7322170d6d07880055fe1152d6fe17125fb7e Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 3 Apr 2013 18:31:19 +0000 Subject: [PATCH] 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 --- include/llvm/Object/ELF.h | 12 ++++++++++-- test/Object/Mips/feature.test | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index fa75053f0a4..719bc08915d 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -1378,8 +1378,16 @@ template error_code ELFObjectFile::sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const { - // FIXME: Unimplemented. - Result = false; + validateSymbol(Symb); + + const Elf_Shdr *sec = reinterpret_cast(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; } diff --git a/test/Object/Mips/feature.test b/test/Object/Mips/feature.test index e8da6097460..340301450a5 100644 --- a/test/Object/Mips/feature.test +++ b/test/Object/Mips/feature.test @@ -2,10 +2,12 @@ RUN: llvm-objdump -disassemble -triple mips64el -mattr +mips64r2 %p/../Inputs/de 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 -- 2.34.1