VS 链接器生成两个具有相同名称的部分

VS linker produces two sections with the same name

我使用此代码创建新部分:

#pragma section(".new", execute, read, write)
#pragma code_seg(".new")

当我在PeView中打开PE文件时,我看到已经创建了两个同名的部分,其他部分的目的是什么?

第二个 pragma 指定要分配函数的代码部分(在您的情况下为 .new 部分)

使用不带段名字符串的#pragma code_seg 会将分配重置为编译开始时的状态。