--- ./gdb/dwarf2/read.c_orig	2021-11-21 02:56:10 +0000
+++ ./gdb/dwarf2/read.c	2021-11-21 02:58:11 +0000
@@ -6529,6 +6529,16 @@
 			       htab_up &types_htab)
 {
   for (dwarf2_section_info &section : type_sections)
+    /* Create type hashes only if section has been read completely.
+       Otherwise for types like 'long' it would try to read it as 108(ascii l)
+       For example the the abbrev number created in abbreviation section
+       with xlc dwarf for c programs woth objdump --dwarf=info output would be.
+        <1><57>: Abbrev Number: 2 (DW_TAG_base_type)
+        <58>   DW_AT_name        : long long
+        <62>   DW_AT_byte_size   : 8
+        <63>   DW_AT_encoding    : 5        (signed)
+       C++ program doesn't seem to have these kind of entries. */
+    if (!section.empty() && section.readin)
     create_debug_type_hash_table (per_objfile, dwo_file, &section, types_htab,
 				  rcuh_kind::TYPE);
 }
