Dexlayout fix for duplicate class data and preserving last code item.

This change fixes a dexlayout issue when multiple class defs reference
the same class data. A set is used to tell what class data has already
been visited.

This change also makes dexlayout preserve the offset of the last code
item in the dex file if the following section is not 4-byte aligned.
Due to limitations in dexlayout, it is difficult to adjust the offsets
of sections if more space is needed. An overhaul of dexlayout should
be done to properly fix this.

Bug: 35451910
Test: mm test-art-host-gtest-dexlayout_test
Change-Id: I8d066c2151a1a57c382ce35f12bf53a519da89f6
diff --git a/dexlayout/dexlayout.h b/dexlayout/dexlayout.h
index ac1a4a6..3918706 100644
--- a/dexlayout/dexlayout.h
+++ b/dexlayout/dexlayout.h
@@ -105,8 +105,9 @@
   void DumpSField(uint32_t idx, uint32_t flags, int i, dex_ir::EncodedValue* init);
   void DumpDexFile();
 
-  std::vector<dex_ir::ClassDef*> LayoutClassDefsAndClassData(const DexFile* dex_file);
-  int32_t LayoutCodeItems(std::vector<dex_ir::ClassDef*> new_class_def_order);
+  std::vector<dex_ir::ClassData*> LayoutClassDefsAndClassData(const DexFile* dex_file);
+  int32_t LayoutCodeItems(std::vector<dex_ir::ClassData*> new_class_data_order);
+  bool IsNextSectionCodeItemAligned(uint32_t offset);
   template<class T> void FixupSection(std::map<uint32_t, std::unique_ptr<T>>& map, uint32_t diff);
   void FixupSections(uint32_t offset, uint32_t diff);