From patchwork Wed Mar 18 10:20:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39042 From: gprocida@google.com (Giuliano Procida) Date: Wed, 18 Mar 2020 10:20:55 +0000 Subject: [PATCH] dwarf-reader: Use high bits of Bloom filter words. Message-ID: <20200318102055.109824-1-gprocida@google.com> Most of the bit values used for GNU hash ELF section Bloom filtering were being ignored due to integer narrowing, reducing missing symbol filtering efficiency considerably. This patch fixes this. * src/abg-dwarf-reader.cc (lookup_symbol_from_gnu_hash_tab): Don't narrow calculated Bloom word to 8 bits before using it to mask the fetched Bloom word. Reviewed-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 3454fcf5..5556bde5 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2025,7 +2025,7 @@ lookup_symbol_from_gnu_hash_tab(const environment* env, // filter, in bits. int c = get_elf_class_size_in_bytes(elf_handle) * 8; int n = (h1 / c) % ht.bf_nwords; - unsigned char bitmask = (1ul << (h1 % c)) | (1ul << (h2 % c)); + GElf_Word bitmask = (1ul << (h1 % c)) | (1ul << (h2 % c)); // Test if the symbol is *NOT* present in this ELF file. if ((bloom_word_at(elf_handle, ht.bloom_filter, n) & bitmask) != bitmask)