message: Register individual FDEs for musl libc
diff: @@ -59,9 +59,13 @@ impl UnwindRegistry {
  #[allow(clippy::cast_ptr_alignment)]
  unsafe fn register_frames(&mut self, eh_frame: &[u8]) {
  - cfg_if::cfg_if! {
  - if #[cfg(target_os = "macos")] {
  - // On macOS, `__register_frame` takes a pointer to a single FDE
  + if cfg!(all(target_os = "linux", target_env = "gnu")) {
  + // On gnu (libgcc), `__register_frame` will walk the FDEs until an entry of length 0
  + let ptr = eh_frame.as_ptr();
  + __register_frame(ptr);
  + self.registrations.push(ptr as usize);
  + } else {
  + // For libunwind, `__register_frame` takes a pointer to a single FDE
  let start = eh_frame.as_ptr();
  let end = start.add(eh_frame.len());
  let mut current = start;
  @@ -79,20 +83,6 @@ impl UnwindRegistry {
  // Move to the next table entry (+4 because the length itself is not inclusive)
  current = current.add(len + 4);
  }
  - } else {
  - // On other platforms, `__register_frame` will walk the FDEs until an entry of length 0
  -
  - // Registering an empty `eh_frame` (i.e. which
  - // contains empty FDEs) cause problems on Linux when
  - // deregistering it. We must avoid this
  - // scenario. Usually, this is handled upstream by the
  - // compilers.
  - debug_assert_ne!(eh_frame, &[0, 0, 0, 0], "`eh_frame` seems to contain empty FDEs");
  -
  - let ptr = eh_frame.as_ptr();
  - __register_frame(ptr);
  - self.registrations.push(ptr as usize);
  - }
  }
  }
  }
  