Skip to content

Commit f235cee

Browse files
[BOLT] addRelocation does not add pending relocs
Use addPendingRelocation for that.
1 parent dcd6207 commit f235cee

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

bolt/include/bolt/Core/BinarySection.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,9 @@ class BinarySection {
358358

359359
/// Add a new relocation at the given /p Offset.
360360
void addRelocation(uint64_t Offset, MCSymbol *Symbol, uint64_t Type,
361-
uint64_t Addend, uint64_t Value = 0,
362-
bool Pending = false) {
361+
uint64_t Addend, uint64_t Value = 0) {
363362
assert(Offset < getSize() && "offset not within section bounds");
364-
if (!Pending) {
365-
Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
366-
} else {
367-
PendingRelocations.emplace_back(
368-
Relocation{Offset, Symbol, Type, Addend, Value});
369-
}
363+
Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
370364
}
371365

372366
/// Add a dynamic relocation at the given /p Offset.

bolt/unittests/Core/BinaryContext.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
9292
DataSize, 4);
9393
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
9494
ASSERT_TRUE(RelSymbol1);
95-
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0, true);
95+
BS.addPendingRelocation(
96+
Relocation{8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0});
9697
MCSymbol *RelSymbol2 = BC->getOrCreateGlobalSymbol(16, "Func2");
9798
ASSERT_TRUE(RelSymbol2);
98-
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0, true);
99+
BS.addPendingRelocation(
100+
Relocation{12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0});
99101

100-
std::error_code EC;
101102
SmallVector<char> Vect(DataSize);
102103
raw_svector_ostream OS(Vect);
103104

@@ -133,12 +134,13 @@ TEST_P(BinaryContextTester, FlushPendingRelocJUMP26) {
133134
(uint8_t *)Data, Size, 4);
134135
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
135136
ASSERT_TRUE(RelSymbol1);
136-
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_JUMP26, 0, 0, true);
137+
BS.addPendingRelocation(
138+
Relocation{8, RelSymbol1, ELF::R_AARCH64_JUMP26, 0, 0});
137139
MCSymbol *RelSymbol2 = BC->getOrCreateGlobalSymbol(16, "Func2");
138140
ASSERT_TRUE(RelSymbol2);
139-
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_JUMP26, 0, 0, true);
141+
BS.addPendingRelocation(
142+
Relocation{12, RelSymbol2, ELF::R_AARCH64_JUMP26, 0, 0});
140143

141-
std::error_code EC;
142144
SmallVector<char> Vect(Size);
143145
raw_svector_ostream OS(Vect);
144146

@@ -216,4 +218,4 @@ TEST_P(BinaryContextTester, BaseAddressSegmentsSmallerThanAlignment) {
216218
BC->getBaseAddressForMapping(0xaaaaaaab1000, 0x1000);
217219
ASSERT_TRUE(BaseAddress.has_value());
218220
ASSERT_EQ(*BaseAddress, 0xaaaaaaaa0000ULL);
219-
}
221+
}

0 commit comments

Comments
 (0)