@@ -409,6 +409,7 @@ int llext_link(struct llext_loader *ldr, struct llext *ext, const struct llext_l
409
409
elf_rela_t rel = {0 };
410
410
elf_word rel_cnt = 0 ;
411
411
const char * name ;
412
+ int link_err = 0 ;
412
413
int i , ret ;
413
414
414
415
for (i = 0 ; i < ext -> sect_cnt ; ++ i ) {
@@ -510,52 +511,52 @@ int llext_link(struct llext_loader *ldr, struct llext *ext, const struct llext_l
510
511
return ret ;
511
512
}
512
513
513
- #ifdef CONFIG_LLEXT_LOG_LEVEL
514
- if (CONFIG_LLEXT_LOG_LEVEL >= LOG_LEVEL_INF ) {
515
- uintptr_t link_addr ;
516
- uintptr_t op_loc =
517
- llext_get_reloc_instruction_location (ldr , ext ,
518
- shdr -> sh_info ,
519
- & rel );
520
- elf_sym_t sym ;
521
-
522
- ret = llext_read_symbol (ldr , ext , & rel , & sym );
523
-
524
- if (ret != 0 ) {
525
- return ret ;
526
- }
514
+ #if CONFIG_LLEXT_LOG_LEVEL > LOG_LEVEL_INF /* also gets skipped without CONFIG_LOG */
515
+ uintptr_t link_addr ;
516
+ uintptr_t op_loc = llext_get_reloc_instruction_location (ldr , ext ,
517
+ shdr -> sh_info ,
518
+ & rel );
519
+ elf_sym_t sym ;
520
+ const char * inv_str = "" ;
527
521
522
+ ret = llext_read_symbol (ldr , ext , & rel , & sym );
523
+ if (ret == 0 ) {
528
524
name = llext_symbol_name (ldr , ext , & sym );
525
+ ret = llext_lookup_symbol (ldr , ext , & link_addr , & rel , & sym ,
526
+ name , shdr );
527
+ } else {
528
+ name = "<unknown>" ;
529
+ }
529
530
530
- ret = llext_lookup_symbol (ldr , ext , & link_addr , & rel , & sym , name ,
531
- shdr );
532
-
533
- if (ret != 0 ) {
534
- LOG_ERR ("Could not find symbol %s!" , name );
535
- return ret ;
536
- }
537
-
538
- LOG_DBG ("relocation %d:%d info %#zx (type %zd, sym %zd) offset %zd"
539
- " sym_name %s sym_type %d sym_bind %d sym_ndx %d" ,
540
- i , j , (size_t )rel .r_info , (size_t )ELF_R_TYPE (rel .r_info ),
541
- (size_t )ELF_R_SYM (rel .r_info ), (size_t )rel .r_offset ,
542
- name , ELF_ST_TYPE (sym .st_info ),
543
- ELF_ST_BIND (sym .st_info ), sym .st_shndx );
544
-
545
- LOG_DBG ("writing relocation type %d at %#lx with symbol %s (%#lx)" ,
546
- (int )ELF_R_TYPE (rel .r_info ), op_loc , name , link_addr );
531
+ if (ret != 0 ) {
532
+ inv_str = "(invalid) " ;
533
+ memset (& sym , 0 , sizeof (sym ));
534
+ link_addr = 0 ;
547
535
}
548
- #endif /* CONFIG_LLEXT_LOG_LEVEL */
549
536
537
+ LOG_DBG ("%srelocation %d:%d info %#zx (type %zd, sym %zd) offset %zd"
538
+ " sym_name %s sym_type %d sym_bind %d sym_ndx %d" ,
539
+ inv_str , i , j , (size_t )rel .r_info , (size_t )ELF_R_TYPE (rel .r_info ),
540
+ (size_t )ELF_R_SYM (rel .r_info ), (size_t )rel .r_offset ,
541
+ name , ELF_ST_TYPE (sym .st_info ),
542
+ ELF_ST_BIND (sym .st_info ), sym .st_shndx );
550
543
551
- /* relocation */
544
+ LOG_DBG ("%swriting relocation type %d at %#lx with symbol %s (%#lx)" ,
545
+ inv_str , (int )ELF_R_TYPE (rel .r_info ), op_loc , name , link_addr );
546
+ #endif /* CONFIG_LLEXT_LOG_LEVEL > LOG_LEVEL_INF */
547
+
548
+ /* relocation, collect first error */
552
549
ret = arch_elf_relocate (ldr , ext , & rel , shdr );
553
- if (ret ! = 0 ) {
554
- return ret ;
550
+ if (link_err = = 0 ) {
551
+ link_err = ret ;
555
552
}
556
553
}
557
554
}
558
555
556
+ if (link_err != 0 ) {
557
+ return link_err ;
558
+ }
559
+
559
560
#ifdef CONFIG_CACHE_MANAGEMENT
560
561
/* Make sure changes to memory regions are flushed to RAM */
561
562
for (i = 0 ; i < LLEXT_MEM_COUNT ; ++ i ) {
0 commit comments