[vm, elf] Add a terminating DT_NULL to .dynamic.

gold appears to assume shared libraries have one, though it has no effect during loading.

Bug: b/135481201
Change-Id: I6da4f829d0ab9a8e6174ddd39db6c206794f8d4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106431
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc
index 40ef3a4..9b1c566 100644
--- a/runtime/vm/elf.cc
+++ b/runtime/vm/elf.cc
@@ -57,6 +57,7 @@
 static const intptr_t STT_OBJECT = 1;  // I.e., data.
 static const intptr_t STT_FUNC = 2;
 
+static const intptr_t DT_NULL = 0;
 static const intptr_t DT_HASH = 4;
 static const intptr_t DT_STRTAB = 5;
 static const intptr_t DT_SYMTAB = 6;
@@ -323,6 +324,7 @@
     AddEntry(DT_STRSZ, strtab->memory_size);
     AddEntry(DT_SYMTAB, symtab->memory_offset);
     AddEntry(DT_SYMENT, kElfSymbolTableEntrySize);
+    AddEntry(DT_NULL, 0);
   }
 
   void Write(Elf* stream) {