how to share a C include file between C and Gas
Posted: Mon Feb 18, 2013 5:01 pm
Hi everybody
firstly apologies for this question but I need your help one more time.
I want to share a C header file with Gas but I can't do it.
As a simple example I have 3 files with code below and I get link errors, wich is right because the constants (macros) HOLA_MUNDO and TAM_HOLA_MUNDO is not present in the assembly file.
----------------------------------------------------------
main.c
----------------------------------------------------------
#include <stdio.h>
int main()
{
saludar();
return 0;
}
----------------------------------------------------------
saludos.h
----------------------------------------------------------
#define HOLA_MUNDO "Hola mundo\n"
#define TAM_HOLA_MUNDO 11
#define COMO_ESTAS "Como estas?\n"
----------------------------------------------------------
saludar.s
----------------------------------------------------------
.include "saludos.inc"
.code32
.section .text
.global saludar
saludar:
pushl %ebp
movl %esp, %ebp
movl $4, %eax
movl $1, %ebx
movl HOLA_MUNDO, %ecx
movl TAM_HOLA_MUNDO, %edx
int $0x80
leave
ret
fin:
xorl %eax, %eax
incl %eax
xorl %ebx, %ebx
int $0x80
.end
I tried some options to compile but I failed, also I was reading in google that it's not possible, is it truth?. Do you know some hack that can help me.
Thanks.
firstly apologies for this question but I need your help one more time.
I want to share a C header file with Gas but I can't do it.
As a simple example I have 3 files with code below and I get link errors, wich is right because the constants (macros) HOLA_MUNDO and TAM_HOLA_MUNDO is not present in the assembly file.
----------------------------------------------------------
main.c
----------------------------------------------------------
#include <stdio.h>
int main()
{
saludar();
return 0;
}
----------------------------------------------------------
saludos.h
----------------------------------------------------------
#define HOLA_MUNDO "Hola mundo\n"
#define TAM_HOLA_MUNDO 11
#define COMO_ESTAS "Como estas?\n"
----------------------------------------------------------
saludar.s
----------------------------------------------------------
.include "saludos.inc"
.code32
.section .text
.global saludar
saludar:
pushl %ebp
movl %esp, %ebp
movl $4, %eax
movl $1, %ebx
movl HOLA_MUNDO, %ecx
movl TAM_HOLA_MUNDO, %edx
int $0x80
leave
ret
fin:
xorl %eax, %eax
incl %eax
xorl %ebx, %ebx
int $0x80
.end
I tried some options to compile but I failed, also I was reading in google that it's not possible, is it truth?. Do you know some hack that can help me.
Thanks.