Skip to content

Commit 42350aa

Browse files
committed
ulittle32_t, skip for PE and continue instead of return
1 parent b302bd9 commit 42350aa

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

llvm/lib/ObjCopy/COFF/COFFWriter.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/Object/COFF.h"
1515
#include "llvm/Support/CRC.h"
1616
#include "llvm/Support/Errc.h"
17+
#include "llvm/Support/Endian.h"
1718
#include "llvm/Support/ErrorHandling.h"
1819
#include <cstddef>
1920
#include <cstdint>
@@ -94,9 +95,13 @@ Error COFFWriter::finalizeSymbolContents() {
9495
}
9596

9697
Error COFFWriter::finalizeCFGuardContents() {
98+
// CFGuards shouldn't be present in PE
99+
if (Obj.IsPE)
100+
return Error::success();
101+
97102
DenseMap<size_t, size_t> SymIdMap;
98103
bool NeedUpdate = false;
99-
for (Symbol &Sym : Obj.getMutableSymbols()) {
104+
for (const auto &Sym : Obj.getSymbols()) {
100105
NeedUpdate |= Sym.OriginalRawIndex == Sym.RawIndex;
101106
SymIdMap[Sym.OriginalRawIndex] = Sym.RawIndex;
102107
}
@@ -128,14 +133,14 @@ Error COFFWriter::finalizeCFGuardContents() {
128133
// Nothing to do and also CheckSum will be -1 instead of 0 if we recalculate
129134
// it on empty input.
130135
if (RawIds.size() == 0)
131-
return Error::success();
136+
continue;
132137

133138
// Create updated content
134-
ArrayRef<uint32_t> Ids(reinterpret_cast<const uint32_t *>(RawIds.data()),
135-
RawIds.size() / 4);
136-
std::vector<uint32_t> NewIds;
139+
ArrayRef<support::ulittle32_t> Ids(reinterpret_cast<const support::ulittle32_t *>(RawIds.data()),
140+
RawIds.size() / 4);
141+
std::vector<support::ulittle32_t> NewIds;
137142
for (auto Id : Ids)
138-
NewIds.push_back(SymIdMap[Id]);
143+
NewIds.push_back(support::ulittle32_t(SymIdMap[Id]));
139144
ArrayRef<uint8_t> NewRawIds(reinterpret_cast<uint8_t *>(NewIds.data()),
140145
RawIds.size());
141146
// Update check sum

0 commit comments

Comments
 (0)