38 39 /** 40 * Architecture endian-ness. 41 */ 42 private static final int endian = Elf64_Ehdr.ELFDATA2LSB; 43 44 /** 45 * Target OS string. 46 */ 47 private static String osName; 48 49 static { 50 // Find the target arch details 51 String archStr = System.getProperty("os.arch").toLowerCase(); 52 if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { 53 System.out.println("Only Little Endian byte order supported!"); 54 } 55 56 if (archStr.equals("amd64") || archStr.equals("x86_64")) { 57 arch = Elf64_Ehdr.EM_X86_64; 58 } else { 59 System.out.println("Unsupported architecture " + archStr); 60 arch = Elf64_Ehdr.EM_NONE; 61 } 62 63 osName = System.getProperty("os.name").toLowerCase(); 64 if (!osName.equals("linux") && !osName.equals("sunos")) { 65 System.out.println("Unsupported Operating System " + osName); 66 osName = "Unknown"; 67 } 68 } 69 70 static char getElfArch() { 71 return arch; 72 } 73 74 static int getElfEndian() { 75 return endian; 76 } 77 | 38 39 /** 40 * Architecture endian-ness. 41 */ 42 private static final int endian = Elf64_Ehdr.ELFDATA2LSB; 43 44 /** 45 * Target OS string. 46 */ 47 private static String osName; 48 49 static { 50 // Find the target arch details 51 String archStr = System.getProperty("os.arch").toLowerCase(); 52 if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { 53 System.out.println("Only Little Endian byte order supported!"); 54 } 55 56 if (archStr.equals("amd64") || archStr.equals("x86_64")) { 57 arch = Elf64_Ehdr.EM_X86_64; 58 } else if (archStr.equals("amd64") || archStr.equals("aarch64")) { 59 arch = Elf64_Ehdr.EM_AARCH64; 60 } else { 61 System.out.println("Unsupported architecture " + archStr); 62 arch = Elf64_Ehdr.EM_NONE; 63 } 64 65 osName = System.getProperty("os.name").toLowerCase(); 66 if (!osName.equals("linux") && !osName.equals("sunos")) { 67 System.out.println("Unsupported Operating System " + osName); 68 osName = "Unknown"; 69 } 70 } 71 72 static char getElfArch() { 73 return arch; 74 } 75 76 static int getElfEndian() { 77 return endian; 78 } 79 |