From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by sourceware.org (Postfix) with ESMTPS id CBC3E3858C2C for ; Tue, 4 Jan 2022 12:05:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBC3E3858C2C Received: by mail-qv1-xf2e.google.com with SMTP id fq10so34088911qvb.10 for ; Tue, 04 Jan 2022 04:05:31 -0800 (PST) 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=+8ZoqZWpIuRaDPdpQlKEgM459LwDbzHlHajsirvytOo=; b=eaMEVUwGkejrc2vUWCkwgv5mTnU5jCqbZPOGFH1UK6VsGkUGntQcOu8wdFLSv1SY0e AUfZYTkW6/ELkHEJIssaxDcoD9zUmonHkjLp9q3dFy+8gcnEc3/FoUcalsfNf1C+5/zI MOld+1tgaJwm9g/warlnxQcW0fLWKXCr5PcsZVlY8pZAdOyTpyKp2ihTu9YyTmhh+hWC ztkidy7FB9kRBwf4NTTNRbO3uZTZGLnUajvajOtUNRp/cHOlSn6jfO+vmn67pc2PNmQE qzijWdpJb+QsnpYR02N9449oktmdZz6KTJeSUUpErKMUWzCLx0icWqIKKHZUzAJvaHcE lALA== X-Gm-Message-State: AOAM532NXBZ82SF6tFg4Z0y2ByDn+2NaOhR3E5zk9T2TUNynGORmQQew tVHP6b6rXFgy6TopaA1tJfGGOlKvG8y95w== X-Google-Smtp-Source: ABdhPJw+oKVNThKibXkvU3dhVBfw+X+8Zg3rRI27rb6Jx8R4imtOzKQP1YZZl2ylTOI79dQixJu/rA== X-Received: by 2002:a05:6214:2b0c:: with SMTP id jx12mr23060032qvb.84.1641297930925; Tue, 04 Jan 2022 04:05:30 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:a350:1960:9a87:fba4:a664? ([2804:431:c7ca:a350:1960:9a87:fba4:a664]) by smtp.gmail.com with ESMTPSA id bs16sm31597180qkb.45.2022.01.04.04.05.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Jan 2022 04:05:30 -0800 (PST) Message-ID: Date: Tue, 4 Jan 2022 09:05:28 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v4 04/13] or1k: startup and dynamic linking code Content-Language: en-US To: Stafford Horne Cc: GLIBC patches , Openrisc References: <20211229044251.2203653-1-shorne@gmail.com> <20211229044251.2203653-5-shorne@gmail.com> <152802e5-0bac-e450-3898-016fc00bdd4f@linaro.org> From: Adhemerval Zanella In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Tue, 04 Jan 2022 12:05:33 -0000 On 04/01/2022 00:08, Stafford Horne wrote: > On Tue, Jan 04, 2022 at 10:28:15AM +0900, Stafford Horne wrote: >> On Mon, Jan 03, 2022 at 03:17:15PM -0300, Adhemerval Zanella wrote: >>> >>> >>> On 29/12/2021 01:42, Stafford Horne via Libc-alpha wrote: >>>> +/* Return nonzero iff ELF header is compatible with the running host. */ >>>> +static inline int __attribute__ ((unused)) >>>> +elf_machine_matches_host (const Elf32_Ehdr *ehdr) >>>> +{ >>>> + return ehdr->e_machine == EM_OPENRISC; >>>> +} >>>> + >>>> +static inline Elf32_Addr * >>>> +or1k_get_got (void) >>>> +{ >>>> + Elf32_Addr *got; >>>> + >>>> + asm ("l.jal 0x8\n" >>>> + " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n" >>>> + "l.ori %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n" >>>> + "l.add %0, %0, r9\n" >>>> + : "=r" (got) : : "r9"); >>> >>> >>> I think this requires a "memory" clobber. >> >> Why would it? This does not do any memory loads or stores. >> >> Let me test with "memory" clobber and see what the difference is. > > If seem that with the "memory" clobber the compiler can no longer optimize away > calling or1k_get_got the second time in elf_machine_load_address. > > I will leave it out unless there is a good reason for it. Fair enough, I had the impression it does access memory but it seems it just my lack of or1k assembly knowledge. Sorry for the noise.