Segmentation fault :(
-
Hi!
Hab gerade mein erstes prog mit asm und linux hinbekommen, aber kommt segfaultsection .text global _start msg db "Hello, Linux!", 0 len equ $ - msg _syscall: int 0x25 ret _start: push dword len push dword msg push dword 1 mov eax, 0x3 call _syscall add esp, 12 push dword 0 mov eax, 0x3f call _syscall
kann wer helfen?
greets,
cNc
-
Linux-Syscalls ruft man auf int 0x80 auf und nicht 0x25
Und stimmen die Syscall-nummern? Die sind zwar Systemabhängig, aber ich würde zumindets denken dass sie unter Linux halbdwegs gleich sind. Bei mri kommt da raus read und dup2. Kann natürlich sien dass meine dohc anders sind :>
-
Aber selbst so kommt bei mir ein segfault
section .text global _start msg db "Hello, Linux!", 0 len equ $ - msg _syscall: int 0x80 ret _start: push dword len push dword msg push dword 1 mov eax, 4 call _syscall add esp, 12 push dword 0 mov eax, 1 call _syscall
is schon echt depri als anfänger schon solche fehler
greets,
cNc
-
Die Argumente werden über Register übergeben. Lies einfach mal auf z.B. www.linuxassembly.org nach anstatt sinnlos rumzuprobieren.
-
Du bist ja soo lustig bashar!
Was meinste woher ich den code hab? Genau! Von Linuxassembly.org!
Und selbst wenn ich den code 1:1 kopiere, funtzt nix und es kommt ein segfault!
-
cNcMasta schrieb:
Du bist ja soo lustig bashar!
Du Held bist noch viel lustiger. Hier: http://www.linuxassembly.org/intro/hello.html steht zwar das Programm, was du gepostet hast. Aber das ist die BeOS-Version. Linux ist weiter oben.
BTW kann ich solche Arroganz von Newbies nicht ausstehen.
-
ich hab jetzt den linuxcode genommen aber der funtzt auzch nicht, auch segfault
greets,
cNc
-
Bei mir gehts (Debian woody, nasm 0.98.28):
section .text global _start ;must be declared for linker (ld) msg db 'Hello, world!',0xa ;our dear string len equ $ - msg ;length of our dear string _start: ;tell linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel
$ nasm -f elf hello.asm $ ld hello.o $ ./a.out Hello, world! $ _
PS: Das ';' am Anfang vom Hello-world-String gehört da nicht hin und läßt sich auch nicht wegeditieren, Forums-Bug schätz ich ...
-
jetzt funtzt es auch .. hatte das *.o file als "hello" (ohne o) erstellen lassen und dann versucht sdas auszuführen