summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2019-10-24 22:11:10 +0000
committerguenther <guenther@openbsd.org>2019-10-24 22:11:10 +0000
commit2f142762b0a7726368575af60dc4899cdc65bc9f (patch)
tree4655cbf4e642a96a7cb82226ebd17a5941c8bf3b
parentFix ifconfig(8) compiler warnings regarding variable "name" reuse. (diff)
downloadwireguard-openbsd-2f142762b0a7726368575af60dc4899cdc65bc9f.tar.xz
wireguard-openbsd-2f142762b0a7726368575af60dc4899cdc65bc9f.zip
Delete unused support for relocations that don't require alignment.
ok mpi@ kettenis@
-rw-r--r--libexec/ld.so/aarch64/rtld_machine.c26
-rw-r--r--libexec/ld.so/arm/rtld_machine.c26
-rw-r--r--libexec/ld.so/i386/rtld_machine.c31
-rw-r--r--libexec/ld.so/sh/rtld_machine.c26
4 files changed, 12 insertions, 97 deletions
diff --git a/libexec/ld.so/aarch64/rtld_machine.c b/libexec/ld.so/aarch64/rtld_machine.c
index e59bee50517..315743795a1 100644
--- a/libexec/ld.so/aarch64/rtld_machine.c
+++ b/libexec/ld.so/aarch64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.11 2019/10/23 19:55:08 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.12 2019/10/24 22:11:10 guenther Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@@ -49,7 +49,6 @@ Elf_Addr _dl_bind(elf_object_t *object, int index);
#define _RF_P 0x20000000 /* Location relative */
#define _RF_G 0x10000000 /* GOT offset */
#define _RF_B 0x08000000 /* Load address relative */
-#define _RF_U 0x04000000 /* Unaligned */
#define _RF_V 0x02000000 /* ERROR */
#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */
#define _RF_RS(s) ((s) & 0xff) /* right shift */
@@ -75,7 +74,6 @@ static const int reloc_target_flags[] = {
#define RELOC_RESOLVE_SYMBOL(t) ((reloc_target_flags[t] & _RF_S) != 0)
#define RELOC_PC_RELATIVE(t) ((reloc_target_flags[t] & _RF_P) != 0)
#define RELOC_BASE_RELATIVE(t) ((reloc_target_flags[t] & _RF_B) != 0)
-#define RELOC_UNALIGNED(t) ((reloc_target_flags[t] & _RF_U) != 0)
#define RELOC_USE_ADDEND(t) ((reloc_target_flags[t] & _RF_A) != 0)
#define RELOC_TARGET_SIZE(t) ((reloc_target_flags[t] >> 8) & 0xff)
#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff)
@@ -221,26 +219,8 @@ resolve_failed:
value >>= RELOC_VALUE_RIGHTSHIFT(type);
value &= mask;
- if (RELOC_UNALIGNED(type)) {
- /* Handle unaligned relocations. */
- Elf_Addr tmp = 0;
- char *ptr = (char *)where;
- int i, size = RELOC_TARGET_SIZE(type)/8;
-
- /* Read it in one byte at a time. */
- for (i=0; i<size; i++)
- tmp = (tmp << 8) | ptr[i];
-
- tmp &= ~mask;
- tmp |= value;
-
- /* Write it back out. */
- for (i=0; i<size; i++)
- ptr[i] = ((tmp >> (8*i)) & 0xff);
- } else {
- *where &= ~mask;
- *where |= value;
- }
+ *where &= ~mask;
+ *where |= value;
}
return fails;
diff --git a/libexec/ld.so/arm/rtld_machine.c b/libexec/ld.so/arm/rtld_machine.c
index 86a7a521a3c..5c60f9d7e0d 100644
--- a/libexec/ld.so/arm/rtld_machine.c
+++ b/libexec/ld.so/arm/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.32 2019/10/23 19:55:09 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.33 2019/10/24 22:11:10 guenther Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@@ -49,7 +49,6 @@ Elf_Addr _dl_bind(elf_object_t *object, int reloff);
#define _RF_P 0x20000000 /* Location relative */
#define _RF_G 0x10000000 /* GOT offset */
#define _RF_B 0x08000000 /* Load address relative */
-#define _RF_U 0x04000000 /* Unaligned */
#define _RF_E 0x02000000 /* ERROR */
#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */
#define _RF_RS(s) ((s) & 0xff) /* right shift */
@@ -102,7 +101,6 @@ static const int reloc_target_flags[] = {
#define RELOC_RESOLVE_SYMBOL(t) ((reloc_target_flags[t] & _RF_S) != 0)
#define RELOC_PC_RELATIVE(t) ((reloc_target_flags[t] & _RF_P) != 0)
#define RELOC_BASE_RELATIVE(t) ((reloc_target_flags[t] & _RF_B) != 0)
-#define RELOC_UNALIGNED(t) ((reloc_target_flags[t] & _RF_U) != 0)
#define RELOC_USE_ADDEND(t) ((reloc_target_flags[t] & _RF_A) != 0)
#define RELOC_TARGET_SIZE(t) ((reloc_target_flags[t] >> 8) & 0xff)
#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff)
@@ -284,26 +282,8 @@ resolve_failed:
value >>= RELOC_VALUE_RIGHTSHIFT(type);
value &= mask;
- if (RELOC_UNALIGNED(type)) {
- /* Handle unaligned relocations. */
- Elf_Addr tmp = 0;
- char *ptr = (char *)where;
- int i, size = RELOC_TARGET_SIZE(type)/8;
-
- /* Read it in one byte at a time. */
- for (i=0; i<size; i++)
- tmp = (tmp << 8) | ptr[i];
-
- tmp &= ~mask;
- tmp |= value;
-
- /* Write it back out. */
- for (i=0; i<size; i++)
- ptr[i] = ((tmp >> (8*i)) & 0xff);
- } else {
- *where &= ~mask;
- *where |= value;
- }
+ *where &= ~mask;
+ *where |= value;
}
return fails;
diff --git a/libexec/ld.so/i386/rtld_machine.c b/libexec/ld.so/i386/rtld_machine.c
index 8191e6f5fd7..fd46970a6ad 100644
--- a/libexec/ld.so/i386/rtld_machine.c
+++ b/libexec/ld.so/i386/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.43 2019/10/23 19:55:09 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.44 2019/10/24 22:11:10 guenther Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -98,7 +98,6 @@ int64_t pcookie __attribute__((section(".openbsd.randomdata"))) __dso_hidden;
#define _RF_P 0x20000000 /* Location relative */
#define _RF_G 0x10000000 /* GOT offset */
#define _RF_B 0x08000000 /* Load address relative */
-#define _RF_U 0x04000000 /* Unaligned */
#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */
#define _RF_RS(s) ((s) & 0xff) /* right shift */
static const int reloc_target_flags[] = {
@@ -131,7 +130,6 @@ static const int reloc_target_flags[] = {
#define RELOC_RESOLVE_SYMBOL(t) ((reloc_target_flags[t] & _RF_S) != 0)
#define RELOC_PC_RELATIVE(t) ((reloc_target_flags[t] & _RF_P) != 0)
#define RELOC_BASE_RELATIVE(t) ((reloc_target_flags[t] & _RF_B) != 0)
-#define RELOC_UNALIGNED(t) ((reloc_target_flags[t] & _RF_U) != 0)
#define RELOC_USE_ADDEND(t) ((reloc_target_flags[t] & _RF_A) != 0)
#define RELOC_TARGET_SIZE(t) ((reloc_target_flags[t] >> 8) & 0xff)
#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff)
@@ -282,31 +280,8 @@ resolve_failed:
value >>= RELOC_VALUE_RIGHTSHIFT(type);
value &= mask;
- if (RELOC_UNALIGNED(type)) {
- /* Handle unaligned relocations. */
- Elf_Addr tmp = 0;
- char *ptr = (char *)where;
- int i, size = RELOC_TARGET_SIZE(type)/8;
-
- /* Read it in one byte at a time. */
- for (i=0; i<size; i++)
- tmp = (tmp << 8) | ptr[i];
-
- tmp &= ~mask;
- tmp |= value;
-
- /* Write it back out. */
- for (i=0; i<size; i++)
- ptr[i] = ((tmp >> (8*i)) & 0xff);
- } else if (RELOC_TARGET_SIZE(type) > 32) {
- *where &= ~mask;
- *where |= value;
- } else {
- Elf_Addr *where32 = (Elf_Addr *)where;
-
- *where32 &= ~mask;
- *where32 |= value;
- }
+ *where &= ~mask;
+ *where |= value;
}
return fails;
diff --git a/libexec/ld.so/sh/rtld_machine.c b/libexec/ld.so/sh/rtld_machine.c
index b0fcd2de9a3..f2c252ac1d3 100644
--- a/libexec/ld.so/sh/rtld_machine.c
+++ b/libexec/ld.so/sh/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.31 2019/10/23 19:55:09 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.32 2019/10/24 22:11:10 guenther Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@@ -50,7 +50,6 @@ Elf_Addr _dl_bind(elf_object_t *object, int reloff);
#define _RF_P 0x20000000 /* Location relative */
#define _RF_G 0x10000000 /* GOT offset */
#define _RF_B 0x08000000 /* Load address relative */
-#define _RF_U 0x04000000 /* Unaligned */
#define _RF_E 0x02000000 /* ERROR */
#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */
#define _RF_RS(s) ((s) & 0xff) /* right shift */
@@ -319,7 +318,6 @@ static const int reloc_target_flags[] = {
#define RELOC_RESOLVE_SYMBOL(t) ((reloc_target_flags[t] & _RF_S) != 0)
#define RELOC_PC_RELATIVE(t) ((reloc_target_flags[t] & _RF_P) != 0)
#define RELOC_BASE_RELATIVE(t) ((reloc_target_flags[t] & _RF_B) != 0)
-#define RELOC_UNALIGNED(t) ((reloc_target_flags[t] & _RF_U) != 0)
#define RELOC_USE_ADDEND(t) ((reloc_target_flags[t] & _RF_A) != 0)
#define RELOC_TARGET_SIZE(t) ((reloc_target_flags[t] >> 8) & 0xff)
#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff)
@@ -722,26 +720,8 @@ resolve_failed:
value >>= RELOC_VALUE_RIGHTSHIFT(type);
value &= mask;
- if (RELOC_UNALIGNED(type)) {
- /* Handle unaligned relocations. */
- Elf_Addr tmp = 0;
- char *ptr = (char *)where;
- int i, size = RELOC_TARGET_SIZE(type)/8;
-
- /* Read it in one byte at a time. */
- for (i=0; i<size; i++)
- tmp = (tmp << 8) | ptr[i];
-
- tmp &= ~mask;
- tmp |= value;
-
- /* Write it back out. */
- for (i=0; i<size; i++)
- ptr[i] = ((tmp >> (8*i)) & 0xff);
- } else {
- *where &= ~mask;
- *where |= value;
- }
+ *where &= ~mask;
+ *where |= value;
}
return fails;