Class: Rubycc::Backend::X86_64::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/rubycc/backend/x86_64.rb

Overview

Result of compiling one function: bytes is the machine code (an ASCII-8BIT String), symbols is an array of { name:, offset:, size: } describing the emitted function symbols, and relocations is an array of relocation records the linker must resolve (each offset is relative to the start of this function's code). Every record carries a kind:

* { kind: :call, offset:, symbol: } — a "call rel32" site, resolved
against the named symbol (R_X86_64_PLT32);
* { kind: :string, offset:, string_id: } — a "lea rip" displacement
addressing read-only string `string_id` (R_X86_64_PC32 against the
.rodata section);
* { kind: :global, offset:, symbol: } — a "lea rip" displacement
addressing the named file-scope variable `symbol` (R_X86_64_PC32
against that symbol);
* { kind: :func, offset:, symbol: } — a "lea rip" displacement taking
the address of the function `symbol` (a function designator or
"&f"), resolved like a `call` against that (defined or undefined)
symbol;
* { kind: :got, offset:, symbol: } — a "mov rax, [rip+disp32]" that
loads `symbol`'s address from its Global Offset Table slot (the PIC
form of :global/:func for a symbol this unit does not define),
resolved as R_X86_64_REX_GOTPCRELX against that symbol.

Instance Attribute Summary collapse

Instance Attribute Details

#bytesObject (readonly)

Returns the value of attribute bytes

Returns:

  • (Object)

    the current value of bytes



72
73
74
# File 'lib/rubycc/backend/x86_64.rb', line 72

def bytes
  @bytes
end

#relocationsObject (readonly)

Returns the value of attribute relocations

Returns:

  • (Object)

    the current value of relocations



72
73
74
# File 'lib/rubycc/backend/x86_64.rb', line 72

def relocations
  @relocations
end

#symbolsObject (readonly)

Returns the value of attribute symbols

Returns:

  • (Object)

    the current value of symbols



72
73
74
# File 'lib/rubycc/backend/x86_64.rb', line 72

def symbols
  @symbols
end