From patchwork Thu May 26 16:49:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 54414 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 21E70385782D for ; Thu, 26 May 2022 16:54:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21E70385782D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584047; bh=idnnxolFhpYeIuIfD5b+5osiqghxfhqlzdqNoKJXW8k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TuBkkwqHELosg+XrLxoPEBGhYMvijUH0B/cSTl+RZ4IaFYTjgxr4XYIWoMS5syUqs w5AlE103R8XATb2GOF/uCK/LrvycmfmZ9VA/bgZ6J9wNx2xdPO9kO2qaoXVhEbn4tN dEMT0NR9SfERUDWL9Ljgu13ZLBTzTlvglA3GKIuc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id E565D3857340 for ; Thu, 26 May 2022 16:50:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E565D3857340 Received: by mail-oi1-x22a.google.com with SMTP id l84so2747200oif.10 for ; Thu, 26 May 2022 09:50:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=idnnxolFhpYeIuIfD5b+5osiqghxfhqlzdqNoKJXW8k=; b=W87u9K2bgZNEYCSy/HRRJdHNTQWkS2ZC43+Pgo9iKVE+OZ0NTI1iqkMlep0TVmNhna ju1ntXjn3Ax23Vt5w/evMtet9m05rIVX1LhNqf0YhS+8MV92N6yEi8AusHf1B6uJPjti YjHPT/rpnFnLz0lFGQGshXfThp0QlmogORrRqJF75TL0l+Dl7BCjS/ngazYD9L/mhmnu ks2kFHIQFqGwh9wByyiOXHBtM0FtN9pXH8TI/ng5GXChJiBPkNQrI086xzoXynlULyJJ 3ngOVjbk8zMUvfmduaZLfn552plardWUnBZc76cSE8o113M7S0XUhq5edwgHxfGcmp0v +buw== X-Gm-Message-State: AOAM530dPWlSnRY/W3kQpwO2o3JCwBh/9OqcNLp5XMGmoJonkIjkPIG1 TKgYQlt0Q0gi9nSq+gBJoAdJS8i8LSiSxw== X-Google-Smtp-Source: ABdhPJwMegjhBfLwdX2L2ji487BHNVI/n+Tekjb8w1bvgxpW9TZLewo/GOcbFdKRkz/cFD2xxoANYw== X-Received: by 2002:a05:6808:1b12:b0:32b:8181:8e38 with SMTP id bx18-20020a0568081b1200b0032b81818e38mr1684598oib.153.1653583815011; Thu, 26 May 2022 09:50:15 -0700 (PDT) Received: from birita.. ([2804:431:c7cb:9f85:b1e1:5370:63bd:a2ac]) by smtp.gmail.com with ESMTPSA id y26-20020a9d461a000000b0060603221255sm802521ote.37.2022.05.26.09.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:14 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 05/17] hppa: Remove _dl_skip_args usage (BZ# 29165) Date: Thu, 26 May 2022 13:49:51 -0300 Message-Id: <20220526165003.705355-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220526165003.705355-1-adhemerval.zanella@linaro.org> References: <20220526165003.705355-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Different than other architectures, hppa creates an unrelated stack frame where ld.so argc/argv adjustments done by ad43cac44a6860eaefc is not done on the argc/argv saved/restore by _dl_start_user. Instead load _dl_argc and _dl_argv directlty instead of adjust them using _dl_skip_args value. Checked on hppa-linux-gnu. --- sysdeps/hppa/dl-machine.h | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index 8c0ca32fc6..7d7230a291 100644 --- a/sysdeps/hppa/dl-machine.h +++ b/sysdeps/hppa/dl-machine.h @@ -415,10 +415,8 @@ asm ( \ So, obviously, we can't just pass %sp to _dl_start. That's \ okay, argv-4 will do just fine. \ \ - The pleasant part of this is that if we need to skip \ - arguments we can just decrement argc and move argv, because \ - the stack pointer is utterly unrelated to the location of \ - the environment and argument vectors. */ \ + It also mean that to get the correct argc and argv if the \ + program is ld.so it requires to read _dl_argc and _dl_argv. */\ \ /* This is always within range so we'll be okay. */ \ " bl _dl_start,%rp\n" \ @@ -430,22 +428,18 @@ asm ( \ /* Save the entry point in %r3. */ \ " copy %ret0,%r3\n" \ \ - /* See if we were called as a command with the executable file \ - name as an extra leading argument. */ \ -" addil LT'_dl_skip_args,%r19\n" \ -" ldw RT'_dl_skip_args(%r1),%r20\n" \ -" ldw 0(%r20),%r20\n" \ - \ -" ldw -40(%sp),%r25\n" /* argc */ \ -" comib,= 0,%r20,.Lnofix\n" /* FIXME: Mispredicted branch */\ -" ldw -44(%sp),%r24\n" /* argv (delay slot) */ \ - \ -" sub %r25,%r20,%r25\n" \ + /* Load argc and store the argc if the loader changes it. */ \ +" addil LT'_dl_argc,%r19\n" \ +" ldw RT'_dl_argc(%r1),%r20\n" \ +" ldw 0(%r20),%r25\n" \ " stw %r25,-40(%sp)\n" \ -" sh2add %r20,%r24,%r24\n" \ + \ + /* Same for argv. */ \ +" addil LT'_dl_argv,%r19\n" \ +" ldw RT'_dl_argv(%r1),%r20\n" \ +" ldw 0(%r20),%r24\n" \ " stw %r24,-44(%sp)\n" \ \ -".Lnofix:\n" \ /* Call _dl_init(main_map, argc, argv, envp). */ \ " addil LT'_rtld_local,%r19\n" \ " ldw RT'_rtld_local(%r1),%r26\n" \