x.h
===
int add(int a, int b);
a.c
===
#include "x.h"
extern int extra;
int main()
{
int a = 9;
int b = 8;
int c;
c = add(9, 8) + extra;
return 0;
}
b.c
===
#include "x.h"
int extra = 9;
int add(int a, int b)
{
return a+b;
}
start.S
=======
.globl _start
_start:
call main
movl $1, %eax
xorl %ebx, %ebx
int $0x80
Now do
~/# gcc -c -nostdlib a.c
~/# gcc -c -nostdlib b.c
~/# gcc -c -nostdlib start.S
~/# ld -o test a.o b.o start.o
Your executable test is ready!!
Source: https://blogs.oracle.com/ksplice/entry/hello_from_a_libc_free
No comments:
Post a Comment