Skip to content

Commit

Permalink
vmlinux.lds.h: Add markers for text_unlikely and text_hot sections
Browse files Browse the repository at this point in the history
Add markers like __hot_text_start, __hot_text_end, __unlikely_text_start,
and __unlikely_text_end which will be included in System.map. These markers
indicate how the compiler groups functions, providing valuable information
to developers about the layout and optimization of the code.

Co-developed-by: Han Shen <shenhan@google.com>
Signed-off-by: Han Shen <shenhan@google.com>
Signed-off-by: Rong Xu <xur@google.com>
Suggested-by: Sriraman Tallam <tmsriram@google.com>
Tested-by: Yonghong Song <yonghong.song@linux.dev>
Tested-by: Yabin Cui <yabinc@google.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Rong Xu authored and Masahiro Yamada committed Nov 27, 2024
1 parent 0043ece commit db0b299
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,16 @@
__cpuidle_text_end = .; \
__noinstr_text_end = .;

#define TEXT_UNLIKELY \
__unlikely_text_start = .; \
*(.text.unlikely .text.unlikely.*) \
__unlikely_text_end = .;

#define TEXT_HOT \
__hot_text_start = .; \
*(.text.hot .text.hot.*) \
__hot_text_end = .;

/*
* .text section. Map to function alignment to avoid address changes
* during second ld run in second ld pass when generating System.map
Expand All @@ -565,9 +575,9 @@
ALIGN_FUNCTION(); \
*(.text.asan.* .text.tsan.*) \
*(.text.unknown .text.unknown.*) \
*(.text.unlikely .text.unlikely.*) \
TEXT_UNLIKELY \
. = ALIGN(PAGE_SIZE); \
*(.text.hot .text.hot.*) \
TEXT_HOT \
*(TEXT_MAIN .text.fixup) \
NOINSTR_TEXT \
*(.ref.text)
Expand Down

0 comments on commit db0b299

Please sign in to comment.