23 Star 30 Fork 165

src-openEuler/gcc
关闭

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0377-oeAware-Fix-.GCC4OE_oeAware-section-dup-in-namespace.patch 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
huzife 提交于 2025-05-20 19:10 +08:00 . [Sync] Sync patches from openeuler/gcc
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/gcc.git
git@gitee.com:src-openeuler/gcc.git
src-openeuler
gcc
gcc
master

搜索帮助