public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Empty hash table fix in .debug_names reader
@ 2024-01-18 20:37 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-01-18 20:37 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3a862152958a1d17742cef7fc43c4d51dd2dcbab
commit 3a862152958a1d17742cef7fc43c4d51dd2dcbab
Author: Tom Tromey <tom@tromey.com>
Date: Mon Dec 4 07:58:48 2023 -0700
Empty hash table fix in .debug_names reader
The handling of an empty hash table in the .debug_names reader is
slightly wrong.
Currently the code assumes there is always an array of hashes.
However, section 6.1.1.4.5 Hash Lookup Table says:
The optional hash lookup table immediately follows the list of
type signatures.
and then:
The hash lookup table is actually two separate arrays: an array of
buckets, followed immediately by an array of hashes.
My reading of this is that the hash table as a whole is optional, and
so the hashes will not exist in this case. (This also makes sense
because the hashes are not useful without the buckets anyway.)
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25950
Diff:
---
gdb/dwarf2/read-debug-names.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index a2a9fd425ae..b4ff36f0ed6 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -294,7 +294,8 @@ read_debug_names_from_section (struct objfile *objfile,
map.bucket_table_reordered = reinterpret_cast<const uint32_t *> (addr);
addr += map.bucket_count * 4;
map.hash_table_reordered = reinterpret_cast<const uint32_t *> (addr);
- addr += map.name_count * 4;
+ if (map.bucket_count != 0)
+ addr += map.name_count * 4;
/* Name Table */
map.name_table_string_offs_reordered = addr;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-18 20:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18 20:37 [binutils-gdb] Empty hash table fix in .debug_names reader Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).