diff mbox series

[09/10] valgrind: tests build fixes for musl

Message ID a5f3f461ce4f14d5b1964e4784f93f60bec7129b.1499520469.git.raj.khem@gmail.com
State Accepted
Commit 459907cd548b97e50b26036e6898d32685cee01e
Headers show
Series Glibc 2.26 update and musl updates (rebased) | expand

Commit Message

Khem Raj July 8, 2017, 1:34 p.m. UTC
x86/aarch64 needed minor changes to make few testcases portable

Signed-off-by: Khem Raj <raj.khem@gmail.com>

---
 ...m64-Define-__THROW-if-not-already-defined.patch | 32 ++++++++++
 ...emcheck-x86-Define-__THROW-if-not-defined.patch | 32 ++++++++++
 ...verride-Replace-__modify_ldt-with-syscall.patch | 68 ++++++++++++++++++++++
 meta/recipes-devtools/valgrind/valgrind_3.12.0.bb  |  3 +
 4 files changed, 135 insertions(+)
 create mode 100644 meta/recipes-devtools/valgrind/valgrind/0001-memcheck-arm64-Define-__THROW-if-not-already-defined.patch
 create mode 100644 meta/recipes-devtools/valgrind/valgrind/0002-memcheck-x86-Define-__THROW-if-not-defined.patch
 create mode 100644 meta/recipes-devtools/valgrind/valgrind/0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch

-- 
2.13.2

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
diff mbox series

Patch

diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-memcheck-arm64-Define-__THROW-if-not-already-defined.patch b/meta/recipes-devtools/valgrind/valgrind/0001-memcheck-arm64-Define-__THROW-if-not-already-defined.patch
new file mode 100644
index 0000000000..a48d7db070
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0001-memcheck-arm64-Define-__THROW-if-not-already-defined.patch
@@ -0,0 +1,32 @@ 
+From 3409dc35c15bb14c8a525239806322648e079ab1 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 5 Jul 2017 17:12:43 -0700
+Subject: [PATCH 1/3] memcheck/arm64: Define __THROW if not already defined
+
+Helps compiling with musl where __THROW is not available
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Submitted
+
+ memcheck/tests/arm64-linux/scalar.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/memcheck/tests/arm64-linux/scalar.h b/memcheck/tests/arm64-linux/scalar.h
+index 9008816..8ef050f 100644
+--- a/memcheck/tests/arm64-linux/scalar.h
++++ b/memcheck/tests/arm64-linux/scalar.h
+@@ -12,6 +12,10 @@
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ 
++#ifndef __THROW
++#define __THROW
++#endif
++
+ // Since we use vki_unistd.h, we can't include <unistd.h>.  So we have to
+ // declare this ourselves.
+ extern long int syscall (long int __sysno, ...) __THROW;
+-- 
+2.13.2
+
diff --git a/meta/recipes-devtools/valgrind/valgrind/0002-memcheck-x86-Define-__THROW-if-not-defined.patch b/meta/recipes-devtools/valgrind/valgrind/0002-memcheck-x86-Define-__THROW-if-not-defined.patch
new file mode 100644
index 0000000000..5433472291
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0002-memcheck-x86-Define-__THROW-if-not-defined.patch
@@ -0,0 +1,32 @@ 
+From 67d199dbdcbb3feff5f8928f87725fc64c0307d7 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 5 Jul 2017 17:36:42 -0700
+Subject: [PATCH 2/3] memcheck/x86: Define __THROW if not defined
+
+musl does not have __THROW, therefore make it null
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Submitted
+
+ memcheck/tests/x86-linux/scalar.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/memcheck/tests/x86-linux/scalar.h b/memcheck/tests/x86-linux/scalar.h
+index ef28b03..52f742e 100644
+--- a/memcheck/tests/x86-linux/scalar.h
++++ b/memcheck/tests/x86-linux/scalar.h
+@@ -11,6 +11,10 @@
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ 
++#ifndef __THROW
++#define __THROW
++#endif
++
+ // Since we use vki_unistd.h, we can't include <unistd.h>.  So we have to
+ // declare this ourselves.
+ extern long int syscall (long int __sysno, ...) __THROW;
+-- 
+2.13.2
+
diff --git a/meta/recipes-devtools/valgrind/valgrind/0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch b/meta/recipes-devtools/valgrind/valgrind/0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch
new file mode 100644
index 0000000000..fa1344c853
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch
@@ -0,0 +1,68 @@ 
+From d103475875858ab8a2e6b53ce178bb2f63883d4c Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 5 Jul 2017 17:37:56 -0700
+Subject: [PATCH 3/3] tests/seg_override: Replace __modify_ldt() with syscall()
+
+__modify_ldt() is specific to glibc, replacing it with syscall()
+makes it more portable.
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Submitted
+
+ none/tests/x86-linux/seg_override.c | 15 ++++++---------
+ 1 file changed, 6 insertions(+), 9 deletions(-)
+
+diff --git a/none/tests/x86-linux/seg_override.c b/none/tests/x86-linux/seg_override.c
+index b7619c9..c89874b 100644
+--- a/none/tests/x86-linux/seg_override.c
++++ b/none/tests/x86-linux/seg_override.c
+@@ -2,6 +2,8 @@
+ #include <stdio.h>
+ #include <errno.h>
+ #include <string.h>
++#include <unistd.h>
++#include <syscall.h>
+ 
+ /* Stuff from Wine. */
+ 
+@@ -52,14 +54,11 @@ inline static unsigned int wine_ldt_get_limit( const LDT_ENTRY *ent )
+ /* our copy of the ldt */
+ LDT_ENTRY ldt_copy[8192];
+ 
+-/* System call to set LDT entry.  */
+-//extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
+-extern int __modify_ldt (int, void *, size_t);
+-
+ void print_ldt ( void )
+ {
+    int res;
+-   res = __modify_ldt( 0, ldt_copy, 8192*sizeof(LDT_ENTRY) );
++   /* System call to set LDT entry.  */
++   res = syscall(SYS_modify_ldt, 0, ldt_copy, 8192*sizeof(LDT_ENTRY) );
+    printf("got %d bytes\n", res );   
+    perror("error is");
+ }
+@@ -83,9 +82,6 @@ struct modify_ldt_ldt_s
+   unsigned int empty:25;
+ };
+ 
+-/* System call to set LDT entry.  */
+-//extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
+-
+ void set_ldt1 ( void* base )
+ {
+   int stat;
+@@ -102,7 +98,8 @@ void set_ldt1 ( void* base )
+   ldt_entry.read_exec_only = 0;
+   ldt_entry.limit_in_pages = 0;
+   ldt_entry.seg_not_present = 0;
+-  stat = __modify_ldt (1, &ldt_entry, sizeof (ldt_entry));
++  /* System call to set LDT entry.  */
++  stat = syscall(SYS_modify_ldt, 1, &ldt_entry, sizeof (ldt_entry));
+   printf("stat = %d\n", stat);
+ }
+ 
+-- 
+2.13.2
+
diff --git a/meta/recipes-devtools/valgrind/valgrind_3.12.0.bb b/meta/recipes-devtools/valgrind/valgrind_3.12.0.bb
index 4cf8062031..b63d27861d 100644
--- a/meta/recipes-devtools/valgrind/valgrind_3.12.0.bb
+++ b/meta/recipes-devtools/valgrind/valgrind_3.12.0.bb
@@ -32,6 +32,9 @@  SRC_URI = "http://www.valgrind.org/downloads/valgrind-${PV}.tar.bz2 \
            file://0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch \
            file://0006-pth_detached3.c-Dereference-pthread_t-before-adding-.patch \
            file://0001-memcheck-tests-Use-ucontext_t-instead-of-struct-ucon.patch \
+           file://0001-memcheck-arm64-Define-__THROW-if-not-already-defined.patch \
+           file://0002-memcheck-x86-Define-__THROW-if-not-defined.patch \
+           file://0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch \
            "
 SRC_URI_append_libc-musl = "\
            file://0001-fix-build-for-musl-targets.patch \