Skip to content

Commit

Permalink
Build with gcc - otherwise we'd need to dynamically link the librarie…
Browse files Browse the repository at this point in the history
…s 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)
  • Loading branch information
smtlaissezfaire committed Nov 29, 2009
1 parent 85d35ba commit a2845cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions 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
Expand Down
4 changes: 2 additions & 2 deletions ch04/cpuid2.s
Expand Up @@ -10,8 +10,8 @@ output:
.lcomm buffer, 12

.section .text
.globl _start
_start:
.globl main
main:

# same as before
nop
Expand Down

0 comments on commit a2845cf

Please sign in to comment.