linux 汇编 cqo,x64asm: 包括内存汇编程序,解析器和链接器的C ++库

2023-11-08

x64asm

x64asm is a c++11 library for working with x86_64 assembly. It provides a parser, in-memory assembler and linker, and primitives for building data flow analyses. x64asm was built with the following design goals in mind:

Simplicity: x64 asm does NOT include a register allocator, instruction scheduler, control flow graph builder, or any of the features you would expect of a full compiler. It is a low-level library for building YOUR optimizing compiler.

Completeness: x64asm supports the entire ring 3 application level subset of the x86_64 instruction set, including the most recent AVX2/BMI1/BMI2/FMA extensions.

Correctness: The majority of the source in the x64asm repository is auto-generated using a declarative specification. This means that bugs can be fixed quickly without major modifications to its codebase.

Supported Platforms:

Ubuntu 12.04 LTS

Ubuntu 13.10

Ubuntu 14.04 LTS

Getting started:

Dependencies are available through apt-get.

$ sudo apt-get install bison ccache doxygen flex g++ g++-multilib ghc libghc-regex-tdfa-dev libghc-regex-compat-dev libghc-split-dev

To build x64asm, type:

$ make (release|profile|debug)

For examples of how to use the library, browse the examples/ folder:

abi.cc How the assembler API interacts with the linux ABI.

constants.cc Shows off the set of built-in assembler constants.

context.cc How to assemble functions that modify program state.

dataflow.cc How to use the dataflow API.

functions.cc How to assemble functions that call other functions.

hello.cc How to use the assembler API; look here first.

linker.cc How to assemble functions with external linkage.

And to use x64asm as an assembler from the command line, type:

$ cat test.s | /bin/asm

To use x64asm as part of a larger project, include the header:

#include "/include/x64asm.h"

int main() {

// ...

return 0;

}

and link against the library:

$ g++ code.cc -I/lib/x64.a

Undefined Assembler Behavior

Jumps to undefined labels are handled by emitting a 32-bit relative displacement of 0x00000000.

Assembler Simplifications

Deciding between the 8- and 32-bit relative displacement forms of jump instructions is known as the (NP hard) branch displacement problem. The primary consequence of this decision is code size. Most compilers solve this problem using an iterative algorithm which initially assumes 8-bit displacements and then adjusts as necessary. We emit all jumps to labels using the 32-bit form.

Memory Types

In many cases, the only thing distinguishing two otherwise identical instructions is operand type. Furthermore, certain operand types (ie. M16) are required for infering prefix bytes. We account for this by introducing a distinct memory type for each operand type appearing in the Intel manual. Barring these requirements, a single memory type would simplify our implementation.

Ambiguity

The x86_64 instruction set contains many instructions that are indistinguishable up to mnemonic and operand. These ambiguities represent a distinction without a difference. They are alternate hardware methods for performing the same operation, which as far as we know, have no noticable performance tradeoffs. We remove this redudancy by choosing the encoding preferred by g++.

Intel Eratta

Most of the source code in this project is automatically generated using the the x64.csv spreadsheet. Unless otherwise noted below, the contents of the spreadsheet are transcribed directly from the Intel manuals. If you discover an error, or an edit which has not been documented below, please submit an error report.

String Instructions

Each instruction in this class takes an optional memory argument(s) which is (are) ignored except for the purpose of distinguishing operand width, ie: CMPS M8 = CMPSB, and for specifying a memory address prefix (67), which affects the implicit memory operand. Note that for the short form of these instructions, we add a PREF.66+ annotation, as there is no operand to induce this value.

Although in principle, the short form versions of these instructions can be modified by the addition of a memory address prefix (67), we ignore this possibility and require the user to use the long form.

The Intel manual omits any mention of the memory address prefix (67) for the LODS class of instructions. This is likely a typo, and we support the behavior per the other instructions in this class.

CWD/CDQ/CQO/POPF/PUSHF

Each of the instructions in this class require a word prefix (66) to distinguish the word version of the instruction from the otherwise identical long version. Because there are no operands to infer this prefix, we add it explicitly.

POPA/PUSHA

Each of the instructions in this class would have a similar problem to the above. However, as these are unsupported in 64-bit mode, we ignore these.

IRET/IRETD/IRETQ

Each of the instructions in this class APPEAR as though they would have a similar problem to the above, but don't. We've left them unmodified.

LEAVE/MOV/POP/RET/SYSEXT/SYSRET

Each of the instructions in this class suffer from ambiguity due to lack of mnemonic variation. Furthermore, some of the instructions in this class, even if they could be disambiguated by mnemonic, require prefix bytes which cannot be infered due to lack of operand. We add both an explicit annotation and operand to distinguish these cases. The Intel manual is unclear on what adding the REX.w+ prefix to MOV [mem8] AL accomplishes, but we support this behavior nonetheless.

XLATB

The rex.w prefix is a meaningless distinction in 64-bit mode. As a result, we do not support a distinction between the latter two variants of this instruction.

REP/REPE/REPZ/REPNE/REPNZ

The REX.w prefix has no control over count register for these instructions. It functions simply to disambiguate the 64-bit operand version of some versions of the instruction. Count register width is controled by the address width prefix which follows from the long form version of each instruction. Note that in contrast to the non-repeated versions of these instructions, no short form is given.

In either case, where the REX.w prefix isn't used to disambiguate a 64 bit operand form, it's use is meaningless. For these rows, any arbitrary choice of encoding will suffice.

Note that we have also added underscores to these mnemonics to maintain the one-word-per-mnemonic invariant.

Dataflow Values

Some dataflow information is missing and/or incomplete. If you discover an error, please submit a bug report.

Further documenation

See SPREADSHEET.md for the tiny bit of documentation on the internals that we have, which is focused on the x86.csv file.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

linux 汇编 cqo,x64asm: 包括内存汇编程序,解析器和链接器的C ++库 的相关文章

  • os.path.expanduser

    path os path expanduser linux系统path为 home newt windows系统path为 C Users newt 其中newt为我的用户名
  • XSS攻击修改服务器的代码,XSS攻击的定义,类型以及防御方法

    经常跟大家讲 CC攻击 好像还没有给大家分享过XSS攻击它的类型怎么去防御 今天云都小编就带大家了解下 什么是XSS攻击 XXS 攻击全称跨站脚本攻击 是一种在Web应用中的计算机安全漏洞 它允许恶意Web用户将代码植入到提供给其他使用的页
  • 《机器学习》实验五:实现K-means聚类

    机器学习 实验五 实现K means聚类 机器学习 实验五 实现K means聚类 实验目的 实验原理 实验内容与要求 实验器材 设备 元器件 实验步骤 心得体会 机器学习 实验五 实现K means聚类 实验目的 了解聚类的基本概念 掌握
  • javascript对象小探之三——undefined和undeclared

    一 undefined undefined是javascript的一个数据类型对象 var i 那么i的值就是undefined 二 undeclared undeclared是一种语法错误 不是数据类型 不要误会了 但是js引擎不会报错
  • R语言学习笔记(三)数据处理

    本文的示例数据框集 egData 如下 值标签 if FALSE 值标签 levels代表变量实际值 labels代表标签值 egData sex lt factor egData sex levels c 1 2 labels c mal
  • WSL2+Docker+IDEA一站式开发调试

    WSL2 Docker IDEA一站式开发调试 将就看吧 不知道为什么CSDN无法转储并展示jsdelivr的图片 但博客园正常展示 前言 我们知道 Docker是一个容器引擎 对于开发者来说 使用Dokcer容器部署各种开发需要的中间件
  • linux端口开放指定端口的两种方法

    开放端口的方法 方法一 命令行方式 1 开放端口命令 sbin iptables I INPUT p tcp dport 8080 j ACCEPT 2 保存 etc rc d init d iptables save 3 重启服务 etc
  • 正则表达式和三剑客

    正则表达式与三剑客 Linux正则表达式 由一类特殊字符及文本字符所编写的模式 其中有些字符不表示其字面意义 而是用于表示控制或通配符的功能 分两类 基本正则表达式 BRE 扩展正则表达式 ERE 基本正则表达式DRE集合 元字符 作用 只
  • ROS环境搭建步骤总结

    ROS环境搭建踩坑总结 Ubuntu 16 04安装ROS Kinetic ROS安装 进入到 ROS官网选择安装的版本和系统 配置Ubuntu的repositories 以允许 restricted universe 和 multiver
  • vue element el-select下拉选择不回显问题

    el select下拉选择无效 问题描述 在使用Vue开发使用element ui时 el select下拉框出现在点击选择的时候数据无法显示的问题
  • MMX及SSE优化--SSE篇

    上回讲到针对整数运算的MMX优化技术 然而真正大运算量的图形和声音处理大都用的是浮点运算 而且现在对浮点运算的要求也是越来越高 在这样一个条件下INTEL终于在Pentium III处理中增加针对浮点运算优化的SSE指令 所以所有用过SSE
  • 初学者适合什么副业?适合初学者做的8个副业

    有网友曾说过 安全感是主业给的 但财富是靠副业创造的 可见 找一份靠谱的副业是多么的重要 但是 想找一份靠谱的副业 特别难 尤其是以前没有了解过的 看到各种副业吹嘘 根本无法下手 今天 聪少就给大家分享几个适合新手的副业 帮助大家快速走上副
  • 基于SpringBoot的外卖点餐管理系统

    项目背景 随着科学技术的飞速发展 各行各业都在努力与现代先进技术接轨 通过科技手段提高自身的优势社会的发展和科学技术的进步 互联网技术越来越受欢迎 网络计算机的生活方式逐渐受到广大人民群众的喜爱 也逐渐进入了每个用户的使用 互联网具有便利性
  • 基于STM32CUBEMX,HAL库蓝牙通信

    蓝牙通信 实现手机与stm32连接 1 准备工作 蓝牙模块HC 05模块 安卓APP软件 HC 05蓝牙模块支持AT指令 要进入AT指令模式 需要先按住蓝牙模块上的按键 接通电源 当模块上的LED灯进入慢闪后再松开按键 此时已经进入AT指令
  • vue-cli3.0引入高德地图3d效果两种方法+实例+填坑

    前言 因为项目需要引入高德地图的3d效果 找了很多资料 在这里记录下方法和实例组件 注意 因为两个方法代码量都特别大 这里分2个页面详细说一下 方法一是链接出去专门说 最下面有更多资料 高德3d官网地址和别的资料地址 方法一 使用官方案例
  • 掌握Python的X篇_32_使用python编辑pdf文件_pdfrw

    本篇介绍利用python操作pdf文件 我们平时也会有合并和拆分pdf的需求 此时我们就可以使用本节内容 文章目录 1 pdfrw的安装 2 切分pdf文件 3 pdfrw官网及实现一版四面的实例 1 pdfrw的安装 pip instal
  • React中函数组件和类式组件

    React中函数组件和类式组件 定义组件有两个要求 组件名称必须以大写字母开头 组件的返回值只能有一个根元素 1 函数组件 函数组件也称无状态组件 顾名思义就是通过函数编写的形式去实现一个React组件 是React中定义组件最简单的方式
  • 字符串 - 二进制和文本字符串 - 探究

    1 应用场景 主要用于探究字符串中的二进制和文本字符串 以及它们的区别和应用场景 2 学习 操作 1 文档阅读 重要来自于与chatgpt的对话问答 以及其他技术文章 2 整理输出 2 1 是什么 二进制和文本字符串都是计算机中常用的数据类
  • 相机触发模式

    一 图像采集模式分类 相机的图像采集模式分为内触发模式与外触发模式 其中内触发模式包含连续采集 单帧采集两种形式 外触发模式包含软件触发 硬件外触发 本文以海康相机的软件平台作介绍 该软件去海康机器人官网下载 内触发模式与外触发模式可以通过

随机推荐

  • matlab 降维工具

    降维工具箱drtool 这个工具箱的 主页如下 现在的最新版本是2013 3 21更新 版本v0 8 1b http homepage tudelft nl 19j49 Matlab Toolbox for Dimensionality R
  • 系统服务器地云盘上,系统服务器地云盘上

    系统服务器地云盘上 内容精选 换一换 磁盘增强型弹性云服务器自带高存储带宽和IOPS的本地盘 具有高存储IOPS以及读写带宽的优势 同时 本地盘的价格更加低廉 在海量数据存储场景下 具备更高的性价比 磁盘增强型弹性云服务器具备如下特点 本地
  • 依赖注入之@Value原理(整体流程)

    Autowired等注解 Spring依赖注入之 Autowired Qualifier Primary Priority注解用法 Spring依赖注入之 Autowired Qualifier Primary Priority注解原理 上
  • win10 蓝牙耳机已连接但是耳机仍没有声音,音频仍是扬声器输出问题的出现条件及解决方案

    此问题可能分电脑分耳机类型出现 本人因耳机Fill CC2连接笔记本频繁出现此问题故以此文记录 问题出现原因 疑似 1 笔记本后台挂的程序应用过多 且笔记本开机通电时间过长 2 连接蓝牙耳机时笔记本扬声器正在发声 解决方法 27条消息 wi
  • 【xgboost】贝叶斯自动调参代码

    工作中 很多场景下会用到xgboost模型 如风控 催收 营销 推荐等待 在用xgboost模型进行模型训练的时候 也经常用贝叶斯自动调参来搜索最优的参数 现在把相关的代码贴出来 供大家参考 目前是支持了xgboost和lightgbm模型
  • VS2010安装失败解决办法

    1 运行regedit打开注册表 2 找到HKEY LOCAL MACHINE SOFWARE Microsoft Internet Explorer MAIN 3 MAIN子键的权限问题 修改成 允许完全控制 MAIN子键点击右键里弹出权
  • 解决Vue引入百度地图JSSDK:BMap is undefined 问题

    百度地图官网文档介绍使用JSSDK时 仅提供了三种引入方式 script引入 异步加载 npm install vue baidu map save 或 cnpm install vue baidu map save 全局引入 但vue项目
  • 每天一练——斐波那契数列前N项之和

    什么是斐波那契数列 斐波那契数列就是前两项之和会等于第三项 斐波那契数列通常以一为起始 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 正如我所说的前两项之和会等于第三项以此类推 那么
  • 【Unity3D】Unity5.6的Mecanim Animator动画系统结合MMD4Mecanim插件舞蹈动画

    1 下载MMD4Mecanim 官网 http stereoarts jp 我用的是最新版的MMD4Mecanim Beta 20170423 zip Unity是5 6 0版本的 2 解压后导入MMD4Mecanim unitypacka
  • 打印机漏洞(rce)

    20210510 0 出发 在翻阅论文的时候 突然想起来之前的时候 看到过一些打印机的漏洞 然后就在谷歌上搜索了一下 printer rce 然后找到了这篇文章 A Sheep in Wolf s Clothing Finding RCE
  • 老鸟重写程序需要准备点什么

    整体来说 老鸟工作已久 对语言 架构 算法 性能 安全 业务 各类型特点会掌控能力更高 但是年久未动手 不免生疏 为此专门整理需要的基本内容 可以抽空回味一下 在紧急上手之后 两周内查缺补漏 区别与新手面对任何问题的一脸懵逼 老鸟对所有技术
  • Redis配置优化

    Redis Redis 远程字典服务器 是一个开源的 使用c语言编写的NoSQL数据库 Redis 基于内存运行并支持持久化 采用key value 键值对 的存储形式 是目前分布式架构中不可或缺的一环 Redis服务器程序是单进程模型 也
  • 21世纪的管理挑战

    朋友很早前推荐看的德鲁克系列 最近在孔网搞到了 顺便在此记录读书笔记和想法 如下 第一章 管理的新范式 管理是企业管理 新学科 公共管理 不同组织的任务和挑战也不存在巨大的差异 企业必须具有一个恰当的组织形式 组织不是绝对的 它是提高人们在
  • 科学计数法 C语言

    题目 科学计数法是科学家用来表示很大或很小的数字的一种方便的方法 其满足正则表达式 1 9 0 9 E 0 9 即数字的整数部分只有 1 位 小数部分至少有 1 位 该数字及其指数部分的正负号即使对正数也必定明确给出 现以科学计数法的格式给
  • gcc (GNU编译器套件)

    gcc GNU编译器套件 编辑 GNU编译器套件 GNU Compiler Collection 包括 C C Objective C Fortran Java Ada和 Go语言的前端 也包括了这些语言的库 如libstdc libgcj
  • va_list(),va_start(),va_arg(),va_end()

    va list va start va arg va end 详解 一 写一个简单的可变参数的C函数 下面我们来探讨如何写一个简单的可变参数的C函数 写可变参数的C函数要在程序中用到以下这些宏 void va start va list a
  • python redis 获取所有key

    使用scan代替getKeys 线上的登录用户有几百万 数据量比较多 keys算法是遍历算法 复杂度是O n 也就是数据越多 时间越高 数据量达到几百万 keys这个指令就会导致 Redis 服务卡顿 因为 Redis 是单线程程序 顺序执
  • Nodejs——时间戳与日期相互转换

    时间格式化的库 silly datetime 安装 npm i silly datetime save var sillyDateTime require silly datetime 获取当前时间 并转换为年月份 时分秒的格式 conso
  • Mybatis 插入大量数据性能问题的解决(Caused by: java.sql.SQLException: ORA-04030: 在尝试分配 2024 字节 (kxs-heap-c,kg hs)

    最近写的需求 需要频繁的往数据库中插入大量的数据 多达上万条 最后导致oracle 数据库直接挂掉了 这个问题肯定要解决的 主要的原因就是一次性插入这么多数据 oracle 数据库承受不住 最后 报Caused by java sql SQ
  • linux 汇编 cqo,x64asm: 包括内存汇编程序,解析器和链接器的C ++库

    x64asm x64asm is a c 11 library for working with x86 64 assembly It provides a parser in memory assembler and linker and