我在写汇编语言,程序是这样的:
.data
.equ b,3
.text
.globl _start
_start:
movl $2,%ebx
movl $b,%ecx
movl $1,%eax
int $0x80
我是在ubuntu 64bit版本下编译的。我希望得到一个 32 位版本,所以在 shell 下我可以这样做:
$ as my.s -32
$ ld a.out -o my
好的,没问题。我希望使用 scons 来管理这个过程,所以我有 SConstruct:
Program('my.s')
这将首先使用'as my.s -o my.o'和'gcc my.o -o my'进行编译,并报告'_start'重定义错误。
我的问题是:
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?
最佳答案
为了将标志传递给汇编程序,ASFLAGS 应该可以工作。
为了将标志传递给链接器,LINKFLAGS 应该可以工作
要设置用于链接器的可执行文件,LINK(或 SHLINK)应该可以解决问题。
联机帮助页中列出了所有这些:http://scons.org/doc/production/HTML/scons-man.html
以下可能对您有用:
env=Environment(tools=['as','gnulink'])
env['ASFLAGS'] = '-32'
env['LINK'] = 'ld'
env.Program('my',['my.s'])
关于linux - 如何指定 scons 中使用的 linux 程序集的命令行 args 和 liker?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39818000/