Bonjour,
J'ai compile le code suivant :
Afin de pratiquer l'inclusion de symbols C dans le code assembleur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 ;importing exter C symbol extern _printf ;declarating variables section .data ;filling the variable hello: db 'Hello World', 10, 0 ;entry point for main function global _main ;start assembly program section .text ;coding the _main symbol _main: ;pushing the hello variable on the stack push hello ;calling the _printf C function call _printf ;cleaning the stack by unstacking the hello variable on the EAX register pop EAX ;exiting from _main symbol ret
Pour compiler (je travaille sous Linux) j'ai fait :
Et tout parait bien marcher...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 nasm -f elf -o hello.o hello.asm
J'ai regarde sur internet pour pouvoir linker ca a la lib de C et j'ai fait :
La reponse que j'obtient est :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 ld -o hello -lc hello.o
Comment resoudre ca ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 ld: warning: cannot find entry symbol _start; defaulting to 0000000008048100 hello.o: In function `_main': hello.asm:(.text+0x6): undefined reference to `_printf'
Merci d'avance.
Partager