diff options
-rw-r--r-- | absl/debugging/symbolize_test.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/absl/debugging/symbolize_test.cc b/absl/debugging/symbolize_test.cc index 52c6915537e8..8b28e5c53951 100644 --- a/absl/debugging/symbolize_test.cc +++ b/absl/debugging/symbolize_test.cc @@ -51,6 +51,28 @@ void ABSL_ATTRIBUTE_NOINLINE Foo::func(int) { ABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); } +// Create functions that will remain in different text sections in the +// final binary when linker option "-z,keep-text-section-prefix" is used. +int ABSL_ATTRIBUTE_SECTION_VARIABLE(.text.unlikely) unlikely_func() { + return 0; +} + +int ABSL_ATTRIBUTE_SECTION_VARIABLE(.text.hot) hot_func() { + return 0; +} + +int ABSL_ATTRIBUTE_SECTION_VARIABLE(.text.startup) startup_func() { + return 0; +} + +int ABSL_ATTRIBUTE_SECTION_VARIABLE(.text.exit) exit_func() { + return 0; +} + +int ABSL_ATTRIBUTE_SECTION_VARIABLE(.text) regular_func() { + return 0; +} + // Thread-local data may confuse the symbolizer, ensure that it does not. // Variable sizes and order are important. #if ABSL_PER_THREAD_TLS @@ -136,6 +158,14 @@ TEST(Symbolize, SymbolizeWithDemangling) { EXPECT_STREQ("Foo::func()", TrySymbolize((void *)(&Foo::func))); } +TEST(Symbolize, SymbolizeSplitTextSections) { + EXPECT_STREQ("unlikely_func()", TrySymbolize((void *)(&unlikely_func))); + EXPECT_STREQ("hot_func()", TrySymbolize((void *)(&hot_func))); + EXPECT_STREQ("startup_func()", TrySymbolize((void *)(&startup_func))); + EXPECT_STREQ("exit_func()", TrySymbolize((void *)(&exit_func))); + EXPECT_STREQ("regular_func()", TrySymbolize((void *)(®ular_func))); +} + // Tests that verify that Symbolize stack footprint is within some limit. #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION |