Class: Omnizip::Filters::BcjIa64
- Inherits:
-
FilterBase
- Object
- FilterBase
- Omnizip::Filters::BcjIa64
- Defined in:
- lib/omnizip/filters/bcj_ia64.rb
Overview
BCJ filter for IA-64 (Itanium) executables.
This filter preprocesses Itanium machine code by converting relative addresses in branch instructions. IA-64 uses a complex VLIW (Very Long Instruction Word) architecture with 16-byte instruction bundles containing 3 instructions plus a template.
The filter improves compression by making branch targets position-independent.
Constant Summary collapse
- BUNDLE_SIZE =
Size of IA-64 instruction bundle (16 bytes, little-endian)
16- TEMPLATE_MASKS =
Template lookup table for instruction slot positions Each bit pattern indicates which slots may contain branch instr
0x334B0000
Class Method Summary collapse
-
.metadata ⇒ Hash
Get metadata about this filter.
Instance Method Summary collapse
-
#decode(data, position = 0) ⇒ String
Decode (postprocess) IA-64 executable data after decompression.
-
#encode(data, position = 0) ⇒ String
Encode (preprocess) IA-64 executable data for compression.
Class Method Details
.metadata ⇒ Hash
Get metadata about this filter.
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/omnizip/filters/bcj_ia64.rb', line 106 def { name: "BCJ-IA64", description: "Branch converter for IA-64 (Itanium) " \ "executables", architecture: "IA-64 / Itanium", alignment: 16, endian: "little", complexity: "high", } end |
Instance Method Details
#decode(data, position = 0) ⇒ String
Decode (postprocess) IA-64 executable data after decompression.
Reverses the encoding by converting absolute addresses back to relative addresses.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/omnizip/filters/bcj_ia64.rb', line 78 def decode(data, position = 0) return data.dup if data.bytesize < BUNDLE_SIZE result = data.b size = data.bytesize & ~(BUNDLE_SIZE - 1) i = 0 pc = (position >> 4) << 1 while i < size # Check template byte for slots with potential branches template = result.getbyte(i) & 0x1E mask = (TEMPLATE_MASKS >> template) & 3 pc += 2 i += BUNDLE_SIZE next if mask.zero? # Process each marked slot process_bundle_slots(result, i - BUNDLE_SIZE, mask, pc, false) end result end |
#encode(data, position = 0) ⇒ String
Encode (preprocess) IA-64 executable data for compression.
Scans 16-byte instruction bundles for branch instructions and converts relative addresses to absolute addresses.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/omnizip/filters/bcj_ia64.rb', line 46 def encode(data, position = 0) return data.dup if data.bytesize < BUNDLE_SIZE result = data.b size = data.bytesize & ~(BUNDLE_SIZE - 1) i = 0 pc = (position >> 4) << 1 while i < size # Check template byte for slots with potential branches template = result.getbyte(i) & 0x1E mask = (TEMPLATE_MASKS >> template) & 3 pc += 2 i += BUNDLE_SIZE next if mask.zero? # Process each marked slot process_bundle_slots(result, i - BUNDLE_SIZE, mask, pc, true) end result end |