x32: Verify that NPTL structures are correct [BZ #22298]

Message ID 20171015151226.GA25459@gmail.com
State New, archived
Headers

Commit Message

H.J. Lu Oct. 15, 2017, 3:12 p.m. UTC
  Add a build-time check to verify that NPTL structures are correct.

OK for master and 2.25/2.26 branches after fix for [BZ #22298] is
applied?

H.J.
	[BZ #22298]
	* sysdeps/x86_64/x32/nptl/Makefile: New file.
	* sysdeps/x86_64/x32/nptl/nptl-check.sym: Likewise.
---
 sysdeps/x86_64/x32/nptl/Makefile       | 4 ++++
 sysdeps/x86_64/x32/nptl/nptl-check.sym | 9 +++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 sysdeps/x86_64/x32/nptl/Makefile
 create mode 100644 sysdeps/x86_64/x32/nptl/nptl-check.sym
  

Comments

Adhemerval Zanella Oct. 16, 2017, 7:18 p.m. UTC | #1
On 15/10/2017 13:12, H.J. Lu wrote:
> Add a build-time check to verify that NPTL structures are correct.
> 
> OK for master and 2.25/2.26 branches after fix for [BZ #22298] is
> applied?
> 
> H.J.
> 	[BZ #22298]
> 	* sysdeps/x86_64/x32/nptl/Makefile: New file.
> 	* sysdeps/x86_64/x32/nptl/nptl-check.sym: Likewise.
> ---
>  sysdeps/x86_64/x32/nptl/Makefile       | 4 ++++
>  sysdeps/x86_64/x32/nptl/nptl-check.sym | 9 +++++++++
>  2 files changed, 13 insertions(+)
>  create mode 100644 sysdeps/x86_64/x32/nptl/Makefile
>  create mode 100644 sysdeps/x86_64/x32/nptl/nptl-check.sym
> 
> diff --git a/sysdeps/x86_64/x32/nptl/Makefile b/sysdeps/x86_64/x32/nptl/Makefile
> new file mode 100644
> index 0000000000..e780beaf11
> --- /dev/null
> +++ b/sysdeps/x86_64/x32/nptl/Makefile
> @@ -0,0 +1,4 @@
> +ifeq ($(subdir),csu)
> +# Verify that NPTL structures are correct.
> +gen-as-const-headers += nptl-check.sym
> +endif
> diff --git a/sysdeps/x86_64/x32/nptl/nptl-check.sym b/sysdeps/x86_64/x32/nptl/nptl-check.sym
> new file mode 100644
> index 0000000000..c4b07b83bf
> --- /dev/null
> +++ b/sysdeps/x86_64/x32/nptl/nptl-check.sym
> @@ -0,0 +1,9 @@
> +#include <sysdep.h>
> +#include <pthread.h>
> +
> +PREV			offsetof (struct __pthread_internal_list, __prev)
> +NEXT			offsetof (struct __pthread_internal_list, __next)
> +
> +#if __PTHREAD_MUTEX_HAVE_PREV != 1
> +# error __PTHREAD_MUTEX_HAVE_PREV must be 1
> +#endif

I am working on a similar test to check for the internal offset required
to static pthread mutex initializers and the idea is to check against hard
coded values (similar to the stack guard offset) and against all platforms.
I will send it along with the update BZ#22298 fix.
  

Patch

diff --git a/sysdeps/x86_64/x32/nptl/Makefile b/sysdeps/x86_64/x32/nptl/Makefile
new file mode 100644
index 0000000000..e780beaf11
--- /dev/null
+++ b/sysdeps/x86_64/x32/nptl/Makefile
@@ -0,0 +1,4 @@ 
+ifeq ($(subdir),csu)
+# Verify that NPTL structures are correct.
+gen-as-const-headers += nptl-check.sym
+endif
diff --git a/sysdeps/x86_64/x32/nptl/nptl-check.sym b/sysdeps/x86_64/x32/nptl/nptl-check.sym
new file mode 100644
index 0000000000..c4b07b83bf
--- /dev/null
+++ b/sysdeps/x86_64/x32/nptl/nptl-check.sym
@@ -0,0 +1,9 @@ 
+#include <sysdep.h>
+#include <pthread.h>
+
+PREV			offsetof (struct __pthread_internal_list, __prev)
+NEXT			offsetof (struct __pthread_internal_list, __next)
+
+#if __PTHREAD_MUTEX_HAVE_PREV != 1
+# error __PTHREAD_MUTEX_HAVE_PREV must be 1
+#endif