mirror of
https://github.com/samsonjs/compiler.git
synced 2026-04-26 14:47:43 +00:00
added relocation tables
This commit is contained in:
parent
558d5e73a9
commit
fe37723c2f
1 changed files with 33 additions and 7 deletions
40
asm/macho.rb
40
asm/macho.rb
|
|
@ -3,8 +3,9 @@ require 'asm/cstruct'
|
||||||
# The MachO module contains constants and structures related to the
|
# The MachO module contains constants and structures related to the
|
||||||
# Mach Object format (Mach-O). They are relevant to Darwin on OS X.
|
# Mach Object format (Mach-O). They are relevant to Darwin on OS X.
|
||||||
#
|
#
|
||||||
# Constants and structures as defined in /usr/include/mach-o/loader.h on
|
# Constants and structures as defined in /usr/include/mach-o/loader.h
|
||||||
# Mac OS X Leopard (10.5.7). Also see <mach-o/stab.h> and <mach-o/nlist.h>.
|
# on Mac OS X Leopard (10.5.7). Also see <mach-o/stab.h>,
|
||||||
|
# <mach-o/nlist.h>, and <mach-o/reloc.h>.
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
|
|
||||||
|
|
@ -25,8 +26,8 @@ module MachO
|
||||||
end
|
end
|
||||||
|
|
||||||
# Values for the magic field.
|
# Values for the magic field.
|
||||||
MH_MAGIC = 0xfeedface # Mach magic number.
|
MH_MAGIC = 0xfeedface # Mach magic number (big-endian).
|
||||||
MH_CIGAM = 0xcefaedfe # In the reverse byte-order.
|
MH_CIGAM = 0xcefaedfe # Little-endian version.
|
||||||
|
|
||||||
# Values for the filetype field.
|
# Values for the filetype field.
|
||||||
MH_OBJECT = 0x1
|
MH_OBJECT = 0x1
|
||||||
|
|
@ -58,8 +59,8 @@ module MachO
|
||||||
# Values for the cmd member of LoadCommand CStructs (incomplete!).
|
# Values for the cmd member of LoadCommand CStructs (incomplete!).
|
||||||
LC_SEGMENT = 0x1
|
LC_SEGMENT = 0x1
|
||||||
LC_SYMTAB = 0x2
|
LC_SYMTAB = 0x2
|
||||||
LC_SYMSEG = 0x3
|
LC_SYMSEG = 0x3
|
||||||
LC_THREAD = 0x4
|
LC_THREAD = 0x4
|
||||||
LC_UNIXTHREAD = 0x5
|
LC_UNIXTHREAD = 0x5
|
||||||
|
|
||||||
class SegmentCommand < LoadCommand
|
class SegmentCommand < LoadCommand
|
||||||
|
|
@ -122,7 +123,32 @@ module MachO
|
||||||
S_ZEROFILL = 0x1
|
S_ZEROFILL = 0x1
|
||||||
S_CSTRING_LITERALS = 0x2
|
S_CSTRING_LITERALS = 0x2
|
||||||
|
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Relocation info support #
|
||||||
|
###########################
|
||||||
|
|
||||||
|
class RelocationInfo < CStruct
|
||||||
|
int32 :r_address # offset in the section to what is being relocated
|
||||||
|
uint32 :r_info
|
||||||
|
end
|
||||||
|
|
||||||
|
# NOTE: r_info is a packed bit field with the following members:
|
||||||
|
#
|
||||||
|
# (CStruct should eventually support bitfields, but doesn't right now.)
|
||||||
|
#
|
||||||
|
# uint32 r_symbolnum : 24 -- symbol index if r_extern == 1 or section ordinal if r_extern == 0
|
||||||
|
# int r_pcrel : 1 -- was relocated pc relative already
|
||||||
|
# int r_length : 2 -- 0=byte, 1=word, 2=long, 3=quad
|
||||||
|
# int r_extern : 1 -- 1 for exported symbols, 0 othewise
|
||||||
|
# int r_type : 4 -- if not 0, machine specific relocation type (always 0)
|
||||||
|
|
||||||
|
R_ABS = 0 # Absolute relocation type
|
||||||
|
# (r_symbolnum == R_ABS for absolute symbols that don't need reloc)
|
||||||
|
|
||||||
|
# Relocation types (r_type)
|
||||||
|
GENERIC_RELOC_VANILLA = 0
|
||||||
|
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# Symbol table support #
|
# Symbol table support #
|
||||||
|
|
@ -161,4 +187,4 @@ module MachO
|
||||||
NO_SECT = 0
|
NO_SECT = 0
|
||||||
MAX_SECT = 255
|
MAX_SECT = 255
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue