4

if we compile some C code with gcc we often see the following assembly result

0x08048494 <+0>:   push   ebp
0x08048495 <+1>:   mov    ebp,esp
0x08048497 <+3>:   and    esp,0xfffffff0
0x0804849a <+6>:   sub    esp,0x130
0x080484a0 <+12>:   mov    eax,DWORD PTR [ebp+0xc]
0x080484a3 <+15>:   mov    DWORD PTR [esp+0x1c],eax
0x080484a7 <+19>:   mov    eax,gs:0x14

this is a simple function prologue. from the +19 line, we can see the stack protector value is obtained from gs:0x14. my question is, can I know the actual virtual address of gs:0x14 with gdb? the gs segment selector value indicates the offset from GDT however, a user level process such as gdb cannot access the GDT information. how can I figure out the base address of gs segment using gdb or other debugger? is this impossible?

thank you in advance.

daehee
  • 5,047
  • 7
  • 44
  • 70

0 Answers0