From 4e61412a9215922e6ef944624481c07968eba071 Mon Sep 17 00:00:00 2001 From: kettenis Date: Tue, 24 Jul 2018 09:27:44 +0000 Subject: [PATCH] Fix address calculation for _DYNAMIC. We want to address of _DYNAMIC itself, not the address of its GOT entry. The current code mixed the high bits of the GOT entry address with the low bits of the true address. This only worked by accident for small binaries where _DYNAMIC and its GOT entry happen to reside on the same page. ok guenther@, mortimer@ --- lib/csu/aarch64/md_init.h | 4 ++-- libexec/ld.so/aarch64/ldasm.S | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/csu/aarch64/md_init.h b/lib/csu/aarch64/md_init.h index f235a2fa2e3..96465d7b63f 100644 --- a/lib/csu/aarch64/md_init.h +++ b/lib/csu/aarch64/md_init.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md_init.h,v 1.4 2017/08/11 20:13:30 guenther Exp $ */ +/* $OpenBSD: md_init.h,v 1.5 2018/07/24 09:27:44 kettenis Exp $ */ /*- * Copyright (c) 2001 Ross Harvey @@ -93,7 +93,7 @@ " sub sp, sp, #8+8+(16*8) \n" \ " add x1, sp, #4 \n" \ " \n" \ - " adrp x2, :got:_DYNAMIC \n" \ + " adrp x2, _DYNAMIC \n" \ " add x2, x2, #:lo12:_DYNAMIC \n" \ " \n" \ " bl _dl_boot_bind \n" \ diff --git a/libexec/ld.so/aarch64/ldasm.S b/libexec/ld.so/aarch64/ldasm.S index 890936c2275..2ba592fd6f1 100644 --- a/libexec/ld.so/aarch64/ldasm.S +++ b/libexec/ld.so/aarch64/ldasm.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ldasm.S,v 1.5 2017/12/21 00:32:55 kettenis Exp $ */ +/* $OpenBSD: ldasm.S,v 1.6 2018/07/24 09:27:44 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -41,7 +41,7 @@ ENTRY(_dl_start) mov x0, x29 // original stack mov x1, x20 // dl_data - adrp x2, :got:_DYNAMIC /* &_DYNAMIC */ + adrp x2, _DYNAMIC /* &_DYNAMIC */ add x2, x2, #:lo12:_DYNAMIC bl _dl_boot_bind -- 2.20.1