Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ See docs/process.md for more on how version tagging works.
- The undocumented `FS.filesystems` object was removed. Replace things like
`FS.filesystems['MEMFS']` with plain `MEMFS`. (#27940)
- libpng port updated from 1.6.58 to 1.6.59. (#27956)
- libunwind was updated to LLVM 23.1.3. (#28014)

6.0.12 - 10/08/26
-----------------
Expand Down
6 changes: 3 additions & 3 deletions system/lib/libunwind/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
LLVM's libunwind
----------------

These files are from the llvm-project based on release 22.1.8.
These files are from the llvm-project based on release 23.1.3.

We maintain a local fork of llvm-project that contains any Emscripten
specific patches:

https://github.com/emscripten-core/llvm-project

The current patch is based on the emscripten-libs-22 branch.
The current patch is based on the emscripten-libs-23 branch.

Update Instructions
-------------------
Expand All @@ -20,4 +20,4 @@ Modifications

For a list of changes from upstream see the libunwind files that are part of:

https://github.com/llvm/llvm-project/compare/llvmorg-22.1.8...emscripten-core:emscripten-libs-22
https://github.com/llvm/llvm-project/compare/llvmorg-23.1.3...emscripten-core:emscripten-libs-23
2 changes: 1 addition & 1 deletion system/lib/libunwind/include/__libunwind_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef ____LIBUNWIND_CONFIG_H__
#define ____LIBUNWIND_CONFIG_H__

#define _LIBUNWIND_VERSION 15000
#define _LIBUNWIND_VERSION 230000

#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
!defined(__ARM_DWARF_EH__) && !defined(__SEH__)
Expand Down
2 changes: 1 addition & 1 deletion system/lib/libunwind/include/libunwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
__unwind_ptrauth_restricted_intptr(ptrauth_key_function_pointer, 1, \
__ptrauth_unwind_cie_info_personality_disc)

// ptrauth_string_discriminator("personality") == 0x7EAD)
// ptrauth_string_discriminator("personality") == 0x7EAD
#define __ptrauth_unwind_pauthtest_personality_disc 0x7EAD

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ struct unwind_info_section_header_lsda_index_entry

struct unwind_info_regular_second_level_entry
{
uint32_t functionOffset;
uint32_t functionOffset;
compact_unwind_encoding_t encoding;
};

Expand Down
2 changes: 1 addition & 1 deletion system/lib/libunwind/include/unwind_itanium.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct _Unwind_Exception {
// The implementation of _Unwind_Exception uses an attribute mode on the
// above fields which has the side effect of causing this whole struct to
// round up to 32 bytes in size (48 with SEH). To be more explicit, we add
// pad fields added for binary compatibility.
// pad fields for binary compatibility.
uint32_t reserved[3];
#endif
// The Itanium ABI requires that _Unwind_Exception objects are "double-word
Expand Down
9 changes: 5 additions & 4 deletions system/lib/libunwind/src/CompactUnwinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef __COMPACT_UNWINDER_HPP__
#define __COMPACT_UNWINDER_HPP__

#include <inttypes.h>
#include <stdint.h>
#include <stdlib.h>

Expand Down Expand Up @@ -335,8 +336,8 @@ int CompactUnwinder_x86_64<A>::stepWithCompactEncodingRBPFrame(
default:
(void)functionStart;
_LIBUNWIND_DEBUG_LOG("bad register for RBP frame, encoding=%08X for "
"function starting at 0x%llX",
compactEncoding, functionStart);
"function starting at 0x%" PRIu64 "X",
compactEncoding, functionStart);
_LIBUNWIND_ABORT("invalid compact unwind encoding");
}
savedRegisters += 8;
Expand Down Expand Up @@ -454,8 +455,8 @@ int CompactUnwinder_x86_64<A>::stepWithCompactEncodingFrameless(
break;
default:
_LIBUNWIND_DEBUG_LOG("bad register for frameless, encoding=%08X for "
"function starting at 0x%llX",
encoding, functionStart);
"function starting at 0x%" PRIu64 "X",
encoding, functionStart);
_LIBUNWIND_ABORT("invalid compact unwind encoding");
}
savedRegisters += 8;
Expand Down
43 changes: 17 additions & 26 deletions system/lib/libunwind/src/DwarfInstructions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ class DwarfInstructions {
__builtin_unreachable();
}
#if defined(_LIBUNWIND_TARGET_AARCH64)
static bool isReturnAddressSigned(A &addressSpace, R registers, pint_t cfa,
PrologInfo &prolog);
static bool isReturnAddressSignedWithPC(A &addressSpace, R registers,
pint_t cfa, PrologInfo &prolog);
enum RASignStatus {
RANotSigned = 0,
RASigned = 1,
RASignedWithPC = 2,
};
static RASignStatus getReturnAddressSignStatus(A &addressSpace, R registers,
pint_t cfa,
PrologInfo &prolog);
#endif
};

Expand Down Expand Up @@ -177,7 +181,8 @@ v128 DwarfInstructions<A, R>::getSavedVectorRegister(
}
#if defined(_LIBUNWIND_TARGET_AARCH64)
template <typename A, typename R>
bool DwarfInstructions<A, R>::isReturnAddressSigned(A &addressSpace,
typename DwarfInstructions<A, R>::RASignStatus
DwarfInstructions<A, R>::getReturnAddressSignStatus(A &addressSpace,
R registers, pint_t cfa,
PrologInfo &prolog) {
pint_t raSignState;
Expand All @@ -187,24 +192,9 @@ bool DwarfInstructions<A, R>::isReturnAddressSigned(A &addressSpace,
else
raSignState = getSavedRegister(addressSpace, registers, cfa, regloc);

// Only bit[0] is meaningful.
return raSignState & 0x01;
}

template <typename A, typename R>
bool DwarfInstructions<A, R>::isReturnAddressSignedWithPC(A &addressSpace,
R registers,
pint_t cfa,
PrologInfo &prolog) {
pint_t raSignState;
auto regloc = prolog.savedRegisters[UNW_AARCH64_RA_SIGN_STATE];
if (regloc.location == CFI_Parser<A>::kRegisterUnused)
raSignState = static_cast<pint_t>(regloc.value);
else
raSignState = getSavedRegister(addressSpace, registers, cfa, regloc);

// Only bit[1] is meaningful.
return raSignState & 0x02;
// bits[1:0] describe how RA is signed.
assert((raSignState & 0x3) != 3 && "unexpected RA sign state");
return static_cast<RASignStatus>(raSignState & 0x3);
}
#endif

Expand Down Expand Up @@ -317,8 +307,9 @@ int DwarfInstructions<A, R>::stepWithDwarf(
// return address needs to be authenticated before the return address is
// restored. autia1716 is used instead of autia as autia1716 assembles
// to a NOP on pre-v8.3a architectures.
if ((R::getArch() == REGISTERS_ARM64) &&
isReturnAddressSigned(addressSpace, registers, cfa, prolog) &&
RASignStatus RAState =
getReturnAddressSignStatus(addressSpace, registers, cfa, prolog);
if ((R::getArch() == REGISTERS_ARM64) && RAState != RANotSigned &&
returnAddress != 0) {
#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
return UNW_ECROSSRASIGNING;
Expand All @@ -329,7 +320,7 @@ int DwarfInstructions<A, R>::stepWithDwarf(
// We use the hint versions of the authentication instructions below to
// ensure they're assembled by the compiler even for targets with no
// FEAT_PAuth/FEAT_PAuth_LR support.
if (isReturnAddressSignedWithPC(addressSpace, registers, cfa, prolog)) {
if (RAState == RASignedWithPC) {
register unsigned long long x15 __asm("x15") =
prolog.ptrAuthDiversifier;
if (cieInfo.addressesSignedWithBKey) {
Expand Down
2 changes: 1 addition & 1 deletion system/lib/libunwind/src/FrameHeaderCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE(msg, ...)
#endif

// This cache should only be be used from within a dl_iterate_phdr callback.
// This cache should only be used from within a dl_iterate_phdr callback.
// dl_iterate_phdr does the necessary synchronization to prevent problems
// with concurrent access via the libc load lock. Adding synchronization
// for other uses is possible, but not currently done.
Expand Down
23 changes: 17 additions & 6 deletions system/lib/libunwind/src/Registers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "libunwind_ext.h"
#include "shadow_stack_unwind.h"

#if defined(__APPLE__)
#include <sys/sysctl.h>
#endif
#if defined(_LIBUNWIND_HAVE_GETAUXVAL) || defined(_LIBUNWIND_HAVE_ELF_AUX_INFO)
#include <sys/auxv.h>
#endif
Expand Down Expand Up @@ -1892,7 +1895,7 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
uint64_t value = _registers.__pc;
#if defined(_LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING)
// Note the value of the PC was signed to its address in the register state
// but everyone else expects it to be sign by the SP, so convert on return.
// but everyone else expects it to be signed by the SP, so convert on return.
value = (uint64_t)ptrauth_auth_and_resign((void *)_registers.__pc,
ptrauth_key_return_address,
&_registers.__pc,
Expand Down Expand Up @@ -1940,7 +1943,15 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
_LIBUNWIND_ABORT("SME ZA disable failed");
}

#if defined(_LIBUNWIND_HAVE_GETAUXVAL)
#if defined(__APPLE__)
static bool checkHasSME() {
int has_sme = 0;
size_t size = sizeof(has_sme);
if (sysctlbyname("hw.optional.arm.FEAT_SME", &has_sme, &size, NULL, 0))
return false;
return has_sme != 0;
}
#elif defined(_LIBUNWIND_HAVE_GETAUXVAL)
static bool checkHasSME() {
constexpr int hwcap2_sme = (1 << 23);
unsigned long hwcap2 = getauxval(AT_HWCAP2);
Expand Down Expand Up @@ -3724,21 +3735,21 @@ inline void Registers_sparc::setRegister(int regNum, uint32_t value) {
inline bool Registers_sparc::validFloatRegister(int) const { return false; }

inline double Registers_sparc::getFloatRegister(int) const {
_LIBUNWIND_ABORT("no Sparc float registers");
_LIBUNWIND_ABORT("no sparc float registers");
}

inline void Registers_sparc::setFloatRegister(int, double) {
_LIBUNWIND_ABORT("no Sparc float registers");
_LIBUNWIND_ABORT("no sparc float registers");
}

inline bool Registers_sparc::validVectorRegister(int) const { return false; }

inline v128 Registers_sparc::getVectorRegister(int) const {
_LIBUNWIND_ABORT("no Sparc vector registers");
_LIBUNWIND_ABORT("no sparc vector registers");
}

inline void Registers_sparc::setVectorRegister(int, v128) {
_LIBUNWIND_ABORT("no Sparc vector registers");
_LIBUNWIND_ABORT("no sparc vector registers");
}

inline const char *Registers_sparc::getRegisterName(int regNum) {
Expand Down
6 changes: 4 additions & 2 deletions system/lib/libunwind/src/Unwind-wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
}

/// Not used in Wasm.
_LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t) {}
_LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
uintptr_t value) {}

/// Called by personality handler to get LSDA for current frame.
_LIBUNWIND_EXPORT uintptr_t
Expand All @@ -96,7 +97,8 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
}

/// Not used in Wasm.
_LIBUNWIND_EXPORT uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context *) {
_LIBUNWIND_EXPORT uintptr_t
_Unwind_GetRegionStart(struct _Unwind_Context *context) {
return 0;
}

Expand Down
Loading
Loading