From a2845cf50945c79b49d68a724a2009bad5837b14 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 29 Nov 2009 15:47:30 -0500 Subject: [PATCH] Build with gcc - otherwise we'd need to dynamically link the libraries manually: ld -dynamic-linker /lib/ld-linux.so.2 -o cpuid2 -lc cpuid2.o Change the _start symbol to main for usage with gcc (alternatively, we could specify the flag could to gcc) --- ch04/Rakefile | 12 +++++------- ch04/cpuid2.s | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ch04/Rakefile b/ch04/Rakefile index 148af27..34eafa7 100644 --- a/ch04/Rakefile +++ b/ch04/Rakefile @@ -1,15 +1,13 @@ task :default => :compile -PROGS = ["cpuid"] +PROGS = ["cpuid", "cpuid2"] ASM_FLAGS = [] task :compile do - PROGS.each do |prog| - sh [ - "as #{ASM_FLAGS.join(" ")} -o #{prog}.o #{prog}.s", - "ld -o #{prog} #{prog}.o" - ].join(" && ") - end + asm_flags = ASM_FLAGS.join + + sh "as #{asm_flags} -o cpuid.o cpuid.s && ld -o cpuid cpuid.o" + sh "gcc -o cpuid2 cpuid2.s" end task :compile_debug do diff --git a/ch04/cpuid2.s b/ch04/cpuid2.s index edc5c63..cf79b75 100644 --- a/ch04/cpuid2.s +++ b/ch04/cpuid2.s @@ -10,8 +10,8 @@ output: .lcomm buffer, 12 .section .text -.globl _start -_start: +.globl main +main: # same as before nop