Merge pull request #2261 from BrzVlad/fix-arm-fast-tls-master
[mono.git] / mcs / class / PEAPI / PEAPI.cs
index faf351513c323cc75e31f6f1040bd7e03b4ab10c..ec3cb4107176a74c0065e82b37a7e856322056bf 100644 (file)
@@ -162,8 +162,10 @@ namespace PEAPI {
 
                private uint GetNextSectStart(uint rva, uint tide) 
                {
-                       if (tide < SectionAlignment) return rva + SectionAlignment;
-                       return rva + ((tide / SectionAlignment) + 1) * SectionAlignment;
+                       uint c = tide / SectionAlignment;
+                       if ((tide % SectionAlignment) != 0)
+                               c++;
+                       return rva + (c * SectionAlignment);
                }
 
                private void BuildTextSection() 
@@ -588,8 +590,6 @@ namespace PEAPI {
                private static readonly string mscorlibName = "mscorlib";
                private Module thisMod;
                private ClassDef moduleClass;
-               private ArrayList classRefList = new ArrayList();
-               private ArrayList classDefList = new ArrayList();
                private ArrayList resources = new ArrayList ();
                private Assembly thisAssembly;
                private static bool isMSCorlib;
@@ -753,6 +753,11 @@ namespace PEAPI {
                        return modRef;
                }
 
+               public ClassRef AddExternClass(string ns, string name, TypeAttr attrs, MetaDataElement declRef)
+               {
+                       return new ExternClassRef (attrs, ns, name, declRef, metaData);
+               }
+               
                /// <summary>
                /// Add a "global" method to this module
                /// </summary>
@@ -918,6 +923,11 @@ namespace PEAPI {
                        return file;
                }
 
+               public PrimitiveTypeRef AddPrimitiveType (PrimitiveType type)
+               {
+                       return new PrimitiveTypeRef (type, metaData);
+               }
+
                /// <summary>
                /// Add a manifest resource to this PEFile NOT YET IMPLEMENTED
                /// </summary>
@@ -935,6 +945,12 @@ namespace PEAPI {
                        element.HasCustomAttr = true;
                }
 
+               public void AddCustomAttribute (Method meth, Constant constant, MetaDataElement element)
+               {
+                       metaData.AddCustomAttribute (new CustomAttribute (element, meth, constant));
+                       element.HasCustomAttr = true;
+               }
+
                public void AddDeclSecurity (SecurityAction sec_action, byte [] data, MetaDataElement element)
                {
                        metaData.AddDeclSecurity (new DeclSecurity (element, (ushort) sec_action, data));