mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 06:46:33 +00:00
[BOLT] Prevent addRelocation from adding pending relocs (#123635)
`addPendingRelocation` is the only way to add a pending relocation. Can no longer use `addRelocation` for this. Update the only user (`BinaryContextTester`).
This commit is contained in:
parent
257754011c
commit
385af283cd
@ -359,15 +359,9 @@ public:
|
||||
|
||||
/// Add a new relocation at the given /p Offset.
|
||||
void addRelocation(uint64_t Offset, MCSymbol *Symbol, uint64_t Type,
|
||||
uint64_t Addend, uint64_t Value = 0,
|
||||
bool Pending = false) {
|
||||
uint64_t Addend, uint64_t Value = 0) {
|
||||
assert(Offset < getSize() && "offset not within section bounds");
|
||||
if (!Pending) {
|
||||
Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
|
||||
} else {
|
||||
PendingRelocations.emplace_back(
|
||||
Relocation{Offset, Symbol, Type, Addend, Value});
|
||||
}
|
||||
Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
|
||||
}
|
||||
|
||||
/// Add a dynamic relocation at the given /p Offset.
|
||||
|
@ -93,12 +93,13 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
|
||||
DataSize, 4);
|
||||
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
|
||||
ASSERT_TRUE(RelSymbol1);
|
||||
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0, true);
|
||||
BS.addPendingRelocation(
|
||||
Relocation{8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0});
|
||||
MCSymbol *RelSymbol2 = BC->getOrCreateGlobalSymbol(16, "Func2");
|
||||
ASSERT_TRUE(RelSymbol2);
|
||||
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0, true);
|
||||
BS.addPendingRelocation(
|
||||
Relocation{12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0});
|
||||
|
||||
std::error_code EC;
|
||||
SmallVector<char> Vect(DataSize);
|
||||
raw_svector_ostream OS(Vect);
|
||||
|
||||
@ -134,12 +135,13 @@ TEST_P(BinaryContextTester, FlushPendingRelocJUMP26) {
|
||||
(uint8_t *)Data, Size, 4);
|
||||
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
|
||||
ASSERT_TRUE(RelSymbol1);
|
||||
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_JUMP26, 0, 0, true);
|
||||
BS.addPendingRelocation(
|
||||
Relocation{8, RelSymbol1, ELF::R_AARCH64_JUMP26, 0, 0});
|
||||
MCSymbol *RelSymbol2 = BC->getOrCreateGlobalSymbol(16, "Func2");
|
||||
ASSERT_TRUE(RelSymbol2);
|
||||
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_JUMP26, 0, 0, true);
|
||||
BS.addPendingRelocation(
|
||||
Relocation{12, RelSymbol2, ELF::R_AARCH64_JUMP26, 0, 0});
|
||||
|
||||
std::error_code EC;
|
||||
SmallVector<char> Vect(Size);
|
||||
raw_svector_ostream OS(Vect);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user