shai-tan |
Valuable expert |
|
|
Joined: Feb 22, 2005 |
Posts: 477 |
|
|
|
|
|
|
|
Quote: | Sorry, I know what is happening, I use lot of macros I made for my code, so to get a code that everyone could compile I used nasm -e and posted the output, but by mistake I didn't select one line before containing [global main]. So to get the code working you have to add global main to the top of the code. |
Shifted to debian from Ubuntu yesterday.
Added the [global main] to the top and it compiled perfectly. Ill try it in a VM tomorrow as for now I need some sleep.
Added [global main] version:
Code: | CLONE_VM equ 0x00000100
CLONE_THREAD equ 0x00010000
CLONE_SIGHAND equ 0x00000800
SIGCHLD equ 17
[global main]
[extern printf]
[section .data]
forked db " >> fork: %d",10,0
[section .text]
no_child:
push eax
push forked
call printf
xor ebx, ebx
mov eax, 1
call 0xffffe400
bad:
[section .data]
..@4.cadena: db " !! Can't create thread",10
[section .text]
mov ebx, 1
mov ecx, ..@4.cadena
mov edx, 23+1
mov eax, 4
call 0xffffe400
mov ebx, -1
mov eax, 1
call 0xffffe400
main:
mov eax, 2
call 0xffffe400
test eax, eax
jnz no_child
[section .data]
..@13.cadena: db " >> Creating thread...",10
[section .text]
mov ebx, 1
mov ecx, ..@13.cadena
mov edx, 22+1
mov eax, 4
call 0xffffe400
mov ebx, CLONE_VM | CLONE_THREAD | CLONE_SIGHAND | SIGCHLD
xor ecx, ecx
mov eax, 120
call 0xffffe400
test eax, eax
jz child
test eax, 0x80000000
jnz bad
xor ebx, ebx
mov eax, 1
call 0xffffe400
child:
xor ebx, ebx
mov eax, 26
call 0xffffe400
test eax, eax
jnz bad2
[section .data]
..@26.cadena: db " >> Thread attached and running",10
[section .text]
mov ebx, 1
mov ecx, ..@26.cadena
mov edx, 31+1
mov eax, 4
call 0xffffe400
aki: jmp aki
bad2:
[section .data]
..@32.cadena: db " !! Can't attach",10
[section .text]
mov ebx, 1
mov ecx, ..@32.cadena
mov edx, 16+1
mov eax, 4
call 0xffffe400
mov ebx, -1
mov eax, 1
call 0xffffe400 |
result:
Code: |
shaitan:/home/zeb# nasm -felf test.asm ; gcc test.o -o test
shaitan:/home/zeb# ls test*
test test.asm test.o
|
|
|