zoukankan      html  css  js  c++  java
  • Ubuntu x86-64汇编(2)

    开发工具链

    汇编编译器: yasm
    连接器: ld
    载入工具: os自带
    Debug工具:  ddd

    yasm安装

    tar zxvf yasm-1.3.0.tar.gz 
    cd yasm-1.3.0/
    ./configure --prefix=/opt/yasm
    make
    sudo make install
    cd /usr/bin/
    sudo ln -s /opt/yasm/bin/yasm yasm
    yasm --version

    编译命令

    yasm -g dwarf2 -f elf64 example.asm -l example.lst
    

    -g  dwarf2 在object文件里包含debug信息
    -f elf64 使用Linux 64位系统的ELF64格式
    -l <filename> 创建filename这个连接文件

    连接器

    命令格式

    ld -­g -o example example.o
    

     -g 在输出的可执行文件中包含debug信息
    -o 指定可执行文件的文件名, 默认会使用 a.out

    方便编译和连接的Shell脚本

    可以创建一个脚本以方便编译和连接asm文件

    #!/bin/bash
    # Simple assemble/link script.
    
    if [ -z "$1" ]; then
      echo "Usage: ./asm <asmMainFile> (no extension)"
      exit
    fi
    # Verify no extensions were entered
    if [ ! -e "$1.asm" ]; then
      echo "Error, $1.asm not found."
      echo "Note, do not enter file extensions."
      exit
    fi
    # Compile, assemble, and link.
    yasm -g dwarf2 -f elf64 $1.asm -l $1.lst
    ld -g -o $1 $1.o
    

    执行时, 参数需要删除.asm扩展名

    Debug工具 ddd

    可以直接通过apt安装

    sudo apt-get install ddd
    

    使用时, 需要确认勾选这两个参数 Edit / Preference / General / Suppress X Warning 和 Edit / Preference / Source / Display Source Line Number

    可以通过下方的控制台窗口, 或者弹出的控制菜单, 对debug进行控制.

    .

  • 相关阅读:
    Python中文乱码(转)
    一千行MySQL学习笔记
    pycharm在同目录下import,pycharm会提示错误,但是可以运行
    PyCharm3.0默认快捷键
    Sublime Text 3 快捷键
    window下spyder的快捷键
    Anaconda更新和第三方包更新
    PyCharm 教程
    centos7.9 源码编译安装php
    centos7.9 源码编译安装nginx
  • 原文地址:https://www.cnblogs.com/milton/p/9030692.html
Copyright © 2011-2022 走看看