MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / elf_load_deinit

Function elf_load_deinit

components/lwp/lwp_elf.c:896–927  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

894 * @param load_info Pointer to the structure containing ELF loading information.
895 */
896static 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.

Callers 1

elf_file_loadFunction · 0.85

Calls 2

elf_file_closeFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected