reloc.c (a6fe717c2a876105123214c05176cd74106fb94b) reloc.c (d8925a5f42b517131f926d665538be95db710c4a)
1/*-
2 * Copyright (c) 2014-2015 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * Portions of this software were developed by Andrew Turner
6 * under sponsorship from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 15 unchanged lines hidden (view full) ---

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/types.h>
31
1/*-
2 * Copyright (c) 2014-2015 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * Portions of this software were developed by Andrew Turner
6 * under sponsorship from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 15 unchanged lines hidden (view full) ---

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/types.h>
31
32#include <machine/sysarch.h>
33
32#include <stdlib.h>
33
34#include "debug.h"
35#include "rtld.h"
36#include "rtld_printf.h"
37
38/*
39 * It is possible for the compiler to emit relocations for unaligned data.

--- 7 unchanged lines hidden (view full) ---

47 * a function pointer to a simple asm function.
48 */
49void *_rtld_tlsdesc_static(void *);
50void *_rtld_tlsdesc_undef(void *);
51void *_rtld_tlsdesc_dynamic(void *);
52
53void _exit(int);
54
34#include <stdlib.h>
35
36#include "debug.h"
37#include "rtld.h"
38#include "rtld_printf.h"
39
40/*
41 * It is possible for the compiler to emit relocations for unaligned data.

--- 7 unchanged lines hidden (view full) ---

49 * a function pointer to a simple asm function.
50 */
51void *_rtld_tlsdesc_static(void *);
52void *_rtld_tlsdesc_undef(void *);
53void *_rtld_tlsdesc_dynamic(void *);
54
55void _exit(int);
56
57bool
58arch_digest_note(struct Struct_Obj_Entry *obj __unused, const Elf_Note *note)
59{
60 const char *note_name;
61 const uint32_t *note_data;
62
63 note_name = (const char *)(note + 1);
64 /* Only handle GNU notes */
65 if (note->n_namesz != sizeof(ELF_NOTE_GNU) ||
66 strncmp(note_name, ELF_NOTE_GNU, sizeof(ELF_NOTE_GNU)) != 0)
67 return (false);
68
69 /* Only handle GNU property notes */
70 if (note->n_type != NT_GNU_PROPERTY_TYPE_0)
71 return (false);
72
73 /*
74 * note_data[0] - Type
75 * note_data[1] - Length
76 * note_data[2] - Data
77 * note_data[3] - Padding?
78 */
79 note_data = (const uint32_t *)(note_name + note->n_namesz);
80
81 /* Only handle AArch64 feature notes */
82 if (note_data[0] != GNU_PROPERTY_AARCH64_FEATURE_1_AND)
83 return (false);
84
85 /* We expect at least 4 bytes of data */
86 if (note_data[1] < 4)
87 return (false);
88
89 /* TODO: Only guard if HWCAP2_BTI is set */
90 if ((note_data[2] & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) != 0) {
91 struct arm64_guard_page_args guard;
92
93 guard.addr = (uintptr_t)obj->mapbase;
94 guard.len = obj->mapsize;
95
96 sysarch(ARM64_GUARD_PAGE, &guard);
97 }
98
99 return (true);
100}
101
55void
56init_pltgot(Obj_Entry *obj)
57{
58
59 if (obj->pltgot != NULL) {
60 obj->pltgot[1] = (Elf_Addr) obj;
61 obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start;
62 }

--- 473 unchanged lines hidden ---
102void
103init_pltgot(Obj_Entry *obj)
104{
105
106 if (obj->pltgot != NULL) {
107 obj->pltgot[1] = (Elf_Addr) obj;
108 obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start;
109 }

--- 473 unchanged lines hidden ---