[libc-commits] [libc] [libc++] Fix the behavior of throwing `operator new` under -fno-exceptions (PR #69498)

Reid Kleckner via libc-commits libc-commits at lists.llvm.org
Thu Oct 19 11:04:36 PDT 2023


================
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___OVERRIDABLE_FUNCTION
+#define _LIBCPP___OVERRIDABLE_FUNCTION
+
+#include <__config>
+#include <cstdint>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE                                                                   \
+  __attribute__((__section__("__TEXT,__lcxx_override,regular,pure_instructions")))
----------------
rnk wrote:

To port this to ELF, I think you could use `__attribute__((section("lcxx_override")))`, and then declare external `__start_lcxx_override` and `__stop_lcxx_override` symbols. That should work with all the linkers we care about. COFF can probably be done, but I'm sure it's more involved and probably not worth doing.

https://github.com/llvm/llvm-project/pull/69498


More information about the libc-commits mailing list