Skip to content

Commit aed7275

Browse files
committed
libs/libc/elf: Fix the nxstyle errors around the FDPIC changes.
The FDPIC work touches these four files, and nxstyle reports errors on the lines around every hunk, which fails the check job. The errors are older than this series: a switch body indented two columns too deep in elf_symbols.c and in the SHN_UNDEF branch of elf_bind.c, an initializer brace one level in, and a declaration with no blank line after it. Whitespace and one reworded comment, no change in behaviour. Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
1 parent c182011 commit aed7275

4 files changed

Lines changed: 173 additions & 166 deletions

File tree

libs/libc/elf/elf_bind.c

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -867,50 +867,50 @@ static int libelf_relocatedyn(FAR struct module_s *modp,
867867

868868
if (sym[idx_sym].st_shndx == SHN_UNDEF)
869869
{
870-
FAR void *ep;
871-
872-
ep = libelf_findglobal(modp, loadinfo, symhdr,
873-
&sym[idx_sym]);
874-
875-
/* libelf_findglobal() searches only the registered
876-
* symbols. A module from exec() has its own export
877-
* table, and an FDPIC module imports its libc there.
878-
*/
879-
880-
if (ep == NULL && exports != NULL)
881-
{
882-
FAR const struct symtab_s *sm;
883-
884-
sm = symtab_findbyname(exports,
885-
(FAR char *)
886-
loadinfo->iobuffer,
887-
nexports);
888-
if (sm != NULL)
889-
{
890-
ep = (FAR void *)sm->sym_value;
891-
}
892-
}
893-
894-
if ((ep == NULL) && (ELF_ST_BIND(sym[idx_sym].st_info)
895-
!= STB_WEAK))
896-
{
897-
berr("ERROR: Unable to resolve addr of ext ref %s\n",
898-
loadinfo->iobuffer);
899-
ret = -EINVAL;
900-
lib_free(sym);
901-
lib_free(rels);
902-
lib_free(dyn);
903-
return ret;
904-
}
905-
906-
addr = libelf_addr(loadinfo, rel->r_offset);
907-
908-
if (reldata.relrela[idx_rel] == 1)
909-
{
910-
addr += rela->r_addend;
911-
}
912-
913-
*(FAR uintptr_t *)addr = (uintptr_t)ep;
870+
FAR void *ep;
871+
872+
ep = libelf_findglobal(modp, loadinfo, symhdr,
873+
&sym[idx_sym]);
874+
875+
/* libelf_findglobal() searches only the registered
876+
* symbols. A module from exec() has its own export
877+
* table, and an FDPIC module imports its libc there.
878+
*/
879+
880+
if (ep == NULL && exports != NULL)
881+
{
882+
FAR const struct symtab_s *sm;
883+
884+
sm = symtab_findbyname(exports,
885+
(FAR char *)
886+
loadinfo->iobuffer,
887+
nexports);
888+
if (sm != NULL)
889+
{
890+
ep = (FAR void *)sm->sym_value;
891+
}
892+
}
893+
894+
if ((ep == NULL) && (ELF_ST_BIND(sym[idx_sym].st_info)
895+
!= STB_WEAK))
896+
{
897+
berr("ERROR: Unable to resolve addr of ext ref %s\n",
898+
loadinfo->iobuffer);
899+
ret = -EINVAL;
900+
lib_free(sym);
901+
lib_free(rels);
902+
lib_free(dyn);
903+
return ret;
904+
}
905+
906+
addr = libelf_addr(loadinfo, rel->r_offset);
907+
908+
if (reldata.relrela[idx_rel] == 1)
909+
{
910+
addr += rela->r_addend;
911+
}
912+
913+
*(FAR uintptr_t *)addr = (uintptr_t)ep;
914914
}
915915
else if (loadinfo->fdpic)
916916
{
@@ -947,9 +947,9 @@ static int libelf_relocatedyn(FAR struct module_s *modp,
947947
else
948948
{
949949
Elf_Sym dynsym =
950-
{
951-
0
952-
};
950+
{
951+
0
952+
};
953953

954954
addr = libelf_addr(loadinfo, rel->r_offset);
955955

@@ -1046,6 +1046,7 @@ int libelf_bind(FAR struct module_s *modp,
10461046
/* Get the index to the relocation section */
10471047

10481048
int infosec = loadinfo->shdr[i].sh_info;
1049+
10491050
if (infosec >= loadinfo->ehdr.e_shnum)
10501051
{
10511052
continue;
@@ -1178,6 +1179,7 @@ int libelf_bind(FAR struct module_s *modp,
11781179
if (loadinfo->addrenv != NULL)
11791180
{
11801181
int status = libelf_addrenv_restore(loadinfo);
1182+
11811183
if (status < 0)
11821184
{
11831185
berr("ERROR: libelf_addrenv_restore() failed: %d\n", status);

libs/libc/elf/elf_insert.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void libelf_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo)
8585
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
8686
{
8787
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
88+
8889
binfo("Sections %d:\n", i);
8990
# ifdef CONFIG_ARCH_USE_SEPARATED_SECTION
9091
if (loadinfo->ehdr.e_type == ET_REL)
@@ -420,27 +421,27 @@ FAR void *libelf_insert(FAR const char *filename, FAR const char *modname)
420421
case ET_REL :
421422
case ET_DYN :
422423

423-
/* Process any preinit_array entries */
424+
/* Process any preinit_array entries */
424425

425-
array = (FAR void (**)(void))loadinfo.preiarr;
426-
for (i = 0; i < loadinfo.nprei; i++)
427-
{
428-
array[i]();
429-
}
426+
array = (FAR void (**)(void))loadinfo.preiarr;
427+
for (i = 0; i < loadinfo.nprei; i++)
428+
{
429+
array[i]();
430+
}
430431

431-
/* Process any init_array entries */
432+
/* Process any init_array entries */
432433

433-
array = (FAR void (**)(void))loadinfo.initarr;
434-
for (i = 0; i < loadinfo.ninit; i++)
435-
{
436-
array[i]();
437-
}
434+
array = (FAR void (**)(void))loadinfo.initarr;
435+
for (i = 0; i < loadinfo.ninit; i++)
436+
{
437+
array[i]();
438+
}
438439

439-
modp->initarr = loadinfo.initarr;
440-
modp->ninit = loadinfo.ninit;
441-
modp->finiarr = loadinfo.finiarr;
442-
modp->nfini = loadinfo.nfini;
443-
break;
440+
modp->initarr = loadinfo.initarr;
441+
modp->ninit = loadinfo.ninit;
442+
modp->finiarr = loadinfo.finiarr;
443+
modp->nfini = loadinfo.nfini;
444+
break;
444445
}
445446

446447
/* Add the new module entry to the registry */

libs/libc/elf/elf_load.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ static inline int libelf_loadfile(FAR struct mod_loadinfo_s *loadinfo)
419419
else
420420
{
421421
size_t bsssize = phdr->p_memsz - phdr->p_filesz;
422+
422423
ret = libelf_read(loadinfo, data, phdr->p_filesz,
423424
phdr->p_offset);
424425
memset(data + phdr->p_filesz, 0, bsssize);
@@ -663,6 +664,7 @@ static int libelf_xipacquire(FAR struct mod_loadinfo_s *loadinfo)
663664
if (ioctl(loadinfo->filfd, XIPFSIOC_PIN, (unsigned long)&base) >= 0)
664665
{
665666
int ret = libelf_pinhold(loadinfo);
667+
666668
if (ret < 0)
667669
{
668670
berr("ERROR: Failed to hold the pinned file: %d\n", ret);

0 commit comments

Comments
 (0)