0
点赞
收藏
分享

微信扫一扫

nasm安装 Assembler messages Error: invalid instruction suffix for `pushf‘


nasm-2.10.09.tar.gz $ autoconf --version

autoconf (GNU Autoconf) 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David J. MacKenzie and Akim Demaille.

autoconf版本要跟nasm版本匹配。可以通过年份 - 这里autoconf是2012年的

nasm安装 Assembler messages Error: invalid instruction suffix for `pushf‘_GNU

nasm依赖autoconf 和 m4,2012年的autoconf,比nasm年份略低,大概率 没什么问题。报错的话,就换个版本,年份相近的。版本号最后 major.minor.trivial, 最右边的号是修改bug版本号,所以选最大的。中间的号是+feature,但是兼容之前版本。最左边的号major出现大改动,废弃掉低版本的功能。

$ m4 --version

m4 (GNU M4) 1.4.18
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Rene' Seindal.

gunzip -c nasm-2.10.09.tar.gz | tar -xvf -

sh ./autogen.sh

sh ./configure

make

sudo make install

nasm安装 Assembler messages Error: invalid instruction suffix for `pushf‘_汇编_02

Assembler messages Error: invalid instruction suffix for `pushf'

app.asm

; nasm -felf64 app.asm
; ld app.o -o app
; ./app

section .bss
; variables

section .data
; constants
    hello: db "Hi Mom.",10 ; string to print
    helloLen: equ $-hello    ; length of string

section .text
    global _start    ; entry point for linker

    _start:    ; start here
        mov rax,1   ; sys_write
        mov rdi,1   ; stdout
        mov rsi,hello  ; message to write
        mov rdx,helloLen  ; message length
        syscall            ; call kernel
; end program
        mov rax,60   ; sys_exit
        mov rdi,0    ; err code 0 (success)
        syscall

 mzh@DESKTOP-GITL67P:/mnt/e/usr/source/nasm/nasm-2.10.09/test$ nasm -felf64 app.asm && ld app.o -o app && ./app
Hi Mom.

nasm安装 Assembler messages Error: invalid instruction suffix for `pushf‘_汇编_03

-felf64 以上是64位Linux平台ELF格式的.o目标文件。对于32-bit寄存器对照表

nasm安装 Assembler messages Error: invalid instruction suffix for `pushf‘_GNU_04

8 09/05 p@q.Eu 汇编语言是人类可:/ 读的最低层次的编程语言。今天,它被...;^^2oYTLdtdxH8^^打👐ÐŌÙýĨŃ搜索

Assembler messages

Error: invalid instruction suffix for `pushf'

pushf是32位的指令,编译64位.o出错。可以在CMakeLists.txt中添加

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")

 常用的编译参数:

gcc -g foo.S -o foo -m32 -nostdlib -static  # static binary with absolutely no libraries or startup code

as foo.S -o foo.o -g --32 &&      # skips the preprocessor
ld -o foo foo.o  -m elf_i386
file foo
foo: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped

linux64 g 编译器,关于linux:在64位系统上组装32位二进制文件(GNU工具链)

举报

相关推荐

0 条评论