[libc-commits] [libc] [libc] Also remove _FORTIFY_SOURCE before including <stdlib.h> in overlay mode. (PR #142647)

via libc-commits libc-commits at lists.llvm.org
Tue Jun 3 10:48:51 PDT 2025


https://github.com/lntue created https://github.com/llvm/llvm-project/pull/142647

None

>From f5e614c8d69b11d6fadccf96eff604607e08999d Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Tue, 3 Jun 2025 17:46:52 +0000
Subject: [PATCH] [libc] Also remove _FORTIFY_SOURCE before including
 <stdlib.h> in overlay mode.

---
 libc/hdr/stdlib_overlay.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libc/hdr/stdlib_overlay.h b/libc/hdr/stdlib_overlay.h
index f095cafe5e0bc..53c32ec0ae332 100644
--- a/libc/hdr/stdlib_overlay.h
+++ b/libc/hdr/stdlib_overlay.h
@@ -19,6 +19,11 @@
 // functions, causing external alias errors.  They are guarded by
 // `__USE_FORTIFY_LEVEL`, which will be temporarily disabled.
 
+#ifdef _FORTIFY_SOURCE
+#define LIBC_OLD_FORTIFY_SOURCE _FORTIFY_SOURCE
+#undef _FORTIFY_SOURCE
+#endif
+
 #ifdef __USE_FORTIFY_LEVEL
 #define LIBC_OLD_USE_FORTIFY_LEVEL __USE_FORTIFY_LEVEL
 #undef __USE_FORTIFY_LEVEL
@@ -27,6 +32,11 @@
 
 #include <stdlib.h>
 
+#ifdef LIBC_OLD_FORTIFY_SOURCE
+#define _FORTIFY_SOURCE LIBC_OLD_FORTIFY_SOURCE
+#undef LIBC_OLD_FORTIFY_SOURCE
+#endif
+
 #ifdef LIBC_OLD_USE_FORTIFY_LEVEL
 #undef __USE_FORTIFY_LEVEL
 #define __USE_FORTIFY_LEVEL LIBC_OLD_USE_FORTIFY_LEVEL



More information about the libc-commits mailing list