flat assembler
Message board for the users of flat assembler.
Index
> Linux > Segmentation fault |
Author |
|
revolution 08 Aug 2016, 18:43
You don't have any return back to the OS when the code finishes, after the POPAD is executed.
|
|||
08 Aug 2016, 18:43 |
|
MIHIP 08 Aug 2016, 18:52
revolution wrote: You don't have any return back to the OS when the code finishes, after the POPAD is executed. Hi! Well, how i can realize that in linux assembly? Any examples? (binary data after popad -> file, specified in cli) |
|||
08 Aug 2016, 18:52 |
|
revolution 08 Aug 2016, 19:00
MIHIP wrote: Well, how i can realize that in linux assembly? Any examples? |
|||
08 Aug 2016, 19:00 |
|
MIHIP 08 Aug 2016, 19:24
revolution wrote:
So.. I don't see any examples of calling write function in fasm examples. Huh? |
|||
08 Aug 2016, 19:24 |
|
revolution 08 Aug 2016, 19:43
Code: ; fasm demonstration of writing simple ELF executable format ELF executable 3 entry start segment readable executable start: mov eax,4 mov ebx,1 mov ecx,msg mov edx,msg_size int 0x80 mov eax,1 xor ebx,ebx int 0x80 segment readable writeable msg db 'Hello world!',0xA msg_size = $-msg |
|||
08 Aug 2016, 19:43 |
|
MIHIP 08 Aug 2016, 19:45
Uhm, thanks, okay, will try to do something.
|
|||
08 Aug 2016, 19:45 |
|
MIHIP 08 Aug 2016, 19:55
So, it not works. "Segmentation fault".
Code: format ELF executable 3 entry start segment readable executable start: pushad mov ecx,[size] mov esi,[dataz] lea edi,[esi+ecx] xor eax,eax @@b:lodsb mov edx,eax mov ebx,eax and eax,7 shr edx,3 and edx,7 shr ebx,6 mov ah,byte[num+eax] mov al,byte[num+edx] shl eax,8 mov al,byte[num+ebx] mov [edi],eax add edi,3 loop @@b popad mov eax,4 mov ebx,1 mov ecx,[dataz] mov edx,datasize int 0x80 mov eax,1 xor ebx,ebx int 0x80 segment readable writeable num db '01234ABC' size dd 1 dataz dd 'ABC',0xA datasize = $-dataz |
|||
08 Aug 2016, 19:55 |
|
ProphetOfDoom 08 Aug 2016, 23:45
MIHIP,
Sorry I don't have the time or the inclination to debug your code but there are two things you can do. First, run the code under gdb like so: Code: gdb my_program run When it segfaults, it will stop. Then type: Code: x/4i $eip It will print the instruction that caused the segfault, followed by three more instructions. This should help you to investigate. Another thing worth trying is to install the program "valgrind" and run your app under that: Code:
valgrind ./my_program
It will tell you if your code is doing anything wrong like illegal reads/writes amongst other stuff. |
|||
08 Aug 2016, 23:45 |
|
MIHIP 09 Aug 2016, 00:55
Brilliant!
Thanks |
|||
09 Aug 2016, 00:55 |
|
revolution 09 Aug 2016, 04:52
I suspect that mov esi,[dataz] should be mov esi,dataz.
And also that dataz dd 'ABC',0xA should be dataz db 'ABC',0xA. There are other problems also, I'll let you figure out the rest. |
|||
09 Aug 2016, 04:52 |
|
revolution 09 Aug 2016, 05:11
I thought I recognised the code:
http://board.flatassembler.net/topic.php?p=176080#176080 MIHIP: You made some very basic mistakes there when copying the code. Assembly coding requires a lot of attention to the details. And the suggestion above to use a debugger is very good. With a bit of patience you will learn a lot about what is happening by following through with the debugger. |
|||
09 Aug 2016, 05:11 |
|
MIHIP 09 Aug 2016, 19:22
Thanks a lot, revolution! I am already has fixed code and ready to update it again.
|
|||
09 Aug 2016, 19:22 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.