Giter VIP home page Giter VIP logo

mc-asm's Introduction

mc-asm

mc-asm provides a Python API for turning assembly into machine code, providing rich symbolic information.

Copyright and Acknowledgments

Copyright (C) 2020 GrammaTech, Inc.

This code is licensed under the MIT license. See the LICENSE file in the project root for license terms.

This project is sponsored by the Office of Naval Research, One Liberty Center, 875 N. Randolph Street, Arlington, VA 22203 under contract # N68335-17-C-0700. The content of the information does not necessarily reflect the position or policy of the Government and no official endorsement should be inferred.

The header files under the src/llvm-headers/ directory are copied from the LLVM project and are licensed under the Apache License v2.0 with LLVM Exceptions (a copy of that license is included in the src/llvm-headers/ directory).

The following files from the open-source LLVM project are included in the MCASM repository.

  • Files:
    • AArch64MCExpr.h (from llvm/lib/Target/AArch64/MCTargetDesc/)
    • MipsMCExpr.h (from llvm/lib/Target/Mips/MCTargetDesc/)
  • Project Name: LLVM
  • Project Version: 14.0.6
  • License: Apache License v2.0 with LLVM Exceptions

mc-asm's People

Contributors

bfairservice-gt avatar eschulte avatar jranieri-grammatech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mc-asm's Issues

Should fix a bug, jump address or call address

In the default execution of

asm(
R"(
mov %eax, %eax
call 0x12345678
)"
);

[
  {
    "kind": "changeSection",
    "section": {
      "alignment": 1,
      "characteristics": 1610612768,
      "class": "MCSectionCOFF",
      "isVirtual": false,
      "kind": {
        "isBSS": false,
        "isCommon": false,
        "isData": false,
        "isExecuteOnly": false,
        "isGlobalWriteableData": false,
        "isMergeableCString": false,
        "isMergeableConst": false,
        "isMetadata": false,
        "isReadOnly": false,
        "isReadOnlyWithRel": false,
        "isText": true,
        "isThreadBSS": false,
        "isThreadLocal": false,
        "isWriteable": false
      },
      "name": ".text"
    }
  },
  {
    "data": "89c0",
    "fixups": [],
    "inst": {
      "desc": {
        "canFoldAsLoad": false,
        "hasDelaySlot": false,
        "hasOptionalDef": false,
        "hasUnmodeledSideEffects": false,
        "implicitDefs": [],
        "implicitUses": [],
        "isAdd": false,
        "isAuthenticated": false,
        "isBarrier": false,
        "isBitcast": false,
        "isBranch": false,
        "isCall": false,
        "isCompare": false,
        "isConditionalBranch": false,
        "isConvergent": false,
        "isExtractSubregLike": false,
        "isIndirectBranch": false,
        "isInsertSubregLike": false,
        "isMoveImmediate": false,
        "isMoveReg": true,
        "isNotDuplicable": false,
        "isPredicable": false,
        "isPseudo": false,
        "isRegSequenceLike": false,
        "isReturn": false,
        "isSelect": false,
        "isTerminator": false,
        "isTrap": false,
        "isUnconditionalBranch": false,
        "isVariadic": false,
        "mayLoad": false,
        "mayRaiseFPException": false,
        "mayStore": false,
        "numDefs": 1,
        "variadicOpsAreDefs": false
      },
      "flags": 0,
      "opcode": "MOV32rr",
      "operands": [
        {
          "kind": "reg",
          "reg": "EAX"
        },
        {
          "kind": "reg",
          "reg": "EAX"
        }
      ]
    },
    "kind": "instruction"
  },
  {
    "data": "e800000000",
    "fixups": [
      {
        "flags": [
          "IsPCRel"
        ],
        "name": "FK_PCRel_4",
        "offset": 1,
        "targetOffset": 0,
        "targetSize": 32,
        "value": {
          "kind": "binaryExpr",
          "lhs": {
            "kind": "constant",
            "useHexFormat": false,
            "value": 305419896
          },
          "opcode": "Add",
          "rhs": {
            "kind": "constant",
            "useHexFormat": false,
            "value": -4
          }
        }
      }
    ],
    "inst": {
      "desc": {
        "canFoldAsLoad": false,
        "hasDelaySlot": false,
        "hasOptionalDef": false,
        "hasUnmodeledSideEffects": false,
        "implicitDefs": [],
        "implicitUses": [
          "ESP",
          "SSP"
        ],
        "isAdd": false,
        "isAuthenticated": false,
        "isBarrier": false,
        "isBitcast": false,
        "isBranch": false,
        "isCall": true,
        "isCompare": false,
        "isConditionalBranch": false,
        "isConvergent": false,
        "isExtractSubregLike": false,
        "isIndirectBranch": false,
        "isInsertSubregLike": false,
        "isMoveImmediate": false,
        "isMoveReg": false,
        "isNotDuplicable": false,
        "isPredicable": false,
        "isPseudo": false,
        "isRegSequenceLike": false,
        "isReturn": false,
        "isSelect": false,
        "isTerminator": false,
        "isTrap": false,
        "isUnconditionalBranch": false,
        "isVariadic": false,
        "mayLoad": false,
        "mayRaiseFPException": false,
        "mayStore": false,
        "numDefs": 0,
        "variadicOpsAreDefs": false
      },
      "flags": 0,
      "opcode": "CALLpcrel32",
      "operands": [
        {
          "imm": 305419896,
          "kind": "imm"
        }
      ]
    },
    "kind": "instruction"
  }
]

The actual address of the generated assembly code is 0x00000000

The module address is missing here, so llvm does not calculate the address that should be called correctly.

Or maybe I don't use ATT or INTEL assembly syntax.

Please advise me

Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.