Skip to content

Commit 491c7bd

Browse files
committed
MCAsmBackend::applyFixup: Replace Data.getSize() with F.getSize()
to facilitate replacing `MutableArrayRef<char> Data` (fragment content) with the relocated location. This is necessary to fix the pointer-overflow sanitizer issue and reland llvm#150846
1 parent 228e96b commit 491c7bd

File tree

14 files changed

+14
-14
lines changed

14 files changed

+14
-14
lines changed

llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ void AArch64AsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
461461
Value <<= Info.TargetOffset;
462462

463463
unsigned Offset = Fixup.getOffset();
464-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
464+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
465465

466466
// Used to point to big endian bytes.
467467
unsigned FulleSizeInBytes = getFixupKindContainereSizeInBytes(Fixup.getKind());

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void AMDGPUAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
149149

150150
unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
151151
uint32_t Offset = Fixup.getOffset();
152-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
152+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
153153

154154
// For each byte of the fragment that the fixup touches, mask in the bits from
155155
// the fixup value.

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ void ARMAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
11251125
const unsigned NumBytes = getFixupKindNumBytes(Kind);
11261126

11271127
unsigned Offset = Fixup.getOffset();
1128-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
1128+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
11291129

11301130
// Used to point to big endian bytes.
11311131
unsigned FullSizeBytes;

llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ void AVRAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
398398
Value <<= Info.TargetOffset;
399399

400400
unsigned Offset = Fixup.getOffset();
401-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
401+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
402402

403403
// For each byte of the fragment that the fixup touches, mask in the
404404
// bits from the fixup value.

llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void CSKYAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
220220
unsigned Offset = Fixup.getOffset();
221221
unsigned NumBytes = alignTo(Info.TargetSize + Info.TargetOffset, 8) / 8;
222222

223-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
223+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
224224

225225
// For each byte of the fragment that the fixup touches, mask in the
226226
// bits from the fixup value.

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ void HexagonAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
669669
// to a real offset before we can use it.
670670
uint32_t Offset = Fixup.getOffset();
671671
unsigned NumBytes = getFixupKindNumBytes(Kind);
672-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
672+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
673673
char *InstAddr = Data.data() + Offset;
674674

675675
Value = adjustFixupValue(Kind, FixupValue);

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void LoongArchAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
169169
unsigned Offset = Fixup.getOffset();
170170
unsigned NumBytes = alignTo(Info.TargetSize + Info.TargetOffset, 8) / 8;
171171

172-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
172+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
173173
// For each byte of the fragment that the fixup touches, mask in the
174174
// bits from the fixup value.
175175
for (unsigned I = 0; I != NumBytes; ++I) {

llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void M68kAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
8585
Asm->getWriter().recordRelocation(F, Fixup, Target, Value);
8686

8787
unsigned Size = 1 << getFixupKindLog2Size(Fixup.getKind());
88-
assert(Fixup.getOffset() + Size <= Data.size() && "Invalid fixup offset!");
88+
assert(Fixup.getOffset() + Size <= F.getSize() && "Invalid fixup offset!");
8989
// Check that uppper bits are either all zeros or all ones.
9090
// Specifically ignore overflow/underflow as long as the leakage is
9191
// limited to the lower bits. This is to remain compatible with

llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void MSP430AsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
120120
unsigned Offset = Fixup.getOffset();
121121
unsigned NumBytes = alignTo(Info.TargetSize + Info.TargetOffset, 8) / 8;
122122

123-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
123+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
124124

125125
// For each byte of the fragment that the fixup touches, mask in the
126126
// bits from the fixup value.

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ void RISCVAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
901901
unsigned Offset = Fixup.getOffset();
902902
unsigned NumBytes = alignTo(Info.TargetSize + Info.TargetOffset, 8) / 8;
903903

904-
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
904+
assert(Offset + NumBytes <= F.getSize() && "Invalid fixup offset!");
905905

906906
// For each byte of the fragment that the fixup touches, mask in the
907907
// bits from the fixup value.

0 commit comments

Comments
 (0)