@@ -220,6 +220,7 @@ static int libelf_symcallback(FAR struct module_s *modp, FAR void *arg)
220220
221221#if CONFIG_LIBC_ELF_MAXDEPEND > 0
222222 int ret = libelf_depend (exportinfo -> modp , modp );
223+
223224 if (ret < 0 )
224225 {
225226 berr ("ERROR: libelf_depend failed: %d\n" , ret );
@@ -354,108 +355,108 @@ int libelf_symvalue(FAR struct module_s *modp,
354355
355356 switch (sym -> st_shndx )
356357 {
357- case SHN_COMMON :
358- {
359- /* NuttX ELF modules should be compiled with -fno-common. */
360-
361- berr ("ERROR: SHN_COMMON: Re-compile with -fno-common\n" );
362- return - ENOSYS ;
363- }
364-
365- case SHN_ABS :
366- {
367- /* st_value already holds the correct value */
368-
369- binfo ("SHN_ABS: st_value=%08lx\n" , (long )sym -> st_value );
370- return OK ;
371- }
372-
373- case SHN_UNDEF :
374- {
375- /* Get the name of the undefined symbol */
376-
377- ret = libelf_symname (loadinfo , sym , sh_offset );
378- if (ret < 0 )
379- {
380- /* There are a few relocations for a few architectures that do
381- * no depend upon a named symbol. We don't know if that is the
382- * case here, but return and special error to the caller to
383- * indicate the nameless symbol.
384- */
385-
386- berr ("ERROR: SHN_UNDEF: Failed to get symbol name: %d\n" , ret );
387- return ret ;
388- }
389-
390- /* First check if the symbol is exported by an installed module.
391- * Newest modules are installed at the head of the list. Therefore,
392- * if the symbol is exported by numerous modules, then the most
393- * recently installed will take precedence.
394- */
395-
396- exportinfo .name = (FAR const char * )loadinfo -> iobuffer ;
397- exportinfo .modp = modp ;
398- exportinfo .symbol = NULL ;
399-
400- ret = libelf_registry_foreach (libelf_symcallback ,
401- (FAR void * )& exportinfo );
402- if (ret < 0 )
403- {
404- berr ("ERROR: libelf_symcallback failed: %d\n" , ret );
405- return ret ;
406- }
407-
408- symbol = exportinfo .symbol ;
409-
410- /* If the symbol is not exported by any module, then check if the
411- * base code exports a symbol of this name.
412- */
413-
414- if (symbol == NULL )
415- {
416- symbol = symtab_findbyname (exports , exportinfo .name ,
417- nexports );
418- }
419-
420- /* Was the symbol found from any exporter? */
421-
422- if (symbol == NULL )
423- {
424- berr ("ERROR: SHN_UNDEF: Exported symbol \"%s\" not found\n" ,
425- loadinfo -> iobuffer );
426- return - ENOENT ;
427- }
428-
429- /* Yes... add the exported symbol value to the ELF symbol tablei
430- * entry
431- */
432-
433- binfo ("SHN_UNDEF: name=%s "
434- "%08" PRIxPTR "+%08" PRIxPTR "=%08" PRIxPTR "\n" ,
435- loadinfo -> iobuffer ,
436- (uintptr_t )sym -> st_value , (uintptr_t )symbol -> sym_value ,
437- (uintptr_t )(sym -> st_value + (uintptr_t )symbol -> sym_value ));
438-
439- sym -> st_value += ((uintptr_t )symbol -> sym_value );
440- }
441- break ;
442-
443- default :
444- {
445- secbase = loadinfo -> shdr [sym -> st_shndx ].sh_addr ;
446-
447- binfo ("Other[%d]: %08" PRIxPTR "+%08" PRIxPTR "=%08" PRIxPTR "\n" ,
448- sym -> st_shndx ,
449- (uintptr_t )sym -> st_value , secbase ,
450- (uintptr_t )(sym -> st_value + secbase ));
451-
452- sym -> st_value += secbase ;
453- if (loadinfo -> gotindex >= 0 )
454- {
455- sym -> st_value -= loadinfo -> shdr [sym -> st_shndx ].sh_offset ;
456- }
457- }
458- break ;
358+ case SHN_COMMON :
359+ {
360+ /* NuttX ELF modules should be compiled with -fno-common. */
361+
362+ berr ("ERROR: SHN_COMMON: Re-compile with -fno-common\n" );
363+ return - ENOSYS ;
364+ }
365+
366+ case SHN_ABS :
367+ {
368+ /* st_value already holds the correct value */
369+
370+ binfo ("SHN_ABS: st_value=%08lx\n" , (long )sym -> st_value );
371+ return OK ;
372+ }
373+
374+ case SHN_UNDEF :
375+ {
376+ /* Get the name of the undefined symbol */
377+
378+ ret = libelf_symname (loadinfo , sym , sh_offset );
379+ if (ret < 0 )
380+ {
381+ /* There are a few relocations for a few architectures that do
382+ * no depend upon a named symbol. We don't know if that is the
383+ * case here, but return and special error to the caller to
384+ * indicate the nameless symbol.
385+ */
386+
387+ berr ("ERROR: SHN_UNDEF: Failed to get symbol name: %d\n" , ret );
388+ return ret ;
389+ }
390+
391+ /* First check if the symbol is exported by an installed module.
392+ * Newest modules are installed at the head of the list. So if
393+ * the symbol is exported by numerous modules, then the most
394+ * recently installed will take precedence.
395+ */
396+
397+ exportinfo .name = (FAR const char * )loadinfo -> iobuffer ;
398+ exportinfo .modp = modp ;
399+ exportinfo .symbol = NULL ;
400+
401+ ret = libelf_registry_foreach (libelf_symcallback ,
402+ (FAR void * )& exportinfo );
403+ if (ret < 0 )
404+ {
405+ berr ("ERROR: libelf_symcallback failed: %d\n" , ret );
406+ return ret ;
407+ }
408+
409+ symbol = exportinfo .symbol ;
410+
411+ /* If the symbol is not exported by any module, then check if the
412+ * base code exports a symbol of this name.
413+ */
414+
415+ if (symbol == NULL )
416+ {
417+ symbol = symtab_findbyname (exports , exportinfo .name ,
418+ nexports );
419+ }
420+
421+ /* Was the symbol found from any exporter? */
422+
423+ if (symbol == NULL )
424+ {
425+ berr ("ERROR: SHN_UNDEF: Exported symbol \"%s\" not found\n" ,
426+ loadinfo -> iobuffer );
427+ return - ENOENT ;
428+ }
429+
430+ /* Yes... add the exported symbol value to the ELF symbol tablei
431+ * entry
432+ */
433+
434+ binfo ("SHN_UNDEF: name=%s "
435+ "%08" PRIxPTR "+%08" PRIxPTR "=%08" PRIxPTR "\n" ,
436+ loadinfo -> iobuffer ,
437+ (uintptr_t )sym -> st_value , (uintptr_t )symbol -> sym_value ,
438+ (uintptr_t )(sym -> st_value + (uintptr_t )symbol -> sym_value ));
439+
440+ sym -> st_value += ((uintptr_t )symbol -> sym_value );
441+ }
442+ break ;
443+
444+ default :
445+ {
446+ secbase = loadinfo -> shdr [sym -> st_shndx ].sh_addr ;
447+
448+ binfo ("Other[%d]: %08" PRIxPTR "+%08" PRIxPTR "=%08" PRIxPTR "\n" ,
449+ sym -> st_shndx ,
450+ (uintptr_t )sym -> st_value , secbase ,
451+ (uintptr_t )(sym -> st_value + secbase ));
452+
453+ sym -> st_value += secbase ;
454+ if (loadinfo -> gotindex >= 0 )
455+ {
456+ sym -> st_value -= loadinfo -> shdr [sym -> st_shndx ].sh_offset ;
457+ }
458+ }
459+ break ;
459460 }
460461
461462 return OK ;
@@ -596,6 +597,7 @@ static int findep(FAR const void *c1, FAR const void *c2)
596597{
597598 FAR const struct eptable_s * m1 = (FAR const struct eptable_s * )c1 ;
598599 FAR const struct eptable_s * m2 = (FAR const struct eptable_s * )c2 ;
600+
599601 return strcmp ((FAR const char * )m1 -> epname , (FAR const char * )m2 -> epname );
600602}
601603
0 commit comments