[asan] Implement address sanitizer on AIX: build configuration (#139583)

Update asan build configuration for AIX:
- Adds import lists
- Guards shared library code

Issue: #138916

---------

Co-authored-by: Hubert Tong <hubert.reinterpretcast@gmail.com>
This commit is contained in:
Jake Egan
2025-06-25 11:26:39 -04:00
committed by GitHub
parent c3b160bcaa
commit 60285d98ef
4 changed files with 167 additions and 0 deletions

View File

@@ -582,6 +582,24 @@ macro(add_compiler_rt_script name)
DESTINATION ${COMPILER_RT_INSTALL_BINARY_DIR})
endmacro(add_compiler_rt_script src name)
macro(add_compiler_rt_cfg target_name file_name component arch)
set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}")
get_compiler_rt_output_dir(${arch} output_dir)
set(dst_file "${output_dir}/${file_name}")
add_custom_command(OUTPUT ${dst_file}
DEPENDS ${src_file}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file}
COMMENT "Copying ${file_name}...")
add_custom_target(${target_name} DEPENDS ${dst_file})
install(FILES ${file_name}
DESTINATION ${COMPILER_RT_INSTALL_LIBRARY_DIR}
COMPONENT ${component})
add_dependencies(${component} ${target_name})
set_target_properties(${target_name} PROPERTIES FOLDER "Compiler-RT Misc")
endmacro()
# Builds custom version of libc++ and installs it in <prefix>.
# Can be used to build sanitized versions of libc++ for running unit tests.
# add_custom_libcxx(<name> <prefix>

View File

@@ -281,6 +281,8 @@ else()
PARENT_TARGET asan)
endif()
# On AIX, we only need the static libraries.
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
foreach(arch ${ASAN_SUPPORTED_ARCH})
if (COMPILER_RT_HAS_VERSION_SCRIPT)
if(WIN32)
@@ -382,10 +384,21 @@ else()
endif()
endif()
endforeach()
endif()
endif()
add_compiler_rt_resource_file(asan_ignorelist asan_ignorelist.txt asan)
# On AIX, static sanitizer libraries are not added to the DSO, so we need to put
# asan.link_with_main_exec.txt and asan_cxx.link_with_main_exec.txt to the build
# and install dir for use in resolving undefined sanitizer symbols at runtime.
if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
foreach(arch ${ASAN_SUPPORTED_ARCH})
add_compiler_rt_cfg(asan_symbols_${arch} asan.link_with_main_exec.txt asan ${arch})
add_compiler_rt_cfg(asan_cxx_symbols_${arch} asan_cxx.link_with_main_exec.txt asan ${arch})
endforeach()
endif()
add_subdirectory(scripts)
if(COMPILER_RT_INCLUDE_TESTS)

View File

@@ -0,0 +1,115 @@
#! .
__asan_report_load_n
__asan_loadN
__asan_report_load1
__asan_load1
__asan_report_load2
__asan_load2
__asan_report_load4
__asan_load4
__asan_report_load8
__asan_load8
__asan_report_load16
__asan_load16
__asan_report_store_n
__asan_storeN
__asan_report_store1
__asan_store1
__asan_report_store2
__asan_store2
__asan_report_store4
__asan_store4
__asan_report_store8
__asan_store8
__asan_report_store16
__asan_store16
__asan_report_exp_load_n
__asan_exp_loadN
__asan_report_exp_load1
__asan_exp_load1
__asan_report_exp_load2
__asan_exp_load2
__asan_report_exp_load4
__asan_exp_load4
__asan_report_exp_load8
__asan_exp_load8
__asan_report_exp_load16
__asan_exp_load16
__asan_report_exp_store_n
__asan_exp_storeN
__asan_report_exp_store1
__asan_exp_store1
__asan_report_exp_store2
__asan_exp_store2
__asan_report_exp_store4
__asan_exp_store4
__asan_report_exp_store8
__asan_exp_store8
__asan_report_exp_store16
__asan_exp_store16
__asan_memmove
__asan_memcpy
__asan_memset
__asan_handle_no_return
__sanitizer_ptr_cmp
__sanitizer_ptr_sub
__asan_before_dynamic_init
__asan_after_dynamic_init
__asan_register_globals
__asan_unregister_globals
__asan_register_image_globals
__asan_unregister_image_globals
__asan_register_elf_globals
__asan_unregister_elf_globals
__asan_init
__asan_version_mismatch_check_v8
__asan_stack_malloc_0
__asan_stack_malloc_1
__asan_stack_malloc_2
__asan_stack_malloc_3
__asan_stack_malloc_4
__asan_stack_malloc_5
__asan_stack_malloc_6
__asan_stack_malloc_7
__asan_stack_malloc_8
__asan_stack_malloc_9
__asan_stack_malloc_10
__asan_stack_malloc_always_0
__asan_stack_malloc_always_1
__asan_stack_malloc_always_2
__asan_stack_malloc_always_3
__asan_stack_malloc_always_4
__asan_stack_malloc_always_5
__asan_stack_malloc_always_6
__asan_stack_malloc_always_7
__asan_stack_malloc_always_8
__asan_stack_malloc_always_9
__asan_stack_malloc_always_10
__asan_stack_free_0
__asan_stack_free_1
__asan_stack_free_2
__asan_stack_free_3
__asan_stack_free_4
__asan_stack_free_5
__asan_stack_free_6
__asan_stack_free_7
__asan_stack_free_8
__asan_stack_free_9
__asan_stack_free_10
__asan_set_shadow_00
__asan_set_shadow_01
__asan_set_shadow_02
__asan_set_shadow_03
__asan_set_shadow_04
__asan_set_shadow_05
__asan_set_shadow_06
__asan_set_shadow_07
__asan_set_shadow_f1
__asan_set_shadow_f2
__asan_set_shadow_f3
__asan_set_shadow_f5
__asan_set_shadow_f8
__asan_poison_stack_memory
__asan_unpoison_stack_memory
__asan_option_detect_stack_use_after_return
__asan_shadow_memory_dynamic_address

View File

@@ -0,0 +1,21 @@
#! .
_ZdaPv
_ZdaPvRKSt9nothrow_t
_ZdaPvSt11align_val_t
_ZdaPvSt11align_val_tRKSt9nothrow_t
_ZdaPvm
_ZdaPvmSt11align_val_t
_ZdlPv
_ZdlPvRKSt9nothrow_t
_ZdlPvSt11align_val_t
_ZdlPvSt11align_val_tRKSt9nothrow_t
_ZdlPvm
_ZdlPvmSt11align_val_t
_Znam
_ZnamRKSt9nothrow_t
_ZnamSt11align_val_t
_ZnamSt11align_val_tRKSt9nothrow_t
_Znwm
_ZnwmRKSt9nothrow_t
_ZnwmSt11align_val_t
_ZnwmSt11align_val_tRKSt9nothrow_t