什么是COMDAT部分用于? [英] What is the COMDAT section used for?

查看:741
本文介绍了什么是COMDAT部分用于?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到/ Gy选项,我想知道为什么我会使用它? http://msdn.microsoft.com/en-us/library/xsa71f43.aspx

I see the /Gy option and am wondering why I would use it? http://msdn.microsoft.com/en-us/library/xsa71f43.aspx

推荐答案

目前接受的答案< a>有些不完整。

The currently accepted answer is somewhat incomplete.

COMDAT节的目的是允许在多个目标文件中定义重复节。通常,如果在多个目标文件中定义了相同的符号,则链接器将报告错误。这可能会导致某些C ++语言功能(如模板)出现问题,可能会在不同的cpp文件中实例化相同的符号。

The purpose of a COMDAT section is to allow "duplicate" sections to be defined in multiple object files. Normally, if the same symbol is defined in multiple object files, the linker will report errors. This can cause problems for some C++ language features, like templates, that may instantiate the same symbols in different cpp files.

COMDAT节用于解决此问题。当一个节在目标文件中标记为COMDAT时,它还指定一个标志,指示应如何解决冲突。有很多选项,包括只是选择任何你喜欢的,确保所有副本的大小相同,确保所有副本具有相同的内容,选择最大的一个等。

COMDAT sections are used to get around this. When a section is marked as a COMDAT in an object file, it also specifies a flag that indicates how conflicts should be resolved. There are a bunch of options, including "just pick anyone you like", "make sure all dups. are the same size", "make sure all dups. have the same content", "pick the largest one", etc. See the COFF spec for a complete list.

在任何情况下,与目前接受的答案说,没有要求,单向或其他,关于COMDAT部分的内容是什么。它们可以包含一个过程,许多过程,数据或代码和数据的任意组合。

In any case, unlike what the currently accepted answer said, there's no requirements, one way or the other, on what the contents of a COMDAT section has to be. They can contain one procedure, many procedures, data, or any combination of both code and data.

这篇关于什么是COMDAT部分用于?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆