From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 92D8D3857400 for ; Fri, 29 Jul 2022 20:14:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 92D8D3857400 Received: by mail-pj1-x102a.google.com with SMTP id e8-20020a17090a280800b001f2fef7886eso6247292pjd.3 for ; Fri, 29 Jul 2022 13:14:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F4Rwlq0aq5cfiy93TVXjPZnDpnZz378IGLofwCa4iTQ=; b=1qGwychUPRqUwNnnVp19Ton1nDJ+2zGIK8gRBFYWr4BnIy/Yazg+lvcstS/ZCiX2IU GKlRtz1edD9wIfStqI9p8s79GG9tEoMDXxxEJvzVTrOt8zZi5v0YbujS02RT8ncEzlR9 sehNINtuO2d4ZKUTu2w0l3fGwgxq2+UmiH9ALitc7WEdvEWl/oL7hN2HZgr44Uq2BO6p QrCHn65G47tFaz/xha1ekliSQCxf6BPyFlbQNfBtuYA7uuU/xlPiWgGn/boo5ywyRuyM H2SJ9z3S0/MMQzs4oKSDtiek/4jpWwU5oXfXw3FjgLpZ23cjV4jqdtrOkrMrjR4+QnRG 8/Kg== X-Gm-Message-State: ACgBeo0t0dwuJs2Mg+nfFt/6YDQpAtjuk3TAu5ShBZ3eFyvdGv67Lo+g 1aWC3othOR5E7T7fp6yy7ZAn7lVmW6qf12U1s7g= X-Google-Smtp-Source: AA6agR5OiKrQXVkl7yEFKqas8jSWrEwhFut0PDd/BhomPXjyFK1Y5BnoCsCJq6QZ9FF/xlgsPKopQQhC2uXwaoaL3+k= X-Received: by 2002:a17:90b:4a47:b0:1f2:b626:3a88 with SMTP id lb7-20020a17090b4a4700b001f2b6263a88mr6527317pjb.177.1659125659351; Fri, 29 Jul 2022 13:14:19 -0700 (PDT) MIME-Version: 1.0 References: <20220625175259.3171982-1-och95@yandex.ru> In-Reply-To: <20220625175259.3171982-1-och95@yandex.ru> From: Cary Coutant Date: Fri, 29 Jul 2022 13:14:08 -0700 Message-ID: Subject: Re: [PATCH] gold/aarch64: Fix adrp distance check To: Vladislav Khmelevsky Cc: Binutils Content-Type: text/plain; charset="UTF-8" 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, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2022 20:14:22 -0000 > The offset between destination and location is a signed number, > currently the offset is treated as unsigned number, thus mathematical > shifting of negative value is performed incorrectly. Do you have a test case to illustrate the problem? + int64_t offset + = static_cast (Reloc::Page (dest) - Reloc::Page (location)); + int64_t adrp_imm = offset < 0 ? ~(~offset >> 12) : offset >> 12; C++ conventions: No space before paren in a function call. The cast is unnecessary here for assignment to an int64_t. Once the result is in a signed int, I don't think you need to go to all that extra trouble to shift it. I'd suggest this instead: int64_t adrp_imm = Reloc::Page(dest) - Reloc::Page(location); adrp_imm >>= 12; -cary