chen@chen:~/cfile/ldscript$ cat link.lds
OUTPUT(ad.out)
INPUT(test.o)
SECTIONS
{
.text 0x400404 : { *(.text) }
empty : { *(.helloworld) ; good = . ; }
}
chen@chen:~/cfile/ldscript$ cat makefile
.PHONY:all clean
ENTRY=-e main
all:
gcc -fno-builtin -c test.c -o test.o -g
ld -T link.lds -g $(ENTRY)
clean:
rm -f test.o *.out
chen@chen:~/cfile/ldscript$ cat test.c
int main() {
asm("movl $42, %ebx \n\t"
"movl $1 , %eax \n\t"
"int $0x80 \n\t");
}
chen@chen:~/cfile/ldscript$ make clean
rm -f test.o *.out
chen@chen:~/cfile/ldscript$ ls
link.lds makefile test.c
chen@chen:~/cfile/ldscript$ make
gcc -fno-builtin -c test.c -o test.o -g
ld -T link.lds -g -e main
chen@chen:~/cfile/ldscript$ ./ad.out
chen@chen:~/cfile/ldscript$