From patchwork Thu May 26 16:49:47 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: 54410 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 5C89F3857355 for ; Thu, 26 May 2022 16:51:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C89F3857355 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653583872; bh=a3EHeRFX/s4xweqfndf1aDY9doZYfpsGYYWmYMVE0CY=; 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=OriRcHbR3J/LkjsHXAf5GutrfxpeoJUg67l+xXxNQ+Z7OHWlF1/vHROEj1QjnU2JG sVLermQ+SlXF3PnvQyNUZcwyextbgsg8znKktt0+Vn0hX9v4Q4652hRUzWp4X2p7as ArK4BbJSJC8Od4qKBSAUR0vIwploUROVTqWpXdEY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by sourceware.org (Postfix) with ESMTPS id 68CF43857428 for ; Thu, 26 May 2022 16:50:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 68CF43857428 Received: by mail-oo1-xc31.google.com with SMTP id c17-20020a4ac311000000b0040ea8bf80f2so383377ooq.1 for ; Thu, 26 May 2022 09:50:11 -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=a3EHeRFX/s4xweqfndf1aDY9doZYfpsGYYWmYMVE0CY=; b=dODropFPWmhU/Sov9hTwlzkRzjUmQpi6FMp7M4Z4tSCxn+SPaFUhdRpWYxmthL87F7 q7UcKhPD+kuKnF184nua78qq9baHvTqvjqyGs6bKTye+isjDzoKf2DPH8URG1DLHwhZn 3q7Sj1unonsvCwamIcMme2Di+o9/b6nhuxlyU2DtKcLNuccCQvsUC9WTRzNGWU4DQMFB lYKCdz98NFDDMZrM1fRgdOwMp68VX6gs/BHy2zhnk9J129Kux00u2m85dDnksai50PC8 3oH2ti6FKB8dEeMNzurHimgsIaumRhdzXkr7aAu6BveHhhB3OTxFaB+sLGu+rTjBJOWh mTag== X-Gm-Message-State: AOAM531FilwQ3CQjEkZeOc4dsHSKLzBDdc8bY19i9HOdR/T+J1C/Z5p0 4Km6jitFarllpABO/1QuFWMzY59owlqJow== X-Google-Smtp-Source: ABdhPJwEdzlAT2+0jMMAw4JGG4uk1YvnFeaWrALq2uPWlAzMO6EGCPM5/4mNrmyoeHqoSHeaj/1pkw== X-Received: by 2002:a4a:c19a:0:b0:40e:4a3c:202e with SMTP id w26-20020a4ac19a000000b0040e4a3c202emr15285126oop.48.1653583809339; Thu, 26 May 2022 09:50:09 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:08 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 01/17] alpha: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:47 -0300 Message-Id: <20220526165003.705355-2-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=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SCC_5_SHORT_WORD_LINES, 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. It makes the fixup_stack branch ununsed. Checked with qemu-user that arguments are correctly passed on both constructors and main program. --- sysdeps/alpha/dl-machine.h | 41 -------------------------------------- 1 file changed, 41 deletions(-) diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h index ccee972c96..f0ba8e88af 100644 --- a/sysdeps/alpha/dl-machine.h +++ b/sysdeps/alpha/dl-machine.h @@ -156,12 +156,6 @@ _dl_start_user: \n\ .prologue 0 \n\ /* Save the user entry point address in s0. */ \n\ mov $0, $9 \n\ - /* See if we were run as a command with the executable \n\ - file name as an extra leading argument. */ \n\ - ldah $1, _dl_skip_args($gp) !gprelhigh \n\ - ldl $1, _dl_skip_args($1) !gprellow \n\ - bne $1, $fixup_stack \n\ -$fixup_stack_ret: \n\ /* The special initializer gets called with the stack \n\ just as the application's entry point will see it; \n\ it can switch stacks if it moves these contents \n\ @@ -182,41 +176,6 @@ $fixup_stack_ret: \n\ /* Jump to the user's entry point. */ \n\ mov $9, $27 \n\ jmp ($9) \n\ -$fixup_stack: \n\ - /* Adjust the stack pointer to skip _dl_skip_args words.\n\ - This involves copying everything down, since the \n\ - stack pointer must always be 16-byte aligned. */ \n\ - ldah $7, __GI__dl_argv($gp) !gprelhigh \n\ - ldq $2, 0($sp) \n\ - ldq $5, __GI__dl_argv($7) !gprellow \n\ - subq $31, $1, $6 \n\ - subq $2, $1, $2 \n\ - s8addq $6, $5, $5 \n\ - mov $sp, $4 \n\ - s8addq $1, $sp, $3 \n\ - stq $2, 0($sp) \n\ - stq $5, __GI__dl_argv($7) !gprellow \n\ - /* Copy down argv. */ \n\ -0: ldq $5, 8($3) \n\ - addq $4, 8, $4 \n\ - addq $3, 8, $3 \n\ - stq $5, 0($4) \n\ - bne $5, 0b \n\ - /* Copy down envp. */ \n\ -1: ldq $5, 8($3) \n\ - addq $4, 8, $4 \n\ - addq $3, 8, $3 \n\ - stq $5, 0($4) \n\ - bne $5, 1b \n\ - /* Copy down auxiliary table. */ \n\ -2: ldq $5, 8($3) \n\ - ldq $6, 16($3) \n\ - addq $4, 16, $4 \n\ - addq $3, 16, $3 \n\ - stq $5, -8($4) \n\ - stq $6, 0($4) \n\ - bne $5, 2b \n\ - br $fixup_stack_ret \n\ .end _dl_start_user \n\ .set noat \n\ .previous"); From patchwork Thu May 26 16:49:48 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: 54411 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 AE9583857350 for ; Thu, 26 May 2022 16:51:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE9583857350 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653583914; bh=63aRecK8MU2YPraF6VBttloiJVnJsxcFR3sF05HLeXw=; 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=sGI4kWxqaQ5SBU9xIwo1YHMYRZbcvTrKFWguV8JKl+kb1lmsEzrAJ5lAYRMcFSidL +qHWz9qQXQYFlRBs02kywVqrW3QmAq5b2LwPuSg5grjjiv/d3gh4IGOvvdUGOhiFYG TWHQKi7lXBVkR0t9KEv9GdBP4V2AesSmUr5cSTsM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by sourceware.org (Postfix) with ESMTPS id BB0A838376ED for ; Thu, 26 May 2022 16:50:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BB0A838376ED Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-f2bb84f9edso2827045fac.10 for ; Thu, 26 May 2022 09:50:12 -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=63aRecK8MU2YPraF6VBttloiJVnJsxcFR3sF05HLeXw=; b=h4ALy66uwDyICg2ba81+kckvs3ih4sXZ4Z8nArkl/dn94202opV/6yttH4YXOHXH7+ XsW4WU3knphVBIHXtXNYa/q+wMNQcG5JX6FR1k0L+gvWgmfVr6/RWSruBJ6cZFuaGBTu nuflTOA5g+Z6dcGoXFQnkffjesFatzXoBuvYNDWWtZAejHgnvtigxBIJ5bV5ZNyFkkhT bzxSFfNBlkAFWM0cwF5WqXiKeT3wpZ1TozOizf48ygD+zbNNYiRYGs3OwacO0yBeYs4x kqdILqENdJ0+XXfcn39d9hURDSO3/dkiOsnbMkVco6wj431StbCnPKpbj61CYFPRkImp b3mg== X-Gm-Message-State: AOAM533bBm0Whd73d6diu0b5In8t5IlkZv+L4hXm5UxUOQXnrZ3P0A+c JGgu/eCbxzNPn8hwecYJwfCs15WRq9ul2w== X-Google-Smtp-Source: ABdhPJy7cf+kn4ri/UZDHlJbr8E+p1nkzmVu8xV43Nxh+jxVyM9+nUYHakTCCSWioYWmFxa9KlY8lg== X-Received: by 2002:a05:6870:ecac:b0:f2:c445:482a with SMTP id eo44-20020a056870ecac00b000f2c445482amr1760961oab.60.1653583810826; Thu, 26 May 2022 09:50:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:10 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 02/17] arm: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:48 -0300 Message-Id: <20220526165003.705355-3-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.4 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. It makes the _fixup_stack branch ununsed. Checked with qemu-user that arguments are correctly passed on both constructors and main program. --- sysdeps/arm/dl-machine.h | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h index 2a7f795e46..6a422713bd 100644 --- a/sysdeps/arm/dl-machine.h +++ b/sysdeps/arm/dl-machine.h @@ -130,9 +130,6 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], _start:\n\ @ we are PIC code, so get global offset table\n\ ldr sl, .L_GET_GOT\n\ - @ See if we were run as a command with the executable file\n\ - @ name as an extra leading argument.\n\ - ldr r4, .L_SKIP_ARGS\n\ @ at start time, all the args are on the stack\n\ mov r0, sp\n\ bl _dl_start\n\ @@ -147,10 +144,6 @@ _dl_start_user:\n\ ldr r1, [sp]\n\ @ get the argv address\n\ add r2, sp, #4\n\ - @ Fix up the stack if necessary.\n\ - cmp r4, #0\n\ - bne .L_fixup_stack\n\ -.L_done_fixup:\n\ @ compute envp\n\ add r3, r2, r1, lsl #2\n\ add r3, r3, #4\n\ @@ -164,41 +157,9 @@ _dl_start_user:\n\ add r0, sl, r0\n\ @ jump to the user_s entry point\n\ " BX(r6) "\n\ -\n\ - @ iWMMXt and EABI targets require the stack to be eight byte\n\ - @ aligned - shuffle arguments etc.\n\ -.L_fixup_stack:\n\ - @ subtract _dl_skip_args from original arg count\n\ - sub r1, r1, r4\n\ - @ store the new argc in the new stack location\n\ - str r1, [sp]\n\ - @ find the first unskipped argument\n\ - mov r3, r2\n\ - add r4, r2, r4, lsl #2\n\ - @ shuffle argv down\n\ -1: ldr r5, [r4], #4\n\ - str r5, [r3], #4\n\ - cmp r5, #0\n\ - bne 1b\n\ - @ shuffle envp down\n\ -1: ldr r5, [r4], #4\n\ - str r5, [r3], #4\n\ - cmp r5, #0\n\ - bne 1b\n\ - @ shuffle auxv down\n\ -1: ldmia r4!, {r0, r5}\n\ - stmia r3!, {r0, r5}\n\ - cmp r0, #0\n\ - bne 1b\n\ - @ Update _dl_argv\n\ - ldr r3, .L_ARGV\n\ - str r2, [sl, r3]\n\ - b .L_done_fixup\n\ \n\ .L_GET_GOT:\n\ .word _GLOBAL_OFFSET_TABLE_ - .L_GET_GOT\n\ -.L_SKIP_ARGS:\n\ - .word _dl_skip_args(GOTOFF)\n\ .L_FINI_PROC:\n\ .word _dl_fini(GOTOFF)\n\ .L_ARGV:\n\ From patchwork Thu May 26 16:49:49 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: 54412 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 3DC5E38376ED for ; Thu, 26 May 2022 16:52:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DC5E38376ED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653583962; bh=HuZwuGaz8lhU0DuyefILpq0xUYYyREhgpKT5TED3yWs=; 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=wM0wm3Gt5t0EOFWzgTV5BLlULse7rkEfER9KkCVDmyRgGyq/3GlOyUlbB6jogxQa6 HFmFdn/p6Rj2bnbFlqqAiAWQQ+jHMvrUpTk/l3YJkxqppthRKQW1wja0pMoWSGps/9 dCmE3zvEvsGDhPzoYJkyOv4It/cEaYQWaf35lxDY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by sourceware.org (Postfix) with ESMTPS id 628CB385737E for ; Thu, 26 May 2022 16:50:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 628CB385737E Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-edeb6c3642so2862971fac.3 for ; Thu, 26 May 2022 09:50:13 -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=HuZwuGaz8lhU0DuyefILpq0xUYYyREhgpKT5TED3yWs=; b=t2WV7N3wT7aT6YUUmdZ97uPrI041KDuXbqiL8SRR9TJ3n8qQTRJvHa1bB1zcYPGe15 yWW57MO+BAtwuBez+N3nZorA7q/t1suLubTDQzQ/mYlnWDnIYaGb+uM7tqFZjPZfcRH4 mMLX2KQwBBoHh/MaWBKt5og63zVFqB9drG9z80F/CTP3CxlX7fPlzQEHS91WTAA3rCO4 ESsdbZsn6Xu5b7FncScWHKvH76siLoTYEOYsQjefr3kiD3HxfCZa96CBtmnPXTebrtx9 Ne+kbqeoMPgEOJS5DdZZ5h6Oe8VDRm1mvv6Gslz3WwdZXSKmCZjuH5eZYwcIE56krS3g e3ig== X-Gm-Message-State: AOAM533vjsycIDwgI3FyHOKmQ009h+8ZTK2OQO+UisO5Bk1M+QFobuhR iGmjuXGZLMSizLqcswv2eh+yAugQRij/XA== X-Google-Smtp-Source: ABdhPJznkBkZxG3esODeOgnsRaI2EdVmkx9XsXYhEf6b1+5M5L5tIBO6tnQLA+mC3suvMQ7JGq4Rkw== X-Received: by 2002:a05:6870:8315:b0:e9:c1a:a1e0 with SMTP id p21-20020a056870831500b000e90c1aa1e0mr1783597oae.153.1653583812130; Thu, 26 May 2022 09:50:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:11 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 03/17] arc: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:49 -0300 Message-Id: <20220526165003.705355-4-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.5 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. --- sysdeps/arc/dl-machine.h | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h index 4ac3848557..c6ad232384 100644 --- a/sysdeps/arc/dl-machine.h +++ b/sysdeps/arc/dl-machine.h @@ -161,29 +161,16 @@ __start: \n\ bl.d _dl_start \n\ mov_s r0, sp /* pass ptr to aux vector tbl. */ \n\ mov r13, r0 /* safekeep app elf entry point. */ \n\ - \n\ - /* (2). If ldso ran with executable as arg. */ \n\ - /* skip the extra args calc by dl_start. */ \n\ ld_s r1, [sp] /* orig argc. */ \n\ - ld r12, [pcl, _dl_skip_args@pcl] \n\ - breq r12, 0, 1f \n\ \n\ - add2 sp, sp, r12 /* discard argv entries from stack. */ \n\ - sub_s r1, r1, r12 /* adjusted argc on stack. */ \n\ - st_s r1, [sp] \n\ - add r2, sp, 4 \n\ - /* intermediate LD for ST emcoding limitations. */ \n\ - ld r3, [pcl, _dl_argv@gotpc] \n\ - st r2, [r3] \n\ -1: \n\ - /* (3). call preinit stuff. */ \n\ + /* (2). call preinit stuff. */ \n\ ld r0, [pcl, _rtld_local@pcl] \n\ add r2, sp, 4 ; argv \n\ add2 r3, r2, r1 \n\ add r3, r3, 4 ; env \n\ bl _dl_init@plt \n\ \n\ - /* (4) call app elf entry point. */ \n\ + /* (3) call app elf entry point. */ \n\ add r0, pcl, _dl_fini@pcl \n\ j [r13] \n\ \n\ From patchwork Thu May 26 16:49:50 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: 54413 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 63E113857419 for ; Thu, 26 May 2022 16:53:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63E113857419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584005; bh=5joDfwt1mKzqc1i7NFeokoEyVF7YEWKALuEQKpCyUwM=; 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=pyCQBc4wMEKKO+zvif44G/qgyfsFmlTJ4EysjI4rJqkT3DNW31s7Fa53Dn6NXfXsF KijkyLcs9XL3AA81qb3NATxu5nxAVtNH5Mtzq1jwbpgveILYvm55Prp/csvMmUC6oO DqKK1y19kYjuUeGTL5K7zXk1ILnMnePr5w2e9diA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 6A3F73857357 for ; Thu, 26 May 2022 16:50:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A3F73857357 Received: by mail-oi1-x230.google.com with SMTP id t144so2763864oie.7 for ; Thu, 26 May 2022 09:50:14 -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=5joDfwt1mKzqc1i7NFeokoEyVF7YEWKALuEQKpCyUwM=; b=CcoA13WJbcWhPjdn1MPUsDuzDxdxoYnipHHx/dMxB7XN3oa4ivIEu5K22UdyQB0Qjm BMV7xP+KCqIhIwwedNh5HUuuBMZsd0TuW3O+G//nlX0cm2TZkzOOI+dHR73d7bCoGME5 GVaH+FLGdYG0X6KFpfv33f8tSVBYjvitElRqiOQNP4cpJJRRYzk4gzl1ALWmLVYY2yYS YynFyJbyf9lFZFRkfUSjlI643YA2WlobdRNOi18F67ZTRkhoGX6WyTnYt8Of+ksNZB8/ E6WXfsUnWnGavxjrq7eSzNVje8Rq5aIGsV97Sh5PNtxd33njGreUudkEi+aeyqsxznOt JgDQ== X-Gm-Message-State: AOAM532KEM16JpRonxahOb1+ihv4/RVLwBIvK9Lex+Qo3lB3v22De3my 2pcoxjkZB3UWBKDvDqe3EAcFBcLeckgoQw== X-Google-Smtp-Source: ABdhPJxX3+2sZMC2W4oC2NDuPeUAJ+LsDPTWhJnVJN7vNjvfip3ovAggt2h/G+TVQQ34b4g7x4BlDA== X-Received: by 2002:a05:6808:170d:b0:2f7:338b:1fc2 with SMTP id bc13-20020a056808170d00b002f7338b1fc2mr1667602oib.60.1653583813582; Thu, 26 May 2022 09:50:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:13 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 04/17] csky: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:50 -0300 Message-Id: <20220526165003.705355-5-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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. It makes the fixup_stack branch ununsed. --- sysdeps/csky/dl-machine.h | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/sysdeps/csky/dl-machine.h b/sysdeps/csky/dl-machine.h index f81448a141..48787ce3c7 100644 --- a/sysdeps/csky/dl-machine.h +++ b/sysdeps/csky/dl-machine.h @@ -113,11 +113,7 @@ _start:\n\ addu t1, gb\n\ jsr t1\n\ _dl_start_user:\n\ - /* get _dl_skip_args */ \n\ - lrw r11, _dl_skip_args@GOTOFF\n\ - addu r11, gb\n\ - ldw r11, (r11, 0)\n\ - /* store program entry address in r11 */ \n\ + /* store program entry address in r10 */ \n\ mov r10, a0\n\ /* Get argc */\n\ ldw a1, (sp, 0)\n\ @@ -125,8 +121,6 @@ _dl_start_user:\n\ mov a2, sp\n\ addi a2, 4\n\ cmpnei r11, 0\n\ - bt .L_fixup_stack\n\ -.L_done_fixup:\n\ mov a3, a1\n\ lsli a3, 2\n\ add a3, a2\n\ @@ -141,17 +135,6 @@ _dl_start_user:\n\ lrw a0, _dl_fini@GOTOFF\n\ addu a0, gb\n\ jmp r10\n\ -.L_fixup_stack:\n\ - subu a1, r11\n\ - lsli r11, 2\n\ - addu sp, r11\n\ - stw a1, (sp, 0)\n\ - mov a2, sp\n\ - addi a2, 4\n\ - lrw a3, _dl_argv@GOTOFF\n\ - addu a3, gb\n\ - stw a2, (a3, 0)\n\ - br .L_done_fixup\n\ "); /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or 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" \ From patchwork Thu May 26 16:49:52 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: 54415 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 2C4573857407 for ; Thu, 26 May 2022 16:54:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C4573857407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584089; bh=i5KlYEPzjSckCokP3AcZf4AjcAQKUkrviZhY4dk6IiY=; 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=YmutNBopTG4BcnxUNy/9bBLAtc5VUtl5PZMjJ1ImJ8tIIipvQfHZeimg0n5zFH1tX YqBxyFjiqbKEUPt9fJtMOgaJ6XdnOy1RoZ2RM1FkP8zblDlUI/EZMmB7yf9W/PqvdZ mSk+Lcaq/8BOLfayQR0JOxsgvz5T73kKiv1Ey4Sw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by sourceware.org (Postfix) with ESMTPS id BE96738376E9 for ; Thu, 26 May 2022 16:50:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BE96738376E9 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-f2e0a41009so1433807fac.6 for ; Thu, 26 May 2022 09:50:17 -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=i5KlYEPzjSckCokP3AcZf4AjcAQKUkrviZhY4dk6IiY=; b=U62PWmtZsbmb7YLD7OswBSIKjShcc7MvBaQsdM6pUVxd8gZ6Qa7z1R0Ylh19WYhn1w 67pgh+xYTC/Uc2XRd3R4D2aN408RlJuhTDsN5Wr0/FZ4ZyXztE4St/TM2+gZVZ+1CIAP PUWbPb3CTsQMG4gEuo3UfUBTJC9VZo3BqT1v4mFwBSxlddFhQk7zHIbJ67KBi41JvaMu 37K/VB0tQjBIEepd5k/D4wv9piyJ/s+GAQlLIm6Pdp9hmoJon1JuchkKF3jMkbUxbRnm MaMcbGQfUJ8gqir725PPQuRzctUsnr/OZC/jbCqUd9pHW/CHSsFP1N6ScNzIAq2rWb7Y 0cCw== X-Gm-Message-State: AOAM531fFCh6NVfnUDBG+LRft5cKIAKSaP4QkqcoWbjk5rhbjP9kOxYu t27A/GMR/91etwPZG7EKUGlJ+LPjCSoMvw== X-Google-Smtp-Source: ABdhPJxli5YQU12tGjiWwezzvxS6uP/EARGvEAaKOi9YtZuE553sfiwGcUnq0s1CdTxvG+O8SM4aCA== X-Received: by 2002:a05:6870:d209:b0:f2:e231:6647 with SMTP id g9-20020a056870d20900b000f2e2316647mr1223371oac.99.1653583816365; Thu, 26 May 2022 09:50:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:16 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 06/17] i686: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:52 -0300 Message-Id: <20220526165003.705355-7-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.7 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked on i686-linux-gnu. Reviewed-by: H.J. Lu --- sysdeps/i386/dl-machine.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 1f8d734215..8779983c8c 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -143,17 +143,8 @@ _dl_start_user:\n\ # Point %ebx at the GOT.\n\ call 0b\n\ addl $_GLOBAL_OFFSET_TABLE_, %ebx\n\ - # See if we were run as a command with the executable file\n\ - # name as an extra leading argument.\n\ - movl _dl_skip_args@GOTOFF(%ebx), %eax\n\ - # Pop the original argument count.\n\ - popl %edx\n\ - # Adjust the stack pointer to skip _dl_skip_args words.\n\ - leal (%esp,%eax,4), %esp\n\ - # Subtract _dl_skip_args from argc.\n\ - subl %eax, %edx\n\ - # Push argc back on the stack.\n\ - push %edx\n\ + # Read the original argument count.\n\ + movl (%esp), %edx\n\ # The special initializer gets called with the stack just\n\ # as the application's entry point will see it; it can\n\ # switch stacks if it moves these contents over.\n\ From patchwork Thu May 26 16:49:53 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: 54416 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 2428D3836E7E for ; Thu, 26 May 2022 16:55:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2428D3836E7E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584131; bh=Y9oP31otS7kZMWSu8yhni9BGyllbuibJmFlk9phAT4k=; 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=XQSYo9IqWdcj3LDiFrNWxYVisaX1B24EOU5n1c2/0QB+L4Lun3UKpuSOZZ8oJa1BU 2VvvUn3aV0uEE7Pf1xqhs2hysZkGMbwwNmf2XukhKvRyYukUjVX+vAnNGyd/AfSDEg u7tPDvNyDkWZjhMf8hzzudX3Sy6WSD59U8/g0Mcs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 88B9438560B3 for ; Thu, 26 May 2022 16:50:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 88B9438560B3 Received: by mail-oi1-x231.google.com with SMTP id q8so2726688oif.13 for ; Thu, 26 May 2022 09:50:19 -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=Y9oP31otS7kZMWSu8yhni9BGyllbuibJmFlk9phAT4k=; b=YedlpDr6Nbhq/AbF/bN4aSi/z5tF3dorbSOZgv97ZB0LUlGf4qostepvt0223XakEd AgqS8LCSP/fXMhgiykusjOiJwq9JcwZaD+1UBjjR2W6IovfxpsNeh0siyaKLUFN2xuTe msmFm5Yy5lg44A+QmkRgpYyywitwg3QpQM1x5MloovIPw5O9/j6fVc71OX1UZYWATLyg jTH2qTbFJ4aQnV8U7kSM/Q7nzpfXxz68jjmpijYDKQixBCZy0rZ6ARTml2Up1jn1fnt4 RfTmQaTKzdPasH6Wr+QpWjwIMPMyjE4gdb3XxLCoYgwiPtle7mRPAhtHYUsz5zVJSwYX oSvw== X-Gm-Message-State: AOAM5331JMGjmkOcNiaD+ssDdOAEYlAfNWddAKbG7mkLwtpC5FOQuoeD m33fGXvbyNN5VxxJcxwjC6bsO7+vFHQWjw== X-Google-Smtp-Source: ABdhPJy13JlIMELAW98aqcBwh9Gho+QnhKdrN4+VcRmvI6Cz01Z4AaKbUk+VLPNND/oRyiWEUSbJTg== X-Received: by 2002:a05:6808:91:b0:32a:e345:e81b with SMTP id s17-20020a056808009100b0032ae345e81bmr1776590oic.99.1653583818099; Thu, 26 May 2022 09:50:18 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:17 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 07/17] ia64: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:53 -0300 Message-Id: <20220526165003.705355-8-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.7 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. The startup code is changed to read the _dl_argc and _dl_argv values, and envp is calculated from argc and argv. Checked on ia64-linux-gnu. --- sysdeps/ia64/dl-machine.h | 70 ++++++++------------------------------- 1 file changed, 14 insertions(+), 56 deletions(-) diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h index 20e586aa35..704dbd1f8c 100644 --- a/sysdeps/ia64/dl-machine.h +++ b/sysdeps/ia64/dl-machine.h @@ -201,81 +201,39 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], " .save ar.pfs, r32\n" \ " .body\n" \ " { .mii\n" \ -" addl r3 = @gprel(_dl_skip_args), gp\n" \ -" adds r11 = 24, sp /* Load the address of argv. */\n" \ " /* Save the pointer to the user entry point fptr in loc2. */\n" \ " mov loc2 = ret0\n" \ +" addl r2 = @ltoff(_dl_argc), gp\n" \ " ;;\n" \ " }\n" \ " { .mii\n" \ -" ld4 r3 = [r3]\n" \ -" adds r10 = 16, sp /* Load the address of argc. */\n" \ -" mov out2 = r11\n" \ -" ;;\n" \ -" /* See if we were run as a command with the executable file\n" \ -" name as an extra leading argument. If so, adjust the argv\n" \ -" pointer to skip _dl_skip_args words.\n" \ -" Note that _dl_skip_args is an integer, not a long - Jes\n" \ -"\n" \ -" The stack pointer has to be 16 byte aligned. We cannot simply\n" \ -" addjust the stack pointer. We have to move the whole argv and\n" \ -" envp and adjust _dl_argv by _dl_skip_args. H.J. */\n" \ -" }\n" \ -" { .mib\n" \ -" ld8 out1 = [r10] /* is argc actually stored as a long\n" \ -" or as an int? */\n" \ -" addl r2 = @ltoff(_dl_argv), gp\n" \ +" ld8 out1 = [r2] /* Get the _dl_argc address. */\n" \ +" addl r3 = @ltoff(_dl_argv), gp\n" \ " ;;\n" \ " }\n" \ " { .mmi\n" \ -" ld8 r2 = [r2] /* Get the address of _dl_argv. */\n" \ -" sub out1 = out1, r3 /* Get the new argc. */\n" \ -" shladd r3 = r3, 3, r0\n" \ -" ;;\n" \ -" }\n" \ -" {\n" \ -" .mib\n" \ -" ld8 r17 = [r2] /* Get _dl_argv. */\n" \ -" add r15 = r11, r3 /* The address of the argv we move */\n" \ -" ;;\n" \ -" }\n" \ -" /* ??? Could probably merge these two loops into 3 bundles.\n" \ -" using predication to control which set of copies we're on. */\n" \ -"1: /* Copy argv. */\n" \ -" { .mfi\n" \ -" ld8 r16 = [r15], 8 /* Load the value in the old argv. */\n" \ +" ld8 out2 = [r3] /* Get the _dl_argv address. */\n" \ +" ld8 out1 = [out1] /* Get the adjusted _dl_argc. */\n" \ +" addl r2 = @gprel(_rtld_local), gp\n" \ " ;;\n" \ " }\n" \ -" { .mib\n" \ -" st8 [r11] = r16, 8 /* Store it in the new argv. */\n" \ -" cmp.ne p6, p7 = 0, r16\n" \ -"(p6) br.cond.dptk.few 1b\n" \ +" { .mmi\n" \ +" sxt4 out3 = out1 /* envp = argv + argc + 1 */\n" \ " ;;\n" \ " }\n" \ " { .mmi\n" \ -" mov out3 = r11\n" \ -" sub r17 = r17, r3 /* Substract _dl_skip_args. */\n" \ -" addl out0 = @gprel(_rtld_local), gp\n" \ -" }\n" \ -"1: /* Copy env. */\n" \ -" { .mfi\n" \ -" ld8 r16 = [r15], 8 /* Load the value in the old env. */\n" \ +" adds out3 = 1, out3\n" \ " ;;\n" \ " }\n" \ -" { .mib\n" \ -" st8 [r11] = r16, 8 /* Store it in the new env. */\n" \ -" cmp.ne p6, p7 = 0, r16\n" \ -"(p6) br.cond.dptk.few 1b\n" \ +" { .mmi\n" \ +" ld8 out2 = [out2] /* Get the adjusted _dl_argv. */\n" \ +" shladd out3 = out3, 3, r0\n" \ " ;;\n" \ " }\n" \ " { .mmb\n" \ -" st8 [r10] = out1 /* Record the new argc. */\n" \ -" ld8 out0 = [out0] /* get the linkmap */\n" \ -" }\n" \ -" { .mmb\n" \ -" st8 [r2] = r17 /* Load the new _dl_argv. */\n" \ +" add out3 = out3, out2\n" \ +" ld8 out0 = [r2] /* Get the linkmap. */\n" \ " br.call.sptk.many b0 = _dl_init#\n" \ -" ;;\n" \ " }\n" \ " /* Pass our finalizer function to the user,\n" \ " and jump to the user's entry point. */\n" \ From patchwork Thu May 26 16:49:54 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: 54417 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 622163836674 for ; Thu, 26 May 2022 16:56:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 622163836674 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584173; bh=pYtq2gKf5WQATYnqbsbIf1P3eoL0xNRQHt7ovGFFeos=; 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=QSxU0VDC8SMRqXJNpCVb1wJfBbyFkooBTsciRG7q3ImrTYekNepOYAogWd3lGI6TK OJl1tguggbEZD42zX3ifwYU1FGrsxjeqbkPzq+CqAjzmZxu9xapi07bswwiSsNTQIu eaMsVEHijBLGo1BSYWhSLZJFdXxqT4Wc3pfoeIJ4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 984AD3839C69 for ; Thu, 26 May 2022 16:50:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 984AD3839C69 Received: by mail-oi1-x233.google.com with SMTP id y66so2802510oia.1 for ; Thu, 26 May 2022 09:50: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:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pYtq2gKf5WQATYnqbsbIf1P3eoL0xNRQHt7ovGFFeos=; b=cuISB8vQb5QMp//RAd76cRTt0QpK1DXS3+GKEf+v4vP+71LMFTyHf5j9G9AZopuTxl Iv08Kk7jiHadyPvcaP3B9wbSs45WSiG3xG3zamXtwdqCTZz/hS4MB0ARsN3bzgZ44+RA w32zbLt/VqeUw52FRhqPSRHQjXMqntWq7bVmXLWBaP415i05sC9NyuEPoKTxLtyqUMgl /jfxQBeSaEoqGzNMfP1oLRu3dCayIK3+GVCgRQWEgBmkwAcOCSTScrY7V2Na9LU56pOu INV0z6t6oNBKNIOKZhHg1h3znVLHMG7akW+ELkA5N0+M3z1LvPeoLsefnwHavfzmzeDq OF7g== X-Gm-Message-State: AOAM532RQp6p3MajyjoeUeTxiPiHbTO4b1wf8r1aYp6q8T4+v8w4hwXv tjXJAGljsGn3to/fW98+SVGXIb74vRm+lg== X-Google-Smtp-Source: ABdhPJxW5Uc7yJrbve8HwZVPc2p2xyGquzEKB/18VZKmqBRsarUhvmeLE87ZYGAnIwV+rjn6/AdAyw== X-Received: by 2002:a05:6808:10c5:b0:327:2259:ef7d with SMTP id s5-20020a05680810c500b003272259ef7dmr1629071ois.156.1653583819826; Thu, 26 May 2022 09:50:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:19 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 08/17] m68k: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:54 -0300 Message-Id: <20220526165003.705355-9-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.7 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked with qemu-user that arguments are correctly passed on both constructors and main program. --- sysdeps/m68k/dl-machine.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h index bb51b4198c..4204fa3df8 100644 --- a/sysdeps/m68k/dl-machine.h +++ b/sysdeps/m68k/dl-machine.h @@ -142,15 +142,10 @@ _start:\n\ _dl_start_user:\n\ | Save the user entry point address in %a4.\n\ move.l %d0, %a4\n\ - | See if we were run as a command with the executable file\n\ - | name as an extra leading argument.\n\ - " PCREL_OP ("move.l", "_dl_skip_args", "%d0", "%d0", "%pc") "\n\ | Pop the original argument count\n\ move.l (%sp)+, %d1\n\ - | Subtract _dl_skip_args from it.\n\ - sub.l %d0, %d1\n\ - | Adjust the stack pointer to skip _dl_skip_args words.\n\ - lea (%sp, %d0*4), %sp\n\ + | Adjust the stack pointer to skip the loaders arguments.\n\ + lea (%sp), %sp\n\ | Push back the modified argument count.\n\ move.l %d1, -(%sp)\n\ # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\ From patchwork Thu May 26 16:49:55 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: 54418 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 77AC93836675 for ; Thu, 26 May 2022 16:57:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77AC93836675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584220; bh=2eXxHf8KN28baSKYoD8TjVXeq+l+S9f9VDSGbtdcRgc=; 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=TJhurCWjR7MIS4aehN3GO+OzexMLS/OfoDT+dEje4znJNbL0GvU9Tkld8LsyEGBI7 GXBfFkuxHHFq6vDzXJ8ZURPg8egepjdLX8+Wx5RHZvM7KDqSEgkxTnIWTJdIgF9rrq zlQCM1xLGawpj6gWYZqW2GKrIjV1evILO5eNzyjs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by sourceware.org (Postfix) with ESMTPS id 115E838376FD for ; Thu, 26 May 2022 16:50:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 115E838376FD Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-f2c8c0d5bdso2859533fac.4 for ; Thu, 26 May 2022 09:50:22 -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=2eXxHf8KN28baSKYoD8TjVXeq+l+S9f9VDSGbtdcRgc=; b=Dom3sSReQbPG+OEWCqdHgQ3qSYfj+CQvPhc80C+ETM2pao+pofec+6Y+StGKL/dskw Axfc/PtCjjaq5RgDoTCQ5TP/SMMcNqOXC148vVViuvb+yPXbXYLk1+aJNwXn6qJ69uhA gWpNRvVFCfRtKUFDv0OFgUlKST7sqBAsET2dh1W06plcBYhgGLiXAKBJ8lpf/6dpalCe E88AiZTNQZM+E3yXVIWSm13HW1+8CqONKgXT47/3P1vvy6toI2I7y7FGmsdzSAHLt/YJ HcBlTc/q5Z9xoZtvNv/ub/jMQyaRvQBzD7R1tgpdC591KzyAJBOUdvhbrYpHeTlugdpY /9Zw== X-Gm-Message-State: AOAM530nwsqpksSwR7DYqxCvfnFtAjaxiyEbNbZbNkRNU21tFNQSppgG wRt5glo0XLMhQY1NwnJAF5m6DBUhMy/X9g== X-Google-Smtp-Source: ABdhPJyXBGPOCJ3sJ56nQvQ/gv9lrM4H4/cGxQUWcWXyJolnaDZui5QADkJwtY5Y7E19W9YvirypBg== X-Received: by 2002:a05:6870:58a4:b0:f2:2720:884d with SMTP id be36-20020a05687058a400b000f22720884dmr1793301oab.13.1653583821171; Thu, 26 May 2022 09:50:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:20 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 09/17] microblaze: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:55 -0300 Message-Id: <20220526165003.705355-10-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.7 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked with qemu-user that arguments are correctly passed on both constructors and main program. --- sysdeps/microblaze/dl-machine.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sysdeps/microblaze/dl-machine.h b/sysdeps/microblaze/dl-machine.h index fd996d6ff1..e6e4e13fa2 100644 --- a/sysdeps/microblaze/dl-machine.h +++ b/sysdeps/microblaze/dl-machine.h @@ -117,12 +117,7 @@ _start:\n\ _dl_start_user:\n\ mfs r20,rpc\n\ addik r20,r20,_GLOBAL_OFFSET_TABLE_+8\n\ - lwi r4,r20,_dl_skip_args@GOTOFF\n\ lwi r5,r1,24\n\ - rsubk r5,r4,r5\n\ - addk r4,r4,r4\n\ - addk r4,r4,r4\n\ - addk r1,r1,r4\n\ swi r5,r1,24\n\ swi r3,r1,20\n\ addk r6,r5,r0\n\ From patchwork Thu May 26 16:49:56 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: 54419 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 CDBF138376EA for ; Thu, 26 May 2022 16:57:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDBF138376EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584262; bh=JSh2y7F3Zp6SsTOAqeXdubHFFt/m2QbbcdrJ8BT0qJk=; 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=eQyN7up8yiIvBfP4LHy+BmNHmgSPGXNBXDw+UqkK9+Ed6deJOypnwqVcrG/6nEaIa N69+r5IooRzxfHeUYPORi7nM2iU6iCY+QnIoMCKfDNxF2bZc1udcUVW6TFEA1uFzc7 sTY2NqQClHsuMiOMmJzQSNFnKPyiiVKYewG6WwvI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 6770638376ED for ; Thu, 26 May 2022 16:50:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6770638376ED Received: by mail-oi1-x232.google.com with SMTP id s188so2786302oie.4 for ; Thu, 26 May 2022 09:50:23 -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=JSh2y7F3Zp6SsTOAqeXdubHFFt/m2QbbcdrJ8BT0qJk=; b=T2Xf/Nmo7j53vaBHZjTzevNX4n/FDnaWs2vdILlxrRdrpuOhOtHZNXRVtWd6hcLs7q sVkDChtrUs65WaqMwwxKnuXGrg65BGvrVT3dbfegrckK8tF+HjYc+bu/jde7xvs6YGip nIdq+ZXUxjWmwMoHowkMPB4EAU/WjtEzTplqMzZNRKuUcyj6LGdc2ZuQl/uqhTZi1Mnj R5Vm4xSzhOAzNPyhyvL5DKfCPBWEzxnnpX4VOEdMMCMmxvrBmahfqSL95FWXS7V7uqhL TABrtJXQOjezcFovrClMZqLHlpsw6dq3FEaH3BN/E472JVgI5vJz/E1PIf0kdPFZToQV GjeA== X-Gm-Message-State: AOAM532UovWfr9XvSXoQb/WxD4QyIKBXCUVDxNPwQ0s4jvC5hcCTfVel srvVIhw5RP+xUPYiKN3qkoE8wzBHIIxYSg== X-Google-Smtp-Source: ABdhPJz7WMx0IXd+ng3M5ITcqitQ/Cxh/7db7Ay1VRh2lHagmHDI57A1NBu8MOagHemaQCscaNQh3A== X-Received: by 2002:a05:6808:168f:b0:325:2974:77d6 with SMTP id bb15-20020a056808168f00b00325297477d6mr1765548oib.199.1653583822589; Thu, 26 May 2022 09:50:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:22 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 10/17] mips: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:56 -0300 Message-Id: <20220526165003.705355-11-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.8 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked with qemu-user that arguments are correctly passed on both constructors and main program. --- sysdeps/mips/dl-machine.h | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h index 9105b5b75c..b68066d430 100644 --- a/sysdeps/mips/dl-machine.h +++ b/sysdeps/mips/dl-machine.h @@ -278,20 +278,7 @@ do { \ move $16, $28\n\ # Save the user entry point address in a saved register.\n\ move $17, $2\n\ - # See if we were run as a command with the executable file\n\ - # name as an extra leading argument.\n\ - lw $2, _dl_skip_args\n\ - beq $2, $0, 1f\n\ - # Load the original argument count.\n\ - " STRINGXP(PTR_L) " $4, 0($29)\n\ - # Subtract _dl_skip_args from it.\n\ - subu $4, $2\n\ - # Adjust the stack pointer to skip _dl_skip_args words.\n\ - sll $2, " STRINGXP (PTRLOG) "\n\ - " STRINGXP(PTR_ADDU) " $29, $2\n\ - # Save back the modified argument count.\n\ - " STRINGXP(PTR_S) " $4, 0($29)\n\ -1: # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\ + # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\ " STRINGXP(PTR_L) " $4, _rtld_local\n\ " STRINGXP(PTR_L) /* or lw??? fixme */ " $5, 0($29)\n\ " STRINGXP(PTR_LA) " $6, " STRINGXP (PTRSIZE) "($29)\n\ @@ -352,21 +339,7 @@ do { \ addu $16, $4\n\ move $17, $2\n\ move $28, $16\n\ - lw $4, %got(_dl_skip_args)($16)\n\ - lw $4, 0($4)\n\ - beqz $4, 1f\n\ - # Load the original argument count.\n\ - lw $5, 0($sp)\n\ - # Subtract _dl_skip_args from it.\n\ - subu $5, $4\n\ - # Adjust the stack pointer to skip _dl_skip_args words.\n\ - sll $4, " STRINGXP (PTRLOG) "\n\ - move $6, $sp\n\ - addu $6, $4\n\ - move $sp, $6\n\ - # Save back the modified argument count.\n\ - sw $5, 0($sp)\n\ -1: # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\ + # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\ lw $4, %got(_rtld_local)($16)\n\ lw $4, 0($4)\n\ lw $5, 0($sp)\n\ From patchwork Thu May 26 16:49:57 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: 54420 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 0AD55383820F for ; Thu, 26 May 2022 16:58:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AD55383820F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584305; bh=lMadIYMEAZEWRFzWkeknmU/QGuNGuePQFktfwJOai+I=; 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=gija9a6zHpImJCx2xiLJASa48NA9pPjMgxWNvRBBohMoDrTZnIaqEF7ibwLWQ4zDg TYTdm+M1wsxxILTCKaI8GBtvfpIGnB9eWyw/maeB8I7KgRnf68BUZ5aBzLN/z3ywZI zwu45HllWbdh+hIDj0OOLq2fxW1m9xug0zJEJ1Yo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 6943F385737E for ; Thu, 26 May 2022 16:50:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6943F385737E Received: by mail-oi1-x22d.google.com with SMTP id r68so2737929oie.12 for ; Thu, 26 May 2022 09:50:25 -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=lMadIYMEAZEWRFzWkeknmU/QGuNGuePQFktfwJOai+I=; b=2LgZaVcuOv1WJR6iDITsnSwOVVZjobhtnBKsh1Iv2AmuAdvsKbQh+pXxRSvlREdCOH Ok/UHsmcW//hv1+FSh8HMpGEEg/CBqy2xZBCvlrCOiUE8AkdCL+ZS49qivieawV/uyuR AwoJvOpmullgLBVDtCZtcuqct8Y/r79n81MEPjhsV2kKEMkxssaFq7vffTFlGSuthfwn 0a2bfDxEr3yRHO36/xFciFOjL4Vs6YfENht03sfIyFbYs0BOwH9k7+2cQlJsVmLZVI+y nhuqc3B7EgCV9t3FJlk695/uIapSgJf82USmgxrJePWANZvcI+E/Civaa/AxHV1hHtcB uC4Q== X-Gm-Message-State: AOAM533J4xnfyfoPdRg8VlQe63E4MSsRDPsuVgGxRshAh0U6WPwFMmFp 6lJRc34edlPOTbAtxSDCSdj9wVZtpyU+Uw== X-Google-Smtp-Source: ABdhPJylxwoJHiB98gZ+Bd3/F17DFxz2ejwB6MyUovCVqLq9ONbCBX4MaaZCOBiZ9WWxXkcpDQA0uw== X-Received: by 2002:a05:6808:210f:b0:32b:a8f:5bec with SMTP id r15-20020a056808210f00b0032b0a8f5becmr1606595oiw.245.1653583824403; Thu, 26 May 2022 09:50:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:23 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 11/17] nios2: Remove _dl_skip_args usage (BZ# 29187) Date: Thu, 26 May 2022 13:49:57 -0300 Message-Id: <20220526165003.705355-12-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.8 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked with qemu-user that arguments are correctly passed on both constructors and main program. --- sysdeps/nios2/dl-machine.h | 50 ++++++++------------------------------ 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/sysdeps/nios2/dl-machine.h b/sysdeps/nios2/dl-machine.h index 80de6fd041..9a35cf4160 100644 --- a/sysdeps/nios2/dl-machine.h +++ b/sysdeps/nios2/dl-machine.h @@ -128,53 +128,23 @@ _start:\n\ ldw r8, %call(_dl_nios2_get_gp_value)(r22)\n\ callr r8\n\ mov gp, r2\n\ -\n\ - /* Find the number of arguments to skip. */\n\ - ldw r8, %got(_dl_skip_args)(r22)\n\ - ldw r8, 0(r8)\n\ \n\ /* Find the main_map from the GOT. */\n\ ldw r4, %got(_rtld_local)(r22)\n\ ldw r4, 0(r4)\n\ \n\ - /* Find argc. */\n\ - ldw r5, 0(sp)\n\ - sub r5, r5, r8\n\ - stw r5, 0(sp)\n\ -\n\ - /* Find the first unskipped argument. */\n\ - slli r8, r8, 2\n\ - addi r6, sp, 4\n\ - add r9, r6, r8\n\ - mov r10, r6\n\ -\n\ - /* Shuffle argv down. */\n\ -3: ldw r11, 0(r9)\n\ - stw r11, 0(r10)\n\ - addi r9, r9, 4\n\ - addi r10, r10, 4\n\ - bne r11, zero, 3b\n\ + /* Load adjusted argc. */\n\ + ldw r2, %got(_dl_argc)(r22)\n\ + ldw r5, 0(r2)\n\ \n\ - /* Shuffle envp down. */\n\ - mov r7, r10\n\ -4: ldw r11, 0(r9)\n\ - stw r11, 0(r10)\n\ - addi r9, r9, 4\n\ - addi r10, r10, 4\n\ - bne r11, zero, 4b\n\ -\n\ - /* Shuffle auxv down. */\n\ -5: ldw r11, 4(r9)\n\ - stw r11, 4(r10)\n\ - ldw r11, 0(r9)\n\ - stw r11, 0(r10)\n\ - addi r9, r9, 8\n\ - addi r10, r10, 8\n\ - bne r11, zero, 5b\n\ -\n\ - /* Update _dl_argv. */\n\ + /* Load adjsuted argv. */\n\ ldw r2, %got(_dl_argv)(r22)\n\ - stw r6, 0(r2)\n\ + ldw r6, 0(r2)\n\ +\n\ + /* envp = argv + argc + 1 */\n\ + addi r7, r5, 1\n\ + slli r7, r7, 2\n\ + add r7, r7, r6\n\ \n\ /* Call _dl_init through the PLT. */\n\ ldw r8, %call(_dl_init)(r22)\n\ From patchwork Thu May 26 16:49:58 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: 54421 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 87E8A3839C69 for ; Thu, 26 May 2022 16:59:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87E8A3839C69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584347; bh=mHElq5ANBzL7tLdL9y8OlVNy3xNIsjcpY+GGEuOBMoM=; 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=Bk3PWN2s+8VDsSjfuZ1c3M+Zxyb0OnQzu9r+cndL+qOe08i63NyG1qwY7Kp8/sGvP 8jzKOOBl8JfhvGXmPhbgIgd/teE9VskejCwAS+OLkz0AT8jD+ckasvu5SbBQ2u4tul hOoV8UdaMsv5V17ZJWA3sBHtUX5dhAb8M4WHgUAg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id B24B3385737E for ; Thu, 26 May 2022 16:50:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B24B3385737E Received: by mail-oi1-x22e.google.com with SMTP id r68so2737995oie.12 for ; Thu, 26 May 2022 09:50:26 -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=mHElq5ANBzL7tLdL9y8OlVNy3xNIsjcpY+GGEuOBMoM=; b=L0oywuoXH0ckgkfejI7z3mE/2VuVmkYQevOYP/nxbbtjciJVsAESDmLB75IpRMBZqD awr0kE9HoU4I553Nrcn1OB7UvYMhNsFERMTyndRGUEFBQn93VsVW4T/U1xzwUPMUfIlM WdUnECXaV9LHXIstz2XwLQfd0BhWKQTjYoHnCEyewWNTX3N0wvHSTt9rlm42wAtoJld3 TVTKbyD7QNdAt1ZO6/9iBZ1v8heYcrB39+E88/57m+ROVb6hEMUHWcln66nZ7ILGn0bK RWInpfymzS4in3K99lDH1OKQ4k6MGL2MOh7AIFl0Zh0Soq+PJbGJtw2La+d2gbz8uT0+ f2gA== X-Gm-Message-State: AOAM530+AIzLt7+xu2ibuNM9RvMA2ZctnLesRLYvYyP7Lp3HXSsSz9T5 VlqAjHCcZTSk/h0rlGl2UcGe1H1/Vi/sRg== X-Google-Smtp-Source: ABdhPJwGGLr18tLx0kC5MA6J81i244qN1XR9vabC4Utbm4sdXAdlE7MyN3wtnx+/tC4s5vXHhiaXuw== X-Received: by 2002:a05:6808:23cb:b0:32b:6370:6624 with SMTP id bq11-20020a05680823cb00b0032b63706624mr1712831oib.206.1653583825896; Thu, 26 May 2022 09:50:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:25 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 12/17] riscv: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:58 -0300 Message-Id: <20220526165003.705355-13-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.8 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked with qemu-user that arguments are correctly passed on both constructors and main program. --- sysdeps/riscv/dl-machine.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h index 4912735c2b..ba02f17431 100644 --- a/sysdeps/riscv/dl-machine.h +++ b/sysdeps/riscv/dl-machine.h @@ -107,18 +107,6 @@ elf_machine_dynamic (void) " _RTLD_PROLOGUE (_dl_start_user) "\ # Stash user entry point in s0.\n\ mv s0, a0\n\ - # See if we were run as a command with the executable file\n\ - # name as an extra leading argument.\n\ - lw a0, _dl_skip_args\n\ - # Load the original argument count.\n\ - " STRINGXP (REG_L) " a1, 0(sp)\n\ - # Subtract _dl_skip_args from it.\n\ - sub a1, a1, a0\n\ - # Adjust the stack pointer to skip _dl_skip_args words.\n\ - sll a0, a0, " STRINGXP (PTRLOG) "\n\ - add sp, sp, a0\n\ - # Save back the modified argument count.\n\ - " STRINGXP (REG_S) " a1, 0(sp)\n\ # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\ " STRINGXP (REG_L) " a0, _rtld_local\n\ add a2, sp, " STRINGXP (SZREG) "\n\ From patchwork Thu May 26 16:49:59 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: 54422 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 120E83836E52 for ; Thu, 26 May 2022 16:59:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 120E83836E52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584390; bh=mIsoBODNxGVyNdhJpp2x04tBplzdzw4kUwmhftlMCUk=; 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=s0RQ5TAhTJ5Kw3bt/hV6vmLvGbmVEqTEAn4Si6nLMp6ju2bR5h25D77utCMqd/Pc+ d7Pq6UkcKt/FQ1ZILxUSlNGQLTPJbKeunEpk+uSoCN6yHnnerlZcRtr2NdNdBQ6hc5 i28//0egXxxh4uoR+HvuEqQBKn/tUu2VgvcrLh6Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by sourceware.org (Postfix) with ESMTPS id B3B2B3836677 for ; Thu, 26 May 2022 16:50:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B3B2B3836677 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-f2bb84f9edso2827045fac.10 for ; Thu, 26 May 2022 09:50:27 -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=mIsoBODNxGVyNdhJpp2x04tBplzdzw4kUwmhftlMCUk=; b=5V3qsusFrpqa2Ow4L1cg0sDET7DppvUt4PQpoEZKEPrc1zl+UFOKEViCBtz+LeLDsw BbW06DcRgCcQTZVchJgforr35KTqZJBtEp7z21kytbUAJc4wmGasRSClioJQ2VltJaqV xdYNLc1/13esv8vvJ5HqWNsiVu5C4cyJENiLOa0CG7AUnnKtZkFjXuMZJLFNFQsT1XIi +YfvByEvklRERedQhr4GafWtdpg83dlJJp0Qvwsil8E3zasJLkyUSw/oGOGV/yv1llvk syXrf49ZX3JF3kfORKdFv06ciUAyyy4FfAhn6sal6M91l4JO8VvzgfirTaSLkKIMVM6L gX3A== X-Gm-Message-State: AOAM531r01fR0XvlCq7o9wv+iHPakSyjM7aN4Zw5iY8ybACWnr0KDpqP 8O6iMCHy3JCBcFdYgXCbph0D3dwo4BwHVg== X-Google-Smtp-Source: ABdhPJzsI13ySoUGJ1DEIoYDI5IXrp1O9jHpTh/7iGLu/CxDojLFWVL9JMscoi4GPltDYTo/SlU29A== X-Received: by 2002:a05:6870:8314:b0:ee:72a1:ce63 with SMTP id p20-20020a056870831400b000ee72a1ce63mr1731874oae.285.1653583827202; Thu, 26 May 2022 09:50:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:26 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 13/17] s390: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:49:59 -0300 Message-Id: <20220526165003.705355-14-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.8 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked on s390x-linux-gnu and s390-linux-gnu. --- sysdeps/s390/s390-32/dl-machine.h | 46 ------------------------------- sysdeps/s390/s390-64/dl-machine.h | 16 ----------- 2 files changed, 62 deletions(-) diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h index 4392abb355..b69787b0ad 100644 --- a/sysdeps/s390/s390-32/dl-machine.h +++ b/sysdeps/s390/s390-32/dl-machine.h @@ -186,52 +186,6 @@ _dl_start_user:\n\ # Point %r12 at the GOT.\n\ l %r12,.Ladr0-.Llit(%r13)\n\ ar %r12,%r13\n\ - # See if we were run as a command with the executable file\n\ - # name as an extra leading argument.\n\ - l %r1,_dl_skip_args@GOT(%r12)\n\ - l %r1,0(%r1) # load _dl_skip_args\n\ - ltr %r1,%r1\n\ - je 4f # Skip the arg adjustment if there were none.\n\ - # Get the original argument count.\n\ - l %r0,96(%r15)\n\ - # Subtract _dl_skip_args from it.\n\ - sr %r0,%r1\n\ - # Store back the modified argument count.\n\ - st %r0,96(%r15)\n\ - # Copy argv and envp forward to account for skipped argv entries.\n\ - # We skipped at least one argument or we would not get here.\n\ - la %r6,100(%r15) # Destination pointer i.e. &argv[0]\n\ - lr %r5,%r6\n\ - lr %r0,%r1\n\ - sll %r0,2\n # Number of skipped bytes.\n\ - ar %r5,%r0 # Source pointer = Dest + Skipped args.\n\ - # argv copy loop:\n\ -1: l %r7,0(%r5) # Load a word from the source.\n\ - st %r7,0(%r6) # Store the word in the destination.\n\ - ahi %r5,4\n\ - ahi %r6,4\n\ - ltr %r7,%r7\n\ - jne 1b # Stop after copying the NULL.\n\ - # envp copy loop:\n\ -2: l %r7,0(%r5) # Load a word from the source.\n\ - st %r7,0(%r6) # Store the word in the destination.\n\ - ahi %r5,4\n\ - ahi %r6,4\n\ - ltr %r7,%r7\n\ - jne 2b # Stop after copying the NULL.\n\ - # Now we have to zero out the envp entries after NULL to allow\n\ - # start.S to properly find auxv by skipping zeroes.\n\ - # zero out loop:\n\ - lhi %r7,0\n\ -3: st %r7,0(%r6) # Store zero.\n\ - ahi %r6,4 # Advance dest pointer.\n\ - ahi %r1,-1 # Subtract one from the word count.\n\ - ltr %r1,%r1\n\ - jne 3b # Keep copying if the word count is non-zero.\n\ - # Adjust _dl_argv\n\ - la %r6,100(%r15)\n\ - l %r1,_dl_argv@GOT(%r12)\n\ - st %r6,0(%r1)\n\ # The special initializer gets called with the stack just\n\ # as the application's entry point will see it; it can\n\ # switch stacks if it moves these contents over.\n\ diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h index 7a94b3a7a6..74be0552dc 100644 --- a/sysdeps/s390/s390-64/dl-machine.h +++ b/sysdeps/s390/s390-64/dl-machine.h @@ -167,22 +167,6 @@ _dl_start_user:\n\ lgr %r8,%r2\n\ # Point %r12 at the GOT.\n\ larl %r12,_GLOBAL_OFFSET_TABLE_\n\ - # See if we were run as a command with the executable file\n\ - # name as an extra leading argument.\n\ - lghi %r1,_dl_skip_args@GOT\n\ - lg %r1,0(%r1,%r12)\n\ - lgf %r1,0(%r1) # load _dl_skip_args\n\ - # Get the original argument count.\n\ - lg %r0,160(%r15)\n\ - # Subtract _dl_skip_args from it.\n\ - sgr %r0,%r1\n\ - # Adjust the stack pointer to skip _dl_skip_args words.\n\ - sllg %r1,%r1,3\n\ - agr %r15,%r1\n\ - # Set the back chain to zero again\n\ - xc 0(8,%r15),0(%r15)\n\ - # Store back the modified argument count.\n\ - stg %r0,160(%r15)\n\ # The special initializer gets called with the stack just\n\ # as the application's entry point will see it; it can\n\ # switch stacks if it moves these contents over.\n\ From patchwork Thu May 26 16:50:00 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: 54423 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 022A33836677 for ; Thu, 26 May 2022 17:00:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 022A33836677 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584432; bh=PyUNqYR8wcwnigXYACLHUj8ni7A3wSISWgZRTijsr8Y=; 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=Mde2B1IE1A5mmO8Ds/83HDliH8GMxYoeUj218PfJTfW5E36AuSs8RChE0h9W4IzKe ZNSjw3T7NIBsYWBmcROcztbaoOaKMvZy9C4JF36sZw2bgxGQHXnC9fF5A3cxomEefb q1mAoo/ytaV3f9Twqx2K3n/4L2zdGuUhotdNdJHc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by sourceware.org (Postfix) with ESMTPS id 62A5E383666E for ; Thu, 26 May 2022 16:50:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 62A5E383666E Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-e5e433d66dso2853446fac.5 for ; Thu, 26 May 2022 09:50:29 -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=PyUNqYR8wcwnigXYACLHUj8ni7A3wSISWgZRTijsr8Y=; b=x3K1aO8nFwFXAAkOsoRAIUFnh2BgoPg5HBEksZLXHhaH5lwhIICGJgKziK0r65CtmF +vPogR/hk+I764B7F5aC3i+mhmBoqzub5qS99tHyNgOjZxs78wUGR7E9Am/ORBdbaqoc cnW81tR6cDC7XmX0RJcHmMMd9rEfNb2lG7RIwqPrBZcZ7poqkv3bAx+B1JEDLCToGBLx etAcPOIrGkvu3ePQF8GVKn7QPLlmQEkc9ErS8rdjo8GBDgfW4bXNGfZCBFtSTHfIKuTW IcSh7UvMzZ1hQUlbubeI3KJ9A/pegaOPZxWZb2DYL0bV+9/lfK9UHegj9jHDOv47y4WW NZgQ== X-Gm-Message-State: AOAM532b7u6nUTP5MDiTZGf1PN4znL+vR8LycDivXhM8Z2rlgyh/shdc f07kRKyRCr4ELQlwmlMq+DYMOWdRel7/3w== X-Google-Smtp-Source: ABdhPJx1hN93t49lZp5iDi9tG26OwW4lfLXP5f3e4S6ugMMtj2BFxZeclXhtnvpJD1ldgIQSqddBvw== X-Received: by 2002:a05:6871:722:b0:f1:b218:5b59 with SMTP id f34-20020a056871072200b000f1b2185b59mr1754028oap.284.1653583828682; Thu, 26 May 2022 09:50:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:28 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 14/17] sh: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:50:00 -0300 Message-Id: <20220526165003.705355-15-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.8 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked with qemu-user that arguments are correctly passed on both constructors and main program. --- sysdeps/sh/dl-machine.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index 8b08a1fc47..99eb239408 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -149,20 +149,8 @@ _dl_start_user:\n\ add r0,r12\n\ .align 2\n\ 1: .long _GLOBAL_OFFSET_TABLE_\n\ -2: ! See if we were run as a command with the executable file\n\ - ! name as an extra leading argument.\n\ - mov.l .L_dl_skip_args,r0\n\ - mov.l @(r0,r12),r0\n\ - mov.l @r0,r0\n\ - ! Get the original argument count.\n\ +2: ! Get the original argument count.\n\ mov.l @r15,r5\n\ - ! Subtract _dl_skip_args from it.\n\ - sub r0,r5\n\ - ! Adjust the stack pointer to skip _dl_skip_args words.\n\ - shll2 r0\n\ - add r0,r15\n\ - ! Store back the modified argument count.\n\ - mov.l r5,@r15\n\ ! Compute argv address and envp.\n\ mov r15,r6\n\ add #4,r6\n\ @@ -188,8 +176,6 @@ _dl_start_user:\n\ .align 2\n\ .L_dl_start:\n\ .long _dl_start@PLT\n\ -.L_dl_skip_args:\n\ - .long _dl_skip_args@GOT\n\ .L_dl_init:\n\ .long _dl_init@PLT\n\ .L_dl_loaded:\n\ From patchwork Thu May 26 16:50:01 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: 54424 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 4F9123836E6F for ; Thu, 26 May 2022 17:01:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F9123836E6F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584479; bh=/htUQSz7EeRt8AY/+tsT2g54P52cwaCpX9nAh1mBwKw=; 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=FTEq/3Lr3hAEz/2cYq1gZlFU7emFl9DG9Z54j4LGNc+p3pDxh/MiIbLL/r03uq9Gq g8m/hAQxhja7gu5SvRt/vISD8YifoUPL219NXdtWPz0Rw/bvI7vwl4Rg03swhyL/2d Mx3mDcoXJoTTP5hVf69f++UUZSDxHrqjNRl01LOs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 0735B3857357 for ; Thu, 26 May 2022 16:50:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0735B3857357 Received: by mail-ot1-x335.google.com with SMTP id l9-20020a056830268900b006054381dd35so1333913otu.4 for ; Thu, 26 May 2022 09:50:31 -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=/htUQSz7EeRt8AY/+tsT2g54P52cwaCpX9nAh1mBwKw=; b=I0MWMB/sQy/ZWKUavc5/k377njKiOhStVAanyUu9oghJLuP2/1rIWjlfZg7BrREJbr dHVOmNkSsMKwil6X3sjHIGGiJnQlnZP6Sra7UPAWhdRccW8uGGdhQLRJXc1+Le+lYunJ G4ahm+oOZdSriD0e/YwZmLdy7wK+jSFCtbN4yTgKgGC7rM+tvNNrMH9nJBAGYd7Psttb byaHgmq9rO99ZUQgC/enYCzKjBYS/sAP0FewKHSV1jOQLcu5wIondh3Yd1UpVY0yoxHD VpAm5FmZrebV5z04yOIjunQI2mK0UhuXdYSefe+L8lMmR1mywvbLy7TpMnJozPabe9zm 6yJA== X-Gm-Message-State: AOAM532IIcKOuCroslaGkrnTDsxHNMA+ulej64BMV0s3/0AhyyJIdiqS c8nb5gtRdE+xdU3ENgCPn6AweboshKlDRg== X-Google-Smtp-Source: ABdhPJwzLqleudyMnyNj21GQ1ow3msKXAu/yzD4fdt4tIlfA0fPhtfXv5JM7UBhyq8CkPhqj5T9HfA== X-Received: by 2002:a05:6830:1005:b0:60b:1844:cce2 with SMTP id a5-20020a056830100500b0060b1844cce2mr7976570otp.305.1653583830063; Thu, 26 May 2022 09:50:30 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:29 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 15/17] sparc: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:50:01 -0300 Message-Id: <20220526165003.705355-16-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.8 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked on sparc64-linux-gnu and sparcv9-linux-gnu. --- sysdeps/sparc/sparc32/dl-machine.h | 43 ++---------------------------- sysdeps/sparc/sparc64/dl-machine.h | 40 ++------------------------- 2 files changed, 4 insertions(+), 79 deletions(-) diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h index 8c2408b1e6..8baf45be52 100644 --- a/sysdeps/sparc/sparc32/dl-machine.h +++ b/sysdeps/sparc/sparc32/dl-machine.h @@ -196,48 +196,9 @@ _dl_start_user:\n\ add %l7, %o7, %l7\n\ /* Save the user entry point address in %l0 */\n\ mov %o0, %l0\n\ - /* See if we were run as a command with the executable file name as an\n\ - extra leading argument. If so, adjust the contents of the stack. */\n\ - " RTLD_GOT_ADDRESS(%l7, %g2, _dl_skip_args) "\n\ - ld [%g2], %i0\n\ - tst %i0\n\ - beq 3f\n\ - ld [%sp+22*4], %i5 /* load argc */\n\ - /* Find out how far to shift. */\n\ - " RTLD_GOT_ADDRESS(%l7, %l3, _dl_argv) "\n\ - sub %i5, %i0, %i5\n\ - ld [%l3], %l4\n\ - sll %i0, 2, %i2\n\ - st %i5, [%sp+22*4]\n\ - sub %l4, %i2, %l4\n\ - add %sp, 23*4, %i1\n\ - add %i1, %i2, %i2\n\ - st %l4, [%l3]\n\ - /* Copy down argv */\n\ -21: ld [%i2], %i3\n\ - add %i2, 4, %i2\n\ - tst %i3\n\ - st %i3, [%i1]\n\ - bne 21b\n\ - add %i1, 4, %i1\n\ - /* Copy down env */\n\ -22: ld [%i2], %i3\n\ - add %i2, 4, %i2\n\ - tst %i3\n\ - st %i3, [%i1]\n\ - bne 22b\n\ - add %i1, 4, %i1\n\ - /* Copy down auxiliary table. */\n\ -23: ld [%i2], %i3\n\ - ld [%i2+4], %i4\n\ - add %i2, 8, %i2\n\ - tst %i3\n\ - st %i3, [%i1]\n\ - st %i4, [%i1+4]\n\ - bne 23b\n\ - add %i1, 8, %i1\n\ + ld [%sp+22*4], %i5 /* load argc */\n\ /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */\n\ -3: " RTLD_GOT_ADDRESS(%l7, %o0, _rtld_local) "\n\ + " RTLD_GOT_ADDRESS(%l7, %o0, _rtld_local) "\n\ add %sp, 23*4, %o2\n\ sll %i5, 2, %o3\n\ add %o3, 4, %o3\n\ diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h index 8c4bab14fc..d34d9aa470 100644 --- a/sysdeps/sparc/sparc64/dl-machine.h +++ b/sysdeps/sparc/sparc64/dl-machine.h @@ -245,45 +245,9 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], " add %l7, %o7, %l7\n" \ " /* Save the user entry point address in %l0. */\n" \ " mov %o0, %l0\n" \ -" /* See if we were run as a command with the executable file name as an\n" \ -" extra leading argument. If so, we must shift things around since we\n" \ -" must keep the stack doubleword aligned. */\n" \ - RTLD_GOT_ADDRESS(%l7, %g5, _dl_skip_args) \ -" ld [%g5], %i0\n" \ -" brz,pt %i0, 2f\n" \ -" ldx [%sp + " __S(STACK_BIAS) " + 22*8], %i5\n" \ -" /* Find out how far to shift. */\n" \ -" sub %i5, %i0, %i5\n" \ -" sllx %i0, 3, %l6\n" \ - RTLD_GOT_ADDRESS(%l7, %l4, _dl_argv) \ -" stx %i5, [%sp + " __S(STACK_BIAS) " + 22*8]\n" \ -" add %sp, " __S(STACK_BIAS) " + 23*8, %i1\n" \ -" add %i1, %l6, %i2\n" \ -" ldx [%l4], %l5\n" \ -" /* Copy down argv. */\n" \ -"12: ldx [%i2], %i3\n" \ -" add %i2, 8, %i2\n" \ -" stx %i3, [%i1]\n" \ -" brnz,pt %i3, 12b\n" \ -" add %i1, 8, %i1\n" \ -" sub %l5, %l6, %l5\n" \ -" /* Copy down envp. */\n" \ -"13: ldx [%i2], %i3\n" \ -" add %i2, 8, %i2\n" \ -" stx %i3, [%i1]\n" \ -" brnz,pt %i3, 13b\n" \ -" add %i1, 8, %i1\n" \ -" /* Copy down auxiliary table. */\n" \ -"14: ldx [%i2], %i3\n" \ -" ldx [%i2 + 8], %i4\n" \ -" add %i2, 16, %i2\n" \ -" stx %i3, [%i1]\n" \ -" stx %i4, [%i1 + 8]\n" \ -" brnz,pt %i3, 14b\n" \ -" add %i1, 16, %i1\n" \ -" stx %l5, [%l4]\n" \ +" ldx [%sp + " __S(STACK_BIAS) " + 22*8], %i5\n" \ " /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */\n" \ -"2:\t" RTLD_GOT_ADDRESS(%l7, %o0, _rtld_local) \ +"" RTLD_GOT_ADDRESS(%l7, %o0, _rtld_local) \ " sllx %i5, 3, %o3\n" \ " add %sp, " __S(STACK_BIAS) " + 23*8, %o2\n" \ " add %o3, 8, %o3\n" \ From patchwork Thu May 26 16:50:02 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: 54425 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 BD7F03836E7E for ; Thu, 26 May 2022 17:02:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD7F03836E7E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584521; bh=OlWeK9dJVctlDMqbj1ou3QrAVIo3Pm4OgPKQGTZYiV0=; 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=nH7P97t+m2j3nPamU4VLa27TkFlrVnrJgKWH5K/Hby59CqLSXQt+/JJ4UuqNr4h2/ mZOyf/DRquHBDcWda3/izTEag+SaQzsqAyvPBFxvQH83bxMFm0urPgxvOOLk608NEF 0Xq/9Hxh55nGGssdv1A0ZGxk//wk87qArgcpwCvU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 62DC63836670 for ; Thu, 26 May 2022 16:50:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 62DC63836670 Received: by mail-ot1-x335.google.com with SMTP id h9-20020a056830400900b0060b03bfe792so1311418ots.12 for ; Thu, 26 May 2022 09:50:32 -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=OlWeK9dJVctlDMqbj1ou3QrAVIo3Pm4OgPKQGTZYiV0=; b=cFhS5Ev4qkjB66AN9WRiIz2VY271roYYHsarmuS1Fi3gxjv7GM7utZK64J92epfbi3 LcNpYekNdlJnVLIkZpHqaXpvT5C0cFpK/Xm332R13wLDtYkvIKaKus6t3oMJoQDENHg9 iyFlyXiXS3nEI5edWyy+YiU8u1dsVYu56zbLnoWnMqHn6oB9UKzVTZru1mIi9D1Dx6zZ TyxDpgzC6PiiwpSJwTzLftuzFEVSC4SP1ENvd+3h7Asu/A1Kn43UQce9ZRQf40pKxzsH jwj++2puMP4+5pxr94+8v1IgRgPsw6dRkdk/Y8BW4R6/sEfGFiPEysgiV14ZQ5WPrEJG FzUA== X-Gm-Message-State: AOAM5304NSnS21lslghHCG46U93824581y7Cg4kBggWDgpzjjMXy4dyZ jG2D3+lb/i6h/VPG54ihS2rrFL6QsHK1UQ== X-Google-Smtp-Source: ABdhPJznzXD2FhLdkgufMnDq3kJm13nj/NZ8Dl0KehCKE5GHY7pQPisL5g1nQPNtAh0ssuHtRnBmgw== X-Received: by 2002:a9d:6545:0:b0:60b:1ccc:c6c7 with SMTP id q5-20020a9d6545000000b0060b1cccc6c7mr7397983otl.326.1653583831605; Thu, 26 May 2022 09:50:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:31 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 16/17] x86_64: Remove _dl_skip_args usage Date: Thu, 26 May 2022 13:50:02 -0300 Message-Id: <20220526165003.705355-17-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.8 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" Since ad43cac44a the generic code already shuffles the argv/envp/auxv on the stack to remove the ld.so own arguments and thus _dl_skip_args is always 0. So there is no need to adjust the argc or argv. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: H.J. Lu --- sysdeps/x86_64/dl-machine.h | 13 ++----------- sysdeps/x86_64/x32/dl-machine.h | 12 +----------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index c70af7ab1e..e33ca2cc1a 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -140,17 +140,8 @@ _start:\n\ _dl_start_user:\n\ # Save the user entry point address in %r12.\n\ movq %rax, %r12\n\ - # See if we were run as a command with the executable file\n\ - # name as an extra leading argument.\n\ - movl _dl_skip_args(%rip), %eax\n\ - # Pop the original argument count.\n\ - popq %rdx\n\ - # Adjust the stack pointer to skip _dl_skip_args words.\n\ - leaq (%rsp,%rax,8), %rsp\n\ - # Subtract _dl_skip_args from argc.\n\ - subl %eax, %edx\n\ - # Push argc back on the stack.\n\ - pushq %rdx\n\ + # Read the original argument count.\n\ + movq (%rsp), %rdx\n\ # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\ # argc -> rsi\n\ movq %rdx, %rsi\n\ diff --git a/sysdeps/x86_64/x32/dl-machine.h b/sysdeps/x86_64/x32/dl-machine.h index 331374069e..681016c8d8 100644 --- a/sysdeps/x86_64/x32/dl-machine.h +++ b/sysdeps/x86_64/x32/dl-machine.h @@ -45,18 +45,8 @@ _start:\n\ _dl_start_user:\n\ # Save the user entry point address in %r12.\n\ movl %eax, %r12d\n\ - # See if we were run as a command with the executable file\n\ - # name as an extra leading argument.\n\ - movl _dl_skip_args(%rip), %eax\n\ - # Pop the original argument count.\n\ + # Read the original argument count.\n\ movl (%rsp), %edx\n\ - # Adjust the stack pointer to skip _dl_skip_args words.\n\ - lea 4(%rsp,%rax,4), %esp\n\ - # Subtract _dl_skip_args from argc.\n\ - subl %eax, %edx\n\ - # Push argc back on the stack.\n\ - subl $4, %esp\n\ - movl %edx, (%rsp)\n\ # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\ # argc -> rsi\n\ movl %edx, %esi\n\ From patchwork Thu May 26 16:50:03 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: 54426 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 B406B3838214 for ; Thu, 26 May 2022 17:02:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B406B3838214 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653584563; bh=4TklX3PK/gfIsoiQv+ZK50EPrvm8YAytyWdzI0nHihI=; 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=AZighgX6h+QapdIz/Jk9SbP7Bj62K9EQ+/233h5VTPRPOHEYD/JQdWp2IWN59eYFl xuNiR2ibfnjcG17/uI3Jk/cj06tuQtwz0PA9OdC0WnnJJSsHaQR48/ff7VCdtvHpNx FRgDFMMAp1QFutwnNg/3Tfn/BcLydQa3OdNAFUXQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id B9AE63839C69 for ; Thu, 26 May 2022 16:50:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B9AE63839C69 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-f2c296d320so2833602fac.8 for ; Thu, 26 May 2022 09:50:33 -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=4TklX3PK/gfIsoiQv+ZK50EPrvm8YAytyWdzI0nHihI=; b=febA6csVJbFXkZtrtsHWhgToG2k1JhpGDoD7G82ZccFbKMwYN+Frq/6PcAPyYxF4Gr ES+w6facbg6RyD1rT5SkMv8pQfP3kWoGyDevBaFvO8DZ2YUSiUGsv7rLPhyX8ZAOvxVp JCZ0B/2KNdhZ3JbjIYFqjyoJFMW+3lm4tchPWqP8KF+0gHOHVBX61JQKwht2RWuAeIiA +TeQpKRDkNDGNW9oy+UzPcok8vLvN4dr7PeALeI8VaaVYP5EQ8VINx49izyc/Sm/IP+W NE7w2xhCvDLFfX+Wik80L6NBySrctEPU/gTTjLjMRV255MlERpMGwMJsXloCbUSrDx2Q /x4A== X-Gm-Message-State: AOAM531guo4BPCiMgMn+Wm5qt1v7mAReu7G59jLhQWUuRyRPjxnbnBA6 Maz2MARHa5nDotiCnXYDIygW3iPs7v/UKw== X-Google-Smtp-Source: ABdhPJwOJyW4Yv6r4cdkKx/rwkUxUTn9e/tT4sslyHXtaqI8F7PpDpwUhUT0y3U/sJL1HeVYyI+NpA== X-Received: by 2002:a05:6870:c38f:b0:e5:f2c4:acc9 with SMTP id g15-20020a056870c38f00b000e5f2c4acc9mr1740338oao.173.1653583832916; Thu, 26 May 2022 09:50:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 09:50:32 -0700 (PDT) To: libc-alpha@sourceware.org, Szabolcs Nagy Subject: [PATCH 17/17] elf: Remove _dl_skip_args Date: Thu, 26 May 2022 13:50:03 -0300 Message-Id: <20220526165003.705355-18-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.8 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" Now that no architecture uses it anymore. --- elf/rtld.c | 2 -- sysdeps/generic/ldsodefs.h | 4 ---- sysdeps/mach/hurd/dl-sysdep.c | 1 - 3 files changed, 7 deletions(-) diff --git a/elf/rtld.c b/elf/rtld.c index 069940d73f..f5a3d1968f 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -158,8 +158,6 @@ static void process_envvars (struct dl_main_state *state); int _dl_argc attribute_relro attribute_hidden; char **_dl_argv attribute_relro = NULL; -/* Always 0, only kept for not-yet-updated target start code. */ -const unsigned int _dl_skip_args attribute_hidden; rtld_hidden_data_def (_dl_argv) #ifndef THREAD_SET_STACK_GUARD diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 6716e1f382..446d12a68c 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -755,10 +755,6 @@ rtld_hidden_proto (__libc_stack_end) extern int _dl_argc attribute_hidden attribute_relro; extern char **_dl_argv attribute_relro; rtld_hidden_proto (_dl_argv) -#if IS_IN (rtld) -/* Always 0, only kept for not-yet-updated target start code. */ -extern const unsigned int _dl_skip_args attribute_hidden; -#endif #define rtld_progname _dl_argv[0] /* Flag set at startup and cleared when the last initializer has run. */ diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 8373962e62..f23fdee058 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -139,7 +139,6 @@ _dl_sysdep_start (void **start_argptr, mach_port_t memobj; error_t err; - ++_dl_skip_args; --_dl_argc; p = _dl_argv++[1] + 1;