Skip to content

Commit d941a64

Browse files
committed
[BOLT] validate init/fini section address in discoverRtInitAddres/discoverRtFiniAddress
1 parent 9e3d027 commit d941a64

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,11 @@ Error RewriteInstance::discoverRtInitAddress() {
14661466
if (auto EC = InitArraySection.getError())
14671467
return errorCodeToError(EC);
14681468

1469+
if (InitArraySection->getAddress() != *BC->InitArrayAddress) {
1470+
return createStringError(std::errc::not_supported,
1471+
"Inconsistent address of .init_array section");
1472+
}
1473+
14691474
if (const Relocation *Reloc = InitArraySection->getDynamicRelocationAt(0)) {
14701475
if (Reloc->isRelative()) {
14711476
BC->StartFunctionAddress = Reloc->Addend;
@@ -1517,6 +1522,11 @@ Error RewriteInstance::discoverRtFiniAddress() {
15171522
if (auto EC = FiniArraySection.getError())
15181523
return errorCodeToError(EC);
15191524

1525+
if (FiniArraySection->getAddress() != *BC->FiniArrayAddress) {
1526+
return createStringError(std::errc::not_supported,
1527+
"Inconsistent address of .fini_array section");
1528+
}
1529+
15201530
if (const Relocation *Reloc = FiniArraySection->getDynamicRelocationAt(0)) {
15211531
BC->FiniFunctionAddress = Reloc->Addend;
15221532
return Error::success();

0 commit comments

Comments
 (0)