From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 E0D593854834 for ; Sun, 29 May 2022 13:10:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0D593854834 Received: by mail-oi1-x22d.google.com with SMTP id t144so11051904oie.7 for ; Sun, 29 May 2022 06:10:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=yYYgTF14qGdkrbFwaCFS2Bd9n6XJ8IARj2bvoEGnG0Q=; b=HmuDqLM7a9XiS87cWsKhR7L7RUNGorq+f3aJcNQB4ruuOo5YCa7/AMqkOMs1SvDWvU caACC215reawF0nqt+/xEEVivVchlhJS3WT6r5SHNrbfgA/Q0bgjITB320E5R8AW6E0r BEukxg134/RpFZyH1IkmQKmecLjYra0tO/NNb/xQZi40ha/W6rcXnZC/93DJr6XPqQmZ HLnFGS83T9SmrZ+l7g2I8iQnFj6mnlQf6yy+Tw4uRAK/AR+tkLqEApPBztlBXvEyN8xD 0xQeazzLSL/CuYPtyJ0KLDek2/s76b7/ICSJdmwCp7ZvdE6jN3Q9TKZrnQOilo5429rQ VGDQ== X-Gm-Message-State: AOAM532flAijWYB05bbTOLy29pjTVVRcSCsmvrVB758Gvgwgn2E4ehau FQgWFwUL7loNeog3FQ4HyhMxBhcqb3dvAg== X-Google-Smtp-Source: ABdhPJxL5Pgh1UzClOAhcI65HI8UZfhlF9R+DA/wuZgFiHNacPoeCn3YFWDgzgz2CGhnDh4DdAsFlg== X-Received: by 2002:a05:6808:199b:b0:329:92c:4a1e with SMTP id bj27-20020a056808199b00b00329092c4a1emr7691477oib.214.1653829857060; Sun, 29 May 2022 06:10:57 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:9f85:ddfc:46a3:d390:7787? ([2804:431:c7cb:9f85:ddfc:46a3:d390:7787]) by smtp.gmail.com with ESMTPSA id 32-20020a9d0323000000b0060603221281sm3968463otv.81.2022.05.29.06.10.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 May 2022 06:10:56 -0700 (PDT) Message-ID: <83e13bba-5081-3df0-e0d7-9020bf38313e@linaro.org> Date: Sun, 29 May 2022 10:10:53 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v4 04/13] LoongArch: ABI Implementation Content-Language: en-US To: caiyinyu , libc-alpha@sourceware.org Cc: joseph_myers@mentor.com, xuchenghua@loongson.cn References: <20220509023010.1250020-1-caiyinyu@loongson.cn> <20220509023010.1250020-5-caiyinyu@loongson.cn> From: Adhemerval Zanella In-Reply-To: <20220509023010.1250020-5-caiyinyu@loongson.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, 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-List-Received-Date: Sun, 29 May 2022 13:11:01 -0000 On 08/05/2022 23:30, caiyinyu wrote: > --- > +/* Return the run-time load address of the shared object. */ > +static inline ElfW (Addr) elf_machine_load_address (void) > +{ > + ElfW (Addr) got_linktime_addr; > + asm("la.got %0, _GLOBAL_OFFSET_TABLE_" > + /* Link-time address in GOT entry before runtime relocation */ > + : "=r"(got_linktime_addr)); > + return (ElfW (Addr)) _GLOBAL_OFFSET_TABLE_ - got_linktime_addr; > +} > + > +/* Initial entry point code for the dynamic linker. > + The C function `_dl_start' is the real entry point; > + its return value is the user program's entry point. */ > + > +#define RTLD_START \ > + asm(".text\n\ > + " _RTLD_PROLOGUE (ENTRY_POINT) "\ > + .cfi_label .Ldummy \n\ > + " CFI_UNDEFINED (1) " \n\ > + or $a0, $sp, $zero \n\ > + bl _dl_start \n\ > + # Stash user entry point in s0. \n\ > + or $s0, $v0, $zero \n\ > + # See if we were run as a command with the executable file \n\ > + # name as an extra leading argument. \n\ > + la $a0, _dl_skip_args \n\ > + ld.w $a0, $a0, 0 \n\ > + # Load the original argument count. \n\ > + ld.d $a1, $sp, 0 \n\ > + # Subtract _dl_skip_args from it. \n\ > + sub.d $a1, $a1, $a0 \n\ > + # Adjust the stack pointer to skip _dl_skip_args words. \n\ > + slli.d $a0, $a0, 3 \n\ > + add.d $sp, $sp, $a0 \n\ > + # Save back the modified argument count. \n\ > + st.d $a1, $sp, 0 \n\ > + # Call _dl_init (struct link_map *main_map, int argc, char **argv, \ > + char **env) \n\ Since ad43cac44a6860eaefcadadfb2acb349921e96bf there is no need to adjust the arguments using _dl_skip_args; if you don't do anything ABI special you just need to just reload argc from _dl_argc. I have adapted all of architectures to eventually remove _dl_skip_args [1], so please follow the same pattern here. [1] https://patchwork.sourceware.org/project/glibc/list/?series=9706 > + la $a0, _rtld_local \n\ > + ld.d $a0, $a0, 0 \n\ > + addi.d $a2, $sp, 8 \n\ > + slli.d $a3, $a1, 3 \n\ > + add.d $a3, $a3, $a2 \n\ > + addi.d $a3, $a3, 8 \n\ > + # Adjust $sp for 16-aligned \n\ > + srli.d $t0, $sp, 4 \n\ > + slli.d $t0, $t0, 4 \n\ > + ori $t1, $sp, 0 \n\ > + addi.d $sp, $t0, -32 \n\ > + st.d $t1, $sp, 24 \n\ > + # Call the function to run the initializers. \n\ > + bl _dl_init \n\ > + # Pass our finalizer function to _start. \n\ > + ld.d $sp, $sp, 24 \n\ > + la $a0, _dl_fini \n\ > + # Jump to the user entry point. \n\ > + jirl $zero, $s0, 0 \n\ > + " _RTLD_EPILOGUE (ENTRY_POINT) "\ > + .previous"); >