@isopodlabs/binary_libs 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elf.js +8 -8
- package/dist/mach.js +4 -4
- package/dist/pe.js +4 -4
- package/package.json +2 -2
package/dist/elf.js
CHANGED
|
@@ -679,10 +679,10 @@ class ELFFile {
|
|
|
679
679
|
data;
|
|
680
680
|
constructor(s) {
|
|
681
681
|
super(s);
|
|
682
|
-
const flags =
|
|
683
|
-
| (this.p_flags.R ?
|
|
684
|
-
| (this.p_flags.W ?
|
|
685
|
-
| (this.p_flags.X ?
|
|
682
|
+
const flags = binary.MappedMemory.RELATIVE
|
|
683
|
+
| (this.p_flags.R ? binary.MappedMemory.READ : 0)
|
|
684
|
+
| (this.p_flags.W ? binary.MappedMemory.WRITE : 0)
|
|
685
|
+
| (this.p_flags.X ? binary.MappedMemory.EXECUTE : 0);
|
|
686
686
|
this.data = new binary.MappedMemory(s.buffer_at(Number(this.p_offset), Number(this.p_filesz)), Number(this.p_vaddr), flags);
|
|
687
687
|
}
|
|
688
688
|
}
|
|
@@ -701,9 +701,9 @@ class ELFFile {
|
|
|
701
701
|
data;
|
|
702
702
|
constructor(s) {
|
|
703
703
|
super(s);
|
|
704
|
-
const flags =
|
|
705
|
-
| (this.sh_flags.WRITE ?
|
|
706
|
-
| (this.sh_flags.EXECINSTR ?
|
|
704
|
+
const flags = binary.MappedMemory.RELATIVE | binary.MappedMemory.READ
|
|
705
|
+
| (this.sh_flags.WRITE ? binary.MappedMemory.WRITE : 0)
|
|
706
|
+
| (this.sh_flags.EXECINSTR ? binary.MappedMemory.EXECUTE : 0);
|
|
707
707
|
const buffer = this.sh_type === 'NOBITS' ? new Uint8Array(0) : s.buffer_at(Number(this.sh_offset), Number(this.sh_size));
|
|
708
708
|
this.data = new binary.MappedMemory(buffer, Number(this.sh_addr), flags);
|
|
709
709
|
}
|
|
@@ -760,7 +760,7 @@ class ELFFile {
|
|
|
760
760
|
if (+sym.st_shndx) {
|
|
761
761
|
const section = sh[+sym.st_shndx];
|
|
762
762
|
const offset = Number(sym.st_value.value) - Number(section.sh_addr.value);
|
|
763
|
-
const flags = sym.st_info.type === 'FUNC' ? section.data.flags : section.data.flags & ~
|
|
763
|
+
const flags = sym.st_info.type === 'FUNC' ? section.data.flags : section.data.flags & ~binary.MappedMemory.EXECUTE;
|
|
764
764
|
sym.data = new binary.MappedMemory(section.data.data.subarray(offset, offset + Number(sym.st_size)), Number(sym.st_value.value), flags);
|
|
765
765
|
}
|
|
766
766
|
return [binary.utils.decodeTextTo0(names.subarray(sym.st_name), 'utf8'), sym];
|
package/dist/mach.js
CHANGED
|
@@ -424,7 +424,7 @@ function section(bits) {
|
|
|
424
424
|
data;
|
|
425
425
|
constructor(s) {
|
|
426
426
|
super(s);
|
|
427
|
-
const prot = this.flags.ATTRIBUTES.SYS.SOME_INSTRUCTIONS ?
|
|
427
|
+
const prot = this.flags.ATTRIBUTES.SYS.SOME_INSTRUCTIONS ? binary.MappedMemory.EXECUTE | binary.MappedMemory.RELATIVE : binary.MappedMemory.RELATIVE;
|
|
428
428
|
this.data = (async () =>
|
|
429
429
|
//new binary.utils.MappedMemory(await s.file.get(BigInt(this.addr), Number(this.size)), Number(this.addr), prot)
|
|
430
430
|
new binary.MappedMemory(s.subdata(+this.offset, Number(this.size)), Number(this.addr), prot))();
|
|
@@ -458,7 +458,7 @@ function segment(bits) {
|
|
|
458
458
|
const o = binary.read(s, fields);
|
|
459
459
|
async function load() {
|
|
460
460
|
const data = await s.getmem(BigInt(Number(o.vmaddr)), Number(o.filesize)) ?? s.subdata(Number(o.fileoff), Number(o.filesize));
|
|
461
|
-
o.data = new binary.MappedMemory(data, Number(o.vmaddr), o.initprot);
|
|
461
|
+
o.data = new binary.MappedMemory(data, Number(o.vmaddr), o.initprot | binary.MappedMemory.RELATIVE);
|
|
462
462
|
//const sect = section(bits);
|
|
463
463
|
if (o.nsects) {
|
|
464
464
|
o.sections = binary.objectWithNames(binary.ArrayType(o.nsects, section(bits)), binary.field('sectname')).get(s);
|
|
@@ -1053,10 +1053,10 @@ class FATMachFile {
|
|
|
1053
1053
|
constructor(data, mem) {
|
|
1054
1054
|
switch (binary.UINT32_BE.get(new binary.stream(data))) {
|
|
1055
1055
|
case FAT_MAGIC:
|
|
1056
|
-
this.load(new binary.endianStream(data,
|
|
1056
|
+
this.load(new binary.endianStream(data, true), mem);
|
|
1057
1057
|
break;
|
|
1058
1058
|
case FAT_CIGAM:
|
|
1059
|
-
this.load(new binary.endianStream(data,
|
|
1059
|
+
this.load(new binary.endianStream(data, false), mem);
|
|
1060
1060
|
break;
|
|
1061
1061
|
default:
|
|
1062
1062
|
throw new Error('not a fat mach file');
|
package/dist/pe.js
CHANGED
|
@@ -167,10 +167,10 @@ class Section extends binary.ReadClass({
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
get flags() {
|
|
170
|
-
return
|
|
171
|
-
| (this.Characteristics.MEM_READ ?
|
|
172
|
-
| (this.Characteristics.MEM_WRITE ?
|
|
173
|
-
| (this.Characteristics.MEM_EXECUTE ?
|
|
170
|
+
return binary.MappedMemory.RELATIVE
|
|
171
|
+
| (this.Characteristics.MEM_READ ? binary.MappedMemory.READ : 0)
|
|
172
|
+
| (this.Characteristics.MEM_WRITE ? binary.MappedMemory.WRITE : 0)
|
|
173
|
+
| (this.Characteristics.MEM_EXECUTE ? binary.MappedMemory.EXECUTE : 0);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
exports.DIRECTORIES = {
|