summaryrefslogtreecommitdiff
path: root/nuttx/binfmt/libnxflat/libnxflat_bind.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-10-24 16:46:12 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-10-24 16:46:12 +0000
commit31d66d5fb2961c4c2df0d9f415f91ee5405f8d19 (patch)
tree199c1ac47d5ce30532f7b23121bc7df2c580a8c6 /nuttx/binfmt/libnxflat/libnxflat_bind.c
parente2cd590a6f7e1a4132d2eda16e1f29c760b804bb (diff)
downloadpx4-nuttx-31d66d5fb2961c4c2df0d9f415f91ee5405f8d19.tar.gz
px4-nuttx-31d66d5fb2961c4c2df0d9f415f91ee5405f8d19.tar.bz2
px4-nuttx-31d66d5fb2961c4c2df0d9f415f91ee5405f8d19.zip
Add framework to support loadable ELF modules (not much logic in place yet)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5250 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/binfmt/libnxflat/libnxflat_bind.c')
-rw-r--r--nuttx/binfmt/libnxflat/libnxflat_bind.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/nuttx/binfmt/libnxflat/libnxflat_bind.c b/nuttx/binfmt/libnxflat/libnxflat_bind.c
index ca348178d..c18a16cd8 100644
--- a/nuttx/binfmt/libnxflat/libnxflat_bind.c
+++ b/nuttx/binfmt/libnxflat/libnxflat_bind.c
@@ -263,7 +263,6 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
result = OK;
switch (NXFLAT_RELOC_TYPE(reloc.r_info))
{
-
/* NXFLAT_RELOC_TYPE_REL32I Meaning: Object file contains a 32-bit offset
* into I-Space at the offset.
* Fixup: Add mapped I-Space address to the offset.
@@ -329,6 +328,7 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
nxflat_dumpbuffer("GOT", (FAR const uint8_t*)relocs, nrelocs * sizeof(struct nxflat_reloc_s));
}
#endif
+
return ret;
}
@@ -388,7 +388,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
offset < loadinfo->isize + loadinfo->dsize);
imports = (struct nxflat_import_s*)
- (offset - loadinfo->isize + loadinfo->dspace->region);
+ (offset - loadinfo->isize + loadinfo->dspace->region);
/* Now, traverse the list of imported symbols and attempt to bind
* each symbol to the value exported by from the exported symbol
@@ -396,41 +396,41 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
*/
for (i = 0; i < nimports; i++)
- {
- bvdbg("Import[%d] (%08p) offset: %08x func: %08x\n",
- i, &imports[i], imports[i].i_funcname, imports[i].i_funcaddress);
+ {
+ bvdbg("Import[%d] (%08p) offset: %08x func: %08x\n",
+ i, &imports[i], imports[i].i_funcname, imports[i].i_funcaddress);
- /* Get a pointer to the imported symbol name. The name itself
- * lies in the TEXT segment. But the reference to the name
- * lies in DATA segment. Therefore, the name reference should
- * have been relocated when the module was loaded.
- */
+ /* Get a pointer to the imported symbol name. The name itself
+ * lies in the TEXT segment. But the reference to the name
+ * lies in DATA segment. Therefore, the name reference should
+ * have been relocated when the module was loaded.
+ */
offset = imports[i].i_funcname;
DEBUGASSERT(offset < loadinfo->isize);
- symname = (char*)(offset + loadinfo->ispace + sizeof(struct nxflat_hdr_s));
+ symname = (char*)(offset + loadinfo->ispace + sizeof(struct nxflat_hdr_s));
- /* Find the exported symbol value for this this symbol name. */
+ /* Find the exported symbol value for this this symbol name. */
#ifdef CONFIG_SYMTAB_ORDEREDBYNAME
symbol = symtab_findorderedbyname(exports, symname, nexports);
#else
symbol = symtab_findbyname(exports, symname, nexports);
#endif
- if (!symbol)
- {
- bdbg("Exported symbol \"%s\" not found\n", symname);
+ if (!symbol)
+ {
+ bdbg("Exported symbol \"%s\" not found\n", symname);
return -ENOENT;
- }
+ }
- /* And put this into the module's import structure. */
+ /* And put this into the module's import structure. */
- imports[i].i_funcaddress = (uint32_t)symbol->sym_value;
+ imports[i].i_funcaddress = (uint32_t)symbol->sym_value;
- bvdbg("Bound import[%d] (%08p) to export '%s' (%08x)\n",
- i, &imports[i], symname, imports[i].i_funcaddress);
- }
+ bvdbg("Bound import[%d] (%08p) to export '%s' (%08x)\n",
+ i, &imports[i], symname, imports[i].i_funcaddress);
+ }
}
/* Dump the relocation import table */
@@ -441,6 +441,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
nxflat_dumpbuffer("Imports", (FAR const uint8_t*)imports, nimports * sizeof(struct nxflat_import_s));
}
#endif
+
return OK;
}
@@ -484,9 +485,10 @@ int nxflat_bind(FAR struct nxflat_loadinfo_s *loadinfo,
*/
memset((void*)(loadinfo->dspace->region + loadinfo->datasize),
- 0, loadinfo->bsssize);
+ 0, loadinfo->bsssize);
}
}
+
return ret;
}