From patchwork Fri Feb 23 11:07:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 205314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp510354dyb; Fri, 23 Feb 2024 03:07:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWa2dJFnBzHHpYq4Y81eZ1qK4aqfPX1DqZQ7Gmqx6Z2zow7lRhA96DAFt4sNKO5GlDTC8PdGxs0GTjw1XVae6pJAh4L+A== X-Google-Smtp-Source: AGHT+IExAfVLrvM3i1cHYFgT4cY3bahBngT+zySRz8frpi0P6ipQI4udbzYQo9W2swbuRyTDbooj X-Received: by 2002:a05:620a:1a95:b0:787:57db:a5c1 with SMTP id bl21-20020a05620a1a9500b0078757dba5c1mr2039081qkb.39.1708686449086; Fri, 23 Feb 2024 03:07:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708686449; cv=pass; d=google.com; s=arc-20160816; b=q08fwcrO9Ns5bFfP0MumoYqLWg+1OrBZ7wRP+xbSztpasPiK9a1rwwG9gptFuM0uZJ 0HYIMstrmN261X1Sez1LqXzFrYzRg4KRhQl9IjfBd1c7DYh1aCbaFixLj85zjG3uVOt5 hvigqoV1EJrrL1WyES+LKvRsAX96Zjv26sPAuX19uJzYykAxrLHaiMBZ87CyiyPG1hwq KirmGBuO+9XceJcP+N13MOkZm+EL5fKDXthkukn9ojaxeXGdMw1Hih8UJz/A/7Xd2mi9 3VSil/KaHVWD0hLexF56wMgJJD5L5hxEhaAJ4pOfVPFE32F3XmX+QSTCCDa9IvSw4udb PHkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :autocrypt:content-language:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=/6LsMaXcWYY0zzxxeCz/MZBP0IfCXO4MFg6XurzfSLE=; fh=MAG1+jSdZgiZLWrJAfw8yidv7TSuzM87qvj+GzPWqRA=; b=Yu1tPd/bgCbvV8wHAtEvLtow1D4bc87xOWgA7bOoMT+C4wnRj50eXbS6S7tuGAYfW2 0+5Cha8VDwL6eTlVXe7ku9BcAtcXPqgjetWnLdWdpo/OZs7zc8aLNAOsXz16hGRhJSXF i2cDvRRUVP9ui7tml1uMO8cQZvt8B9DDEZqfMDHrbqAScRGr7pafTdrLxcdPNcHl0zp2 jwUzOOEJri6i2/tCTwuol1LfyuF6QO8hSKbZLnnfObmu15vcGOdZKEka7Yqc8I0T5zZg 0YNv/6VnA1L9yMzcJxMbGODX1SeQFFT89h/RhKiYzZcLj5VEUsbvyYYlhvI4IBnlBQkP N8pQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=NH0YkE+P; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x28-20020a05620a14bc00b00787a3eb71e4si2622208qkj.766.2024.02.23.03.07.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 03:07:29 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=NH0YkE+P; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B191B385843B for ; Fri, 23 Feb 2024 11:07:28 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id C3ACD385840C for ; Fri, 23 Feb 2024 11:07:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3ACD385840C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C3ACD385840C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708686439; cv=none; b=dO3KcMxcUr1FENfceQpJv+hiTEC+Ivy1VssEBg2s7jqWIZS8iVowuNxiWpbhZqNHDvNh29JJaTWw9fApz6sit9Og5H8e+Yj0N07Lm7lDmdrpCMtwPFTPFbovSHaSIxNXByCUa0qjlfAK/TGF6RNXD2P3li3fXt9gZR5oVscx4ZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708686439; c=relaxed/simple; bh=GjohSTzRauEmiQQ/z5YMKq8rSV3jqFHkVRZqHK1aL9E=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:Subject:To; b=xD1RmNarA1B9vJaHMHKDuZaR9iNO273n1kmFKXFBTfpNezXimAneLX0P9ZFwlv+wE7+mwAxvWq8EmAEXOvRUf4Jj2eIgDd6W7NFMcFfeamZPeig55VlKFiVsaBoBlv8n5w76Z/7qBa3K2vpW697vKj/eKTVmlaXqoEAR9OoNpqA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a3e550ef31cso75856366b.3 for ; Fri, 23 Feb 2024 03:07:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708686427; x=1709291227; darn=sourceware.org; h=content-transfer-encoding:autocrypt:content-language:cc:to:subject :from:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=/6LsMaXcWYY0zzxxeCz/MZBP0IfCXO4MFg6XurzfSLE=; b=NH0YkE+PZaewjd9mbLXP8ZTzT9PgI1GnV5jrHU0hx0a9p3eHjVSplj5Zxd/B4Df5ag TjOpkI3HHclslw3spcboLhgR+EI+imbIGnx5MYdPgzzKe9PH8C2IR1+oMh7W0TbHu1Sv pmBPAr4MrNQIticwwJu4pohenlLCocwr5JSinM93/6vVj3qyE4CWsGkf8BP5U69Gy0WB 6hnWI6NBjh8ABlOwiKnKlBZlLI6dwYRpCx2/Tq6zwm2WAGLt4uGsXz1fooXJCSCuXy3g W6fHLQNFJ+XPZrzuA43/Pxza8haCgTSkMvqwsSiBgFC7Yf+svVHQvCuWkr/d4n93sbUd BfYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708686427; x=1709291227; h=content-transfer-encoding:autocrypt:content-language:cc:to:subject :from:user-agent:mime-version:date:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/6LsMaXcWYY0zzxxeCz/MZBP0IfCXO4MFg6XurzfSLE=; b=ktCq9UJaWWarngL7iznhAM9DKUYgpkCmSKzjxzzAq44RrJ78s8GF87oRLUyztxzEqm KCf0qxpkO9MHWjSMTL2d8Uv1AqVo+b+86wdT9Jl1MMKSIMr5dYummu+6JvtI6tO9nT3K uOp1t97xX45zS67AHa7xdTaBEA8tm0FTZrvQsZ5OWwx5an4k8tn+RCvyxb29ITa/0ZmW zSNSH4Ti8iNrpxSVWUW/PkVh0zxIhuwVbifkX0FF5cm/m1X9uNGxdrLXmYEKG8hBCfx7 uJn+yQIAOfoE69bmVY21hpIo83ozRi3x5S2Ifh0xZzancOZoFW4NFGtJ5hA2HRw5BURY 1Zqg== X-Gm-Message-State: AOJu0Ywfk/om/mGuMMRgSDDZoLf3O4D1h+lhtK5ehE//KznRqOw8XLOS 0O3j00q3xQ+J7zMGBoXycIV6BgSR/4dHw0uLrWAJQs3MJ9LOoayhrI4b0uzeIoIdmeyMj5SJQ7k = X-Received: by 2002:a17:906:7c48:b0:a3e:f1c8:f5c2 with SMTP id g8-20020a1709067c4800b00a3ef1c8f5c2mr1052781ejp.23.1708686427397; Fri, 23 Feb 2024 03:07:07 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id y2-20020a170906470200b00a3d0dd84276sm6786558ejq.184.2024.02.23.03.07.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Feb 2024 03:07:07 -0800 (PST) Message-ID: Date: Fri, 23 Feb 2024 12:07:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Jan Beulich Subject: [PATCH v3] x86: adjust which Dwarf2 register numbers to use To: Binutils Cc: "H.J. Lu" , Indu Bhagat Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h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jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL X-Spam-Status: No, score=-3025.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791687601980506125 X-GMAIL-MSGID: 1791687601980506125 Consumers can't know which execution mode is in effect for a certain piece of code; they can only go from object file properties. Hence which register numbers to encode ought to depend solely on object file type. In tc_x86_frame_initial_instructions() do away with parsing a register name: We have a symbolic constant already for the 64-bit case, and the 32-bit number isn't going to change either. Said constant's definition needs moving, though, to be available also for non-ELF. While moving also adjust the comment to clarify that it's applicable to 64-bit mode only. --- x86_cie_data_alignment, independent of this change, likely needs adjusting as flag_code changes. The COFF/PE setting of x86_dwarf2_return_column looks bogus as well: 32 is already in use for %xmm15 for 64-bit. Commit ca19b261ecc3 sadly has no explanation at all. Nor did it adjust objdump accordingly. Given that the author has moved on (couldn't find an applicable email address), I'm inclined to simply revert that change. If anything a proper complete set of Windows register number mappings (wherever those are formally documented) would need putting in place. --- v3: Also adjust tc_x86_frame_initial_instructions(). v2: Also adjust md_begin(). --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -3276,7 +3276,7 @@ md_begin (void) operand_chars[(unsigned char) *p] = *p; } - if (flag_code == CODE_64BIT) + if (object_64bit) { #if defined (OBJ_COFF) && defined (TE_PE) x86_dwarf2_return_column = (OUTPUT_FLAVOR == bfd_target_coff_flavour @@ -5410,7 +5410,7 @@ ginsn_dw2_regnum (const reg_entry *ireg) if (ireg->reg_num == RegIP || ireg->reg_num == RegIZ) return GINSN_DW2_REGNUM_RSI_DUMMY; - dwarf_reg = ireg->dw2_regnum[flag_code >> 1]; + dwarf_reg = ireg->dw2_regnum[object_64bit]; if (dwarf_reg == Dw2Inval) { @@ -17548,7 +17548,7 @@ tc_x86_parse_to_dw2regnum (expressionS * if ((addressT) exp->X_add_number < i386_regtab_size) { exp->X_add_number = i386_regtab[exp->X_add_number] - .dw2_regnum[flag_code >> 1]; + .dw2_regnum[object_64bit]; if (exp->X_add_number != Dw2Inval) exp->X_op = O_constant; } @@ -17558,22 +17558,7 @@ tc_x86_parse_to_dw2regnum (expressionS * void tc_x86_frame_initial_instructions (void) { - static unsigned int sp_regno[2]; - - if (!sp_regno[flag_code >> 1]) - { - char *saved_input = input_line_pointer; - char sp[][4] = {"esp", "rsp"}; - expressionS exp; - - input_line_pointer = sp[flag_code >> 1]; - tc_x86_parse_to_dw2regnum (&exp); - gas_assert (exp.X_op == O_constant); - sp_regno[flag_code >> 1] = exp.X_add_number; - input_line_pointer = saved_input; - } - - cfi_add_CFA_def_cfa (sp_regno[flag_code >> 1], -x86_cie_data_alignment); + cfi_add_CFA_def_cfa (object_64bit ? REG_SP : 4, -x86_cie_data_alignment); cfi_add_CFA_offset (x86_dwarf2_return_column, x86_cie_data_alignment); } --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -396,6 +396,11 @@ extern void tc_x86_parse_to_dw2regnum (e #define tc_cfi_frame_initial_instructions tc_x86_frame_initial_instructions extern void tc_x86_frame_initial_instructions (void); +/* DWARF register number of the frame-pointer register in 64-bit mode. */ +#define REG_FP 6 +/* DWARF register number of the stack-pointer register in 64-bit mode. */ +#define REG_SP 7 + #define md_elf_section_type(str,len) i386_elf_section_type (str, len) extern int i386_elf_section_type (const char *, size_t); @@ -425,10 +430,6 @@ extern void x86_cleanup (void); R15 (15). Use SCFI_CALLEE_SAVED_REG_P to identify which registers are callee-saved from this set. */ #define SCFI_MAX_REG_ID 15 -/* Identify the DWARF register number of the frame-pointer register. */ -#define REG_FP 6 -/* Identify the DWARF register number of the stack-pointer register. */ -#define REG_SP 7 /* Some ABIs, like AMD64, use stack for call instruction. For such an ABI, identify the initial (CFA) offset from RSP at the entry of function. */ #define SCFI_INIT_CFA_OFFSET 8