This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] dwarf: Make sect_offset 64-bits


*** TEST RESULTS FOR COMMIT 9d8780f0d0f53d9d326a9d64b7919fe1a628b767 ***

Author: Simon Marchi <simon.marchi@polymtl.ca>
Branch: master
Commit: 9d8780f0d0f53d9d326a9d64b7919fe1a628b767

dwarf: Make sect_offset 64-bits

Does anybody have an opinion about this?  It would be nice to unbreak
the "default" build with clang (i.e. without passing special -Wno-error=
flags).

Here's a version rebased on today's master.

>From 47d28075117fa2ddb93584ec50881e33777a85e5 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Sat, 30 Dec 2017 22:48:18 -0500
Subject: [PATCH] dwarf: Make sect_offset 64-bits

Compiling with Clang 6 shows these errors:

/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:26610:43: error: result of comparison of constant 4294967296 with expression of type 'typename std::underlying_type<sect_offset>::type' (a
ka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
      if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32))
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:26618:43: error: result of comparison of constant 4294967296 with expression of type 'typename std::underlying_type<sect_offset>::type' (a
ka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
      if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32))
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The code in question checks if there is any offset exceeding 32 bits,
and therefore if we need to use the 64-bit DWARF format when writing the
.debug_names section.  The type we use currently to represent section
offsets is an unsigned int (32-bits), which means a value of this type
will never exceed 32 bits, hence the errors above.

There are many signs that we want to support 64-bits DWARF (although I
haven't tested), such as:

 - We correctly read initial length fields (read_initial_length)
 - We take that into account when reading offsets (read_offset_1)
 - The check_dwarf64_offsets function

However, I don't see how it can work if sect_offset is a 32-bits type.
Every time we record a section offset, we risk truncating the value.
And if a file uses the 64-bit DWARF format, it's most likely because
there are such offset values that overflow 32 bits.

Because of this, I think the way forward is to change sect_offset to be
a uint64_t.  It will be able to represent any offset, regardless of the
bitness of the DWARF info.

This patch was regtested on the buildbot.

gdb/ChangeLog:

	* gdbtypes.h (sect_offset): Change type to uint64_t.
	(sect_offset_str): New function.
	* dwarf2read.c (create_addrmap_from_aranges): Use
	sect_offset_str.
	(error_check_comp_unit_head): Likewise.
	(create_debug_type_hash_table): Likewise.
	(read_cutu_die_from_dwo): Likewise.
	(init_cutu_and_read_dies): Likewise.
	(init_cutu_and_read_dies_no_follow): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(partial_die_parent_scope): Likewise.
	(peek_die_abbrev): Likewise.
	(process_queue): Likewise.
	(dwarf2_physname): Likewise.
	(read_namespace_alias): Likewise.
	(read_import_statement): Likewise.
	(create_dwo_cu_reader): Likewise.
	(create_cus_hash_table): Likewise.
	(lookup_dwo_cutu): Likewise.
	(inherit_abstract_dies): Likewise.
	(read_func_scope): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_add_member_fn): Likewise.
	(read_common_block): Likewise.
	(read_module_type): Likewise.
	(read_typedef): Likewise.
	(read_subrange_type): Likewise.
	(load_partial_dies): Likewise.
	(read_partial_die): Likewise.
	(find_partial_die): Likewise.
	(read_str_index): Likewise.
	(dwarf2_string_attr): Likewise.
	(build_error_marker_type): Likewise.
	(lookup_die_type): Likewise.
	(dump_die_shallow): Likewise.
	(follow_die_ref): Likewise.
	(dwarf2_fetch_die_loc_sect_off): Likewise.
	(dwarf2_fetch_constant_bytes): Likewise.
	(follow_die_sig): Likewise.
	(get_signatured_type): Likewise.
	(get_DW_AT_signature_type): Likewise.
	(dwarf2_find_containing_comp_unit): Likewise.
	(set_die_type): Likewise.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]