代码拉取完成,页面将自动刷新
From 81600a0743fd889363339bc1463a56bae84cda60 Mon Sep 17 00:00:00 2001
From: liyancheng <412998149@qq.com>
Date: Sun, 18 May 2025 11:12:12 +0800
Subject: [PATCH 1/2] [oeAware] Fix .GCC4OE_oeAware section dup in namespace
main
This resolves an ICE "section already exists" caused
by incorrectly creating the .GCC4OE_oeAware section
for non-global main functions.
---
gcc/testsuite/gcc.dg/oeaware-main-in-namespace.cpp | 10 ++++++++++
gcc/varasm.cc | 8 +++++---
2 files changed, 15 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/oeaware-main-in-namespace.cpp
diff --git a/gcc/testsuite/gcc.dg/oeaware-main-in-namespace.cpp b/gcc/testsuite/gcc.dg/oeaware-main-in-namespace.cpp
new file mode 100644
index 000000000..5e44f4a1c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/oeaware-main-in-namespace.cpp
@@ -0,0 +1,10 @@
+/* { dg-do compile { target *-*-linux* *-*-gnu* } } */
+/* { dg-options "-foeaware-policy=1" } */
+
+namespace radar8446940 {
+int main () {
+ return 0;
+}
+}
+
+/* { dg-final { scan-assembler-not "GCC4OE_oeAware" } } */
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index bdf02edea..5134c0c1f 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -8572,11 +8572,13 @@ handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED)
void
create_oeaware_section ()
{
- /* To prevent inserting repeated segments and data,
- we only perform the insertion in the file where the main
+ /* To prevent inserting repeated segments and data, we only perform
+ the insertion in the file where the GLOBAL main
function is located. */
if (!cfun || TREE_CODE (cfun->decl) != FUNCTION_DECL
- || !DECL_NAME (cfun->decl) || !MAIN_NAME_P (DECL_NAME (cfun->decl)))
+ || !DECL_NAME (cfun->decl) || !MAIN_NAME_P (DECL_NAME (cfun->decl))
+ || (DECL_CONTEXT (cfun->decl) != NULL_TREE &&
+ TREE_CODE (DECL_CONTEXT (cfun->decl)) != TRANSLATION_UNIT_DECL))
return;
int flags = SECTION_STRINGS;
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。