* @brief Clean up resources allocated during ELF loading. * * This function releases all resources (file descriptors, memory, etc.) that were * allocated during the ELF loading process. It ensures that no memory leaks occur * and all file descriptors are properly closed. * * @param load_info Pointer to the structure containing ELF loading information. */
| 894 | * @param load_info Pointer to the structure containing ELF loading information. |
| 895 | */ |
| 896 | static void elf_load_deinit(elf_load_info_t *load_info) |
| 897 | { |
| 898 | if (load_info->exec_info.fd != ELF_INVALID_FD) |
| 899 | { |
| 900 | elf_file_close(load_info->exec_info.fd); |
| 901 | } |
| 902 | |
| 903 | if (load_info->interp_info.fd != ELF_INVALID_FD) |
| 904 | { |
| 905 | elf_file_close(load_info->interp_info.fd); |
| 906 | } |
| 907 | |
| 908 | if (load_info->exec_info.phdr != RT_NULL) |
| 909 | { |
| 910 | rt_free(load_info->exec_info.phdr); |
| 911 | } |
| 912 | |
| 913 | if (load_info->exec_info.filename != RT_NULL) |
| 914 | { |
| 915 | rt_free(load_info->exec_info.filename); |
| 916 | } |
| 917 | |
| 918 | if (load_info->interp_info.phdr != RT_NULL) |
| 919 | { |
| 920 | rt_free(load_info->interp_info.phdr); |
| 921 | } |
| 922 | |
| 923 | if (load_info->interp_info.filename != RT_NULL) |
| 924 | { |
| 925 | rt_free(load_info->interp_info.filename); |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | /** |
| 930 | * @brief Load the ELF header and program header information. |
no test coverage detected