Skip to content

Commit 60285d9

Browse files
[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>
1 parent c3b160b commit 60285d9

File tree

4 files changed

+167
-0
lines changed

4 files changed

+167
-0
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,24 @@ macro(add_compiler_rt_script name)
582582
DESTINATION ${COMPILER_RT_INSTALL_BINARY_DIR})
583583
endmacro(add_compiler_rt_script src name)
584584

585+
586+
macro(add_compiler_rt_cfg target_name file_name component arch)
587+
set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}")
588+
get_compiler_rt_output_dir(${arch} output_dir)
589+
set(dst_file "${output_dir}/${file_name}")
590+
add_custom_command(OUTPUT ${dst_file}
591+
DEPENDS ${src_file}
592+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file}
593+
COMMENT "Copying ${file_name}...")
594+
add_custom_target(${target_name} DEPENDS ${dst_file})
595+
install(FILES ${file_name}
596+
DESTINATION ${COMPILER_RT_INSTALL_LIBRARY_DIR}
597+
COMPONENT ${component})
598+
add_dependencies(${component} ${target_name})
599+
600+
set_target_properties(${target_name} PROPERTIES FOLDER "Compiler-RT Misc")
601+
endmacro()
602+
585603
# Builds custom version of libc++ and installs it in <prefix>.
586604
# Can be used to build sanitized versions of libc++ for running unit tests.
587605
# add_custom_libcxx(<name> <prefix>

compiler-rt/lib/asan/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ else()
281281
PARENT_TARGET asan)
282282
endif()
283283

284+
# On AIX, we only need the static libraries.
285+
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
284286
foreach(arch ${ASAN_SUPPORTED_ARCH})
285287
if (COMPILER_RT_HAS_VERSION_SCRIPT)
286288
if(WIN32)
@@ -382,10 +384,21 @@ else()
382384
endif()
383385
endif()
384386
endforeach()
387+
endif()
385388
endif()
386389

387390
add_compiler_rt_resource_file(asan_ignorelist asan_ignorelist.txt asan)
388391

392+
# On AIX, static sanitizer libraries are not added to the DSO, so we need to put
393+
# asan.link_with_main_exec.txt and asan_cxx.link_with_main_exec.txt to the build
394+
# and install dir for use in resolving undefined sanitizer symbols at runtime.
395+
if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
396+
foreach(arch ${ASAN_SUPPORTED_ARCH})
397+
add_compiler_rt_cfg(asan_symbols_${arch} asan.link_with_main_exec.txt asan ${arch})
398+
add_compiler_rt_cfg(asan_cxx_symbols_${arch} asan_cxx.link_with_main_exec.txt asan ${arch})
399+
endforeach()
400+
endif()
401+
389402
add_subdirectory(scripts)
390403

391404
if(COMPILER_RT_INCLUDE_TESTS)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#! .
2+
__asan_report_load_n
3+
__asan_loadN
4+
__asan_report_load1
5+
__asan_load1
6+
__asan_report_load2
7+
__asan_load2
8+
__asan_report_load4
9+
__asan_load4
10+
__asan_report_load8
11+
__asan_load8
12+
__asan_report_load16
13+
__asan_load16
14+
__asan_report_store_n
15+
__asan_storeN
16+
__asan_report_store1
17+
__asan_store1
18+
__asan_report_store2
19+
__asan_store2
20+
__asan_report_store4
21+
__asan_store4
22+
__asan_report_store8
23+
__asan_store8
24+
__asan_report_store16
25+
__asan_store16
26+
__asan_report_exp_load_n
27+
__asan_exp_loadN
28+
__asan_report_exp_load1
29+
__asan_exp_load1
30+
__asan_report_exp_load2
31+
__asan_exp_load2
32+
__asan_report_exp_load4
33+
__asan_exp_load4
34+
__asan_report_exp_load8
35+
__asan_exp_load8
36+
__asan_report_exp_load16
37+
__asan_exp_load16
38+
__asan_report_exp_store_n
39+
__asan_exp_storeN
40+
__asan_report_exp_store1
41+
__asan_exp_store1
42+
__asan_report_exp_store2
43+
__asan_exp_store2
44+
__asan_report_exp_store4
45+
__asan_exp_store4
46+
__asan_report_exp_store8
47+
__asan_exp_store8
48+
__asan_report_exp_store16
49+
__asan_exp_store16
50+
__asan_memmove
51+
__asan_memcpy
52+
__asan_memset
53+
__asan_handle_no_return
54+
__sanitizer_ptr_cmp
55+
__sanitizer_ptr_sub
56+
__asan_before_dynamic_init
57+
__asan_after_dynamic_init
58+
__asan_register_globals
59+
__asan_unregister_globals
60+
__asan_register_image_globals
61+
__asan_unregister_image_globals
62+
__asan_register_elf_globals
63+
__asan_unregister_elf_globals
64+
__asan_init
65+
__asan_version_mismatch_check_v8
66+
__asan_stack_malloc_0
67+
__asan_stack_malloc_1
68+
__asan_stack_malloc_2
69+
__asan_stack_malloc_3
70+
__asan_stack_malloc_4
71+
__asan_stack_malloc_5
72+
__asan_stack_malloc_6
73+
__asan_stack_malloc_7
74+
__asan_stack_malloc_8
75+
__asan_stack_malloc_9
76+
__asan_stack_malloc_10
77+
__asan_stack_malloc_always_0
78+
__asan_stack_malloc_always_1
79+
__asan_stack_malloc_always_2
80+
__asan_stack_malloc_always_3
81+
__asan_stack_malloc_always_4
82+
__asan_stack_malloc_always_5
83+
__asan_stack_malloc_always_6
84+
__asan_stack_malloc_always_7
85+
__asan_stack_malloc_always_8
86+
__asan_stack_malloc_always_9
87+
__asan_stack_malloc_always_10
88+
__asan_stack_free_0
89+
__asan_stack_free_1
90+
__asan_stack_free_2
91+
__asan_stack_free_3
92+
__asan_stack_free_4
93+
__asan_stack_free_5
94+
__asan_stack_free_6
95+
__asan_stack_free_7
96+
__asan_stack_free_8
97+
__asan_stack_free_9
98+
__asan_stack_free_10
99+
__asan_set_shadow_00
100+
__asan_set_shadow_01
101+
__asan_set_shadow_02
102+
__asan_set_shadow_03
103+
__asan_set_shadow_04
104+
__asan_set_shadow_05
105+
__asan_set_shadow_06
106+
__asan_set_shadow_07
107+
__asan_set_shadow_f1
108+
__asan_set_shadow_f2
109+
__asan_set_shadow_f3
110+
__asan_set_shadow_f5
111+
__asan_set_shadow_f8
112+
__asan_poison_stack_memory
113+
__asan_unpoison_stack_memory
114+
__asan_option_detect_stack_use_after_return
115+
__asan_shadow_memory_dynamic_address
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#! .
2+
_ZdaPv
3+
_ZdaPvRKSt9nothrow_t
4+
_ZdaPvSt11align_val_t
5+
_ZdaPvSt11align_val_tRKSt9nothrow_t
6+
_ZdaPvm
7+
_ZdaPvmSt11align_val_t
8+
_ZdlPv
9+
_ZdlPvRKSt9nothrow_t
10+
_ZdlPvSt11align_val_t
11+
_ZdlPvSt11align_val_tRKSt9nothrow_t
12+
_ZdlPvm
13+
_ZdlPvmSt11align_val_t
14+
_Znam
15+
_ZnamRKSt9nothrow_t
16+
_ZnamSt11align_val_t
17+
_ZnamSt11align_val_tRKSt9nothrow_t
18+
_Znwm
19+
_ZnwmRKSt9nothrow_t
20+
_ZnwmSt11align_val_t
21+
_ZnwmSt11align_val_tRKSt9nothrow_t

0 commit comments

Comments
 (0)