From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from APC01-HK2-obe.outbound.protection.outlook.com (mail-oln040092255043.outbound.protection.outlook.com [40.92.255.43]) by sourceware.org (Postfix) with ESMTPS id 181EE3858018 for ; Thu, 12 Nov 2020 11:43:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 181EE3858018 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iNs60YzpcKSc7pTazQc4erku+91t68duncm1Q0FXDb/DlThuZh6BaJC3H2Ikx9Ycs7+pp4WTOk4fhmIYYsIPBr2JJ0chDrDOO8ggpOLcKM8Yxg1/4tXl/zvGn4SzcR4Zmq4CAPHqhV2vZ7ugact+ygD3dhcJVHYlw5Q9W8rcLHvqDrIi1W0nXRnHz57d4QrVrmwIk205RHiYbN/Wq99hw7H7iQny7OlDN/FWOK/pci+4imbxUXw2G9J/5b7fBzU767U3Ksc/xl4Pm2xbh7NxD8t7+nL1b/NmQmzQN5yc0TUGJFOUpRhzE3T9a59X9tDoq2n4mUOnsBxwjAj3yvE5lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0GyrcsKroRu7X9J5qKkLsCNLJNb8FrdooBo2RYSgZP0=; b=ma02XB7JUNedib/x2m2+4pp5uPKPSxRDywqwOdEw0rjEKTj0sD1vHFXPl6wnyJHDFaPnZs90kUgU7u/8aRxqEqMgwp/d4XCVCHWperPWGI2HDhacPyfob87uVHrIaM18OPlsbwLx3dQKEBkH8O7j/y4NGjo7Nk44UA51zycfNuusMoPzijk5RZQoIATY5tmTrgPkY0KeWTot83WvJMTdbg7W7+lUKViwjAcz6MAUFbtHxfPWy4S3Wbs/5dBTRyFFvPp71PXR9HjcIUQS5LiOU6p4O8mcpogXwZkawbpT5AMM76HLqNAs2PxVhyxhTYdY+RJc2ueU8nSG7pYgqfxF+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from HK2APC01FT021.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::51) by HK2APC01HT140.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::369) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.22; Thu, 12 Nov 2020 11:43:34 +0000 Received: from SL2PR02MB3596.apcprd02.prod.outlook.com (2a01:111:e400:7ebc::49) by HK2APC01FT021.mail.protection.outlook.com (2a01:111:e400:7ebc::181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.22 via Frontend Transport; Thu, 12 Nov 2020 11:43:34 +0000 Received: from SL2PR02MB3596.apcprd02.prod.outlook.com ([fe80::a1e9:efdc:8c75:8377]) by SL2PR02MB3596.apcprd02.prod.outlook.com ([fe80::a1e9:efdc:8c75:8377%7]) with mapi id 15.20.3541.025; Thu, 12 Nov 2020 11:43:34 +0000 From: x visitor To: Henri Cloetens CC: "gcc-help@gcc.gnu.org" Subject: Re: When will gcc assign local variables to registers? Thread-Topic: When will gcc assign local variables to registers? Thread-Index: AQHWuMCVPoeC50coCEmWuulQyGkUtKnEVlZQ Date: Thu, 12 Nov 2020 11:43:33 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:7B1746BCD8417F9264C3872C53953CEC2DEB2049D8C5B7FC74A2EFE8CA0AA87E; UpperCasedChecksum:0574AC317C92132D6A01F3F9790D8A5EF327EF109B9D4F204D07600C2F6A25E8; SizeAsReceived:7029; Count:44 x-tmn: [fIoU/79viMjWqD8xAikVLulhf1MYjz/paHXh/i4iXiM=] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: be01f597-37ab-467b-73b1-08d887002fcc x-ms-traffictypediagnostic: HK2APC01HT140: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /WY6DET/bE0/tKmwPgV/9ELV+Pkjcf4rqAFyEdFA95gWQ609YooObM8+wltqE6RKH+scWYUR+h37wLiSk7I6WfQFfZVEHrPKL5FBSynm6PRs1VzrIr0iCoEPAmYhL6rjEb+Kg4IH7OrSH7KG7Ex4TWrxVEDN5wQo6BwMDX8mLVARSHj3rqMX9Nd3Qg9itYxAs/o4vLJ8+nho8QaXn0vzpg== x-ms-exchange-antispam-messagedata: MtOpaWCTNn43bLC34ZJu2/QG0yUO0Ab9IZm/PRq7NkYl3dE3Ud0Z65ouTPSrJgh5YUB/ZuTTfL1WOq9i5a1sSOC3FsQykTFd5e99wdE4bqVkPzPf+4rKg4Q/rDPAG4rRNMrPtKGs5myuBZZHkYGU8g== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT021.eop-APC01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: be01f597-37ab-467b-73b1-08d887002fcc X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2020 11:43:33.8876 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2APC01HT140 X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, DEAR_SOMETHING, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2020 11:43:41 -0000 Thank you, Henri. The goal is to determine whether two instructions in binary access the same= variable. This information will be very helpful to detect code similarity and homology. The challenge is that source code is not available (yes, it's more like a r= everse-engineer). Even worse, the compiler options used to generate the target binary remains unkn= own and out of control in a more common case. I suppose this task is a little easier than = reverse-engineer because the latter aims at complete recovery of source code. I'm collecting= alias analysis techniques applicable to binary-only situation with the hope of a solution. I will try -fdump option and take it as a good way to learn gcc's behavior. Thank you again. From: Gcc-help on behalf of Henri Cloetens <= henri.cloetens@blueice.be> Sent: Thursday, November 12, 2020 14:54 To: gcc-help@gcc.gnu.org Subject: Re: When will gcc assign local variables to registers? Dear Sir, What do you want to do ?. - Gcc, especially when the optimizers are turned on, heavily optimizes the source code. If you want to reverse-engineer, in order to recognize the C-source in the assembly, some suggestions: 1. Turn on the debug option. Then, GCC annotates the assembly introducing info as to which assembly statement belongs to which source line. It may not work with the optimizer on. 2. Run the compiler with -fdump-all. Then, it outputs a lot of verbose files, documenting how the compile and optimizations have been done. It includes all the restructuring, and also the register allocation. Now, good luck with that, it are long and difficult to read files. Best Regards, Henri. On 11/12/20 6:04 AM, visitor x via Gcc-help wrote: > Thank you for the pointer. > > I learned SSA and realized that the problem is more challenging than I th= ought. As far, my understanding of SSA is that compilers restrict the defin= ition site of each variable to only one by introducing phi-function and oth= er tools. In this way it facilitates data flow analysis and further optimiz= ation such as dead code elimination. > > My idea before is to list all possible manners that compilers assign vari= ables to registers, then it may be easier to recover variables from binary.= Now it seems to be an impossible mission. So I rethink my ultimate goal, e= ssentially a track to variable access sequence, which doesn=92t require ful= l decompilation (maybe). > > All we need to know is whether two instructions access the same variable = (or say object if compilers care about only values). It sounds like an alia= s analysis in binary. Is it a specialized subfield in program/binary analys= is? >