Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Reactor error - core dumped!


programming / comp.lang.asm.x86 / simple ASM prog segfault

SubjectAuthor
* simple ASM prog segfaultXavier Maillard
+- Re: simple ASM prog segfaultBart
`- Re: simple ASM prog segfaultMelzzzzz

1
Subject: simple ASM prog segfault
From: Xavier Maillard
Newsgroups: comp.lang.asm.x86
Organization: Gegeweb News Server
Date: Tue, 26 Nov 2019 06:12 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: xav...@nospicedham.maillard.im (Xavier Maillard)
Newsgroups: comp.lang.asm.x86
Subject: simple ASM prog segfault
Date: Tue, 26 Nov 2019 07:12:43 +0100
Organization: Gegeweb News Server
Lines: 39
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <alpine.DEB.2.21.1911260708030.4901@kcals.maillard.im>
Mime-Version: 1.0
Content-Type: text/plain; format=flowed; charset=US-ASCII
Injection-Info: reader02.eternal-september.org; posting-host="25562d6b5ce42c843af3a79cac5a3efb";
logging-data="16211"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JHTyWXlavf6ld9HSa0HkPN0k2qJ7XNe4="
User-Agent: Alpine 2.21 (DEB 202 2017-01-01)
Cancel-Lock: sha1:AzHPvlwab17Tg06AokTcuKBBlT0=
View all headers
Hello,

I am just starting to learn writing some fun progs in asm.

I just jotted down some instructions, assembled it and linked it.
Running it just segfault.

The question is: why ? :)

The program is just this:

..section .data

..section .text
..globl _start
_start:

movl $1, %eax
movl $0, %ebx
int $0x80

As you can see, it just does *nothing*

Assembled it using: as
Linked it with ld

This is running on a WSL Debian system (should matter I guess)

Any pointer on what's wrong with this ?

Thanks.

N.B: I am just an amateur and I do not plan writing serious things atm, just having fun :)
--

         - xma

GPG:  BA4909B7 8F04DE1B



Subject: Re: simple ASM prog segfault
From: Bart
Newsgroups: comp.lang.asm.x86
Organization: virginmedia.com
Date: Tue, 26 Nov 2019 20:15 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: bc...@nospicedham.freeuk.com (Bart)
Newsgroups: comp.lang.asm.x86
Subject: Re: simple ASM prog segfault
Date: Tue, 26 Nov 2019 20:15:00 +0000
Organization: virginmedia.com
Lines: 47
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <lJfDF.122357$wg3.93405@fx24.am4>
References: <alpine.DEB.2.21.1911260708030.4901@kcals.maillard.im>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="25562d6b5ce42c843af3a79cac5a3efb";
logging-data="6786"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+S1AX2zCKFtMa3bDpzuTwyIk1wU727OhY="
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101
Thunderbird/60.9.1
Cancel-Lock: sha1:w3SIbr75N0YSV+qTAanX0ezgFRM=
View all headers
On 26/11/2019 06:12, Xavier Maillard wrote:
Hello,

I am just starting to learn writing some fun progs in asm.

I just jotted down some instructions, assembled it and linked it.
Running it just segfault.

The question is: why ? :)

The program is just this:

.section .data

.section .text
.globl _start
_start:

movl $1, %eax
movl $0, %ebx
int $0x80

As you can see, it just does *nothing*
Syscall #1 appears to do 'exit', so it /ought/ to do nothing!

Are you saying it crashes instead of gracefully exiting?

Is your system 64 bits? If so you might try using rax and rbx instead of eax and ebx. However I don't know whether the 64-bit set of syscalls are the same (one set I saw appeared to be different from the 32-bit ones. eg call #1 does sys_write).

(I know nothing about Linux assembly coding, it just looked intriguing.)

If you can't get anywhere, try starting from C and write the simplest program. Compile it like this:

     gcc -S prog.c

to get the assembly output in prog.s, which can also be assembled and linked by gcc (which will invoke as and ld, or you can do that yourself):

    gcc prog.s -oprog

Now you can play with the ASM instructions in prog.s, but starting from something that works.



Subject: Re: simple ASM prog segfault
From: Melzzzzz
Newsgroups: comp.lang.asm.x86
Organization: usenet-news.net
Date: Tue, 26 Nov 2019 21:06 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Melzz...@nospicedham.zzzzz.com (Melzzzzz)
Newsgroups: comp.lang.asm.x86
Subject: Re: simple ASM prog segfault
Date: Tue, 26 Nov 2019 21:06:00 GMT
Organization: usenet-news.net
Lines: 42
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <YsgDF.155020$8yt1.146236@fx12.am4>
References: <alpine.DEB.2.21.1911260708030.4901@kcals.maillard.im>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="25562d6b5ce42c843af3a79cac5a3efb";
logging-data="24157"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Qdx2ZKEi9srCQswc4sgz7U6vFZxNy+Sg="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:ct3dGrTzxR3cnzuyh+vSK3SJpwQ=
View all headers
On 2019-11-26, Xavier Maillard <xavier@nospicedham.maillard.im> wrote:
Hello,

I am just starting to learn writing some fun progs in asm.

I just jotted down some instructions, assembled it and linked it.
Running it just segfault.

The question is: why ? :)

The program is just this:

.section .data

.section .text
.globl _start
_start:

movl $1, %eax
movl $0, %ebx
int $0x80

As you can see, it just does *nothing*

Assembled it using: as
Linked it with ld

This is running on a WSL Debian system (should matter I guess)

Any pointer on what's wrong with this ?

It's probably because you assembled and linked with 64 bits.
You should specify 32 bits...


--
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi --  Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi
bili naoruzani. -- Mladen Gogala



1
rocksolid light 0.7.2
clearneti2ptor