Write link data for dexlayout

Instead of not writing out the link data and leaving an invalid
link_offset, write it out. Fixes dex verifier failures for a few
APKs.

Added test.

Test: test-art-host
Bug: 69561363

Change-Id: Iec1c331f74f9fd58658d4c13465a3bcb6295ce24
diff --git a/dexlayout/dex_ir_builder.cc b/dexlayout/dex_ir_builder.cc
index 924dfe0..1fd963f 100644
--- a/dexlayout/dex_ir_builder.cc
+++ b/dexlayout/dex_ir_builder.cc
@@ -80,6 +80,11 @@
   // Sort the vectors by the map order (same order as the file).
   collections.SortVectorsByMapOrder();
 
+  // Load the link data if it exists.
+  collections.SetLinkData(std::vector<uint8_t>(
+      dex_file.Begin() + dex_file.GetHeader().link_off_,
+      dex_file.Begin() + dex_file.GetHeader().link_off_ + dex_file.GetHeader().link_size_));
+
   return header;
 }