From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by sourceware.org (Postfix) with ESMTPS id 4FD883858C60 for ; Mon, 14 Nov 2022 15:52:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4FD883858C60 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-io1-xd30.google.com with SMTP id s10so8450369ioa.5 for ; Mon, 14 Nov 2022 07:52:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=uwQWmPlcUhaceQb/IWa70fBdW2ILi2hFzFH30h8Geng=; b=WB3HrIW4OiM0/I8Bvf8g40rEw28x/SyT1NSi+VtXLPFqo+jHLep1PeHbXGvyU4W/iH 6XlLpd0RO2jCp2V5j38SqsBNninfbAhQiz8OrXGBwfJZyKal1WYHO/kHCRrBvQpFROaQ rVYr2W11gEZL9/EV0km8a3WgAlJYhoiXmUEsBPEem6l+4dCFDtb3PtdHlpQQrrcCaym6 rI1n71zoBQUWOvIQXT1E+YR7LyrWg28jAl54EgXc8lgKlIgQ62WOs+KvHo7JNF2Ffcdu bovMO7YNKFryYp8TgUFETcc5C5bUt7PacDQf2KbhqJKKLyqo1Hei2s3ofcbnZg43okl3 iBNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uwQWmPlcUhaceQb/IWa70fBdW2ILi2hFzFH30h8Geng=; b=ZRTscvl6o/5IfCUdantgcCmM+k4Lvsnp5xXUOZtJV6XoJyIlRObI1M5Ij1tk1QqNdi c9Wm8g9aDP/HfAgI9UvVE4my9XOA053Jh4iBV+Lo86cYCYmy0LXWDArO96PkG9YvuS3Y wMxl7I2qKwjczjWvjt/159jEQ6YO7iHZbZgv0dQl/Lde2OPCgcGX0HABe4zBr/XkhkG2 8d1LEsUVwJEzKCDnKM5gYDGGOtwTjRxjM8sYNfOdudk/PdyyDQZ/ICe+Q4MBY+tcBAWs oltmyMED6za8Q6cHfCwrXBWWoI+skkAyiSi79ZiuypxSOVE+UxybYj9fWAefGteMmpod G4Gg== X-Gm-Message-State: ANoB5pngDKDEKxcOKDMMjsDUf1un+9QEnXY+rFs7xoUY5CAJUc86aZN2 TFzEi21O9SdOO5A3gDyjweCIWCedFulcIvi5kdas3rcwjl4DBg== X-Google-Smtp-Source: AA0mqf6l6/cifWMzXRvKxJpke43Qyp18KgdulCIOofXcF91amHTJ9wmgrnweoSyJ9sBhWTBAovksEPKei9cFGwxSbu4= X-Received: by 2002:a05:6638:ed1:b0:363:a9de:efd2 with SMTP id q17-20020a0566380ed100b00363a9deefd2mr6142047jas.296.1668441162634; Mon, 14 Nov 2022 07:52:42 -0800 (PST) MIME-Version: 1.0 References: <20221114150348.112815-1-bwerl.dev@gmail.com> <8c1844c9-4b04-0200-c24e-c33009562477@suse.com> In-Reply-To: <8c1844c9-4b04-0200-c24e-c33009562477@suse.com> From: Brett Werling Date: Mon, 14 Nov 2022 09:52:30 -0600 Message-ID: Subject: Re: [PATCH] readelf: use fseeko for elf files >= 2 GiB on x86_64-mingw32 To: Jan Beulich Cc: binutils@sourceware.org Content-Type: multipart/alternative; boundary="000000000000d3db3c05ed703a4b" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,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: --000000000000d3db3c05ed703a4b Content-Type: text/plain; charset="UTF-8" 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. 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 --000000000000d3db3c05ed703a4b--