llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libunwind

Author: Walter Lee (googlewalt)

<details>
<summary>Changes</summary>

Commit fd4113508a64 ("[libunwind] Support extended amd64 segment registers", 
#<!-- -->229176) made libunwind/src/assembly.h include &lt;sys/syscall.h&gt; on 
x86_64 Linux to get SYS_arch_prctl. On Android (Bionic, NDK r29), that header 
includes &lt;sys/cdefs.h&gt; -&gt; &lt;android/api-level.h&gt; -&gt; 
&lt;bits/get_device_api_level_inlines.h&gt;, which contain C declarations 
guarded only by __ASSEMBLY__ (not defined for .S files). As a result, 
UnwindRegistersSave.S and UnwindRegistersRestore.S fail to assemble for x86_64 
Android.

On Linux, use the assembler-safe kernel UAPI header &lt;asm/unistd.h&gt; and 
__NR_arch_prctl alongside the existing &lt;asm/prctl.h&gt;. FreeBSD continues 
to use &lt;sys/syscall.h&gt;.

Fixes fd4113508a64.

Assisted-by: Gemini

---
Full diff: https://github.com/llvm/llvm-project/pull/235756.diff


1 Files Affected:

- (modified) libunwind/src/assembly.h (+6-2) 


``````````diff
diff --git a/libunwind/src/assembly.h b/libunwind/src/assembly.h
index a36d2669eaa50..cb6a06c53ac19 100644
--- a/libunwind/src/assembly.h
+++ b/libunwind/src/assembly.h
@@ -17,15 +17,19 @@
 
 #if defined(__x86_64__) && !defined(_LIBUNWIND_IS_BAREMETAL) &&                
\
     (defined(__linux__) || defined(__FreeBSD__))
-#include <sys/syscall.h>
 #if defined(__linux__)
+// Use the kernel UAPI headers, which are safe to include from assembly. The
+// libc <sys/syscall.h> is not: on Android it pulls in <sys/cdefs.h> and
+// <android/api-level.h>, which contain C declarations.
 #include <asm/prctl.h>
+#include <asm/unistd.h>
 #define X86_64_GET_FSBASE ARCH_GET_FS
 #define X86_64_GET_GSBASE ARCH_GET_GS
 #define X86_64_SET_FSBASE ARCH_SET_FS
 #define X86_64_SET_GSBASE ARCH_SET_GS
-#define X86_64_BASE_SYSCALL SYS_arch_prctl
+#define X86_64_BASE_SYSCALL __NR_arch_prctl
 #else
+#include <sys/syscall.h>
 // <machine/sysarch.h> contains C declarations and cannot be included here.
 #define X86_64_GET_FSBASE 128 // AMD64_GET_FSBASE
 #define X86_64_GET_GSBASE 130 // AMD64_GET_GSBASE

``````````

</details>


https://github.com/llvm/llvm-project/pull/235756
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to