Page MenuHomeFreeBSD

D39452.id119949.diff
No OneTemporary

D39452.id119949.diff

diff --git a/libexec/rtld-elf/aarch64/reloc.c b/libexec/rtld-elf/aarch64/reloc.c
--- a/libexec/rtld-elf/aarch64/reloc.c
+++ b/libexec/rtld-elf/aarch64/reloc.c
@@ -32,6 +32,8 @@
#include <sys/types.h>
+#include <machine/sysarch.h>
+
#include <stdlib.h>
#include "debug.h"
@@ -55,6 +57,50 @@
void _exit(int);
+#define NOTE_GNU_VENDOR "GNU"
+
+void
+digest_note(struct Struct_Obj_Entry *obj __unused, const Elf_Note *note)
+{
+ const char *note_name;
+ const uint32_t *note_data;
+
+ note_name = (const char *)(note + 1);
+ /* Only handle GNU notes */
+ if (note->n_namesz != sizeof(NOTE_GNU_VENDOR) ||
+ strncmp(note_name, NOTE_GNU_VENDOR, sizeof(NOTE_GNU_VENDOR)) != 0)
+ return;
+
+ /* Only handle GNU property notes */
+ if (note->n_type != NT_GNU_PROPERTY_TYPE_0)
+ return;
+
+ /*
+ * note_data[0] - Type
+ * note_data[1] - Length
+ * note_data[2] - Data
+ * note_data[3] - Padding?
+ */
+ note_data = (const uint32_t *)(note_name + note->n_namesz);
+
+ /* Only handle AArch64 feature notes */
+ if (note_data[0] != GNU_PROPERTY_AARCH64_FEATURE_1_AND)
+ return;
+
+ /* We expect at least 4 bytes of data */
+ if (note_data[1] < 4)
+ return;
+
+ if ((note_data[2] & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) != 0) {
+ struct arm64_guard_page_args guard;
+
+ guard.addr = (uintptr_t)obj->mapbase;
+ guard.len = obj->mapsize;
+
+ sysarch(ARM64_GUARD_PAGE, &guard);
+ }
+}
+
void
init_pltgot(Obj_Entry *obj)
{
diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h
--- a/libexec/rtld-elf/aarch64/rtld_machdep.h
+++ b/libexec/rtld-elf/aarch64/rtld_machdep.h
@@ -47,6 +47,8 @@
(const Elf_Dyn *)_dynamic_addr; \
})
+void digest_note(struct Struct_Obj_Entry *obj, const Elf_Note *note);
+
Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,
const Elf_Rel *rel);
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -1721,16 +1721,22 @@
roundup2(note->n_namesz, sizeof(Elf32_Addr)) +
roundup2(note->n_descsz, sizeof(Elf32_Addr)))) {
if (note->n_namesz != sizeof(NOTE_FREEBSD_VENDOR) ||
- note->n_descsz != sizeof(int32_t))
+ note->n_descsz != sizeof(int32_t)) {
+ digest_note(obj, note);
continue;
+ }
if (note->n_type != NT_FREEBSD_ABI_TAG &&
note->n_type != NT_FREEBSD_FEATURE_CTL &&
- note->n_type != NT_FREEBSD_NOINIT_TAG)
+ note->n_type != NT_FREEBSD_NOINIT_TAG) {
+ digest_note(obj, note);
continue;
+ }
note_name = (const char *)(note + 1);
if (strncmp(NOTE_FREEBSD_VENDOR, note_name,
- sizeof(NOTE_FREEBSD_VENDOR)) != 0)
+ sizeof(NOTE_FREEBSD_VENDOR)) != 0) {
+ digest_note(obj, note);
continue;
+ }
switch (note->n_type) {
case NT_FREEBSD_ABI_TAG:
/* FreeBSD osrel note */
@@ -1751,6 +1757,9 @@
obj->crt_no_init = true;
dbg("note crt_no_init");
break;
+ default:
+ digest_note(obj, note);
+ break;
}
}
}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 23, 12:28 AM (9 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17718448
Default Alt Text
D39452.id119949.diff (2 KB)

Event Timeline