Class: YASM::Command
- Inherits:
-
CommandMapper::Command
- Object
- CommandMapper::Command
- YASM::Command
- Defined in:
- lib/yasm/command.rb
Overview
Provides an interface for invoking the yasm utility.
Examples
Assemble a binary file:
YASM::Command.run(syntax: :gas, file: 'hello_world.S', output: 'hello_world.o')
Assemble amd64 assembly, in GAS syntax, into an ELF64 file with debugging information:
YASM::Command.run do |yasm|
yasm.target = :amd64
yasm.syntax = :gas
yasm.file = 'hello_world.S'
yasm.output = 'hello_world.o'
yasm.output_format = :elf64
yasm.debug_format = :stabs
end
yasm options:
--version-yasm.version--license-yasm.license--help-yasm.help--arch-yasm.archx86- x86 (IA-32 and derivatives), AMD64lc3b- LC-3b
--parser-yasm.parsergas- GNU AS (GAS)-compatible parsergnu- GNU AS (GAS)-compatible parsernasm- NASM-compatible parsertasm- TASM-compatible parser
--preproc-yasm.preprocessornasm- Real NASM Preprocessortasm- Real TASM Preprocessorraw- Disable preprocessingcpp- Run input through external C preprocessorgas- GNU AS (GAS)-compatible preprocessor
--oformat-yasm.output_formatdbg- Trace of all info passed to object format modulebin- Flat format binarydosexe- DOS .EXE format binaryelf- ELFelf32- ELF (32-bit)elf64- ELF (64-bit)elfx32- ELF (x32)coff- COFF (DJGPP)macho- Mac OS X ABI Mach-O File Formatmacho32- Mac OS X ABI Mach-O File Format (32-bit)macho64- Mac OS X ABI Mach-O File Format (64-bit)rdf- Relocatable Dynamic Object File Format (RDOFF) v2.0win32- Win32win64- Win64x64- Win64xdf- Extended Dynamic Object
--dformat-yasm.debug_formatcv8- CodeView debugging format for VC8dwarf2- DWARF2 debugging formatnull- No debugging infostabs- Stabs debugging format
--lformat-yasm.list_formatnasm-NASM-style list format
--list-yasm.list_file--objfile-yasm.output--mapfile-yasm.map_file--machine-yasm.machinex86- IA-32 and derivativesamd64- AMD64x32- X32
--force-strict-yasm.force_strict-w-yasm.inhibit_warnings-W-yasm.toggle_warnings-M-yasm.gen_makefile_deps-E-yasm.redirect_errors_to-e-yasm.redirect_errors--preproc-only-yasm.preprocessor_only-I-yasm.include-P-yasm.pre_include-D-yasm.define-U-yasm.undefine-X-yasm.message_stylegnuvc
--prefix-yasm.prefix--suffix-yasm.suffixfile-yasm.file
Direct Known Subclasses
Constant Summary collapse
- TARGETS =
The known YASM targets
{ x86: {arch: :x86, machine: :x86}, amd64: {arch: :x86, machine: :amd64}, lc3b: {arch: :lc3b, machine: :lc3b} }
Instance Method Summary collapse
-
#target ⇒ :x86, ...
Determines which target was set.
-
#target=(name) ⇒ Symbol
Sets that target.
Instance Method Details
#target ⇒ :x86, ...
Determines which target was set.
242 243 244 245 246 |
# File 'lib/yasm/command.rb', line 242 def target if arch && machine TARGETS.key(arch: arch.to_sym, machine: machine.to_sym) end end |
#target=(name) ⇒ Symbol
Sets that target.
260 261 262 263 264 265 266 267 268 |
# File 'lib/yasm/command.rb', line 260 def target=(name) target = TARGETS.fetch(name.to_sym) do raise(ArgumentError,"unknown YASM target: #{name.inspect}") end self.arch = target[:arch] self.machine = target[:machine] return name end |