From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id E69F63858D33; Fri, 20 Jan 2023 16:49:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E69F63858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x42b.google.com with SMTP id bk16so5354542wrb.11; Fri, 20 Jan 2023 08:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=DMuXzoAD3ktPX5ErK5M45Gfj+kzQ70pfadK8ukPC+N8=; b=liaImY2s1PfkA6WdC43SRkpdTwp7FPpLh8x173bJIDT1bGnO2FK4jmE7docW+ePDM/ NB2p+o3ajJ3+BNxWsHotnUCsLsRDwX+MIVHpMO+7wqXYfMSirrS95dHR4I7MOQT+qxP4 R5HMKmjq9CcFQkBDYmDOG3NBV9vnCtgemaOGmlbxQ5mriGYtHorFoVdxUgOy0tz+qdP9 CObMClPD4QDQ/pv1E08IZpVx1UppYXtU3oMRTiFxR9oZaXoVsbUwdYIleGdZD7aSkHWl rwgYimUC83vtUo4hxN4mtukxjHqw+6vJ3T1y421tjNp7o4Tm64jphTlZLK+mAg8xsyX3 kKhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DMuXzoAD3ktPX5ErK5M45Gfj+kzQ70pfadK8ukPC+N8=; b=S3RXbrXvRHPkLVvSYzRQ3MyPz9xksn6YGbf3LRPO2y9nQdZVWckFBuDEbkP23B5GdN /7ttt2sB4fweC5H3rAxxTdV2n4FBgNteQmfP61DTFlatJ/3tCTg0lxisghz9/TtjdoSk Cw1PoroULLnmYh3wPzJ9ylLNI5WpmP4fdm2WvvpNX68pC2MMHCwjyWRaD581Vb+SxvGT ACBPOj9xFzjT5Jpr9koTyvLLFbg5mncP39m6dRAYfzKID5hedhmAaBzD8mhdeh6nuY3w PGj/bsKfImqSrgIZaNV17YxkkXqbSv3SetMnPxcycfCI/07B/fSSWHT14MaptPSvI3CN gNbA== X-Gm-Message-State: AFqh2krDdpg2fNHRA9BaSzciS+p/jWlzndTe7JZrKUG3DnjcKDaInn3X euzuIr1Oot3zgc28NvLtJ9U= X-Google-Smtp-Source: AMrXdXvUusGD+XG2NPcXPJZNA6O6gTFmWyWIFDnvwgkPAe67e/n0osBcb73SOalrTKNof5ImJcHOBg== X-Received: by 2002:adf:fd83:0:b0:2bd:dbd8:d41e with SMTP id d3-20020adffd83000000b002bddbd8d41emr13617929wrr.57.1674233352629; Fri, 20 Jan 2023 08:49:12 -0800 (PST) Received: from [10.21.0.4] ([185.246.211.91]) by smtp.gmail.com with ESMTPSA id c14-20020adfa30e000000b002be50604c81sm2887083wrb.47.2023.01.20.08.49.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Jan 2023 08:49:12 -0800 (PST) Message-ID: Date: Fri, 20 Jan 2023 17:46:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH 3/4] libbacktrace: work with aslr on windows To: Eli Zaretskii , =?UTF-8?Q?Bj=c3=b6rn_Sch=c3=a4pers?= Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org References: <20230120105409.54949-1-gcc@hazardy.de> <20230120105409.54949-3-gcc@hazardy.de> <83zgadmik1.fsf@gnu.org> Content-Language: en-US From: Gabriel Ravier In-Reply-To: <83zgadmik1.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_ABUSEAT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 1/20/23 14:39, Eli Zaretskii via Gcc wrote: >> From: Björn Schäpers >> Date: Fri, 20 Jan 2023 11:54:08 +0100 >> >> @@ -856,7 +870,12 @@ coff_add (struct backtrace_state *state, int descriptor, >> + (sections[i].offset - min_offset)); >> } >> >> - if (!backtrace_dwarf_add (state, /* base_address */ 0, &dwarf_sections, >> +#ifdef HAVE_WINDOWS_H >> + module_handle = (uintptr_t) GetModuleHandleW (NULL); >> + base_address = module_handle - image_base; >> +#endif >> + >> + if (!backtrace_dwarf_add (state, base_address, &dwarf_sections, >> 0, /* FIXME: is_bigendian */ >> NULL, /* altlink */ >> error_callback, data, fileline_fn, > Why do you force using the "wide" APIs here? Won't GetModuleHandle do > the job, whether it resolves to GetModuleHandleA or GetModuleHandleW? I would expect the reason to be either that: - using wide APIs with Windows is generally considered to be a best practice, even when not strictly needed (and in this case I can't see any problem with doing so, unless maybe we want to code to work with Windows 95 or something like that...) - using the narrow API somehow has an actual drawback, for example maybe it might not work if the name of the exe file the NULL will tell it to get a handle to contains wide characters