简体   繁体   中英

How to specify command line args and liker of linux assembly used in scons?

I'm writing assembly language, program like this:

.data
.equ b,3
.text
.globl _start
_start:
movl $2,%ebx
movl $b,%ecx
movl $1,%eax
int $0x80

I compile it under ubuntu 64bit version. I wish to get a 32bit version, so under shell I can do:

$ as my.s -32
$ ld a.out -o my

OK, no problem. I wish to use scons to manage this process, so I have SConstruct:

Program('my.s')

This will first compile using 'as my.s -o my.o' and 'gcc my.o -o my', and report and error of redefinition of '_start'.

My problem is:

How can I pass '-32' option to make sure I compile out 32bit version object file?

How can I specify the linker to be 'ld' but not 'gcc', to make sure I can use '_start' as entry point in my assembly source file?

For passing flags to the assembler, ASFLAGS should work.

For passing flags to linker, LINKFLAGS should work

For setting which executable to use for linker, LINK (or SHLINK) should do the trick.

All these are listed in the manpage: http://scons.org/doc/production/HTML/scons-man.html

Likely the following should work for you:

env=Environment(tools=['as','gnulink'])
env['ASFLAGS'] = '-32'
env['LINK'] = 'ld'
env.Program('my',['my.s'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM