summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/valgrind/valgrind/0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch
blob: fa1344c8539a60f3ef4401240b24ee853a2690a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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