Skip to content

Commit 833d4d8

Browse files
committed
[profile] Make {__start_,__stop_}__llvm_prf_* symbols undefined weak
To make a kind of metadata section usage work, we want to drop the `__start_/__stop_ references retain C identifier name sections` rule from LLD (see D96914). If an application has no `__llvm_prf_data` input section surviving --gc-sections, LLD will error for undefined hidden `{__start_,__stop_}__llvm_prf_*` from `libclang_rt.profile-*`. Other `__llvm_prf_*` sections have similar issues. Making the references weak can address the problem. This probably enables the opportunity to drop zero size dummy sections in `InstrProfilingPlatformLinux.c`. Reviewed By: davidxl Differential Revision: https://reviews.llvm.org/D96936
1 parent 018a484 commit 833d4d8

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

compiler-rt/lib/profile/InstrProfilingPlatformLinux.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@
2626
/* Declare section start and stop symbols for various sections
2727
* generated by compiler instrumentation.
2828
*/
29-
extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY;
30-
extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY;
31-
extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY;
32-
extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY;
33-
extern uint32_t PROF_ORDERFILE_START COMPILER_RT_VISIBILITY;
34-
extern char PROF_NAME_START COMPILER_RT_VISIBILITY;
35-
extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY;
36-
extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY;
37-
extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY;
29+
extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY
30+
COMPILER_RT_WEAK;
31+
extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY
32+
COMPILER_RT_WEAK;
33+
extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY COMPILER_RT_WEAK;
34+
extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY COMPILER_RT_WEAK;
35+
extern uint32_t PROF_ORDERFILE_START COMPILER_RT_VISIBILITY COMPILER_RT_WEAK;
36+
extern char PROF_NAME_START COMPILER_RT_VISIBILITY COMPILER_RT_WEAK;
37+
extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY COMPILER_RT_WEAK;
38+
extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY COMPILER_RT_WEAK;
39+
extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY COMPILER_RT_WEAK;
3840

3941
/* Add dummy data to ensure the section is always created. Add used attribute so
4042
* that they are linker GC roots on supported ELF platforms.

0 commit comments

Comments
 (0)