User applications - Question - ?
Posted: Sat Mar 01, 2003 5:01 am
this a part of code, is an example for user application.
[sup]
40000000 <__code>:
40000000: e9 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............
....
40000010 <main>:
40000010: 55 push %ebp
40000011: 89 e5 mov %esp,%ebp
40000013: 83 ec 14 sub $0x14,%esp
40000016: 53 push %ebx
void writetest(const char *str, unsigned len);
int main()
{
char *msg = "Please Enter your Name : ";
40000017: bb ec 01 00 00 mov $0x1ec,%ebx
4000001c: 8d 74 26 00 lea 0x0(%esi,1),%esi
while(1)
{
writetest(msg, 5);
40000020: 83 c4 f8 add $0xfffffff8,%esp
40000023: 6a 05 push $0x5
40000025: 53 push %ebx
40000026: e8 05 00 00 00 call 40000030 <writetest>
}
[/sup]
but it generate #PF because at 0x40000017: it move this address $0x1ec to %ebx, which will point to msg string and these address is not in the user address space. what I can imagine, that the linker should add this msg to the elf data segment! the user address space begint at 0x40000000
[sup]
40000000 <__code>:
40000000: e9 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............
....
40000010 <main>:
40000010: 55 push %ebp
40000011: 89 e5 mov %esp,%ebp
40000013: 83 ec 14 sub $0x14,%esp
40000016: 53 push %ebx
void writetest(const char *str, unsigned len);
int main()
{
char *msg = "Please Enter your Name : ";
40000017: bb ec 01 00 00 mov $0x1ec,%ebx
4000001c: 8d 74 26 00 lea 0x0(%esi,1),%esi
while(1)
{
writetest(msg, 5);
40000020: 83 c4 f8 add $0xfffffff8,%esp
40000023: 6a 05 push $0x5
40000025: 53 push %ebx
40000026: e8 05 00 00 00 call 40000030 <writetest>
}
[/sup]
but it generate #PF because at 0x40000017: it move this address $0x1ec to %ebx, which will point to msg string and these address is not in the user address space. what I can imagine, that the linker should add this msg to the elf data segment! the user address space begint at 0x40000000