-
-
Notifications
You must be signed in to change notification settings - Fork 49
Is the e_machine field not being read correctly as two bytes? #49
Copy link
Copy link
Closed
Description
x86_64 works fine, not loongarch.
x86_64
single byte.
ELF
Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000: 7F 45 4C 46 02 01 01 00 00 00 00 00 00 00 00 00 .ELF............
00000010: 03 00 3E 00 01 00 00 00 90 97 00 00 00 00 00 00 ..>.............
RESULT
file: /tmp/appimagetool-build-MppgfA/AppDir/usr/bin/mksquashfs
e machine-------------------------->62
loongarch
ELF
Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000: 7F 45 4C 46 02 01 01 00 41 49 02 00 00 00 00 00 .ELF....AI......
00000010: 02 00 02 01 01 00 00 00 E4 4F 01 20 01 00 00 00 ........dO......
RESULT
file: /tmp/appimagetool-build-MppgfA/AppDir/usr/bin/mksquashfs
e machine-------------------------->2
MODIFY
I changed the read_elf_e_machine_field function to:
int16_t read_elf_e_machine_field(const gchar* file_path) {
int16_t e_machine = 0x00;
FILE* file = 0;
file = fopen(file_path, "rb");
if (file) {
fseek(file, 0x12, SEEK_SET);
fread(&e_machine, sizeof(e_machine), 1, file);
fclose(file);
e_machine = GINT16_FROM_LE(e_machine);
}
return e_machine;
}
and it can be identify correctly:
file: /tmp/appimagetool-build-MppgfA/AppDir/usr/bin/mksquashfs
e machine-------------------------->258
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels