Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 60136)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 60137)
@@ -38,5 +38,5 @@
 # 64-bit relocation conversion tool (used via the parent Config.kmk).
 BLDPROGS += VBoxBs3ObjConverter
-VBoxBs3ObjConverter_TEMPLATE = VBoxBldProg
+VBoxBs3ObjConverter_TEMPLATE = VBoxAdvBldProg
 VBoxBs3ObjConverter_SOURCES  = $(VBOX_PATH_BS3KIT_SRC)/VBoxBs3ObjConverter.cpp
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp	(revision 60136)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp	(revision 60137)
@@ -36,4 +36,5 @@
 #include <iprt/ctype.h>
 #include <iprt/assert.h>
+#include <iprt/sort.h>
 #include <iprt/x86.h>
 
@@ -979,11 +980,11 @@
                                  "%#018" ELF_FMT_X64 "  %#018" ELF_FMT_X64 ": unknown fix up %#x  (%+" ELF_FMT_D64 ")\n",
                                  paRelocs[j].r_offset, paRelocs[j].r_info, bType, paRelocs[j].r_addend);
-                if (RT_UNLIKELY(   j > 1
-                                && paRelocs[j].r_offset <= paRelocs[j - 1].r_offset
-                                &&   paRelocs[j].r_offset + ELF_AMD64_RELOC_SIZE(ELF64_R_TYPE(paRelocs[j].r_info))
-                                   < paRelocs[j - 1].r_offset ))
+                if (RT_UNLIKELY(   paRelocs[j].r_offset > paShdrs[i - 1].sh_size
+                                ||   paRelocs[j].r_offset + ELF_AMD64_RELOC_SIZE(ELF64_R_TYPE(paRelocs[j].r_info))
+                                   > paShdrs[i - 1].sh_size))
                     fRet = error(pszFile,
-                                 "%#018" ELF_FMT_X64 "  %#018" ELF_FMT_X64 ": out of offset order (prev %" ELF_FMT_X64 ")\n",
-                                 paRelocs[j].r_offset, paRelocs[j].r_info, paRelocs[j - 1].r_offset);
+                                 "%#018" ELF_FMT_X64 "  %#018" ELF_FMT_X64 ": out of bounds (sh_size %" ELF_FMT_X64 ")\n",
+                                 paRelocs[j].r_offset, paRelocs[j].r_info, paShdrs[i - 1].sh_size);
+
                 uint32_t const iSymbol = ELF64_R_SYM(paRelocs[j].r_info);
                 if (RT_UNLIKELY(iSymbol >= cSymbols))
@@ -992,13 +993,4 @@
                                  paRelocs[j].r_offset, paRelocs[j].r_info, iSymbol, cSymbols);
             }
-            if (RT_UNLIKELY(   cRelocs > 0
-                            && fRet
-                            && (   paRelocs[cRelocs - 1].r_offset > paShdrs[i - 1].sh_size
-                                || paRelocs[cRelocs - 1].r_offset + ELF_AMD64_RELOC_SIZE(ELF64_R_TYPE(paRelocs[cRelocs-1].r_info))
-                                   > paShdrs[i - 1].sh_size )))
-                fRet = error(pszFile,
-                             "%#018" ELF_FMT_X64 "  %#018" ELF_FMT_X64 ": out of bounds (sh_size %" ELF_FMT_X64 ")\n",
-                             paRelocs[cRelocs - 1].r_offset, paRelocs[cRelocs - 1].r_info, paShdrs[i - 1].sh_size);
-
         }
         else if (paShdrs[i].sh_type == SHT_REL)
@@ -1136,5 +1128,5 @@
                         return false;
 
-                    fHaveData |= pThis->paSegments[i].iGrpDef == idxGrpData;
+                    fHaveData |= pThis->paSegments[i].iGrpNm == idxGrpData;
                     break;
                 }
@@ -1421,4 +1413,18 @@
 }
 
+/**
+ * @callback_method_impl{FNRTSORTCMP, For Elf64_Rela tables.}
+ */
+static DECLCALLBACK(int) convertElfCompareRelA(void const *pvElement1, void const *pvElement2, void *pvUser)
+{
+    Elf64_Rela const *pReloc1 = (Elf64_Rela const *)pvElement1;
+    Elf64_Rela const *pReloc2 = (Elf64_Rela const *)pvElement2;
+    if (pReloc1->r_offset < pReloc2->r_offset)
+        return -1;
+    if (pReloc1->r_offset > pReloc2->r_offset)
+        return 1;
+    return 0;
+}
+
 static bool convertElfSectionsToLeDataAndFixupps(POMFWRITER pThis, PCELFDETAILS pElfStuff, uint8_t const *pbFile, size_t cbFile)
 {
@@ -1439,4 +1445,7 @@
         uint8_t const      *pbData     = &pbFile[paShdrs[i].sh_offset];
         uint32_t            off        = 0;
+
+        /* We sort fixups by r_offset in order to more easily split them into chunks. */
+        RTSortShell((void *)paRelocs, cRelocs, sizeof(paRelocs[0]), convertElfCompareRelA, NULL);
 
         /* The OMF record size requires us to split larger sections up.  To make
@@ -1932,5 +1941,5 @@
                 return false;
 
-            fHaveData |= pThis->paSegments[i].iGrpDef == idxGrpData;
+            fHaveData |= pThis->paSegments[i].iGrpNm == idxGrpData;
         }
     }
