From patchwork Fri Oct 16 09:32:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 9179 Received: (qmail 75083 invoked by alias); 16 Oct 2015 09:35:40 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 75055 invoked by uid 89); 16 Oct 2015 09:35:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mailout1.samsung.com From: Maninder Singh To: libc-alpha@sourceware.org, marcus.shawcroft@arm.com Cc: mark.hatle@windriver.com, ajeet.y@samsung.com, hakbong5.lee@samsung.com, doha.hwang@samsung.com, pankaj.m@samsung.com, Maninder Singh , Vaneet Narang Subject: [PATCH 1/1] aarch64/dl-machine.h: Fix load-address for prelink support Date: Fri, 16 Oct 2015 15:02:31 +0530 Message-id: <1444987951-17277-1-git-send-email-maninder1.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Fix load-address for prelink support in aarch64, reference from x86_64. Existing code always use compiled address, whereas it should use compiled address for non-prelinked binaries and prelinked address for prelinked binaries, which it can get from .GOT first entry. Signed-off-by: Vaneet Narang Signed-off-by: Maninder Singh --- sysdeps/aarch64/dl-machine.h | 28 +++++----------------------- 1 files changed, 5 insertions(+), 23 deletions(-) diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h index 217e179..7bb737d 100644 --- a/sysdeps/aarch64/dl-machine.h +++ b/sysdeps/aarch64/dl-machine.h @@ -46,29 +46,11 @@ elf_machine_dynamic (void) static inline ElfW(Addr) __attribute__ ((unused)) elf_machine_load_address (void) { - /* To figure out the load address we use the definition that for any symbol: - dynamic_addr(symbol) = static_addr(symbol) + load_addr - - The choice of symbol is arbitrary. The static address we obtain - by constructing a non GOT reference to the symbol, the dynamic - address of the symbol we compute using adrp/add to compute the - symbol's address relative to the PC. - This depends on 32bit relocations being resolved at link time - and that the static address fits in the 32bits. */ - - ElfW(Addr) static_addr; - ElfW(Addr) dynamic_addr; - - asm (" \n" -" adrp %1, _dl_start; \n" -" add %1, %1, #:lo12:_dl_start \n" -" ldr %w0, 1f \n" -" b 2f \n" -"1: \n" -" .word _dl_start \n" -"2: \n" - : "=r" (static_addr), "=r" (dynamic_addr)); - return dynamic_addr - static_addr; + /* Compute the difference between the runtime address of _DYNAMIC as seen + by an IP-relative reference, and the link-time address found in the + special unrelocated first GOT entry. */ + extern ElfW(Dyn) _DYNAMIC[] attribute_hidden; + return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic (); } /* Set up the loaded object described by L so its unrelocated PLT