1
0
Fork 0
forked from nuttx/nuttx-update

libelf: Appease nxstyle complaints

Also, fix a minor typo.
This commit is contained in:
YAMAMOTO Takashi 2020-03-26 15:54:27 +09:00 committed by Xiang Xiao
parent d6d03d64d5
commit 8ad9d1e0b4
9 changed files with 51 additions and 42 deletions

View file

@ -68,11 +68,12 @@
*
* Description:
* Allocate memory for the ELF image (textalloc and dataalloc). If
* CONFIG_ARCH_ADDRENV=n, textalloc will be allocated using kmm_zalloc() and
* dataalloc will be a offset from textalloc. If CONFIG_ARCH_ADDRENV-y, then
* textalloc and dataalloc will be allocated using up_addrenv_create(). In
* either case, there will be a unique instance of textalloc and dataalloc
* (and stack) for each instance of a process.
* CONFIG_ARCH_ADDRENV=n, textalloc will be allocated using kmm_zalloc()
* and dataalloc will be a offset from textalloc. If
* CONFIG_ARCH_ADDRENV=y, then textalloc and dataalloc will be allocated
* using up_addrenv_create(). In either case, there will be a unique
* instance of textalloc and dataalloc (and stack) for each instance of a
* process.
*
* Input Parameters:
* loadinfo - Load state information

View file

@ -56,8 +56,8 @@
* Pre-processor Definitions
****************************************************************************/
/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to be
* defined or CONFIG_ELF_DUMPBUFFER does nothing.
/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to
* be defined or CONFIG_ELF_DUMPBUFFER does nothing.
*/
#if !defined(CONFIG_DEBUG_INFO) || !defined (CONFIG_DEBUG_BINFMT)
@ -228,8 +228,9 @@ static int elf_relocate(FAR struct elf_loadinfo_s *loadinfo, int relidx,
CONFIG_ELF_RELOCATION_BUFFERCOUNT);
if (ret < 0)
{
berr("Section %d reloc %d: Failed to read relocation entry: %d\n",
relidx, i, ret);
berr("Section %d reloc %d: "
"Failed to read relocation entry: %d\n",
relidx, i, ret);
break;
}
}
@ -296,8 +297,8 @@ static int elf_relocate(FAR struct elf_loadinfo_s *loadinfo, int relidx,
ret = elf_symvalue(loadinfo, sym, exports, nexports);
if (ret < 0)
{
/* The special error -ESRCH is returned only in one condition: The
* symbol has no name.
/* The special error -ESRCH is returned only in one condition:
* The symbol has no name.
*
* There are a few relocations for a few architectures that do
* no depend upon a named symbol. We don't know if that is the
@ -411,8 +412,9 @@ static int elf_relocateadd(FAR struct elf_loadinfo_s *loadinfo, int relidx,
CONFIG_ELF_RELOCATION_BUFFERCOUNT);
if (ret < 0)
{
berr("Section %d reloc %d: Failed to read relocation entry: %d\n",
relidx, i, ret);
berr("Section %d reloc %d: "
"Failed to read relocation entry: %d\n",
relidx, i, ret);
break;
}
}
@ -479,8 +481,8 @@ static int elf_relocateadd(FAR struct elf_loadinfo_s *loadinfo, int relidx,
ret = elf_symvalue(loadinfo, sym, exports, nexports);
if (ret < 0)
{
/* The special error -ESRCH is returned only in one condition: The
* symbol has no name.
/* The special error -ESRCH is returned only in one condition:
* The symbol has no name.
*
* There are a few relocations for a few architectures that do
* no depend upon a named symbol. We don't know if that is the

View file

@ -110,8 +110,8 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
/* Find the index to the section named ".ctors." NOTE: On old ABI system,
* .ctors is the name of the section containing the list of constructors;
* On newer systems, the similar section is called .init_array. It is
* expected that the linker script will force the section name to be ".ctors"
* in either case.
* expected that the linker script will force the section name to be
* ".ctors" in either case.
*/
ctoridx = elf_findsection(loadinfo, ".ctors");
@ -189,7 +189,8 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
for (i = 0; i < loadinfo->nctors; i++)
{
FAR uintptr_t *ptr = (uintptr_t *)((FAR void *)(&loadinfo->ctors)[i]);
FAR uintptr_t *ptr = (uintptr_t *)
((FAR void *)(&loadinfo->ctors)[i]);
binfo("ctor %d: %08lx + %08lx = %08lx\n",
i, *ptr, (unsigned long)loadinfo->textalloc,
@ -200,9 +201,9 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
}
else
{
/* Save the address of the .ctors (actually, .init_array) where it was
* loaded into memory. Since the .ctors lie in allocated memory, they
* will be relocated via the normal mechanism.
/* Save the address of the .ctors (actually, .init_array) where
* it was loaded into memory. Since the .ctors lie in allocated
* memory, they will be relocated via the normal mechanism.
*/
loadinfo->ctors = (binfmt_ctor_t *)shdr->sh_addr;

View file

@ -110,8 +110,8 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
/* Find the index to the section named ".dtors." NOTE: On old ABI system,
* .dtors is the name of the section containing the list of destructors;
* On newer systems, the similar section is called .fini_array. It is
* expected that the linker script will force the section name to be ".dtors"
* in either case.
* expected that the linker script will force the section name to be
* ".dtors" in either case.
*/
dtoridx = elf_findsection(loadinfo, ".dtors");
@ -189,7 +189,8 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
for (i = 0; i < loadinfo->ndtors; i++)
{
FAR uintptr_t *ptr = (uintptr_t *)((FAR void *)(&loadinfo->dtors)[i]);
FAR uintptr_t *ptr = (uintptr_t *)
((FAR void *)(&loadinfo->dtors)[i]);
binfo("dtor %d: %08lx + %08lx = %08lx\n",
i, *ptr, (unsigned long)loadinfo->textalloc,
@ -200,9 +201,9 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
}
else
{
/* Save the address of the .dtors (actually, .init_array) where it was
* loaded into memory. Since the .dtors lie in allocated memory, they
* will be relocated via the normal mechanism.
/* Save the address of the .dtors (actually, .init_array) where
* it was loaded into memory. Since the .dtors lie in allocated
* memory, they will be relocated via the normal mechanism.
*/
loadinfo->dtors = (binfmt_dtor_t *)shdr->sh_addr;

View file

@ -56,8 +56,8 @@
* Pre-processor Definitions
****************************************************************************/
/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to be
* defined or CONFIG_ELF_DUMPBUFFER does nothing.
/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to
* be defined or CONFIG_ELF_DUMPBUFFER does nothing.
*/
#if !defined(CONFIG_DEBUG_INFO) || !defined (CONFIG_DEBUG_BINFMT)
@ -189,11 +189,11 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
ret = elf_verifyheader(&loadinfo->ehdr);
if (ret < 0)
{
/* 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,
* it will -ENOEXEC which simply informs the system that the file is not an
* ELF file. elf_verifyheader() will return other errors if the ELF header
* is not correctly formed.
/* 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, it will -ENOEXEC which simply informs the system
* that the file is not an ELF file. elf_verifyheader() will return
* other errors if the ELF header is not correctly formed.
*/
berr("Bad ELF header: %d\n", ret);

View file

@ -346,11 +346,13 @@ int elf_load(FAR struct elf_loadinfo_s *loadinfo)
exidx = elf_findsection(loadinfo, CONFIG_ELF_EXIDX_SECTNAME);
if (exidx < 0)
{
binfo("elf_findsection: Exception Index section not found: %d\n", exidx);
binfo("elf_findsection: Exception Index section not found: %d\n",
exidx);
}
else
{
up_init_exidx(loadinfo->shdr[exidx].sh_addr, loadinfo->shdr[exidx].sh_size);
up_init_exidx(loadinfo->shdr[exidx].sh_addr,
loadinfo->shdr[exidx].sh_size);
}
#endif

View file

@ -201,7 +201,8 @@ int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo)
/* Get the total size of the section header table */
shdrsize = (size_t)loadinfo->ehdr.e_shentsize * (size_t)loadinfo->ehdr.e_shnum;
shdrsize = (size_t)loadinfo->ehdr.e_shentsize *
(size_t)loadinfo->ehdr.e_shnum;
if (loadinfo->ehdr.e_shoff + shdrsize > loadinfo->filelen)
{
berr("Insufficient space in file for section header table\n");

View file

@ -71,8 +71,8 @@
* 0 (OK) is returned on success and a negated errno is returned on
* failure.
*
* EINVAL - There is something inconsistent in the symbol table (should only
* happen if the file is corrupted).
* EINVAL - There is something inconsistent in the symbol table (should
* only happen if the file is corrupted).
* ESRCH - Symbol has no name
*
****************************************************************************/
@ -252,8 +252,8 @@ int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
* 0 (OK) is returned on success and a negated errno is returned on
* failure.
*
* EINVAL - There is something inconsistent in the symbol table (should only
* happen if the file is corrupted).
* EINVAL - There is something inconsistent in the symbol table (should
* only happen if the file is corrupted).
* ENOSYS - Symbol lies in common
* ESRCH - Symbol has no name
* ENOENT - Symbol undefined and not provided via a symbol table

View file

@ -97,7 +97,8 @@ int elf_verifyheader(FAR const Elf_Ehdr *ehdr)
if (memcmp(ehdr->e_ident, g_elfmagic, EI_MAGIC_SIZE) != 0)
{
binfo("Not ELF magic {%02x, %02x, %02x, %02x}\n",
ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2], ehdr->e_ident[3]);
ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2],
ehdr->e_ident[3]);
return -ENOEXEC;
}