Hi Nithin,

May I ask which platform you are basing your analysis on? And what are the build options you're using?

page_align() function is used in a number of files:

plat/arm/board/fvp/fvp_bl31_setup.c:    hw_config_base_align = page_align(hw_config_info->config_addr, DOWN);
plat/arm/board/fvp/fvp_bl31_setup.c:    mapped_size_align = page_align(hw_config_info->config_max_size, UP);
plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c:   hw_config_base_align = page_align(hw_config_info->config_addr, DOWN);
plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c:   mapped_size_align = page_align(hw_config_info->config_max_size, UP);
plat/common/plat_spmd_manifest.c:       pm_base_align = page_align(pm_base, UP);
plat/common/plat_spmd_manifest.c:       pm_base_align = page_align(pm_base, DOWN);
services/spd/opteed/opteed_main.c:      mapped_data_pa = page_align(data_pa, DOWN);
services/spd/opteed/opteed_main.c:      data_map_size = page_align(data_size + (mapped_data_pa - data_pa), UP);
services/spd/opteed/opteed_main.c:      target_pa = page_align(image_pa, DOWN);
services/spd/opteed/opteed_main.c:      target_size = page_align(target_end_pa, UP) - target_pa;
services/std_svc/drtm/drtm_main.c:      dlme_data_min_size = page_align(dlme_data_min_size, UP)/PAGE_SIZE;
services/std_svc/drtm/drtm_measurements.c:      dlme_img_mapping_bytes = page_align(a->dlme_img_size, UP);
services/std_svc/spm/el3_spmc/spmc_main.c:      manifest_base_align = page_align(manifest_base, DOWN);
services/std_svc/spmd/spmd_main.c:      base_addr_align = page_align(base_addr, DOWN);
services/std_svc/spmd/spmd_main.c:      mapped_size_align = page_align(size, UP);

If you are building for FVP platform, it should be used by BL31. That being said, it's a small helper function, thus it might be inline, which would explain why it's not appearing in the symbol table. But it's definitely not dead code.

The load_*() family of functions are also used for sure, but only in BL1 and BL2 (BL31 does not load any images). So depending on which BL image you're looking at, this might be the reason why you're not seeing them in the symbol table.

Also, the variants with _auth_ in their names are â€‹only used if trusted boot is enabled (see TRUSTED_BOARD_BOOT build option in TF-A documentation). So again if you've not enabled this feature in the binary you're analysing, it would not be pulled.


Coming back to your question:
These functions are not appearing in symbol table also, then no need to take actions on violations reported in these functions?
I don't think we can make that claim generally. The compiler and linker options used in TF-A build system will try to remove any unused function. Thus, true dead code would not appear in the symbol table. But as I said, there are other reasons why a function might not appear in the symbol table : it could be inline ; or it could be unused on this specific platform / using these specific build options, but used in other build environments. In the previous 2 examples, this is not dead code.

Best regards,
Sandrine


From: Nithin G via TF-A <tf-a@lists.trustedfirmware.org>
Sent: 31 August 2023 12:18
To: tf-a@lists.trustedfirmware.org <tf-a@lists.trustedfirmware.org>
Subject: [TF-A] Re: MISRA-C violation for unused functions in Trusted Firmware-A(TFA) code
 
Hi Sandrine,

Thanks for responding,

Here few of the unused function present in bl_common.c file,
1.page_align
2.load_image
3.load_auth_image_internal
3.load_auth_image
These functions are not appearing in symbol table also, then no need to take actions on violations reported in these functions?

Similar to these unused functions are present in other files also. shall we take action on violations reported in these, please suggest.

Regards,
Nithin G
--
TF-A mailing list -- tf-a@lists.trustedfirmware.org
To unsubscribe send an email to tf-a-leave@lists.trustedfirmware.org