--- ./Source/cmXCOFF.cxx_orig	2024-09-19 02:26:55.202346605 -0500
+++ ./Source/cmXCOFF.cxx	2024-09-19 02:31:12.623733306 -0500
@@ -209,7 +209,8 @@
     this->SetErrorMessage("XCOFF loader section missing.");
     return;
   }
-  this->bytes_to_align = this->AuxHeader.o_algndata;
+  this->bytes_to_align = this->AuxHeader.o_algntext > this->AuxHeader.o_algndata?
+                         this->AuxHeader.o_algntext: this->AuxHeader.o_algndata;
   if (!this->Stream->seekg((this->AuxHeader.o_snloader - 1) *
                              sizeof(typename XCOFF::scnhdr),
                            std::ios::cur)) {
@@ -427,12 +428,10 @@
     // We will sometimes get /opt/freeware/lib/libshared.a. So extract
     // the last part only.
     // Example: libshared.a [We need to length of "libshared.a" characters].
-    archive_name_length = static_cast<int>(getLastWordLen(std::string(fname)));
+    archive_name_length = atoi(arHeader.ar_namlen);
 
     // Move to the next even byte.
-    if (archive_name_length % 2 == 0) {
-      nextEvenByte = archive_name_length + 2;
-    } else {
+    if (archive_name_length % 2 != 0) {
       nextEvenByte = archive_name_length + 1;
     }
 
--- ./Source/cmXCOFF.cxx_orig	2024-09-19 05:00:16.415917973 -0500
+++ ./Source/cmXCOFF.cxx	2024-09-19 05:00:59.820205287 -0500
@@ -434,6 +434,9 @@
     if (archive_name_length % 2 != 0) {
       nextEvenByte = archive_name_length + 1;
     }
+    else {
+      nextEvenByte = archive_name_length;
+    }
 
     f->seekg(nextEvenByte, std::ios::cur);
   }
