From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 92CCA3858D1E for ; Mon, 14 Nov 2022 21:43:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 92CCA3858D1E 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-pf1-x434.google.com with SMTP id b185so12290505pfb.9 for ; Mon, 14 Nov 2022 13:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=l/jGsUvUYGva7dll4LxXZ68zO3M0bNVfvz9ofvvm+i8=; b=Y46+4T1bnFiJY/dSe1SrH1DluHNrAJuYWDGHEUhacVaBCe0pwBYx4YNlxl77QLkmfX Wuvc5I9JRO+vkdhnJSHED5FWvI9qkHnH0XL4BMWKoJgi8fVZhjFtMNj94ySk/h/skgug rzpCEI09Icqid7BCG3ED5cREUoV+E+UWLCMrTALDMT3nAOI8rMvcwo0W+/v9a4eXucb9 j8IbYB2Q/ZaKpoAjLoJ2C7/4jVS+pF5dtlGxdxpiEaQ3IMxIBnfd8CBAcds4Y/1mQDqM 9joXg9JAFCxzg8LU3asFlt1Us7xlcM+bq2KaZl5Ya0E7JFmRaSTWDq70hX2ZT/yMdX/k QCsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=l/jGsUvUYGva7dll4LxXZ68zO3M0bNVfvz9ofvvm+i8=; b=xxOu7px6ignVnne7xFIScVOytf0YX6Icji8BR8DnRy5R4K5Z3nIwnhU4qMgimgE/1Q GRczdLjpgrsl1NPHndK6ewh1hMHlEmMrKussOogiR8M5ZY7yotwOWN6J+Tst1Nms4/xp o1FyTruLvqXxJ7ZXRtPoHuEP0rCO6+aPxwRvrjA2YG0gwaX/48mxQlWEglbBhyl/8KFo 8fmyOqvHVY6jq7eLbDku/+GgWGRpC6xD0u2K3p+D4oQNswoaYhtMkymdCH3cJEToQRnZ YBJvalR2ENQSFetaGAZ3TK/FJmbaUDKY1q0r/iFp0PynSJ3TkMs5cNZYkSnDCl9PT0PG lV+w== X-Gm-Message-State: ANoB5plkLbJzd9lUTkj6HuAlyYOp54WHkjbW+l6Zahbl8AqFCDmydg6W PZTPQ2oynbDUaAhzJsnOeu5Bwf590Gw= X-Google-Smtp-Source: AA0mqf6H+s9TPIykVZ0ILbPIX8ZD7VNuxW0fEs2RZT5Hqutev5L+ffAxkZWgk2YB4xZThgUGCReh3w== X-Received: by 2002:a63:e758:0:b0:470:89:8e92 with SMTP id j24-20020a63e758000000b0047000898e92mr12803503pgk.487.1668462179514; Mon, 14 Nov 2022 13:42:59 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id 186-20020a6204c3000000b0056da63c8515sm7397420pfe.91.2022.11.14.13.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 13:42:58 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id EEDFE1140D3D; Tue, 15 Nov 2022 08:12:55 +1030 (ACDT) Date: Tue, 15 Nov 2022 08:12:55 +1030 From: Alan Modra To: Brett Werling Cc: Jan Beulich , binutils@sourceware.org Subject: Re: [PATCH] readelf: use fseeko for elf files >= 2 GiB on x86_64-mingw32 Message-ID: References: <20221114150348.112815-1-bwerl.dev@gmail.com> <8c1844c9-4b04-0200-c24e-c33009562477@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3029.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_NUMSUBJECT,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 Mon, Nov 14, 2022 at 09:52:30AM -0600, Brett Werling via Binutils wrote: > On Mon, Nov 14, 2022 at 9:30 AM Jan Beulich wrote: > > > On 14.11.2022 16:03, Brett Werling via Binutils wrote: > > > Switch all fseek calls to fseeko and cast the given offset as an off_t > > > accordingly. When building readelf for x86_64-mingw32, a long will only > > > be 32 bits wide. If the elf file in question is >= 2 GiB, that is > > > greater than the max long value, and therefore fseek will fail > > > indicating that the offset is negative. > > > > > > To work around this and support up to 4 GiB, we switch to using fseeko > > > and cast the unsigned long offsets as off_t values because the size of > > > off_t is 64 bits on x86_64-mingw32. > > > > Is fseeko() uniformly available on all platforms binutils can be built > > for? I'm afraid the answer is no, so at least you'd need to introduce > > some configure logic for this plus some abstraction. > > > > Jan > > > > I think you are correct, this will need some conditional logic to be "safe" > to > include, and even then the casting to off_t would become a little more > complicated. I will look deeper into what can be done here. See bfd/bfdio.c and bfd/configure.ac > I had also considered iterative calls on fseek() using longs and SEEK_CUR, > just ensuring that we don't blow past LONG_MAX. That didn't seem as > clean or efficient of a change, so I dropped it. > > Brett -- Alan Modra Australia Development Lab, IBM