From patchwork Tue Dec 1 10:36:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1408745 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=cYwLHpi/; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CldnF6dRWz9s1l for ; Tue, 1 Dec 2020 21:36:32 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D30703944824; Tue, 1 Dec 2020 10:36:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D30703944824 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1606818989; bh=faUjZsxs4W3sl/XgHOGmFj7RI3qV3EbkQWZN+B/5ICY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=cYwLHpi/12imQgusWrepLM465/dB5Qbf/6tEEI3iKi/BihyHwG/2Kle/8rpOEeKhV teY9dsnwfAgyhZ8p6wouuzi8npgB4LAzjDC0k2m5kAVyLwzpy/iptlqkBqCSu/v2mp H1FW8IcHBJYUMWHc8n2u6GMLNGN0YP5N0tpGfJtU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 2094F393D019 for ; Tue, 1 Dec 2020 10:36:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2094F393D019 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-332-VYn9ZZr8N72StRGTMN9XTw-1; Tue, 01 Dec 2020 05:36:23 -0500 X-MC-Unique: VYn9ZZr8N72StRGTMN9XTw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D261E190B2BB; Tue, 1 Dec 2020 10:36:22 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-127.ams2.redhat.com [10.36.113.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CA085D6AB; Tue, 1 Dec 2020 10:36:21 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 0B1AaJ3M2016061 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 1 Dec 2020 11:36:19 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 0B1AaIUT2016060; Tue, 1 Dec 2020 11:36:18 +0100 Date: Tue, 1 Dec 2020 11:36:18 +0100 To: Jason Merrill , Richard Biener Subject: [PATCH] dwarf: Add -gdwarf{32,64} options Message-ID: <20201201103618.GS3788@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! The following patch makes the choice between 32-bit and 64-bit DWARF formats selectable by command line switch, rather than being hardcoded through DWARF_OFFSET_SIZE macro. The options themselves don't turn on debug info themselves, so one needs to use -g -gdwarf64 or similar. Ok for trunk if it passes bootstrap/regtest? I've tried it on a few smaller and larger testcases and readelf -wi was happy about the output. 2020-12-01 Jakub Jelinek * common.opt (-gdwarf32, -gdwarf64): New options. * config/rs6000/rs6000.c (rs6000_option_override_internal): Default dwarf_offset_size to 8 if not overridden from the command line. * dwarf2out.c: Change all occurrences of DWARF_OFFSET_SIZE to dwarf_offset_size. * doc/invoke.texi (-gdwarf32, -gdwarf64): Document. Jakub --- gcc/common.opt.jj 2020-11-26 01:14:47.444082913 +0100 +++ gcc/common.opt 2020-12-01 11:07:33.088093473 +0100 @@ -3178,6 +3178,14 @@ gdwarf- Common Driver Joined UInteger Var(dwarf_version) Init(4) Negative(gstabs) Generate debug information in DWARF v2 (or later) format. +gdwarf32 +Common Driver Var(dwarf_offset_size,4) Init(4) RejectNegative +Use 32-bit DWARF format when emitting DWARF debug information. + +gdwarf64 +Common Driver Var(dwarf_offset_size,8) RejectNegative +Use 64-bit DWARF format when emitting DWARF debug information. + ggdb Common Driver JoinedOrMissing Generate debug information in default extended format. --- gcc/config/rs6000/rs6000.c.jj 2020-11-27 11:20:53.484334843 +0100 +++ gcc/config/rs6000/rs6000.c 2020-12-01 11:12:31.618731395 +0100 @@ -3863,6 +3863,12 @@ rs6000_option_override_internal (bool gl if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) rs6000_print_isa_options (stderr, 0, "before defaults", rs6000_isa_flags); +#ifdef XCOFF_DEBUGGING_INFO + /* For AIX default to 64-bit DWARF. */ + if (!global_options_set.x_dwarf_offset_size) + dwarf_offset_size = 8; +#endif + /* Handle explicit -mno-{altivec,vsx,power8-vector,power9-vector} and turn off all of the options that depend on those flags. */ ignore_masks = rs6000_disable_incompatible_switches (); --- gcc/dwarf2out.c.jj 2020-12-01 09:41:07.223490914 +0100 +++ gcc/dwarf2out.c 2020-12-01 11:03:04.692115667 +0100 @@ -182,14 +182,14 @@ static GTY(()) section *debug_frame_sect bytes. However, the SGI/MIPS ABI uses an initial length which is equal to - DWARF_OFFSET_SIZE. It is defined (elsewhere) accordingly. */ + dwarf_offset_size. It is defined (elsewhere) accordingly. */ #ifndef DWARF_INITIAL_LENGTH_SIZE -#define DWARF_INITIAL_LENGTH_SIZE (DWARF_OFFSET_SIZE == 4 ? 4 : 12) +#define DWARF_INITIAL_LENGTH_SIZE (dwarf_offset_size == 4 ? 4 : 12) #endif #ifndef DWARF_INITIAL_LENGTH_SIZE_STR -#define DWARF_INITIAL_LENGTH_SIZE_STR (DWARF_OFFSET_SIZE == 4 ? "-4" : "-12") +#define DWARF_INITIAL_LENGTH_SIZE_STR (dwarf_offset_size == 4 ? "-4" : "-12") #endif /* Round SIZE up to the nearest BOUNDARY. */ @@ -199,7 +199,7 @@ static GTY(()) section *debug_frame_sect /* CIE identifier. */ #if HOST_BITS_PER_WIDE_INT >= 64 #define DWARF_CIE_ID \ - (unsigned HOST_WIDE_INT) (DWARF_OFFSET_SIZE == 4 ? DW_CIE_ID : DW64_CIE_ID) + (unsigned HOST_WIDE_INT) (dwarf_offset_size == 4 ? DW_CIE_ID : DW64_CIE_ID) #else #define DWARF_CIE_ID DW_CIE_ID #endif @@ -287,8 +287,8 @@ static GTY(()) bool do_eh_frame = false; static unsigned int rnglist_idx; /* Data and reference forms for relocatable data. */ -#define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4) -#define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4) +#define DW_FORM_data (dwarf_offset_size == 8 ? DW_FORM_data8 : DW_FORM_data4) +#define DW_FORM_ref (dwarf_offset_size == 8 ? DW_FORM_ref8 : DW_FORM_ref4) #ifndef DEBUG_FRAME_SECTION #define DEBUG_FRAME_SECTION ".debug_frame" @@ -602,10 +602,10 @@ output_fde (dw_fde_ref fde, bool for_eh, ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + j); if (!XCOFF_DEBUGGING_INFO || for_eh) { - if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4 && !for_eh) + if (DWARF_INITIAL_LENGTH_SIZE - dwarf_offset_size == 4 && !for_eh) dw2_asm_output_data (4, 0xffffffff, "Initial length escape value" " indicating 64-bit DWARF extension"); - dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1, + dw2_asm_output_delta (for_eh ? 4 : dwarf_offset_size, l2, l1, "FDE Length"); } ASM_OUTPUT_LABEL (asm_out_file, l1); @@ -613,7 +613,7 @@ output_fde (dw_fde_ref fde, bool for_eh, if (for_eh) dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset"); else - dw2_asm_output_offset (DWARF_OFFSET_SIZE, section_start_label, + dw2_asm_output_offset (dwarf_offset_size, section_start_label, debug_frame_section, "FDE CIE offset"); begin = second ? fde->dw_fde_second_begin : fde->dw_fde_begin; @@ -806,17 +806,17 @@ output_call_frame_info (int for_eh) ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh); if (!XCOFF_DEBUGGING_INFO || for_eh) { - if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4 && !for_eh) + if (DWARF_INITIAL_LENGTH_SIZE - dwarf_offset_size == 4 && !for_eh) dw2_asm_output_data (4, 0xffffffff, "Initial length escape value indicating 64-bit DWARF extension"); - dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1, + dw2_asm_output_delta (for_eh ? 4 : dwarf_offset_size, l2, l1, "Length of Common Information Entry"); } ASM_OUTPUT_LABEL (asm_out_file, l1); /* Now that the CIE pointer is PC-relative for EH, use 0 to identify the CIE. */ - dw2_asm_output_data ((for_eh ? 4 : DWARF_OFFSET_SIZE), + dw2_asm_output_data ((for_eh ? 4 : dwarf_offset_size), (for_eh ? 0 : DWARF_CIE_ID), "CIE Identifier Tag"); @@ -1623,7 +1623,7 @@ loc_list_plus_const (dw_loc_list_ref lis } #define DWARF_REF_SIZE \ - (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE) + (dwarf_version == 2 ? DWARF2_ADDR_SIZE : dwarf_offset_size) /* The number of bits that can be encoded by largest DW_FORM_dataN. In DWARF4 and earlier it is DW_FORM_data8 with 64 bits, in DWARF5 @@ -3229,33 +3229,33 @@ skeleton_chain_node; /* Fixed size portion of the DWARF compilation unit header. */ #define DWARF_COMPILE_UNIT_HEADER_SIZE \ - (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE \ + (DWARF_INITIAL_LENGTH_SIZE + dwarf_offset_size \ + (dwarf_version >= 5 ? 4 : 3)) /* Fixed size portion of the DWARF comdat type unit header. */ #define DWARF_COMDAT_TYPE_UNIT_HEADER_SIZE \ (DWARF_COMPILE_UNIT_HEADER_SIZE \ - + DWARF_TYPE_SIGNATURE_SIZE + DWARF_OFFSET_SIZE) + + DWARF_TYPE_SIGNATURE_SIZE + dwarf_offset_size) /* Fixed size portion of the DWARF skeleton compilation unit header. */ #define DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE \ (DWARF_COMPILE_UNIT_HEADER_SIZE + (dwarf_version >= 5 ? 8 : 0)) /* Fixed size portion of public names info. */ -#define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2) +#define DWARF_PUBNAMES_HEADER_SIZE (2 * dwarf_offset_size + 2) /* Fixed size portion of the address range info. */ #define DWARF_ARANGES_HEADER_SIZE \ - (DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4, \ + (DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + dwarf_offset_size + 4, \ DWARF2_ADDR_SIZE * 2) \ - DWARF_INITIAL_LENGTH_SIZE) /* Size of padding portion in the address range info. It must be aligned to twice the pointer size. */ #define DWARF_ARANGES_PAD_SIZE \ - (DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4, \ + (DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + dwarf_offset_size + 4, \ DWARF2_ADDR_SIZE * 2) \ - - (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4)) + - (DWARF_INITIAL_LENGTH_SIZE + dwarf_offset_size + 4)) /* Use assembler line directives if available. */ #ifndef DWARF2_ASM_LINE_DEBUG_INFO @@ -4787,7 +4787,7 @@ find_string_form (struct indirect_string /* If the string is shorter or equal to the size of the reference, it is always better to put it inline. */ - if (len <= DWARF_OFFSET_SIZE || node->refcount == 0) + if (len <= (unsigned) dwarf_offset_size || node->refcount == 0) return node->form = DW_FORM_string; /* If we cannot expect the linker to merge strings in .debug_str @@ -4795,7 +4795,7 @@ find_string_form (struct indirect_string single module. */ if (DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET || ((debug_str_section->common.flags & SECTION_MERGE) == 0 - && (len - DWARF_OFFSET_SIZE) * node->refcount <= len)) + && (len - dwarf_offset_size) * node->refcount <= len)) return node->form = DW_FORM_string; set_indirect_string (node); @@ -8892,7 +8892,7 @@ output_loclists_offsets (dw_die_ref die) dw_loc_list_ref l = AT_loc_list (a); if (l->offset_emitted) continue; - dw2_asm_output_delta (DWARF_OFFSET_SIZE, l->ll_symbol, + dw2_asm_output_delta (dwarf_offset_size, l->ll_symbol, loc_section_label, NULL); gcc_assert (l->hash == loc_list_idx); loc_list_idx++; @@ -9400,7 +9400,7 @@ size_of_die (dw_die_ref die) size += DWARF2_ADDR_SIZE; break; case dw_val_class_offset: - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; break; case dw_val_class_loc: { @@ -9421,10 +9421,10 @@ size_of_die (dw_die_ref die) size += size_of_uleb128 (AT_loc_list (a)->hash); } else - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; break; case dw_val_class_view_list: - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; break; case dw_val_class_range_list: if (value_format (a) == DW_FORM_rnglistx) @@ -9434,7 +9434,7 @@ size_of_die (dw_die_ref die) size += size_of_uleb128 (r->idx); } else - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; break; case dw_val_class_const: size += size_of_sleb128 (AT_int (a)); @@ -9508,13 +9508,13 @@ size_of_die (dw_die_ref die) else if (dwarf_version == 2) size += DWARF2_ADDR_SIZE; else - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; } else - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; break; case dw_val_class_fde_ref: - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; break; case dw_val_class_lbl_id: if (dwarf_split_debug_info && AT_index (a) != NOT_INDEXED) @@ -9528,12 +9528,12 @@ size_of_die (dw_die_ref die) case dw_val_class_lineptr: case dw_val_class_macptr: case dw_val_class_loclistsptr: - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; break; case dw_val_class_str: form = AT_string_form (a); if (form == DW_FORM_strp || form == DW_FORM_line_strp) - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; else if (form == dwarf_FORM (DW_FORM_strx)) size += size_of_uleb128 (AT_index (a)); else @@ -9546,7 +9546,7 @@ size_of_die (dw_die_ref die) size += 8; break; case dw_val_class_vms_delta: - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; break; case dw_val_class_high_pc: size += DWARF2_ADDR_SIZE; @@ -9724,9 +9724,9 @@ size_of_pubnames (vecname) + DWARF_OFFSET_SIZE + 1 + space_for_flags; + size += strlen (p->name) + dwarf_offset_size + 1 + space_for_flags; - size += DWARF_OFFSET_SIZE; + size += dwarf_offset_size; return size; } @@ -9823,7 +9823,7 @@ value_format (dw_attr_node *a) /* FALLTHRU */ case dw_val_class_vms_delta: case dw_val_class_offset: - switch (DWARF_OFFSET_SIZE) + switch (dwarf_offset_size) { case 4: return DW_FORM_data4; @@ -10525,7 +10525,7 @@ output_range_list_offset (dw_attr_node * if (dwarf_version >= 5) { dw_ranges *r = &(*ranges_table)[a->dw_attr_val.v.val_offset]; - dw2_asm_output_offset (DWARF_OFFSET_SIZE, r->label, + dw2_asm_output_offset (dwarf_offset_size, r->label, debug_ranges_section, "%s", name); } else @@ -10533,7 +10533,7 @@ output_range_list_offset (dw_attr_node * char *p = strchr (ranges_section_label, '\0'); sprintf (p, "+" HOST_WIDE_INT_PRINT_HEX, a->dw_attr_val.v.val_offset * 2 * DWARF2_ADDR_SIZE); - dw2_asm_output_offset (DWARF_OFFSET_SIZE, ranges_section_label, + dw2_asm_output_offset (dwarf_offset_size, ranges_section_label, debug_ranges_section, "%s", name); *p = '\0'; } @@ -10545,7 +10545,7 @@ output_range_list_offset (dw_attr_node * dw2_asm_output_data_uleb128 (r->idx, "%s", name); } else - dw2_asm_output_data (DWARF_OFFSET_SIZE, + dw2_asm_output_data (dwarf_offset_size, a->dw_attr_val.v.val_offset * 2 * DWARF2_ADDR_SIZE, "%s (offset from %s)", name, ranges_section_label); } @@ -10559,7 +10559,7 @@ output_loc_list_offset (dw_attr_node *a) gcc_assert (sym); if (!dwarf_split_debug_info) - dw2_asm_output_offset (DWARF_OFFSET_SIZE, sym, debug_loc_section, + dw2_asm_output_offset (dwarf_offset_size, sym, debug_loc_section, "%s", dwarf_attr_name (a->dw_attr)); else if (dwarf_version >= 5) { @@ -10569,7 +10569,7 @@ output_loc_list_offset (dw_attr_node *a) sym); } else - dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym, loc_section_label, + dw2_asm_output_delta (dwarf_offset_size, sym, loc_section_label, "%s", dwarf_attr_name (a->dw_attr)); } @@ -10582,10 +10582,10 @@ output_view_list_offset (dw_attr_node *a gcc_assert (sym); if (dwarf_split_debug_info) - dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym, loc_section_label, + dw2_asm_output_delta (dwarf_offset_size, sym, loc_section_label, "%s", dwarf_attr_name (a->dw_attr)); else - dw2_asm_output_offset (DWARF_OFFSET_SIZE, sym, debug_loc_section, + dw2_asm_output_offset (dwarf_offset_size, sym, debug_loc_section, "%s", dwarf_attr_name (a->dw_attr)); } @@ -10663,7 +10663,7 @@ output_die (dw_die_ref die) break; case dw_val_class_offset: - dw2_asm_output_data (DWARF_OFFSET_SIZE, a->dw_attr_val.v.val_offset, + dw2_asm_output_data (dwarf_offset_size, a->dw_attr_val.v.val_offset, "%s", name); break; @@ -10857,7 +10857,7 @@ output_die (dw_die_ref die) if (dwarf_version == 2) size = DWARF2_ADDR_SIZE; else - size = DWARF_OFFSET_SIZE; + size = dwarf_offset_size; /* ??? We cannot unconditionally output die_offset if non-zero - others might create references to those DIEs via symbols. @@ -10877,7 +10877,7 @@ output_die (dw_die_ref die) else { gcc_assert (AT_ref (a)->die_offset); - dw2_asm_output_data (DWARF_OFFSET_SIZE, AT_ref (a)->die_offset, + dw2_asm_output_data (dwarf_offset_size, AT_ref (a)->die_offset, "%s", name); } break; @@ -10888,18 +10888,18 @@ output_die (dw_die_ref die) ASM_GENERATE_INTERNAL_LABEL (l1, FDE_LABEL, a->dw_attr_val.v.val_fde_index * 2); - dw2_asm_output_offset (DWARF_OFFSET_SIZE, l1, debug_frame_section, + dw2_asm_output_offset (dwarf_offset_size, l1, debug_frame_section, "%s", name); } break; case dw_val_class_vms_delta: #ifdef ASM_OUTPUT_DWARF_VMS_DELTA - dw2_asm_output_vms_delta (DWARF_OFFSET_SIZE, + dw2_asm_output_vms_delta (dwarf_offset_size, AT_vms_delta2 (a), AT_vms_delta1 (a), "%s", name); #else - dw2_asm_output_delta (DWARF_OFFSET_SIZE, + dw2_asm_output_delta (dwarf_offset_size, AT_vms_delta2 (a), AT_vms_delta1 (a), "%s", name); #endif @@ -10910,28 +10910,28 @@ output_die (dw_die_ref die) break; case dw_val_class_lineptr: - dw2_asm_output_offset (DWARF_OFFSET_SIZE, AT_lbl (a), + dw2_asm_output_offset (dwarf_offset_size, AT_lbl (a), debug_line_section, "%s", name); break; case dw_val_class_macptr: - dw2_asm_output_offset (DWARF_OFFSET_SIZE, AT_lbl (a), + dw2_asm_output_offset (dwarf_offset_size, AT_lbl (a), debug_macinfo_section, "%s", name); break; case dw_val_class_loclistsptr: - dw2_asm_output_offset (DWARF_OFFSET_SIZE, AT_lbl (a), + dw2_asm_output_offset (dwarf_offset_size, AT_lbl (a), debug_loc_section, "%s", name); break; case dw_val_class_str: if (a->dw_attr_val.v.val_str->form == DW_FORM_strp) - dw2_asm_output_offset (DWARF_OFFSET_SIZE, + dw2_asm_output_offset (dwarf_offset_size, a->dw_attr_val.v.val_str->label, debug_str_section, "%s: \"%s\"", name, AT_string (a)); else if (a->dw_attr_val.v.val_str->form == DW_FORM_line_strp) - dw2_asm_output_offset (DWARF_OFFSET_SIZE, + dw2_asm_output_offset (dwarf_offset_size, a->dw_attr_val.v.val_str->label, debug_line_str_section, "%s: \"%s\"", name, AT_string (a)); @@ -11048,10 +11048,10 @@ output_compilation_unit_header (enum dwa { if (!XCOFF_DEBUGGING_INFO) { - if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) + if (DWARF_INITIAL_LENGTH_SIZE - dwarf_offset_size == 4) dw2_asm_output_data (4, 0xffffffff, "Initial length escape value indicating 64-bit DWARF extension"); - dw2_asm_output_data (DWARF_OFFSET_SIZE, + dw2_asm_output_data (dwarf_offset_size, next_die_offset - DWARF_INITIAL_LENGTH_SIZE, "Length of Compilation Unit Info"); } @@ -11071,7 +11071,7 @@ output_compilation_unit_header (enum dwa dw2_asm_output_data (1, ut, "%s", name); dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)"); } - dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label, + dw2_asm_output_offset (dwarf_offset_size, abbrev_section_label, debug_abbrev_section, "Offset Into Abbrev. Section"); if (dwarf_version < 5) @@ -11261,12 +11261,12 @@ output_skeleton_debug_sections (dw_die_r /* Produce the skeleton compilation-unit header. This one differs enough from a normal CU header that it's better not to call output_compilation_unit header. */ - if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) + if (DWARF_INITIAL_LENGTH_SIZE - dwarf_offset_size == 4) dw2_asm_output_data (4, 0xffffffff, "Initial length escape value indicating 64-bit " "DWARF extension"); - dw2_asm_output_data (DWARF_OFFSET_SIZE, + dw2_asm_output_data (dwarf_offset_size, DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE - DWARF_INITIAL_LENGTH_SIZE + size_of_die (comp_unit), @@ -11277,7 +11277,7 @@ output_skeleton_debug_sections (dw_die_r dw2_asm_output_data (1, DW_UT_skeleton, "DW_UT_skeleton"); dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)"); } - dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_abbrev_section_label, + dw2_asm_output_offset (dwarf_offset_size, debug_skeleton_abbrev_section_label, debug_skeleton_abbrev_section, "Offset Into Abbrev. Section"); if (dwarf_version < 5) @@ -11362,7 +11362,7 @@ output_comdat_type_unit (comdat_type_nod output_compilation_unit_header (dwarf_split_debug_info ? DW_UT_split_type : DW_UT_type); output_signature (node->signature, "Type Signature"); - dw2_asm_output_data (DWARF_OFFSET_SIZE, node->type_die->die_offset, + dw2_asm_output_data (dwarf_offset_size, node->type_die->die_offset, "Offset to Type DIE"); output_die (node->root_die); @@ -11491,7 +11491,7 @@ output_pubname (dw_offset die_offset, pu dw_die_ref die = entry->die; int is_static = get_AT_flag (die, DW_AT_external) ? 0 : 1; - dw2_asm_output_data (DWARF_OFFSET_SIZE, die_offset, "DIE offset"); + dw2_asm_output_data (dwarf_offset_size, die_offset, "DIE offset"); if (debug_generate_pub_sections == 2) { @@ -11565,10 +11565,10 @@ output_pubnames (veclabel) - dw2_asm_output_delta (DWARF_OFFSET_SIZE, r->label, + dw2_asm_output_delta (dwarf_offset_size, r->label, ranges_base_label, NULL); } @@ -12219,7 +12219,7 @@ output_line_string (enum dwarf_form form node = find_AT_string_in_table (str, debug_line_str_hash); set_indirect_string (node); node->form = form; - dw2_asm_output_offset (DWARF_OFFSET_SIZE, node->label, + dw2_asm_output_offset (dwarf_offset_size, node->label, debug_line_str_section, "%s: %#x: \"%s\"", entry_kind, 0, node->str); break; @@ -12728,10 +12728,10 @@ output_line_info (bool prologue_only) if (!XCOFF_DEBUGGING_INFO) { - if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) + if (DWARF_INITIAL_LENGTH_SIZE - dwarf_offset_size == 4) dw2_asm_output_data (4, 0xffffffff, "Initial length escape value indicating 64-bit DWARF extension"); - dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1, + dw2_asm_output_delta (dwarf_offset_size, l2, l1, "Length of Source Line Info"); } @@ -12743,7 +12743,7 @@ output_line_info (bool prologue_only) dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size"); dw2_asm_output_data (1, 0, "Segment Size"); } - dw2_asm_output_delta (DWARF_OFFSET_SIZE, p2, p1, "Prolog Length"); + dw2_asm_output_delta (dwarf_offset_size, p2, p1, "Prolog Length"); ASM_OUTPUT_LABEL (asm_out_file, p1); /* Define the architecture-dependent minimum instruction length (in bytes). @@ -28306,7 +28306,7 @@ output_macinfo_op (macinfo_entry *ref) case DW_MACINFO_undef: len = strlen (ref->info) + 1; if (!dwarf_strict - && len > DWARF_OFFSET_SIZE + && len > (size_t) dwarf_offset_size && !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET && (debug_str_section->common.flags & SECTION_MERGE) != 0) { @@ -28347,7 +28347,7 @@ output_macinfo_op (macinfo_entry *ref) dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu", (unsigned long) ref->lineno); if (node->form == DW_FORM_strp) - dw2_asm_output_offset (DWARF_OFFSET_SIZE, node->label, + dw2_asm_output_offset (dwarf_offset_size, node->label, debug_str_section, "The macro: \"%s\"", ref->info); else @@ -28359,7 +28359,7 @@ output_macinfo_op (macinfo_entry *ref) ASM_GENERATE_INTERNAL_LABEL (label, DEBUG_MACRO_SECTION_LABEL, ref->lineno + macinfo_label_base); - dw2_asm_output_offset (DWARF_OFFSET_SIZE, label, NULL, NULL); + dw2_asm_output_offset (dwarf_offset_size, label, NULL, NULL); break; default: fprintf (asm_out_file, "%s unrecognized macinfo code %lu\n", @@ -28443,7 +28443,7 @@ optimize_macinfo_range (unsigned int idx /* The group name format is: wmN.[.]. */ grp_name = XALLOCAVEC (char, 4 + encoded_filename_len + linebuf_len + 1 + 16 * 2 + 1); - memcpy (grp_name, DWARF_OFFSET_SIZE == 4 ? "wm4." : "wm8.", 4); + memcpy (grp_name, dwarf_offset_size == 4 ? "wm4." : "wm8.", 4); tail = grp_name + 4; if (encoded_filename_len) { @@ -28514,7 +28514,7 @@ save_macinfo_strings (void) case DW_MACINFO_undef: len = strlen (ref->info) + 1; if (!dwarf_strict - && len > DWARF_OFFSET_SIZE + && len > (unsigned) dwarf_offset_size && !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET && (debug_str_section->common.flags & SECTION_MERGE) != 0) set_indirect_string (find_AT_string (ref->info)); @@ -28567,11 +28567,11 @@ output_macinfo (const char *debug_line_l { dw2_asm_output_data (2, dwarf_version >= 5 ? 5 : 4, "DWARF macro version number"); - if (DWARF_OFFSET_SIZE == 8) + if (dwarf_offset_size == 8) dw2_asm_output_data (1, 3, "Flags: 64-bit, lineptr present"); else dw2_asm_output_data (1, 2, "Flags: 32-bit, lineptr present"); - dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_line_label, + dw2_asm_output_offset (dwarf_offset_size, debug_line_label, debug_line_section, NULL); } @@ -28660,7 +28660,7 @@ output_macinfo (const char *debug_line_l ref->info = NULL; dw2_asm_output_data (2, dwarf_version >= 5 ? 5 : 4, "DWARF macro version number"); - if (DWARF_OFFSET_SIZE == 8) + if (dwarf_offset_size == 8) dw2_asm_output_data (1, 1, "Flags: 64-bit"); else dw2_asm_output_data (1, 0, "Flags: 32-bit"); @@ -28997,7 +28997,7 @@ output_index_string_offset (indirect_str /* Assert that this node has been assigned an index. */ gcc_assert (node->index != NO_INDEX_ASSIGNED && node->index != NOT_INDEXED); - dw2_asm_output_data (DWARF_OFFSET_SIZE, *offset, + dw2_asm_output_data (dwarf_offset_size, *offset, "indexed string 0x%x: %s", node->index, node->str); *offset += strlen (node->str) + 1; } @@ -29091,11 +29091,11 @@ output_indirect_strings (void) debug_str_hash->traverse_noresize (&last_idx); - str_offsets_length = last_idx * DWARF_OFFSET_SIZE + 4; - if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) + str_offsets_length = last_idx * dwarf_offset_size + 4; + if (DWARF_INITIAL_LENGTH_SIZE - dwarf_offset_size == 4) dw2_asm_output_data (4, 0xffffffff, "Escape value for 64-bit DWARF extension"); - dw2_asm_output_data (DWARF_OFFSET_SIZE, str_offsets_length, + dw2_asm_output_data (dwarf_offset_size, str_offsets_length, "Length of string offsets unit"); dw2_asm_output_data (2, 5, "DWARF string offsets version"); dw2_asm_output_data (2, 0, "Header zero padding"); @@ -29185,10 +29185,10 @@ output_addr_table (void) (&last_idx); addrs_length = last_idx * DWARF2_ADDR_SIZE + 4; - if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) + if (DWARF_INITIAL_LENGTH_SIZE - dwarf_offset_size == 4) dw2_asm_output_data (4, 0xffffffff, "Escape value for 64-bit DWARF extension"); - dw2_asm_output_data (DWARF_OFFSET_SIZE, addrs_length, + dw2_asm_output_data (dwarf_offset_size, addrs_length, "Length of Address Unit"); dw2_asm_output_data (2, 5, "DWARF addr version"); dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address"); @@ -31747,11 +31747,11 @@ dwarf2out_finish (const char *filename) { ASM_GENERATE_INTERNAL_LABEL (l1, DEBUG_LOC_SECTION_LABEL, 2); ASM_GENERATE_INTERNAL_LABEL (l2, DEBUG_LOC_SECTION_LABEL, 3); - if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) + if (DWARF_INITIAL_LENGTH_SIZE - dwarf_offset_size == 4) dw2_asm_output_data (4, 0xffffffff, "Initial length escape value indicating " "64-bit DWARF extension"); - dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1, + dw2_asm_output_delta (dwarf_offset_size, l2, l1, "Length of Location Lists"); ASM_OUTPUT_LABEL (asm_out_file, l1); output_dwarf_version (); --- gcc/doc/invoke.texi.jj 2020-11-27 11:20:53.509334560 +0100 +++ gcc/doc/invoke.texi 2020-12-01 11:23:01.743634441 +0100 @@ -452,7 +452,7 @@ Objective-C and Objective-C++ Dialects}. -gstabs -gstabs+ -gstrict-dwarf -gno-strict-dwarf @gol -gas-loc-support -gno-as-loc-support @gol -gas-locview-support -gno-as-locview-support @gol --gcolumn-info -gno-column-info @gol +-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol -gstatement-frontiers -gno-statement-frontiers @gol -gvariable-location-views -gno-variable-location-views @gol -ginternal-reset-location-views -gno-internal-reset-location-views @gol @@ -9569,6 +9569,18 @@ information as possible into a separate debug information. To be useful, this option requires a debugger capable of reading @file{.dwo} files. +@item -gdwarf32 +@itemx -gdwarf64 +@opindex gdwarf32 +@opindex gdwarf64 +If DWARF debugging information is enabled, the @option{-gdwarf32} selects +the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit +DWARF format. The default is target specific, on most targets it is +@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but +can't support more than 2GiB of debug information in any of the DWARF +debug information sections. The 64-bit DWARF format allows larger debug +information and might not be well supported by all consumers yet. + @item -gdescribe-dies @opindex gdescribe-dies Add description attributes to some DWARF DIEs that have no name attribute,