어 셈 블 리 (objdump - d) 출력 파일 에 대한 vim 정의

16401 단어 편집기
본문http://qiita.com/shiracamus/items/61ffc618f204342e352f
CTF (Capture The Flag) 에 서 는 objdump - d 또는 - D 어 셈 블 리 를 자주 볼 수 있 습 니 다. x86 / x64 바 이 너 리 파일 의 결과 로 vim 관련 탭 을 정의 합 니 다.어 셈 블 리 파일 은 항상 *. dis 또는 *. dis - intel 로 이름 을 짓 는데 이 파일 들 이 열 렸 을 때 관련 vim 정의 에 자동 으로 대응 할 수 있 습 니 다.
git 창 고 를 만 들 었 습 니 다.https://github.com/shiracamus/vim-syntax-x86-objdump-d
~/.vim/filetype.vim
augroup filetypedetect
        au BufRead,BufNewFile *.dis* setfiletype dis
augroup END

~/.vim/syntax/dis.vim
" Vim syntax file
" Language:     x86/x64 GNU Disassembler (objdump -d -Mintel)
" Maintainer:   @shiracamus 
" Last Change:  2013 Dec 30

" For version 5.x: Clear all syntax items
" For version 6.0 and later: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

let s:cpo_save = &cpo
set cpo&vim

syn case ignore

syn match disOffset     "[+-]"
syn match disNumber     "[+-]\?\<0x[0-9a-f]\+\>" contains=disOffset
syn match disNumber     "[+-]\?\" contains=disOffset

syn match disRegister   "\"
syn match disRegister   "\"
syn match disRegister   "\"
syn match disRegister   "\"
syn match disRegister   "[^\t]\"hs=s+1

syn match disAt         "@"
syn match disSection    " \.[a-z][a-z_\.-]*:"he=e-1
syn match disSection    "@[a-z0-9_][a-z0-9_-]\+"hs=s+1 contains=disAt,disNumber

syn match disLabel      ""hs=s+1,he=e-1 contains=disNumber,disSection
syn match disHexDump    ":\t\([0-9a-f][0-9a-f] \)\+"hs=s+1

syn match disError      ""
syn match disError      "(bad)"

syn keyword disTodo     contained TODO

syn region disComment   start="/\*" end="\*/" contains=disTodo
syn match disComment    "[#;!|].*" contains=disLabel,disTodo

syn match disSpecial    display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
syn region disString    start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=disSpecial
syn region disString    start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=disSpecial

syn match disFormat     ": \+file format "
syn match disTitle      "^[^ ]\+: \+file format .*$" contains=disFormat

syn match disMacro      "FWORD"
syn match disMacro      "QWORD"
syn match disMacro      "DWORD"
syn match disMacro      "BYTE"
syn match disMacro      "PTR"

syn match disData       ".word"
syn match disData       ".short"
syn match disData       ".byte"

" Opecode matched disNumber
syn match disOpecode    "\
syn match disOpecode    "\
syn match disOpecode    "\
syn match disOpecode    "\

syn case match

" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_dis_syntax_inits")
  if version < 508
    let did_dis_syntax_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  " The default methods for highlighting.  Can be overridden later
  " Comment
  HiLink disComment     Comment
  " Constant: String, Character, Number, Boolean, Float
  HiLink disNumber      Number
  HiLink disString      String
  " Identifier: Function
  HiLink disHexDump     Identifier
  "Statement: Conditional, Repeat, Label, Operator, Keyword, Exception
  HiLink disLabel       Label
  " PreProc: Include, Define, Macro, PreCondit
  HiLink disData        Define
  HiLink disMacro       Macro
  " Type: StorageClass, Structure, Typedef
  HiLink disRegister    StorageClass
  HiLink disTitle       Typedef
  " Special: SpecialChar, Tag, Delimiter, SpecialComment, Debug
  HiLink disSpecial     SpecialChar
  HiLink disSection     Special
  " Underlined
  " Ignore
  " Error
  HiLink disError       Error
  " Todo
  HiLink disTodo        Todo

  delcommand HiLink
endif

let b:current_syntax = "dis"

let &cpo = s:cpo_save
unlet s:cpo_save

" vim: ts=8 sts=4 sw=2

마지막 효 과 는 다음 과 같다.
用于反汇编(objdump -d)输出文件的vim定义_第1张图片

좋은 웹페이지 즐겨찾기