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" \