diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-10-29 00:52:23 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-10-29 00:52:23 +0000 |
commit | 71fad980c5dfe057dd380a05f1ca1e0bfad2ef1f (patch) | |
tree | 84f10662c214892091c5b7d5dce796b6f736c6b4 /nuttx/binfmt/libelf/libelf_load.c | |
parent | 61c97b1ddcc40f068e549d12dc8e63445d3ee4f5 (diff) | |
download | px4-firmware-71fad980c5dfe057dd380a05f1ca1e0bfad2ef1f.tar.gz px4-firmware-71fad980c5dfe057dd380a05f1ca1e0bfad2ef1f.tar.bz2 px4-firmware-71fad980c5dfe057dd380a05f1ca1e0bfad2ef1f.zip |
Finish implemention of ELF loader static constructor support. Still some issues.
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5272 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/binfmt/libelf/libelf_load.c')
-rw-r--r-- | nuttx/binfmt/libelf/libelf_load.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/nuttx/binfmt/libelf/libelf_load.c b/nuttx/binfmt/libelf/libelf_load.c index 6526004f7..505e2c813 100644 --- a/nuttx/binfmt/libelf/libelf_load.c +++ b/nuttx/binfmt/libelf/libelf_load.c @@ -126,14 +126,8 @@ static inline int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo) if (ret < 0) { bdbg("Failed to read section header table: %d\n", ret); - goto errout_with_alloc; } - return OK; - -errout_with_alloc: - kfree(loadinfo->shdr); - loadinfo->shdr = 0; return ret; } @@ -233,7 +227,7 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo) if (ret < 0) { bdbg("Failed to read section %d: %d\n", i, ret); - goto errout_with_alloc; + return ret; } } @@ -248,11 +242,6 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo) } return OK; - -errout_with_alloc: - kfree((FAR void*)loadinfo->alloc); - loadinfo->alloc = 0; - return ret; } /**************************************************************************** @@ -285,7 +274,7 @@ int elf_load(FAR struct elf_loadinfo_s *loadinfo) if (ret < 0) { bdbg("elf_loadshdrs failed: %d\n", ret); - return ret; + goto errout_with_buffers; } /* Determine total size to allocate */ @@ -298,16 +287,17 @@ int elf_load(FAR struct elf_loadinfo_s *loadinfo) if (ret < 0) { bdbg("elf_loadfile failed: %d\n", ret); - goto errout_with_shdrs; + goto errout_with_buffers; } /* Find static constructors. */ #ifdef CONFIG_ELF_CONSTRUCTORS - ret = elf_findctors(loadinfo); + ret = elf_loadctors(loadinfo); + if (ret < 0) { - bdbg("elf_findctors failed: %d\n", ret); - goto errout_with_shdrs; + bdbg("elf_loadctors failed: %d\n", ret); + goto errout_with_buffers; } #endif @@ -315,9 +305,8 @@ int elf_load(FAR struct elf_loadinfo_s *loadinfo) /* Error exits */ -errout_with_shdrs: - kfree(loadinfo->shdr); - loadinfo->shdr = NULL; +errout_with_buffers: + elf_freebuffers(loadinfo); return ret; } |