mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
binfmt/: More spacing/alignment fixes
This commit is contained in:
@@ -159,7 +159,7 @@ int exec_module(FAR const struct binary_s *binp)
|
|||||||
|
|
||||||
/* Allocate a TCB for the new task. */
|
/* Allocate a TCB for the new task. */
|
||||||
|
|
||||||
tcb = (FAR struct task_tcb_s*)kmm_zalloc(sizeof(struct task_tcb_s));
|
tcb = (FAR struct task_tcb_s *)kmm_zalloc(sizeof(struct task_tcb_s));
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
@@ -189,7 +189,7 @@ int exec_module(FAR const struct binary_s *binp)
|
|||||||
* will need to change if/when we want to support dynamic stack allocation.
|
* will need to change if/when we want to support dynamic stack allocation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
stack = (FAR uint32_t*)kumm_malloc(binp->stacksize);
|
stack = (FAR uint32_t *)kumm_malloc(binp->stacksize);
|
||||||
if (!stack)
|
if (!stack)
|
||||||
{
|
{
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ FAR char *exepath_next(EXEPATH_HANDLE handle, FAR const char *relpath)
|
|||||||
* in the PATH variable have been considered.
|
* in the PATH variable have been considered.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (;;)
|
for (; ; )
|
||||||
{
|
{
|
||||||
/* Make sure that exepath->next points to the beginning of a string */
|
/* Make sure that exepath->next points to the beginning of a string */
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ FAR char *exepath_next(EXEPATH_HANDLE handle, FAR const char *relpath)
|
|||||||
|
|
||||||
/* Verify that a regular file exists at this path */
|
/* Verify that a regular file exists at this path */
|
||||||
|
|
||||||
ret = stat(fullpath, &buf);;
|
ret = stat(fullpath, &buf);
|
||||||
if (ret == OK && S_ISREG(buf.st_mode))
|
if (ret == OK && S_ISREG(buf.st_mode))
|
||||||
{
|
{
|
||||||
return fullpath;
|
return fullpath;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ FAR struct binary_s *g_unloadhead;
|
|||||||
* pid - The task ID of the child task
|
* pid - The task ID of the child task
|
||||||
* bin - This structure must have been allocated with kmm_malloc() and must
|
* bin - This structure must have been allocated with kmm_malloc() and must
|
||||||
* persist until the task unloads
|
* persist until the task unloads
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
|
|||||||
+1
-1
@@ -198,7 +198,7 @@ static void elf_dumpentrypt(FAR struct binary_s *binp,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
elf_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
|
elf_dumpbuffer("Entry code", (FAR const uint8_t *)binp->entrypt,
|
||||||
MIN(loadinfo->textsize - loadinfo->ehdr.e_entry, 512));
|
MIN(loadinfo->textsize - loadinfo->ehdr.e_entry, 512));
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ static inline int elf_readrel(FAR struct elf_loadinfo_s *loadinfo,
|
|||||||
|
|
||||||
/* And, finally, read the symbol table entry into memory */
|
/* And, finally, read the symbol table entry into memory */
|
||||||
|
|
||||||
return elf_read(loadinfo, (FAR uint8_t*)rel, sizeof(Elf32_Rel), offset);
|
return elf_read(loadinfo, (FAR uint8_t *)rel, sizeof(Elf32_Rel), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
{
|
{
|
||||||
/* Allocate memory to hold a copy of the .ctor section */
|
/* Allocate memory to hold a copy of the .ctor section */
|
||||||
|
|
||||||
loadinfo->ctoralloc = (binfmt_ctor_t*)kumm_malloc(ctorsize);
|
loadinfo->ctoralloc = (binfmt_ctor_t *)kumm_malloc(ctorsize);
|
||||||
if (!loadinfo->ctoralloc)
|
if (!loadinfo->ctoralloc)
|
||||||
{
|
{
|
||||||
bdbg("Failed to allocate memory for .ctors\n");
|
bdbg("Failed to allocate memory for .ctors\n");
|
||||||
@@ -174,7 +174,7 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
/* Read the section header table into memory */
|
/* Read the section header table into memory */
|
||||||
|
|
||||||
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->ctors, ctorsize,
|
ret = elf_read(loadinfo, (FAR uint8_t *)loadinfo->ctors, ctorsize,
|
||||||
shdr->sh_offset);
|
shdr->sh_offset);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@@ -206,7 +206,7 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
* will be relocated via the normal mechanism.
|
* will be relocated via the normal mechanism.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
loadinfo->ctors = (binfmt_ctor_t*)shdr->sh_addr;
|
loadinfo->ctors = (binfmt_ctor_t *)shdr->sh_addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
{
|
{
|
||||||
/* Allocate memory to hold a copy of the .dtor section */
|
/* Allocate memory to hold a copy of the .dtor section */
|
||||||
|
|
||||||
loadinfo->ctoralloc = (binfmt_dtor_t*)kumm_malloc(dtorsize);
|
loadinfo->ctoralloc = (binfmt_dtor_t *)kumm_malloc(dtorsize);
|
||||||
if (!loadinfo->ctoralloc)
|
if (!loadinfo->ctoralloc)
|
||||||
{
|
{
|
||||||
bdbg("Failed to allocate memory for .dtors\n");
|
bdbg("Failed to allocate memory for .dtors\n");
|
||||||
@@ -174,7 +174,7 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
/* Read the section header table into memory */
|
/* Read the section header table into memory */
|
||||||
|
|
||||||
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->dtors, dtorsize,
|
ret = elf_read(loadinfo, (FAR uint8_t *)loadinfo->dtors, dtorsize,
|
||||||
shdr->sh_offset);
|
shdr->sh_offset);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@@ -206,7 +206,7 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
* will be relocated via the normal mechanism.
|
* will be relocated via the normal mechanism.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
loadinfo->dtors = (binfmt_dtor_t*)shdr->sh_addr;
|
loadinfo->dtors = (binfmt_dtor_t *)shdr->sh_addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,19 +172,19 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
/* Read the ELF ehdr from offset 0 */
|
/* Read the ELF ehdr from offset 0 */
|
||||||
|
|
||||||
ret = elf_read(loadinfo, (FAR uint8_t*)&loadinfo->ehdr, sizeof(Elf32_Ehdr), 0);
|
ret = elf_read(loadinfo, (FAR uint8_t *)&loadinfo->ehdr, sizeof(Elf32_Ehdr), 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
bdbg("Failed to read ELF header: %d\n", ret);
|
bdbg("Failed to read ELF header: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
elf_dumpbuffer("ELF header", (FAR const uint8_t*)&loadinfo->ehdr, sizeof(Elf32_Ehdr));
|
elf_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr, sizeof(Elf32_Ehdr));
|
||||||
|
|
||||||
/* Verify the ELF header */
|
/* Verify the ELF header */
|
||||||
|
|
||||||
ret = elf_verifyheader(&loadinfo->ehdr);
|
ret = elf_verifyheader(&loadinfo->ehdr);
|
||||||
if (ret <0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* This may not be an error because we will be called to attempt loading
|
/* This may not be an error because we will be called to attempt loading
|
||||||
* EVERY binary. If elf_verifyheader() does not recognize the ELF header,
|
* EVERY binary. If elf_verifyheader() does not recognize the ELF header,
|
||||||
|
|||||||
@@ -157,8 +157,8 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
/* Read each section into memory that is marked SHF_ALLOC + SHT_NOBITS */
|
/* Read each section into memory that is marked SHF_ALLOC + SHT_NOBITS */
|
||||||
|
|
||||||
bvdbg("Loaded sections:\n");
|
bvdbg("Loaded sections:\n");
|
||||||
text = (FAR uint8_t*)loadinfo->textalloc;
|
text = (FAR uint8_t *)loadinfo->textalloc;
|
||||||
data = (FAR uint8_t*)loadinfo->dataalloc;
|
data = (FAR uint8_t *)loadinfo->dataalloc;
|
||||||
|
|
||||||
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
|
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,9 +68,9 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(ELF_DUMP_READDATA)
|
#if defined(ELF_DUMP_READDATA)
|
||||||
static inline void elf_dumpreaddata(char *buffer, int buflen)
|
static inline void elf_dumpreaddata(FAR char *buffer, int buflen)
|
||||||
{
|
{
|
||||||
uint32_t *buf32 = (uint32_t*)buffer;
|
FAR uint32_t *buf32 = (FAR uint32_t *)buffer;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ static inline int elf_sectname(FAR struct elf_loadinfo_s *loadinfo,
|
|||||||
buffer = loadinfo->iobuffer;
|
buffer = loadinfo->iobuffer;
|
||||||
bytesread = 0;
|
bytesread = 0;
|
||||||
|
|
||||||
for (;;)
|
for (; ; )
|
||||||
{
|
{
|
||||||
/* Get the number of bytes to read */
|
/* Get the number of bytes to read */
|
||||||
|
|
||||||
@@ -211,16 +211,18 @@ int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
/* Allocate memory to hold a working copy of the sector header table */
|
/* Allocate memory to hold a working copy of the sector header table */
|
||||||
|
|
||||||
loadinfo->shdr = (FAR Elf32_Shdr*)kmm_malloc(shdrsize);
|
loadinfo->shdr = (FAR FAR Elf32_Shdr *)kmm_malloc(shdrsize);
|
||||||
if (!loadinfo->shdr)
|
if (!loadinfo->shdr)
|
||||||
{
|
{
|
||||||
bdbg("Failed to allocate the section header table. Size: %ld\n", (long)shdrsize);
|
bdbg("Failed to allocate the section header table. Size: %ld\n",
|
||||||
|
(long)shdrsize);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the section header table into memory */
|
/* Read the section header table into memory */
|
||||||
|
|
||||||
ret = elf_read(loadinfo, (FAR uint8_t*)loadinfo->shdr, shdrsize, loadinfo->ehdr.e_shoff);
|
ret = elf_read(loadinfo, (FAR uint8_t *)loadinfo->shdr, shdrsize,
|
||||||
|
loadinfo->ehdr.e_shoff);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
bdbg("Failed to read section header table: %d\n", ret);
|
bdbg("Failed to read section header table: %d\n", ret);
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ static int elf_symname(FAR struct elf_loadinfo_s *loadinfo,
|
|||||||
|
|
||||||
bytesread = 0;
|
bytesread = 0;
|
||||||
|
|
||||||
for (;;)
|
for (; ; )
|
||||||
{
|
{
|
||||||
/* Get the number of bytes to read */
|
/* Get the number of bytes to read */
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
|
|||||||
|
|
||||||
/* And, finally, read the symbol table entry into memory */
|
/* And, finally, read the symbol table entry into memory */
|
||||||
|
|
||||||
return elf_read(loadinfo, (FAR uint8_t*)sym, sizeof(Elf32_Sym), offset);
|
return elf_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf32_Sym), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -53,7 +53,10 @@
|
|||||||
* Private Constant Data
|
* Private Constant Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static const char g_elfmagic[EI_MAGIC_SIZE] = { 0x7f, 'E', 'L', 'F' };
|
static const char g_elfmagic[EI_MAGIC_SIZE] =
|
||||||
|
{
|
||||||
|
0x7f, 'E', 'L', 'F'
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
|
|||||||
@@ -102,14 +102,14 @@
|
|||||||
static inline int nxflat_bindrel32i(FAR struct nxflat_loadinfo_s *loadinfo,
|
static inline int nxflat_bindrel32i(FAR struct nxflat_loadinfo_s *loadinfo,
|
||||||
uint32_t offset)
|
uint32_t offset)
|
||||||
{
|
{
|
||||||
uint32_t *addr;
|
FAR uint32_t *addr;
|
||||||
|
|
||||||
bvdbg("NXFLAT_RELOC_TYPE_REL32I Offset: %08x I-Space: %p\n",
|
bvdbg("NXFLAT_RELOC_TYPE_REL32I Offset: %08x I-Space: %p\n",
|
||||||
offset, loadinfo->ispace + sizeof(struct nxflat_hdr_s));
|
offset, loadinfo->ispace + sizeof(struct nxflat_hdr_s));
|
||||||
|
|
||||||
if (offset < loadinfo->dsize)
|
if (offset < loadinfo->dsize)
|
||||||
{
|
{
|
||||||
addr = (uint32_t*)(offset + loadinfo->dspace->region);
|
addr = (FAR uint32_t *)(offset + loadinfo->dspace->region);
|
||||||
bvdbg(" Before: %08x\n", *addr);
|
bvdbg(" Before: %08x\n", *addr);
|
||||||
*addr += (uint32_t)(loadinfo->ispace + sizeof(struct nxflat_hdr_s));
|
*addr += (uint32_t)(loadinfo->ispace + sizeof(struct nxflat_hdr_s));
|
||||||
bvdbg(" After: %08x\n", *addr);
|
bvdbg(" After: %08x\n", *addr);
|
||||||
@@ -141,14 +141,14 @@ static inline int nxflat_bindrel32i(FAR struct nxflat_loadinfo_s *loadinfo,
|
|||||||
static inline int nxflat_bindrel32d(FAR struct nxflat_loadinfo_s *loadinfo,
|
static inline int nxflat_bindrel32d(FAR struct nxflat_loadinfo_s *loadinfo,
|
||||||
uint32_t offset)
|
uint32_t offset)
|
||||||
{
|
{
|
||||||
uint32_t *addr;
|
FAR uint32_t *addr;
|
||||||
|
|
||||||
bvdbg("NXFLAT_RELOC_TYPE_REL32D Offset: %08x D-Space: %p\n",
|
bvdbg("NXFLAT_RELOC_TYPE_REL32D Offset: %08x D-Space: %p\n",
|
||||||
offset, loadinfo->dspace->region);
|
offset, loadinfo->dspace->region);
|
||||||
|
|
||||||
if (offset < loadinfo->dsize)
|
if (offset < loadinfo->dsize)
|
||||||
{
|
{
|
||||||
addr = (uint32_t*)(offset + loadinfo->dspace->region);
|
addr = (FAR uint32_t *)(offset + loadinfo->dspace->region);
|
||||||
bvdbg(" Before: %08x\n", *addr);
|
bvdbg(" Before: %08x\n", *addr);
|
||||||
*addr += (uint32_t)(loadinfo->dspace->region);
|
*addr += (uint32_t)(loadinfo->dspace->region);
|
||||||
bvdbg(" After: %08x\n", *addr);
|
bvdbg(" After: %08x\n", *addr);
|
||||||
@@ -183,14 +183,14 @@ static inline int nxflat_bindrel32d(FAR struct nxflat_loadinfo_s *loadinfo,
|
|||||||
static inline int nxflat_bindrel32id(FAR struct nxflat_loadinfo_s *loadinfo,
|
static inline int nxflat_bindrel32id(FAR struct nxflat_loadinfo_s *loadinfo,
|
||||||
uint32_t offset)
|
uint32_t offset)
|
||||||
{
|
{
|
||||||
uint32_t *addr;
|
FAR uint32_t *addr;
|
||||||
|
|
||||||
bvdbg("NXFLAT_RELOC_TYPE_REL32D Offset: %08x D-Space: %p\n",
|
bvdbg("NXFLAT_RELOC_TYPE_REL32D Offset: %08x D-Space: %p\n",
|
||||||
offset, loadinfo->dspace->region);
|
offset, loadinfo->dspace->region);
|
||||||
|
|
||||||
if (offset < loadinfo->dsize)
|
if (offset < loadinfo->dsize)
|
||||||
{
|
{
|
||||||
addr = (uint32_t*)(offset + loadinfo->dspace->region);
|
addr = (FAR uint32_t *)(offset + loadinfo->dspace->region);
|
||||||
bvdbg(" Before: %08x\n", *addr);
|
bvdbg(" Before: %08x\n", *addr);
|
||||||
*addr += ((uint32_t)loadinfo->ispace - (uint32_t)(loadinfo->dspace->region));
|
*addr += ((uint32_t)loadinfo->ispace - (uint32_t)(loadinfo->dspace->region));
|
||||||
bvdbg(" After: %08x\n", *addr);
|
bvdbg(" After: %08x\n", *addr);
|
||||||
@@ -231,7 +231,7 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
/* The NXFLAT header is the first thing at the beginning of the ISpace. */
|
/* The NXFLAT header is the first thing at the beginning of the ISpace. */
|
||||||
|
|
||||||
hdr = (FAR struct nxflat_hdr_s*)loadinfo->ispace;
|
hdr = (FAR struct nxflat_hdr_s *)loadinfo->ispace;
|
||||||
|
|
||||||
/* From this, we can get the offset to the list of relocation entries */
|
/* From this, we can get the offset to the list of relocation entries */
|
||||||
|
|
||||||
@@ -348,8 +348,8 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
|
|||||||
#ifdef CONFIG_NXFLAT_DUMPBUFFER
|
#ifdef CONFIG_NXFLAT_DUMPBUFFER
|
||||||
if (ret == OK && nrelocs > 0)
|
if (ret == OK && nrelocs > 0)
|
||||||
{
|
{
|
||||||
relocs = (FAR struct nxflat_reloc_s*)(offset - loadinfo->isize + loadinfo->dspace->region);
|
relocs = (FAR struct nxflat_reloc_s *)(offset - loadinfo->isize + loadinfo->dspace->region);
|
||||||
nxflat_dumpbuffer("GOT", (FAR const uint8_t*)relocs, nrelocs * sizeof(struct nxflat_reloc_s));
|
nxflat_dumpbuffer("GOT", (FAR const uint8_t *)relocs, nrelocs * sizeof(struct nxflat_reloc_s));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -397,7 +397,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
|
|||||||
|
|
||||||
/* The NXFLAT header is the first thing at the beginning of the ISpace. */
|
/* The NXFLAT header is the first thing at the beginning of the ISpace. */
|
||||||
|
|
||||||
hdr = (FAR struct nxflat_hdr_s*)loadinfo->ispace;
|
hdr = (FAR struct nxflat_hdr_s *)loadinfo->ispace;
|
||||||
|
|
||||||
/* From this, we can get the offset to the list of symbols imported by
|
/* From this, we can get the offset to the list of symbols imported by
|
||||||
* this module and the number of symbols imported by this module.
|
* this module and the number of symbols imported by this module.
|
||||||
@@ -440,7 +440,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
|
|||||||
DEBUGASSERT(offset >= loadinfo->isize &&
|
DEBUGASSERT(offset >= loadinfo->isize &&
|
||||||
offset < loadinfo->isize + loadinfo->dsize);
|
offset < loadinfo->isize + loadinfo->dsize);
|
||||||
|
|
||||||
imports = (struct nxflat_import_s*)
|
imports = (FAR 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
|
/* Now, traverse the list of imported symbols and attempt to bind
|
||||||
@@ -462,7 +462,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
|
|||||||
offset = imports[i].i_funcname;
|
offset = imports[i].i_funcname;
|
||||||
DEBUGASSERT(offset < loadinfo->isize);
|
DEBUGASSERT(offset < loadinfo->isize);
|
||||||
|
|
||||||
symname = (char*)(offset + loadinfo->ispace + sizeof(struct nxflat_hdr_s));
|
symname = (FAR 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. */
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
|
|||||||
#ifdef CONFIG_NXFLAT_DUMPBUFFER
|
#ifdef CONFIG_NXFLAT_DUMPBUFFER
|
||||||
if (nimports > 0)
|
if (nimports > 0)
|
||||||
{
|
{
|
||||||
nxflat_dumpbuffer("Imports", (FAR const uint8_t*)imports, nimports * sizeof(struct nxflat_import_s));
|
nxflat_dumpbuffer("Imports", (FAR const uint8_t *)imports, nimports * sizeof(struct nxflat_import_s));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ static inline int nxflat_clearbss(FAR struct nxflat_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
/* Zero the BSS area */
|
/* Zero the BSS area */
|
||||||
|
|
||||||
memset((void*)(loadinfo->dspace->region + loadinfo->datasize), 0,
|
memset((FAR void *)(loadinfo->dspace->region + loadinfo->datasize), 0,
|
||||||
loadinfo->bsssize);
|
loadinfo->bsssize);
|
||||||
|
|
||||||
/* Restore the original address environment */
|
/* Restore the original address environment */
|
||||||
|
|||||||
@@ -118,14 +118,15 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
/* Read the NXFLAT header from offset 0 */
|
/* Read the NXFLAT header from offset 0 */
|
||||||
|
|
||||||
ret = nxflat_read(loadinfo, (char*)&loadinfo->header,
|
ret = nxflat_read(loadinfo, (FAR char *)&loadinfo->header,
|
||||||
sizeof(struct nxflat_hdr_s), 0);
|
sizeof(struct nxflat_hdr_s), 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
bdbg("Failed to read NXFLAT header: %d\n", ret);
|
bdbg("Failed to read NXFLAT header: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
nxflat_dumpbuffer("NXFLAT header", (FAR const uint8_t*)&loadinfo->header,
|
|
||||||
|
nxflat_dumpbuffer("NXFLAT header", (FAR const uint8_t *)&loadinfo->header,
|
||||||
sizeof(struct nxflat_hdr_s));
|
sizeof(struct nxflat_hdr_s));
|
||||||
|
|
||||||
/* Verify the NXFLAT header */
|
/* Verify the NXFLAT header */
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ int nxflat_load(struct nxflat_loadinfo_s *loadinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
loadinfo->ispace = (uint32_t)mmap(NULL, loadinfo->isize, PROT_READ,
|
loadinfo->ispace = (uint32_t)mmap(NULL, loadinfo->isize, PROT_READ,
|
||||||
MAP_SHARED|MAP_FILE, loadinfo->filfd, 0);
|
MAP_SHARED | MAP_FILE, loadinfo->filfd, 0);
|
||||||
if (loadinfo->ispace == (uint32_t)MAP_FAILED)
|
if (loadinfo->ispace == (uint32_t)MAP_FAILED)
|
||||||
{
|
{
|
||||||
bdbg("Failed to map NXFLAT ISpace: %d\n", errno);
|
bdbg("Failed to map NXFLAT ISpace: %d\n", errno);
|
||||||
@@ -189,7 +189,8 @@ int nxflat_load(struct nxflat_loadinfo_s *loadinfo)
|
|||||||
* DSpace memory.
|
* DSpace memory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = nxflat_read(loadinfo, (char*)loadinfo->dspace->region, dreadsize, doffset);
|
ret = nxflat_read(loadinfo, (FAR char *)loadinfo->dspace->region,
|
||||||
|
dreadsize, doffset);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
bdbg("Failed to read .data section: %d\n", ret);
|
bdbg("Failed to read .data section: %d\n", ret);
|
||||||
|
|||||||
@@ -69,9 +69,9 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(NXFLAT_DUMP_READDATA)
|
#if defined(NXFLAT_DUMP_READDATA)
|
||||||
static inline void nxflat_dumpreaddata(char *buffer, int buflen)
|
static inline void nxflat_dumpreaddata(FAR char *buffer, int buflen)
|
||||||
{
|
{
|
||||||
uint32_t *buf32 = (uint32_t*)buffer;
|
FAR uint32_t *buf32 = (FAR uint32_t *)buffer;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
|||||||
@@ -79,14 +79,14 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nxflat_unload(struct nxflat_loadinfo_s *loadinfo)
|
int nxflat_unload(FAR struct nxflat_loadinfo_s *loadinfo)
|
||||||
{
|
{
|
||||||
/* Release the memory segments */
|
/* Release the memory segments */
|
||||||
/* Release the I-Space mmap'ed file */
|
/* Release the I-Space mmap'ed file */
|
||||||
|
|
||||||
if (loadinfo->ispace)
|
if (loadinfo->ispace)
|
||||||
{
|
{
|
||||||
munmap((void*)loadinfo->ispace, loadinfo->isize);
|
munmap((FAR void *)loadinfo->ispace, loadinfo->isize);
|
||||||
loadinfo->ispace = 0;
|
loadinfo->ispace = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -187,7 +187,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
binp->entrypt = (main_t)(loadinfo.ispace + loadinfo.entryoffs);
|
binp->entrypt = (main_t)(loadinfo.ispace + loadinfo.entryoffs);
|
||||||
binp->mapped = (void*)loadinfo.ispace;
|
binp->mapped = (FAR void *)loadinfo.ispace;
|
||||||
binp->mapsize = loadinfo.isize;
|
binp->mapsize = loadinfo.isize;
|
||||||
binp->stacksize = loadinfo.stacksize;
|
binp->stacksize = loadinfo.stacksize;
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
|
|||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
# warning "REVISIT"
|
# warning "REVISIT"
|
||||||
#else
|
#else
|
||||||
binp->alloc[0] = (void*)loadinfo.dspace;
|
binp->alloc[0] = (FAR void *)loadinfo.dspace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
@@ -213,7 +213,7 @@ static int nxflat_loadbinary(struct binary_s *binp)
|
|||||||
up_addrenv_clone(&loadinfo.addrenv, &binp->addrenv);
|
up_addrenv_clone(&loadinfo.addrenv, &binp->addrenv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nxflat_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
|
nxflat_dumpbuffer("Entry code", (FAR const uint8_t *)binp->entrypt,
|
||||||
MIN(loadinfo.isize - loadinfo.entryoffs, 512));
|
MIN(loadinfo.isize - loadinfo.entryoffs, 512));
|
||||||
|
|
||||||
nxflat_uninit(&loadinfo);
|
nxflat_uninit(&loadinfo);
|
||||||
|
|||||||
+1
-1
@@ -352,7 +352,7 @@ static int pcode_load(struct binary_s *binp)
|
|||||||
{
|
{
|
||||||
/* Set up for the next gulp */
|
/* Set up for the next gulp */
|
||||||
|
|
||||||
DEBUGASSERT(nread > 0 && nread <=remaining);
|
DEBUGASSERT(nread > 0 && nread <= remaining);
|
||||||
remaining -= nread;
|
remaining -= nread;
|
||||||
ptr += nread;
|
ptr += nread;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ symtab_findorderedbyvalue(FAR const struct symtab_s *symtab,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mid = (low + high) >> 1;
|
mid = (low + high) >> 1;
|
||||||
if ( value < symtab[mid].sym_value)
|
if (value < symtab[mid].sym_value)
|
||||||
{
|
{
|
||||||
high = mid - 1;
|
high = mid - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user