[kernel][phys] Prevent more inlining in backtrace-test

Fixed: 103357
Change-Id: I84bd8cb652a0e0e4347b2abf18f14f61eb7ba768
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/694248
Reviewed-by: Nick Maniscalco <maniscalco@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Roland McGrath <mcgrathr@google.com>
Reviewed-by: Petr Hosek <phosek@google.com>
diff --git a/zircon/kernel/phys/test/backtrace-test.cc b/zircon/kernel/phys/test/backtrace-test.cc
index f713498..2c36622 100644
--- a/zircon/kernel/phys/test/backtrace-test.cc
+++ b/zircon/kernel/phys/test/backtrace-test.cc
@@ -81,7 +81,7 @@
 
 }  // namespace
 
-int TestMain(void* zbi, arch::EarlyTicks) {
+[[gnu::noinline]] int TestMain(void* zbi, arch::EarlyTicks) {
   MainSymbolize symbolize("backtrace-test");
 
   if (zbi && static_cast<zbi_header_t*>(zbi)->type == ZBI_TYPE_CONTAINER) {
diff --git a/zircon/kernel/phys/test/zbi-test-main.cc b/zircon/kernel/phys/test/zbi-test-main.cc
index 1b61d62..0d02d31 100644
--- a/zircon/kernel/phys/test/zbi-test-main.cc
+++ b/zircon/kernel/phys/test/zbi-test-main.cc
@@ -11,7 +11,9 @@
 
 #include "test-main.h"
 
-void ZbiMain(void* zbi, arch::EarlyTicks ticks) {
+// Make sure ZbiMain can't be inlined into PhysMain via LTO, so that
+// tests will have a known machine-level backtrace to TestMain.
+[[gnu::noinline]] void ZbiMain(void* zbi, arch::EarlyTicks ticks) {
   // Early boot may have filled the screen with logs. Add a newline to
   // terminate any previous line, and another newline to leave a blank.
   printf("\n\n");