跳转至

ev-mold-make-unique-section-001

字段 值
项目 rui314/mold
固定 commit 27162691b71a
路径 src/input-files.cc
行段 L371-L374
特性 std::make_unique
许可证 MIT
代码来源 项目源码
级别 manual
审核 zyuhao7 @ 2026-10-27
测试代码 否
发现方式 manual

用法

用 std::make_unique 在数组中创建派生段对象

为什么典型

工厂函数直接返回 unique_ptr,构造参数在同一表达式内传递,不暴露裸 new。

摘录

      if (ctx.arg.oformat_binary && !(shdr.sh_flags & SHF_ALLOC))
        continue;

      this->sections[i] = std::make_unique<InputSection<E>>(ctx, *this, i);

备注

生产路径;解析输入段时按索引创建 InputSection,所有权立即交给数组。

查看固定 commit 源码 · 返回证据索引