You are not logged in.

#1 2012-12-29 10:35:40

leetow2003
Member
Registered: 2012-04-08
Posts: 25

How to correct the segment fault

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?
Look:

.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"

Offline

#2 2012-12-29 14:35:12

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: How to correct the segment fault

Perhaps it would help if you describe what you're trying to do in English. I'm frankly confused.

Offline

#3 2012-12-29 14:53:28

AndrzejL
Member
Registered: 2012-12-07
Posts: 160

Re: How to correct the segment fault

Hi.

Try installing gdb and then run:

gdb programname

and when you get (gdb) prompt type in:

run

and then when it segfaults and gives you (gdb) prompt back type in:

bt

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.

Regards.

Andrzej


The worst thing about censorship is ██████ ██ ████ ████████████ and ██████ ███████ ███ ███████████.

Offline

#4 2012-12-30 01:23:07

leetow2003
Member
Registered: 2012-04-08
Posts: 25

Re: How to correct the segment fault

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?

Offline

#5 2012-12-30 15:31:50

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: How to correct the segment fault

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.

Offline

Board footer

Powered by FluxBB