Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From d103475875858ab8a2e6b53ce178bb2f63883d4c Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 5 Jul 2017 17:37:56 -0700 |
| 4 | Subject: [PATCH 3/3] tests/seg_override: Replace __modify_ldt() with syscall() |
| 5 | |
| 6 | __modify_ldt() is specific to glibc, replacing it with syscall() |
| 7 | makes it more portable. |
| 8 | |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- |
| 11 | Upstream-Status: Submitted |
| 12 | |
| 13 | none/tests/x86-linux/seg_override.c | 15 ++++++--------- |
| 14 | 1 file changed, 6 insertions(+), 9 deletions(-) |
| 15 | |
| 16 | diff --git a/none/tests/x86-linux/seg_override.c b/none/tests/x86-linux/seg_override.c |
| 17 | index b7619c9..c89874b 100644 |
| 18 | --- a/none/tests/x86-linux/seg_override.c |
| 19 | +++ b/none/tests/x86-linux/seg_override.c |
| 20 | @@ -2,6 +2,8 @@ |
| 21 | #include <stdio.h> |
| 22 | #include <errno.h> |
| 23 | #include <string.h> |
| 24 | +#include <unistd.h> |
| 25 | +#include <syscall.h> |
| 26 | |
| 27 | /* Stuff from Wine. */ |
| 28 | |
| 29 | @@ -52,14 +54,11 @@ inline static unsigned int wine_ldt_get_limit( const LDT_ENTRY *ent ) |
| 30 | /* our copy of the ldt */ |
| 31 | LDT_ENTRY ldt_copy[8192]; |
| 32 | |
| 33 | -/* System call to set LDT entry. */ |
| 34 | -//extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t); |
| 35 | -extern int __modify_ldt (int, void *, size_t); |
| 36 | - |
| 37 | void print_ldt ( void ) |
| 38 | { |
| 39 | int res; |
| 40 | - res = __modify_ldt( 0, ldt_copy, 8192*sizeof(LDT_ENTRY) ); |
| 41 | + /* System call to set LDT entry. */ |
| 42 | + res = syscall(SYS_modify_ldt, 0, ldt_copy, 8192*sizeof(LDT_ENTRY) ); |
| 43 | printf("got %d bytes\n", res ); |
| 44 | perror("error is"); |
| 45 | } |
| 46 | @@ -83,9 +82,6 @@ struct modify_ldt_ldt_s |
| 47 | unsigned int empty:25; |
| 48 | }; |
| 49 | |
| 50 | -/* System call to set LDT entry. */ |
| 51 | -//extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t); |
| 52 | - |
| 53 | void set_ldt1 ( void* base ) |
| 54 | { |
| 55 | int stat; |
| 56 | @@ -102,7 +98,8 @@ void set_ldt1 ( void* base ) |
| 57 | ldt_entry.read_exec_only = 0; |
| 58 | ldt_entry.limit_in_pages = 0; |
| 59 | ldt_entry.seg_not_present = 0; |
| 60 | - stat = __modify_ldt (1, &ldt_entry, sizeof (ldt_entry)); |
| 61 | + /* System call to set LDT entry. */ |
| 62 | + stat = syscall(SYS_modify_ldt, 1, &ldt_entry, sizeof (ldt_entry)); |
| 63 | printf("stat = %d\n", stat); |
| 64 | } |
| 65 | |
| 66 | -- |
| 67 | 2.13.2 |
| 68 | |