Page MenuHomeFreeBSD

libsys/arm: include ARM EABI unwind bits into libsys
ClosedPublic

Authored by fuz on Wed, Feb 11, 10:14 PM.
Tags
None
Referenced Files
F146909511: D55255.diff
Fri, Mar 6, 4:31 PM
Unknown Object (File)
Fri, Feb 27, 3:49 PM
Unknown Object (File)
Mon, Feb 23, 10:49 AM
Unknown Object (File)
Sun, Feb 22, 5:31 PM
Unknown Object (File)
Fri, Feb 20, 1:33 PM
Unknown Object (File)
Thu, Feb 19, 5:14 AM
Unknown Object (File)
Fri, Feb 13, 4:20 AM
Unknown Object (File)
Thu, Feb 12, 5:26 PM

Details

Summary

libsys required ARM EABI unwind symbols like __aeabi_unwind_cpp_pr0.
These symbols are normally provided by libc, but if a binary does
not link libc, the symbol ends up not being resolved.

Among other problems, this prevented gcc14 and newer from building
on arm.

Add the relevant symbols as hidden symbols into libsys to avoid this
problem.

We also switch from abort() to __builtin_trap() in the aeabi_unwind
stubs to avoid a dependency on abort.

(this patch was posted by jrtc27 who has asked me to move it along)

PR: 292539
Submitted by: jrtc27
Tested by: Mark Millard <marklmi26-fbsd@yahoo.com>

Test Plan

lang/gcc14 builds fine with this change set.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

fuz requested review of this revision.Wed, Feb 11, 10:14 PM

Should not these symbols also be marked as weak? Hidden symbols are not 'overloaded' in the same library. kib, jrtc27 any comment about this, please?

Should not these symbols also be marked as weak? Hidden symbols are not 'overloaded' in the same library. kib, jrtc27 any comment about this, please?

I see no use in marking these symbols as weak, They are hidden, which means that they are directly bound to the references, also they are not exported. So they are not interposable.
It might be useful, though, to only link aeabi_uwind_cpp into dso and not include it into libsys.a. If this is your concern that the object file might be found by the static linker.
BTW the same point for libc.

Sorry for my poorly formulated question.
The hidden but not weak aeabi_unwind_cpp_pr* symbols means that we don't expect or want to process exceptions generated in libsys because the unwinder always ends in an abort/trap. So why don't we simply compile libsys with -fno-exceptions?

I'm not questioning the patch itself; I just want to understand its context.
Thanks.

We do want the unwind info generated for libsys. Although libsys cannot generate exceptions synchronously, it still might be the last frame for stack where signal is delivered for process that slept in the slow syscall. The unwinding info is needed for any dwarf stack unwinders then, like gdb, libunwind, etc, even in its armv7 variant, as far as I understand.

So -fno-exceptions is not a choice there.

I understand that libsys might be the last frame.
However, this also means that the unwinder is supposed to call the function aeabi_unwind_cpp_pr0, found in the .ARM.exidx section of the corresponding object.
In your case, this is
buildin_trap().
Is this right?

This is the last question, I promise.

I understand that libsys might be the last frame.
However, this also means that the unwinder is supposed to call the function aeabi_unwind_cpp_pr0, found in the .ARM.exidx section of the corresponding object.
In your case, this is
buildin_trap().
Is this right?

This is the last question, I promise.

Are unwinders really supposed to call anything to just get the backtrace, as opposed to really unwind (e.g. to catch C++ exception)?

I'm not sure if anyone knows the exact, precise response. ARMv7 unwinding is pure mesh. All of my attempts to understand it ended with me turning off the computer and opening a bottle of good wine.
I think it's possible to write a backtrace that doesn't use it, but I also think it's used by the unwinder library, which is also used for backtraces.
My motivation was to be careful about security. If the executable implements real unwinder personalities, we should also use it for libsys

In any case, we've come too far. This patch is clearly a step in the right direction, and I don't want to block it.

Thanks for your effort.

This revision is now accepted and ready to land.Thu, Feb 12, 11:19 AM

Sorry for my poorly formulated question.
The hidden but not weak aeabi_unwind_cpp_pr* symbols means that we don't expect or want to process exceptions generated in libsys because the unwinder always ends in an abort/trap. So why don't we simply compile libsys with -fno-exceptions?
. . .

In my experiments for armv7 specifically, that option did not disable having the unwind tables nor the associated eabi_unwindow_cpp_pr* symbols. The only option I found that did disable at least some of that in the object files also happened to disable all of it: -fno-asynchronous-unwind-tables . See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292539#c13 .