minijail: Move the call to abort(2) into do_fatal_log()
This change moves the invocation to abort(2) into do_fatal_log(). This
causes the compiler to avoid simply inserting a branch to a common place
in large functions (such as minijail_enter()) that eventually calls
abort(2), which in turn should make the breakpad-based stack unwinder be
able to more accurately pinpoint the failing line instead of just
blaming the whole function.
Bug: 111271997
Test: objdump -d minijail0 | grep abort@plt | wc -l # 1
Test: objdump -d libminijailpreload.so | grep abort@plt | wc -l # 2
Change-Id: I770c8f1a06736100506053685f3e380a2576a80b
diff --git a/util.c b/util.c
index 616ac93..ffd1143 100644
--- a/util.c
+++ b/util.c
@@ -81,6 +81,26 @@
};
/* clang-format on */
+#if defined(USE_EXIT_ON_DIE)
+#define do_abort() exit(1)
+#else
+#define do_abort() abort()
+#endif
+
+void do_fatal_log(int priority, const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ if (logging_config.logger == LOG_TO_SYSLOG) {
+ vsyslog(priority, format, args);
+ } else {
+ vdprintf(logging_config.fd, format, args);
+ dprintf(logging_config.fd, "\n");
+ }
+ va_end(args);
+ do_abort();
+}
+
void do_log(int priority, const char *format, ...)
{
if (logging_config.logger == LOG_TO_SYSLOG) {