diff --git a/elfio/elfio_modinfo.hpp b/elfio/elfio_modinfo.hpp index 9ebdfbae0699756be9b836f4e5a0ddd52577bf31..1709f3fcea0d2d9cd190943c9e4962ffa43dc079 100644 --- a/elfio/elfio_modinfo.hpp +++ b/elfio/elfio_modinfo.hpp @@ -43,7 +43,7 @@ template <class S> class modinfo_section_accessor_template //------------------------------------------------------------------------------ bool - get_attribute( Elf_Word no, std::string& field, std::string& value ) const + get_attribute( Elf_Word no, const std::string& field, const std::string& value ) const { if ( no < content.size() ) { field = content[no].first; diff --git a/elfio/elfio_symbols.hpp b/elfio/elfio_symbols.hpp index 52b4bf64b1fa31ae1bab7e769ba3c0207d1f8075..3b53495089701c277a7cc183ea3c97e16a900a64 100644 --- a/elfio/elfio_symbols.hpp +++ b/elfio/elfio_symbols.hpp @@ -356,34 +356,36 @@ template <class S> class symbol_section_accessor_template ( (T)1 << ( hash % ( 8 * sizeof( T ) ) ) ) | ( (T)1 << ( ( hash >> bloom_shift ) % ( 8 * sizeof( T ) ) ) ); - if ( ( convertor( bloom_filter[bloom_index] ) & bloom_bits ) == - bloom_bits ) { - uint32_t bucket = hash % nbuckets; - auto* buckets = - (uint32_t*)( hash_section->get_data() + 4 * sizeof( uint32_t ) + - bloom_size * sizeof( T ) ); - auto* chains = - (uint32_t*)( hash_section->get_data() + 4 * sizeof( uint32_t ) + - bloom_size * sizeof( T ) + - nbuckets * sizeof( uint32_t ) ); - - if ( convertor( buckets[bucket] ) >= symoffset ) { - uint32_t chain_index = convertor( buckets[bucket] ) - symoffset; - uint32_t chain_hash = convertor( chains[chain_index] ); - std::string symname; - while ( true ) { - if ( ( chain_hash >> 1 ) == ( hash >> 1 ) && - get_symbol( chain_index + symoffset, symname, value, - size, bind, type, section_index, other ) && - name == symname ) { - ret = true; - break; - } - - if ( chain_hash & 1 ) - break; - chain_hash = convertor( chains[++chain_index] ); + if ( ( convertor( bloom_filter[bloom_index] ) & bloom_bits ) != + bloom_bits ) + return ret; + + uint32_t bucket = hash % nbuckets; + auto* buckets = + (uint32_t*)( hash_section->get_data() + 4 * sizeof( uint32_t ) + + bloom_size * sizeof( T ) ); + auto* chains = + (uint32_t*)( hash_section->get_data() + 4 * sizeof( uint32_t ) + + bloom_size * sizeof( T ) + + nbuckets * sizeof( uint32_t ) ); + + if ( convertor( buckets[bucket] ) >= symoffset ) { + uint32_t chain_index = convertor( buckets[bucket] ) - symoffset; + uint32_t chain_hash = convertor( chains[chain_index] ); + std::string symname; + + while ( true ) { + if ( ( chain_hash >> 1 ) == ( hash >> 1 ) && + get_symbol( chain_index + symoffset, symname, value, size, + bind, type, section_index, other ) && + name == symname ) { + ret = true; + break; } + + if ( chain_hash & 1 ) + break; + chain_hash = convertor( chains[++chain_index] ); } } diff --git a/elfio/elfio_utils.hpp b/elfio/elfio_utils.hpp index c172cd160c786b0d4d4a3440513a74d79319ea33..e8f5b19a3a612891bb0b87774ac5987917e3440f 100644 --- a/elfio/elfio_utils.hpp +++ b/elfio/elfio_utils.hpp @@ -209,7 +209,8 @@ class address_translator //------------------------------------------------------------------------------ inline uint32_t elf_hash( const unsigned char* name ) { - uint32_t h = 0, g = 0; + uint32_t h = 0; + uint32_t g = 0; while ( *name != '\0' ) { h = ( h << 4 ) + *name++; g = h & 0xf0000000; diff --git a/elfio/elfio_versym.hpp b/elfio/elfio_versym.hpp index 575d720f56997f64f7151215db63e87885714ee1..b2cc64a6976d98f83c83d85d46a1220eb5b5eb62 100644 --- a/elfio/elfio_versym.hpp +++ b/elfio/elfio_versym.hpp @@ -30,7 +30,8 @@ template <class S> class versym_section_accessor_template { public: //------------------------------------------------------------------------------ - versym_section_accessor_template( S* section ) : versym_section( section ) + explicit versym_section_accessor_template( S* section ) + : versym_section( section ) { if ( section ) { entries_num = decltype( entries_num )( section->get_size() /