Added the skeleton for the machine types.

This commit is contained in:
2024-04-11 22:01:15 -05:00
parent 3a452b0922
commit 34f2956922
7 changed files with 65 additions and 18 deletions
+32
View File
@@ -0,0 +1,32 @@
#include "elf_machine_type.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
char* ELF_MACHINE_TYPE_TEXT[] = {
"No ISA Set",
"\x00\x01""AT&T WE 32100",
"\x00\x3E""Advanced Micro Devices x86_64"
};
void GetELFMachineTypeText(ELFMachine type, char buffer[256]) {
if (!buffer) return;
memset(buffer, '\0', 256);
if (type == 0) {
strncpy(buffer, ELF_MACHINE_TYPE_TEXT[0], strlen(ELF_MACHINE_TYPE_TEXT[0]));
return;
}
for(unsigned int i = 1; i < sizeof(ELF_MACHINE_TYPE_TEXT) / sizeof(char*); i++) {
char* text = ELF_MACHINE_TYPE_TEXT[i];
if (type == (unsigned int) text[0] + text[1]) {
strncpy(buffer, &text[2], strlen(&text[2]));
return;
}
}
}