MSILFileFormatSpecWord下载.docx
- 文档编号:21351167
- 上传时间:2023-01-29
- 格式:DOCX
- 页数:37
- 大小:42.96KB
MSILFileFormatSpecWord下载.docx
《MSILFileFormatSpecWord下载.docx》由会员分享,可在线阅读,更多相关《MSILFileFormatSpecWord下载.docx(37页珍藏版)》请在冰豆网上搜索。
10October2000
TableOfContents
1Overview4
1.1StructureoftheRuntimeFileFormat4
1.2ProducersandConsumersoftheRuntimeFileFormat5
1.3RequirementsAddressedbytheRuntimeFileFormatDesign5
1.4OSInteractions7
2EmittingAValidCLRImage8
2.1FileHeaders8
2.1.1Signature8
2.1.2COFFHeader8
2.1.2.1MachineType8
2.1.2.2Characteristics8
2.1.3OptionalHeader9
2.1.3.1OptionalHeaderStandardFields9
2.1.3.2OptionalHeaderWindowsNT-SpecificFields10
2.1.3.2.1SubSystemSettings11
2.1.3.2.2StackReserveSize11
2.1.3.3OptionalHeaderDataDirectories12
2.1.4StoringRuntimeDatainSections13
2.1.5RuntimeHeader13
2.1.5.1RuntimeHeaderDefinition14
2.1.5.2RuntimeFlags15
2.1.5.3EntryPointMetaDataToken15
2.1.5.4VTableFixup16
2.1.5.5Resources17
2.1.5.6StrongNameSignature17
2.2SectionHeaders17
2.3ModificationstoExistingPEData17
2.3.1ImportAddressTable(IAT)18
2.3.2ExportSection(.edata)18
2.3.3ThreadLocalStorageTable18
2.3.4Relocations18
3IntermediateLanguage20
3.1LocalVariableLayout20
3.2FileFormatStructureDefinitions20
3.2.1MethodBody20
3.2.1.1MethodHeaderTypeValues21
3.2.1.2TinyFormat21
3.2.1.3FatFormat21
3.2.1.4IMAGE_COR_ILMETHOD22
3.2.1.5IMAGE_COR_ILMETHOD_TINY22
3.2.1.6IMAGE_COR_ILMETHOD_FAT22
3.2.1.6.1FlagsforMethodHeaders23
3.2.2SectionData23
3.2.3IMAGE_COR_ILMETHOD_SECT_EH24
3.2.3.1IMAGE_COR_ILMETHOD_SECT_EH_SMALL24
3.2.3.2CorExceptionFlagValues24
3.2.3.3IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_SMALL25
3.2.3.4IMAGE_COR_ILMETHOD_SECT_EH_FAT25
3.2.4IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT26
4CodeTransitions27
4.1CallTransitions27
4.1.1TransitionTypes27
EffectsonLikePiecesofCode28
AffectsonILCode28
AffectsonNativeCode28
4.2RuntimeHeaderSupportforTransitions28
4.2.1VTableFixups28
4.2.2ExportAddressTableFix-ups29
5EntryPoints31
5.1RuntimeAPI’s31
5.1.1_CorExeMain31
5.1.2_CorDllMain31
5.1.3EntryPointsforWindowsCE31
5.2ShutDownRequirements31
5.3EntryPointStubs31
5.3.1RuntimeAwareOSLoader31
5.3.2NonRuntimeAwareOSLoader32
5.3.3Samplex86Stubs32
1Overview
ThisdocumentspecifiesafileformatforCommonLanguageRuntime(CLR)componentsthatisbasedon,andisastrictextensionof,thecurrentMicrosoftWindowsPortableExecutable(PE)andCommonObjectFileFormat(COFF).ThisextendedPE/COFFformatenablestheWindowsoperatingsystemtorecognizeruntimeimages,accommodatescodeemittedasruntimeMicrosoftintermediatelanguage(MSIL)ornativecode,andaccommodatesruntimemetadataasanintegralpartoftheemittedcode.
Thissectionprovidesabriefoverviewofandmotivationforthedesignapproach,includingasummaryofrequirementsandconstraints.SubsequentsectionspresentthetechnicalspecificationsasadeltafromthecurrentWindowsPE/COFFfileformat,insufficientdetailthatatoolorcompilercanusethespecificationstoemitvalidruntimeimages.
TheentiredocumentassumesfamiliaritywiththecurrentPE/COFFstructureandterminology.Formoreinformation,refertothe“MicrosoftPortableExecutableandCommonObjectFileFormatSpecification”
StructureoftheRuntimeFileFormat
Thefigurebelowprovidesahigh-levelviewoftheCLRfileformat.Allruntimeimagescontainthefollowing:
∙StandardPE/COFFheaders,withspecificguidelinesonhowfieldvaluesshouldbesetinaruntimefile
∙Aruntimeheaderthatcontainsalloftheruntimespecificdataentries.Currently,theruntimeheaderisread-onlyandmaybeplacedinanyread-onlysection
∙AnyofthedataonecurrentlyfindsinavalidPE/COFFimage,includingimports/exports,data,andcode.Thisspeccallsoutspecificareaswhereweusethisdataintheruntime.
PE/COFFHeaders
CLRHeader
CLRData:
metadata,ILmethodbodies,fix-ups
NativeImageSections:
.rdata,.rsrc,.data,.text,...
TheimageisafullPE/COFFfileimage.ThenormalPE/COFFheadersapply.TheruntimeheaderisfoundusingdirectoryentryIMAGE_DIRECTORY_COR_DESCRIPTORinthePEheader.Theruntimeheaderinturncontainstheaddressandlocationsoftheruntimedataintherestoftheimage.NotethattheruntimedatacanbemergedintootherareasofthePEformatwiththeotherdatabasedontheattributesofthesections(suchasreadonlyversusexecute,etc.).
Whilethebulkofthefileformatisgeneratedbytoolsdirectly,themetadataportionisemittedthroughanAPIthatabstractsthetoolsfromtheunderlyingdatastructures.Thisisinpartbecausethedatastructuresaremanyandcomplex,havingbeentunedforperformanceandsize,andbecausewewanttobeabletodoadditionaltuningofthestructureswithoutimpactingthetoolsthatareemittingthem.And,itisinpartbecausetheruntimemetadataengineeventodaysupportsanumberofdifferentformatsexposedinauniformwaythroughthesameAPI.Forexample,forCOMInterop,aconsumerofruntimemetadatacanimportatypelibasthoughitwereaperfectlyvalidruntimemetadatafile.RefertotheMetadataInterfaces_cor_COM__Metadata_Emit_Import_Interface_Specificationspecfordetailsonemittingandconsumingthemetadataportionofaruntimeimage.
ProducersandConsumersoftheRuntimeFileFormat
Developmenttoolsandcompilerswillemitruntimeimagesthatcanbepackagedanddeployedacrossarangeofruntime-enabledplatforms.DevelopmenttoolswillrangefromRADtools(includingscriptinglanguages)tohigh-levellanguagecompilers.Thefirstcategoryoftoolswillcompileandemitfilesinasinglepassfromthedevelopmentenvironment.Scriptingtoolsmaynotevenhaveaneedtopersisttheresultingfile,butsimplyregeneratethecodeeverytimeit’sexecuted.Thesecondcategoryoftoolshasanincrementalapproach,firstemittingintermediatecompilationunitsandthenlinkingthemtogetherwithresourcesintoaloadableruntimeimage.
Thefileformatneedstoaccommodatenotonlywhattheruntimewillrequireinordertoloadandexecutethesefiles,butitneedstomakeitreasonablystraightforwardforthisrangeofdifferenttoolswithdifferentinternaldatastructuresandcompilationmodelstoemitmetadataandcodeefficiently(alongwithimports/exports,fix-ups,debugginginformation,etc.).
Consumersoftheruntimefileformatincludetheruntimeitselfaswellasdevelopmenttoolsandadministrativetools.TheruntimeconsumesmetadataandILinordertoJIT-compileILtonativecode.Theloaderconsumesmetadatatoloadclassesandtrackmanageddatastructures.Developmenttoolswillimportmetadatatoenablereferencestoruntimetypesandmembers.Administrativetoolswillconsumemetadatatobrowseclassesandconfigureservices.
RequirementsAddressedbytheRuntimeFileFormatDesign
Initialexplorationofalternativedesignapproachesrangedfromintroducinganentirelynewfileformatfortheruntimethatwouldco-existside-by-sidewithtoday’sPEfileformat,toensuringthattheruntimeformatwasanaturalextensionoftoday’sWindowsPEfile.Inhavingchosenthelatterapproach,itmaybeinstructivetoreviewtherequirementsthatdrovethedesignandspecwork.
AnOptionofILorNativeCode
Adeveloperwhowantstotargetarangeofruntimeplatformsmaywanttobuildacomponentorassemblyofcomponentsonceandcompiletonativewhenneededforaparticularplatform.Optionsfor“whenneeded”rangefromdeploymenttimetoinstalltimetoexecutiontime.Inthisscenario,thecodeisemittedasIL,plusthemetadatathattheruntimeJITcompiler(s)usetocompiletheILtonative.
Adeveloperbuildingaruntimecomponentorapplicationinhisorherfavoritelanguagemayhavereasontocompilecodedirectlytonative.Forexample,ifthecodeisknowntotargetonlyaspecificplatform,theremaybenoperceivedbenefitfromgoingthroughanintermediatelanguage.Thisdoesnotmeanthatthedeveloperneedforegothebenefitsoftheruntimemanagedservices.Inthedesignpresentedinthisdocument,thetargetfileformatistoday’sPEfile,either.exeor.dll.
Tobemorespecific,theruntimerecognizesmanagednativecodeandunmanagednativecode.BotharecompiledinanylanguagetothenativeinstructionsetofaCPU.Unlikeunmanagednativecode,managednativecodehasadditionalmetadataandcodingconventionsusedbytheruntimetoenablegarbagecollection,exceptionsandotherruntimefeatures.Thecurrentfileformatspecificationdoesnotdescribethesemetadataandfileformatextensions.Unmanagednativecodeisfullysupported,emittedusingallofthestructuresoftoday’sPE/COFF.
ACombinationofILandNativeCode
TheruntimewillacceptafilecontainingamixtureofILandnativecode.Theruntimefileformataccommodateseitheroneorbothnaturallyinasingleformat,withoutrequiringcompilerstoemit,andOSloaderstorecognize,arangeofdifferentformatsforspecializedpurposes.
Self
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MSILFileFormatSpec