1 // 2 // Copyright (c) 2010-2024 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using System; 8 using Antmicro.Renode.Exceptions; 9 using ELFSharp.ELF; 10 11 namespace Antmicro.Renode.Utilities 12 { 13 public static class ELFUtils 14 { LoadELF(ReadFilePath fileName)15 public static IELF LoadELF(ReadFilePath fileName) 16 { 17 try 18 { 19 if(!ELFReader.TryLoad(fileName, out var result)) 20 { 21 throw new RecoverableException($"Could not load ELF from path: {fileName}"); 22 } 23 return result; 24 } 25 catch(Exception e) 26 { 27 // ELF creating exception are recoverable in the sense of emulator state 28 throw new RecoverableException($"Error while loading ELF: {e.Message}", e); 29 } 30 } 31 } 32 } 33 34