From b282a5ca815536bee9cb82d1aa3592b8250d5738 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 21 Apr 2004 15:16:43 +0000 Subject: [PATCH] Initialise %cs, %ds and %ss in the virtual machine to match the values supplied by the operating system for the code, data and stack segments. Explicit references using these segments still won't work but they will at least produce an assertion to indicate that they aren't supported instead of raising a segmentation fault in the target program because of an apparent privilege violation. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2379 --- coregrind/vg_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 6653dcdc95..5ffca110a2 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -2427,6 +2427,18 @@ static void init_baseBlock ( Addr client_eip, Addr esp_at_startup ) VGOFF_(m_fs) = alloc_BaB_1_set(0); VGOFF_(m_gs) = alloc_BaB_1_set(0); + /* initialise %cs, %ds and %ss to point at the operating systems + default code, data and stack segments */ + asm volatile("movw %%cs, %0" + : + : "m" (VG_(baseBlock)[VGOFF_(m_cs)])); + asm volatile("movw %%ds, %0" + : + : "m" (VG_(baseBlock)[VGOFF_(m_ds)])); + asm volatile("movw %%ss, %0" + : + : "m" (VG_(baseBlock)[VGOFF_(m_ss)])); + VG_(register_noncompact_helper)( (Addr) & VG_(do_useseg) ); #define REG(kind, size) \ -- 2.47.2