This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/cet/property updated. glibc-2.25-617-g121ff35
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 28 Jun 2017 13:55:20 -0000
- Subject: GNU C Library master sources branch hjl/cet/property updated. glibc-2.25-617-g121ff35
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/cet/property has been updated
via 121ff354c6ff4e6e22a0b6d348f100498a8d4110 (commit)
from 043aedabcb854160954ac85ccf32400a89176725 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=121ff354c6ff4e6e22a0b6d348f100498a8d4110
commit 121ff354c6ff4e6e22a0b6d348f100498a8d4110
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Jun 28 06:54:51 2017 -0700
Didn't build
diff --git a/sysdeps/unix/sysv/linux/x86/Makefile b/sysdeps/unix/sysv/linux/x86/Makefile
index 9fb0c6e..a7e719c 100644
--- a/sysdeps/unix/sysv/linux/x86/Makefile
+++ b/sysdeps/unix/sysv/linux/x86/Makefile
@@ -20,7 +20,7 @@ libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \
endif
ifeq ($(subdir),elf)
-sysdep_routines += dl-vdso
+sysdep_routines += dl-vdso dl-cet
endif
ifneq ($(cet_cflags),)
diff --git a/sysdeps/unix/sysv/linux/x86/dl-cet.c b/sysdeps/unix/sysv/linux/x86/dl-cet.c
index a303854..abe1b00 100644
--- a/sysdeps/unix/sysv/linux/x86/dl-cet.c
+++ b/sysdeps/unix/sysv/linux/x86/dl-cet.c
@@ -15,14 +15,16 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-
#include <link.h>
-#include <ldsodefs.h>
+
+#ifndef SHARED
+# include <ldsodefs.h>
+# include "dl-cet.h"
void
internal_function
-_dl_check_cet (const ElfW(Phdr) *phdr, size_t phnum,
- const ElfW(Addr) addr, bool is_executable)
+_dl_setup_cet (const ElfW(Phdr) *phdr, size_t phnum,
+ const ElfW(Addr) addr)
{
if (phdr == NULL)
return;
@@ -46,10 +48,9 @@ _dl_check_cet (const ElfW(Phdr) *phdr, size_t phnum,
&& note->n_type == NT_GNU_PROPERTY_TYPE_0
&& memcmp (note + 1, "GNU", 4) == 0)
{
-#define ROUND(len) (((len) + sizeof (ElfW(Addr)) - 1) & -sizeof (ElfW(Addr)))
unsigned int *ptr
= (unsigned int *) ((char *) ¬e->n_type
- + ROUND (note->n_namesz));
+ + ROUND_PROPERTY_NOTE (note->n_namesz));
if (ptr[0] == GNU_PROPERTY_X86_FEATURE_1_AND)
{
if (ptr[1] == 4)
@@ -62,20 +63,16 @@ _dl_check_cet (const ElfW(Phdr) *phdr, size_t phnum,
}
break;
}
-#undef ROUND
}
-/* Note sections like .note.ABI-tag and .note.gnu.build-id are aligned
- to 4 bytes in 64-bit ELF objects. */
-#define ROUND(len) (((len) + sizeof note->n_type - 1) & -sizeof note->n_type)
note = ((const void *) (note + 1)
- + ROUND (note->n_namesz) + ROUND (note->n_descsz));
-#undef ROUND
+ + ROUND_NOTE (note->n_namesz)
+ + ROUND_NOTE (note->n_descsz));
}
}
}
- /* If IBT isn't enabled on executable, disable IBT. */
- if (is_executable && !ibt_enabled)
+ /* If IBT isn't enabled, disable IBT. */
+ if (!ibt_enabled)
cpu_features->feature[index_arch_IBT_Usable]
&= ~bit_arch_IBT_Usable;
@@ -85,9 +82,11 @@ _dl_check_cet (const ElfW(Phdr) *phdr, size_t phnum,
&= ~bit_arch_SHSTK_Usable;
}
+#else
void
internal_function
_dl_cet_init (struct link_map *main_map, int argc, char **argv, char **env)
{
_dl_init (main_map, argc, argv, env);
}
+#endif
diff --git a/sysdeps/unix/sysv/linux/x86/dl-cet.h b/sysdeps/unix/sysv/linux/x86/dl-cet.h
new file mode 100644
index 0000000..27a7298
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86/dl-cet.h
@@ -0,0 +1,100 @@
+/* Linux/x86 CET inline functions.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define ROUND_PROPERTY_NOTE(len) \
+ (((len) + sizeof (ElfW(Addr)) - 1) & -sizeof (ElfW(Addr)))
+
+/* Note sections like .note.ABI-tag and .note.gnu.build-id are aligned
+ to 4 bytes in 64-bit ELF objects. */
+#define ROUND_NOTE(len) \
+ (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word)))
+
+#ifdef ElfW
+static inline void __attribute__ ((unused))
+dl_process_cet_property_note (struct link_map *l,
+ const ElfW(Nhdr) *note,
+ ElfW(Addr) size)
+{
+ const ElfW(Addr) start = (ElfW(Addr)) note;
+
+ while ((ElfW(Addr)) (note + 1) - start < size)
+ {
+ /* Find the NT_GNU_PROPERTY_TYPE_0 note. */
+ if (note->n_namesz == 4
+ && note->n_type == NT_GNU_PROPERTY_TYPE_0
+ && memcmp (note + 1, "GNU", 4) == 0)
+ {
+ unsigned int *ptr
+ = (unsigned int *) ((char *) ¬e->n_type
+ + ROUND_PROPERTY_NOTE (note->n_namesz));
+ if (ptr[0] == GNU_PROPERTY_X86_FEATURE_1_AND)
+ {
+ if (ptr[1] == 4)
+ {
+ unsigned int pr_data = ptr[2];
+ if ((pr_data & GNU_PROPERTY_X86_FEATURE_1_IBT))
+ l->l_cet |= lc_ibt;
+ if ((pr_data & GNU_PROPERTY_X86_FEATURE_1_SHSTK))
+ l->l_cet |= lc_shstk;
+ }
+ break;
+ }
+ }
+
+ /* Note sections like .note.ABI-tag and .note.gnu.build-id are
+ * aligned to 4 bytes in 64-bit ELF objects. */
+ note = ((const void *) (note + 1)
+ + ROUND_NOTE (note->n_namesz)
+ + ROUND_NOTE (note->n_descsz));
+ }
+}
+
+# ifdef FILEBUF_SIZE
+# define DL_PROCESS_PT_NOTE(l, ph, fd, fbp) \
+ dl_process_pt_note ((l), (ph), (fd), (fbp))
+
+static inline void __attribute__ ((unused))
+dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph,
+ int fd, struct filebuf *fbp)
+{
+ const ElfW(Nhdr) *note;
+ ElfW(Addr) size = ph->p_filesz;
+
+ if (ph->p_offset + size <= (size_t) fbp->len)
+ note = (const void *) (fbp->buf + ph->p_offset);
+ else
+ {
+ note = alloca (size);
+ __lseek (fd, ph->p_offset, SEEK_SET);
+ if (__libc_read (fd, (void *) note, size) != size)
+ return;
+ }
+
+ dl_process_cet_property_note (l, note, size);
+}
+# else
+# define DL_PROCESS_PT_NOTE(l, ph) dl_process_pt_note ((l), (ph))
+
+static inline void __attribute__ ((unused))
+dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
+{
+ const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
+ dl_process_cet_property_note (l, note, ph->p_memsz);
+}
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/x86/dl-sysdep.c b/sysdeps/unix/sysv/linux/x86/dl-machine.h
similarity index 77%
copy from sysdeps/unix/sysv/linux/x86/dl-sysdep.c
copy to sysdeps/unix/sysv/linux/x86/dl-machine.h
index d98258f..4edc10a 100644
--- a/sysdeps/unix/sysv/linux/x86/dl-sysdep.c
+++ b/sysdeps/unix/sysv/linux/x86/dl-machine.h
@@ -1,4 +1,5 @@
-/* Operating system support for run-time dynamic linker. X86 version.
+/* Machine-dependent ELF dynamic relocation inline functions.
+ Linux/x86-64 version.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -16,7 +17,5 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <config.h>
-#include <sysdeps/x86/cpu-tunables.c>
-#include <sysdeps/unix/sysv/linux/x86/dl-cet.c>
-#include <sysdeps/unix/sysv/linux/dl-sysdep.c>
+#include <sysdeps/x86_64/dl-machine.h>
+#include "dl-cet.h"
diff --git a/sysdeps/unix/sysv/linux/x86/dl-sysdep.c b/sysdeps/unix/sysv/linux/x86/dl-sysdep.c
index d98258f..64eb0d7 100644
--- a/sysdeps/unix/sysv/linux/x86/dl-sysdep.c
+++ b/sysdeps/unix/sysv/linux/x86/dl-sysdep.c
@@ -18,5 +18,4 @@
#include <config.h>
#include <sysdeps/x86/cpu-tunables.c>
-#include <sysdeps/unix/sysv/linux/x86/dl-cet.c>
#include <sysdeps/unix/sysv/linux/dl-sysdep.c>
diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
index 3ceeceb..93af5db 100644
--- a/sysdeps/x86/cpu-features.h
+++ b/sysdeps/x86/cpu-features.h
@@ -238,12 +238,8 @@ struct cpu_features
extern const struct cpu_features *__get_cpu_features (void)
__attribute__ ((const));
-# ifdef ENABLE_CET
-/* If <link.h> is included before <dlfcn.h>, _dl_addr won't be
- declared. */
-# include <dlfcn.h>
-extern void _dl_check_cet (const ElfW(Phdr) *, size_t,
- const ElfW(Addr), bool)
+# ifdef ElfW
+extern void _dl_setup_cet (const ElfW(Phdr) *, size_t, const ElfW(Addr))
internal_function attribute_hidden;
# endif
diff --git a/sysdeps/x86/libc-start.c b/sysdeps/x86/libc-start.c
index 85d059d..9584f21 100644
--- a/sysdeps/x86/libc-start.c
+++ b/sysdeps/x86/libc-start.c
@@ -16,7 +16,8 @@
<http://www.gnu.org/licenses/>. */
#ifndef SHARED
-#include <ldsodefs.h>
+# include <link.h>
+# include <ldsodefs.h>
# include <cpu-features.h>
# include <cpu-features.c>
@@ -26,7 +27,7 @@ extern struct cpu_features _dl_x86_cpu_features;
#define ARCH_INIT_CPU_FEATURES() \
{ \
init_cpu_features (&_dl_x86_cpu_features); \
- _dl_check_cet (_dl_phdr, _dl_phnum, 0, true); \
+ _dl_setup_cet (_dl_phdr, _dl_phnum, 0); \
}
#else
# define ARCH_INIT_CPU_FEATURES() \
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index 9faaa59..ba41cfc 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -76,11 +76,6 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
extern void _dl_runtime_profile_avx (ElfW(Word)) attribute_hidden;
extern void _dl_runtime_profile_avx512 (ElfW(Word)) attribute_hidden;
-#ifdef ENABLE_CET
- _dl_check_cet (l->l_phdr, l->l_phnum, l->l_addr,
- l->l_type == lt_executable);
-#endif
-
if (l->l_info[DT_JMPREL] && lazy)
{
/* The GOT entries for functions in the PLT have not yet been filled
@@ -158,7 +153,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
return lazy;
}
-#ifdef ENABLE_CET
+#ifdef DL_PROCESS_PT_NOTE
# define DL_INIT "_dl_cet_init"
#else
# define DL_INIT "_dl_init"
@@ -262,87 +257,6 @@ dl_platform_init (void)
#endif
}
-#define ROUND_PROPERTY_NOTE(len) \
- (((len) + sizeof (ElfW(Addr)) - 1) & -sizeof (ElfW(Addr)))
-
-/* Note sections like .note.ABI-tag and .note.gnu.build-id are aligned
- to 4 bytes in 64-bit ELF objects. */
-#define ROUND_NOTE(len) \
- (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word)))
-
-static inline void __attribute__ ((unused))
-dl_process_cet_property_note (struct link_map *l,
- const ElfW(Nhdr) *note,
- ElfW(Addr) size)
-{
- const ElfW(Addr) start = (ElfW(Addr)) note;
-
- while ((ElfW(Addr)) (note + 1) - start < size)
- {
- /* Find the NT_GNU_PROPERTY_TYPE_0 note. */
- if (note->n_namesz == 4
- && note->n_type == NT_GNU_PROPERTY_TYPE_0
- && memcmp (note + 1, "GNU", 4) == 0)
- {
- unsigned int *ptr
- = (unsigned int *) ((char *) ¬e->n_type
- + ROUND_PROPERTY_NOTE (note->n_namesz));
- if (ptr[0] == GNU_PROPERTY_X86_FEATURE_1_AND)
- {
- if (ptr[1] == 4)
- {
- unsigned int pr_data = ptr[2];
- if ((pr_data & GNU_PROPERTY_X86_FEATURE_1_IBT))
- l->l_cet |= lc_ibt;
- if ((pr_data & GNU_PROPERTY_X86_FEATURE_1_SHSTK))
- l->l_cet |= lc_shstk;
- }
- break;
- }
- }
-
- /* Note sections like .note.ABI-tag and .note.gnu.build-id are
- * aligned to 4 bytes in 64-bit ELF objects. */
- note = ((const void *) (note + 1)
- + ROUND_NOTE (note->n_namesz)
- + ROUND_NOTE (note->n_descsz));
- }
-}
-
-#ifdef FILEBUF_SIZE
-# define DL_PROCESS_PT_NOTE(l, ph, fd, fbp) \
- dl_process_pt_note ((l), (ph), (fd), (fbp))
-
-static inline void __attribute__ ((unused))
-dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph,
- int fd, struct filebuf *fbp)
-{
- const ElfW(Nhdr) *note;
- ElfW(Addr) size = ph->p_filesz;
-
- if (ph->p_offset + size <= (size_t) fbp->len)
- note = (const void *) (fbp->buf + ph->p_offset);
- else
- {
- note = alloca (size);
- __lseek (fd, ph->p_offset, SEEK_SET);
- if (__libc_read (fd, (void *) note, size) != size)
- return;
- }
-
- dl_process_cet_property_note (l, note, size);
-}
-#else
-# define DL_PROCESS_PT_NOTE(l, ph) dl_process_pt_note ((l), (ph))
-
-static inline void __attribute__ ((unused))
-dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
-{
- const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
- dl_process_cet_property_note (l, note, ph->p_memsz);
-}
-#endif
-
static inline ElfW(Addr)
elf_machine_fixup_plt (struct link_map *map, lookup_t t,
const ElfW(Sym) *refsym, const ElfW(Sym) *sym,
-----------------------------------------------------------------------
Summary of changes:
sysdeps/unix/sysv/linux/x86/Makefile | 2 +-
sysdeps/unix/sysv/linux/x86/dl-cet.c | 27 +++---
sysdeps/unix/sysv/linux/x86/dl-cet.h | 100 ++++++++++++++++++++
.../sysv/linux/x86/dl-machine.h} | 8 +-
sysdeps/unix/sysv/linux/x86/dl-sysdep.c | 1 -
sysdeps/x86/cpu-features.h | 8 +-
sysdeps/x86/libc-start.c | 5 +-
sysdeps/x86_64/dl-machine.h | 88 +-----------------
8 files changed, 124 insertions(+), 115 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/x86/dl-cet.h
copy sysdeps/{i386/symbol-hacks.h => unix/sysv/linux/x86/dl-machine.h} (84%)
hooks/post-receive
--
GNU C Library master sources