Fix test bot breakage from bd0dd27bb5be0fbf60c1b2a4ce15188812388574
authorAlexey Lapshin <a.v.lapshin@mail.ru>
Wed, 17 May 2023 08:27:56 +0000 (10:27 +0200)
committerAlexey Lapshin <a.v.lapshin@mail.ru>
Wed, 17 May 2023 08:57:31 +0000 (10:57 +0200)
This addresses the issue found by: https://lab.llvm.org/buildbot/#/builders/93/builds/14929

llvm/include/llvm/DWARFLinker/DWARFLinker.h
llvm/lib/DWARFLinker/DWARFLinker.cpp

index d94e31d..8090bfd 100644 (file)
@@ -713,7 +713,7 @@ private:
     void cloneExpression(DataExtractor &Data, DWARFExpression Expression,
                          const DWARFFile &File, CompileUnit &Unit,
                          SmallVectorImpl<uint8_t> &OutputBuffer,
-                         int64_t AddrRelocAdjustment);
+                         int64_t AddrRelocAdjustment, bool IsLittleEndian);
 
     /// Clone an attribute referencing another DIE and add
     /// it to \p Die.
index 93c03a1..b87fb98 100644 (file)
@@ -1142,7 +1142,7 @@ unsigned DWARFLinker::DIECloner::cloneDieReferenceAttribute(
 void DWARFLinker::DIECloner::cloneExpression(
     DataExtractor &Data, DWARFExpression Expression, const DWARFFile &File,
     CompileUnit &Unit, SmallVectorImpl<uint8_t> &OutputBuffer,
-    int64_t AddrRelocAdjustment) {
+    int64_t AddrRelocAdjustment, bool IsLittleEndian) {
   using Encoding = DWARFExpression::Operation::Encoding;
 
   uint8_t OrigAddressByteSize = Unit.getOrigUnit().getAddressByteSize();
@@ -1208,6 +1208,8 @@ void DWARFLinker::DIECloner::cloneExpression(
         // processed by applyValidRelocs.
         OutputBuffer.push_back(dwarf::DW_OP_addr);
         uint64_t LinkedAddress = SA->Address + AddrRelocAdjustment;
+        if (!IsLittleEndian)
+          sys::swapByteOrder(LinkedAddress);
         ArrayRef<uint8_t> AddressBytes(
             reinterpret_cast<const uint8_t *>(&LinkedAddress),
             OrigAddressByteSize);
@@ -1240,6 +1242,8 @@ void DWARFLinker::DIECloner::cloneExpression(
         if (OutOperandKind) {
           OutputBuffer.push_back(*OutOperandKind);
           uint64_t LinkedAddress = SA->Address + AddrRelocAdjustment;
+          if (!IsLittleEndian)
+            sys::swapByteOrder(LinkedAddress);
           ArrayRef<uint8_t> AddressBytes(
               reinterpret_cast<const uint8_t *>(&LinkedAddress),
               OrigAddressByteSize);
@@ -1294,7 +1298,7 @@ unsigned DWARFLinker::DIECloner::cloneBlockAttribute(
     DWARFExpression Expr(Data, OrigUnit.getAddressByteSize(),
                          OrigUnit.getFormParams().Format);
     cloneExpression(Data, Expr, File, Unit, Buffer,
-                    Unit.getInfo(InputDIE).AddrAdjust);
+                    Unit.getInfo(InputDIE).AddrAdjust, IsLittleEndian);
     Bytes = Buffer;
   }
   for (auto Byte : Bytes)
@@ -2553,7 +2557,8 @@ uint64_t DWARFLinker::DIECloner::cloneAllCompileUnits(
         cloneExpression(Data,
                         DWARFExpression(Data, OrigUnit.getAddressByteSize(),
                                         OrigUnit.getFormParams().Format),
-                        File, *CurrentUnit, OutBytes, RelocAdjustment);
+                        File, *CurrentUnit, OutBytes, RelocAdjustment,
+                        IsLittleEndian);
       };
       Linker.generateUnitLocations(*CurrentUnit, File, ProcessExpr);
     }