Darwin: sanitize %gs and %fs values.
authorTristan Gingold <tristan.gingold@adacore.com>
Thu, 16 Oct 2014 11:50:07 +0000 (13:50 +0200)
committerTristan Gingold <tristan.gingold@adacore.com>
Thu, 16 Oct 2014 11:52:24 +0000 (13:52 +0200)
Some Darwin kernels return values out of bounds for gs and fs segments.
With this commit, they are masked to avoid garbage.

gdb/ChangeLog:
* i386-darwin-nat.c (i386_darwin_fetch_inferior_registers)
(i386_darwin_store_inferior_registers): Sanitize gs and fs values
on amd64.

gdb/ChangeLog
gdb/i386-darwin-nat.c

index 336a3c152d33d9f362813d19acfe73c9d379a40a..62d1d068f8b3686fbd661e1300973d937983332d 100644 (file)
@@ -1,3 +1,9 @@
+2014-10-16  Tristan Gingold  <gingold@adacore.com>
+
+       * i386-darwin-nat.c (i386_darwin_fetch_inferior_registers)
+       (i386_darwin_store_inferior_registers): Sanitize gs and fs values
+       on amd64.
+
 2014-10-15  Pedro Alves  <palves@redhat.com>
 
        * dec-thread.c (dec_thread_count_gdb_threads)
index a60bc6ce3e054b980be0aa40d57f7711cca04ab7..f99e4157eb3b9c5237a80402d25e549c3c0e1fbc 100644 (file)
@@ -73,6 +73,11 @@ i386_darwin_fetch_inferior_registers (struct target_ops *ops,
                                 (unsigned long) current_thread);
              MACH_CHECK_ERROR (ret);
            }
+
+         /* Some kernels don't sanitize the values.  */
+         gp_regs.uts.ts64.__fs &= 0xffff;
+         gp_regs.uts.ts64.__gs &= 0xffff;
+
          amd64_supply_native_gregset (regcache, &gp_regs.uts, -1);
           fetched++;
         }
@@ -183,6 +188,10 @@ i386_darwin_store_inferior_registers (struct target_ops *ops,
 
          amd64_collect_native_gregset (regcache, &gp_regs.uts, regno);
 
+         /* Some kernels don't sanitize the values.  */
+         gp_regs.uts.ts64.__fs &= 0xffff;
+         gp_regs.uts.ts64.__gs &= 0xffff;
+
           ret = thread_set_state (current_thread, x86_THREAD_STATE,
                                   (thread_state_t) &gp_regs,
                                   x86_THREAD_STATE_COUNT);
This page took 0.030353 seconds and 4 git commands to generate.