My codes name is 1.s,and I compile it well,
as 1.s -o 1.o
ld 1.o -o 1
but when I run it,it displays: segment fault,
How to correct it?
.text .global _start _start: jmp s1 s2:popl %esi movl %esi,0x8(%esi) movb $0x0,0x7(%esi) movl $0x0,0xc(%esi) movl $0xb,%eax movl %esi,%ebx leal 0x8(%esi),%ecx leal 0xc(%esi),%edx int $0x80 movl $1,%eax movl $0,%ebx int $0x80 s1:call s2 .string "/bin/ls"
Perhaps it would help if you describe what you're trying to do in English. I'm frankly confused.
Try installing gdb and then run:
and when you get (gdb) prompt type in:
and then when it segfaults and gives you (gdb) prompt back type in:
and look at the backtrace. Maybe the hint will be there. I am not a coder. echo "Hello world" is as far as I go but gdb gave me a clue about few segfaults in the past.
The worst thing about censorship is ██████ ██ ████ ████████████ and ██████ ███████ ███ ███████████.
I am sorry,maybe my english is very poor.I mean when the program ran,the system prompts segmentation fault.
I want to how to correct it?
It is not your English, but your code that confuses me. At a brief examination it looks like you're trying to do something self-modifying, but I don't think that's right. Try explaining what you thought that led you to write this code and maybe we can help you figure out why it's not doing what you want it to.