From 19fbdcd30bfcbfe11b2a1a315039f0e3b68025a1 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 11 Sep 2007 00:01:24 -0400 Subject: Loader: Error if a TLS section is found in the binary. --HG-- extra : convert_revision : d763c0382f3cbcc9786510f5a8e521ec9d55eff1 --- src/base/loader/elf_object.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/base/loader/elf_object.cc') diff --git a/src/base/loader/elf_object.cc b/src/base/loader/elf_object.cc index f76ea593b..ecce175b2 100644 --- a/src/base/loader/elf_object.cc +++ b/src/base/loader/elf_object.cc @@ -343,8 +343,8 @@ ElfObject::loadLocalSymbols(SymbolTable *symtab, Addr addrMask) return loadSomeSymbols(symtab, STB_LOCAL); } -bool -ElfObject::isDynamic() +void +ElfObject::getSections() { Elf *elf; int sec_idx = 1; // there is a 0 but it is nothing, go figure @@ -353,6 +353,8 @@ ElfObject::isDynamic() GElf_Ehdr ehdr; + assert(!sectionNames.size()); + // check that header matches library version if (elf_version(EV_CURRENT) == EV_NONE) panic("wrong elf version number!"); @@ -372,11 +374,17 @@ ElfObject::isDynamic() // While there are no more sections while (section != NULL) { gelf_getshdr(section, &shdr); - if (!strcmp(".interp", elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name))) - return true; + sectionNames.insert(elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name)); section = elf_getscn(elf, ++sec_idx); } // while sections - return false; +} + +bool +ElfObject::sectionExists(string sec) +{ + if (!sectionNames.size()) + getSections(); + return sectionNames.find(sec) != sectionNames.end(); } -- cgit v1.2.3