From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 110802 invoked by alias); 4 Nov 2016 21:24:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 110783 invoked by uid 89); 4 Nov 2016 21:24:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy= X-HELO: topped-with-meat.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: Roland McGrath To: Renlin Li Cc: libc-alpha@sourceware.org, Marcus Shawcroft , Richard Earnshaw Subject: Re: [GLIBC][AARCH64]Rewrite elf_machine_load_address using _DYNAMIC symbol In-Reply-To: Renlin Li's message of Friday, 4 November 2016 09:42:23 +0000 <581C57FF.2090901@foss.arm.com> References: <581C57FF.2090901@foss.arm.com> Message-Id: <20161104212440.A23F42C3AD8@topped-with-meat.com> Date: Fri, 04 Nov 2016 21:24:00 -0000 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=XYkakuJ5 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=m30nbq8-YPw0Z_fxVc4A:9 a=sVyC7_DfsbNA7i2Z:21 a=08FyzXFyhr71xF1i:21 a=CjuIK1q_8ugA:10 X-SW-Source: 2016-11/txt/msg00205.txt.bz2 On many or perhaps all machines, elf_machine_load_address could now be implemented purely in C by using a link-time trick. In C, just: static inline ElfW(Addr) __attribute__ ((unused)) elf_machine_load_address (void) { extern const char _BASE[] __attribute__ ((visibility ("hidden"))); return (ElfW(Addr)) _BASE; } Then add a trivial input linker script to the ld.so link: PROVIDE_HIDDEN(_BASE = 0); I know this works for x86_64 and aarch64, and does not require a load. (On x86_64 it's a single lea; on aarch64 it's a single adr+add pair.)