Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -783,6 +783,9 @@
     Sec->setSHName(Out<ELFT>::ShStrTab->addString(Sec->getName()));
   }
 
+  // DynSymTab->finalize() needs this.
+  Out<ELFT>::ARMExidx = findSection(".ARM.exidx");
+
   // Finalizers fix each section's size.
   // .dynsym is finalized early since that may fill up .gnu.hash.
   if (Out<ELFT>::DynSymTab)
@@ -1296,6 +1299,11 @@
       Sec->writeTo(Buf + Sec->getFileOff());
 }
 
+struct {
+  ulittle32_t StartAddr;
+  uint32_t Data;
+} ARMExidxEntry;
+
 // Write section contents to a mmap'ed file.
 template <class ELFT> void Writer<ELFT>::writeSections() {
   uint8_t *Buf = Buffer->getBufferStart();
@@ -1316,6 +1324,16 @@
   // it should be written after .eh_frame is written.
   if (!Out<ELFT>::EhFrame->empty() && Out<ELFT>::EhFrameHdr)
     Out<ELFT>::EhFrameHdr->writeTo(Buf + Out<ELFT>::EhFrameHdr->getFileOff());
+
+  // Sort ARM exception table by function start address.
+  if (Out<ELFT>::ARMExidx) {
+    auto *Start = (ARMExidxEntry *)(Buf + Out<ELFT>::ARMExidx->getFileOff());
+    size_t NumEnt = Out<ELFT>::ARMExidx->getSize() / sizeof(ARMExidxEntry);
+    std::sort(Start, Start + NumEnt,
+              [](const ARMExidxEntry *A, const ARMExidxEntry *B) {
+                return A->StartAddr < B->StartAddr;
+              });
+  }
 }
 
 template <class ELFT> void Writer<ELFT>::writeBuildId() {