使用细分选择器

时间:2019-05-24 04:50:07

标签: segment

我正在尝试使用细分选择器访问细分中的索引。我可以填充%fs寄存器,但是当我尝试访问%fs:0x0时,得到了SIGSEGV。 我有一个大小为10的经过malloc分配的整数数组,可以将其用作段,并且可以生成它的段描述符,并使用Modify_ldt()将其添加到LDT中。

我确保程序中使用的任何用户级别的源均不使用%fs。

int* arr = calloc(10, sizeof(int)); //base of Segment is set to this. 

asm("movl $0x7, %eax"); /* 0111: 0-Index 1-Using the LDT table 11-RPL of 3 */
asm("movl %eax, %fs");                                                      
asm("movl $0x15, %eax");                                                    
asm("movl %eax, %fs:0x0");  // this gives a segmentation fault

0 个答案:

没有答案
相关问题