]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Initialise %cs, %ds and %ss in the virtual machine to match the values
authorTom Hughes <tom@compton.nu>
Wed, 21 Apr 2004 15:16:43 +0000 (15:16 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 21 Apr 2004 15:16:43 +0000 (15:16 +0000)
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

index 6653dcdc95c1398e3fe7118cf22334163dc64457..5ffca110a241adc73a816fba7cef29aadc878253 100644 (file)
@@ -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) \