mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
binfmt/: Run all .c files under binfmt/ through tools/nxstyle and fix all resulting complaints.
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
98f431d8d8
commit
7a72d1e8ca
@@ -53,6 +53,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* This is an artificial limit to detect error conditions where an argv[]
|
/* This is an artificial limit to detect error conditions where an argv[]
|
||||||
* list is not properly terminated.
|
* list is not properly terminated.
|
||||||
*/
|
*/
|
||||||
@@ -60,7 +61,7 @@
|
|||||||
#define MAX_EXEC_ARGS 256
|
#define MAX_EXEC_ARGS 256
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ int exec(FAR const char *filename, FAR char * const *argv,
|
|||||||
kmm_free(bin);
|
kmm_free(bin);
|
||||||
|
|
||||||
/* TODO: How does the module get unloaded in this case? */
|
/* TODO: How does the module get unloaded in this case? */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
@@ -212,7 +213,6 @@ errout_with_bin:
|
|||||||
errout:
|
errout:
|
||||||
set_errno(errcode);
|
set_errno(errcode);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !CONFIG_BINFMT_DISABLE */
|
#endif /* !CONFIG_BINFMT_DISABLE */
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* If CONFIG_LIBC_EXECFUNCS is defined in the configuration, then the
|
/* If CONFIG_LIBC_EXECFUNCS is defined in the configuration, then the
|
||||||
* following must also be defined:
|
* following must also be defined:
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -291,9 +291,11 @@ static int elf_relocate(FAR struct elf_loadinfo_s *loadinfo, int relidx,
|
|||||||
|
|
||||||
/* Calculate the relocation address. */
|
/* Calculate the relocation address. */
|
||||||
|
|
||||||
if (rel->r_offset < 0 || rel->r_offset > dstsec->sh_size - sizeof(uint32_t))
|
if (rel->r_offset < 0 ||
|
||||||
|
rel->r_offset > dstsec->sh_size - sizeof(uint32_t))
|
||||||
{
|
{
|
||||||
berr("Section %d reloc %d: Relocation address out of range, offset %d size %d\n",
|
berr("Section %d reloc %d: Relocation address out of range, "
|
||||||
|
"offset %d size %d\n",
|
||||||
relidx, i, rel->r_offset, dstsec->sh_size);
|
relidx, i, rel->r_offset, dstsec->sh_size);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -200,7 +200,6 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Save the address of the .ctors (actually, .init_array) where it was
|
/* Save the address of the .ctors (actually, .init_array) where it was
|
||||||
* loaded into memory. Since the .ctors lie in allocated memory, they
|
* loaded into memory. Since the .ctors lie in allocated memory, they
|
||||||
* will be relocated via the normal mechanism.
|
* will be relocated via the normal mechanism.
|
||||||
|
|||||||
@@ -200,7 +200,6 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Save the address of the .dtors (actually, .init_array) where it was
|
/* Save the address of the .dtors (actually, .init_array) where it was
|
||||||
* loaded into memory. Since the .dtors lie in allocated memory, they
|
* loaded into memory. Since the .dtors lie in allocated memory, they
|
||||||
* will be relocated via the normal mechanism.
|
* will be relocated via the normal mechanism.
|
||||||
|
|||||||
@@ -166,7 +166,8 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
|
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
|
||||||
|
|
||||||
/* SHF_ALLOC indicates that the section requires memory during
|
/* SHF_ALLOC indicates that the section requires memory during
|
||||||
* execution */
|
* execution.
|
||||||
|
*/
|
||||||
|
|
||||||
if ((shdr->sh_flags & SHF_ALLOC) == 0)
|
if ((shdr->sh_flags & SHF_ALLOC) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -305,9 +305,12 @@ int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
|
|||||||
/* Check if the base code exports a symbol of this name */
|
/* Check if the base code exports a symbol of this name */
|
||||||
|
|
||||||
#ifdef CONFIG_SYMTAB_ORDEREDBYNAME
|
#ifdef CONFIG_SYMTAB_ORDEREDBYNAME
|
||||||
symbol = symtab_findorderedbyname(exports, (FAR char *)loadinfo->iobuffer, nexports);
|
symbol = symtab_findorderedbyname(exports,
|
||||||
|
(FAR char *)loadinfo->iobuffer,
|
||||||
|
nexports);
|
||||||
#else
|
#else
|
||||||
symbol = symtab_findbyname(exports, (FAR char *)loadinfo->iobuffer, nexports);
|
symbol = symtab_findbyname(exports, (FAR char *)loadinfo->iobuffer,
|
||||||
|
nexports);
|
||||||
#endif
|
#endif
|
||||||
if (!symbol)
|
if (!symbol)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ int elf_unload(struct elf_loadinfo_s *loadinfo)
|
|||||||
{
|
{
|
||||||
kumm_free(loadinfo->ctoralloc);
|
kumm_free(loadinfo->ctoralloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadinfo->dtoralloc != 0)
|
if (loadinfo->dtoralloc != 0)
|
||||||
{
|
{
|
||||||
kumm_free(loadinfo->dtoralloc);
|
kumm_free(loadinfo->dtoralloc);
|
||||||
|
|||||||
@@ -287,9 +287,10 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
|
|||||||
result = OK;
|
result = OK;
|
||||||
switch (NXFLAT_RELOC_TYPE(reloc.r_info))
|
switch (NXFLAT_RELOC_TYPE(reloc.r_info))
|
||||||
{
|
{
|
||||||
/* NXFLAT_RELOC_TYPE_REL32I Meaning: Object file contains a 32-bit offset
|
/* NXFLAT_RELOC_TYPE_REL32I Meaning: Object file contains a 32-bit
|
||||||
* into I-Space at the offset.
|
* offset into I-Space at the offset.
|
||||||
* Fixup: Add mapped I-Space address to the offset.
|
* Fixup: Add mapped I-Space address to the
|
||||||
|
* offset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case NXFLAT_RELOC_TYPE_REL32I:
|
case NXFLAT_RELOC_TYPE_REL32I:
|
||||||
@@ -322,14 +323,16 @@ static inline int nxflat_gotrelocs(FAR struct nxflat_loadinfo_s *loadinfo)
|
|||||||
#ifdef NXFLAT_RELOC_TYPE_REL32ID
|
#ifdef NXFLAT_RELOC_TYPE_REL32ID
|
||||||
case NXFLAT_RELOC_TYPE_REL32ID:
|
case NXFLAT_RELOC_TYPE_REL32ID:
|
||||||
{
|
{
|
||||||
result = nxflat_bindrel32id(loadinfo, NXFLAT_RELOC_OFFSET(reloc.r_info));
|
result = nxflat_bindrel32id(loadinfo,
|
||||||
|
NXFLAT_RELOC_OFFSET(reloc.r_info));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
berr("ERROR: Unrecognized relocation type: %d\n", NXFLAT_RELOC_TYPE(reloc.r_info));
|
berr("ERROR: Unrecognized relocation type: %d\n",
|
||||||
|
NXFLAT_RELOC_TYPE(reloc.r_info));
|
||||||
result = -EINVAL;
|
result = -EINVAL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -348,8 +351,10 @@ 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 *)
|
||||||
nxflat_dumpbuffer("GOT", (FAR const uint8_t *)relocs, nrelocs * sizeof(struct nxflat_reloc_s));
|
(offset - loadinfo->isize + loadinfo->dspace->region);
|
||||||
|
nxflat_dumpbuffer("GOT", (FAR const uint8_t *)relocs,
|
||||||
|
nrelocs * sizeof(struct nxflat_reloc_s));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -462,7 +467,8 @@ 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 = (FAR 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 +500,8 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -166,4 +166,3 @@ int nxflat_read(struct nxflat_loadinfo_s *loadinfo, char *buffer,
|
|||||||
nxflat_dumpreaddata(buffer, readsize);
|
nxflat_dumpreaddata(buffer, readsize);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ int nxflat_uninit(struct nxflat_loadinfo_s *loadinfo)
|
|||||||
{
|
{
|
||||||
close(loadinfo->filfd);
|
close(loadinfo->filfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
int nxflat_unload(FAR 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)
|
||||||
|
|||||||
@@ -119,11 +119,13 @@ static void nxflat_dumploadinfo(FAR struct nxflat_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
binfo(" DSPACE:\n");
|
binfo(" DSPACE:\n");
|
||||||
binfo(" dspace: %08lx\n", loadinfo->dspace);
|
binfo(" dspace: %08lx\n", loadinfo->dspace);
|
||||||
|
|
||||||
if (loadinfo->dspace != NULL)
|
if (loadinfo->dspace != NULL)
|
||||||
{
|
{
|
||||||
binfo(" crefs: %d\n", loadinfo->dspace->crefs);
|
binfo(" crefs: %d\n", loadinfo->dspace->crefs);
|
||||||
binfo(" region: %08lx\n", loadinfo->dspace->region);
|
binfo(" region: %08lx\n", loadinfo->dspace->region);
|
||||||
}
|
}
|
||||||
|
|
||||||
binfo(" datasize: %08lx\n", loadinfo->datasize);
|
binfo(" datasize: %08lx\n", loadinfo->datasize);
|
||||||
binfo(" bsssize: %08lx\n", loadinfo->bsssize);
|
binfo(" bsssize: %08lx\n", loadinfo->bsssize);
|
||||||
binfo(" (pad): %08lx\n", loadinfo->dsize - dsize);
|
binfo(" (pad): %08lx\n", loadinfo->dsize - dsize);
|
||||||
@@ -299,6 +301,7 @@ int nxflat_initialize(void)
|
|||||||
{
|
{
|
||||||
berr("Failed to register binfmt: %d\n", ret);
|
berr("Failed to register binfmt: %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user