[llvm] [BOLT] Add support for BOLT-reserved space in a binary (PR #90300)

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 15:37:53 PDT 2024


================
@@ -3526,6 +3531,24 @@ void RewriteInstance::updateMetadata() {
 void RewriteInstance::mapFileSections(BOLTLinker::SectionMapper MapSection) {
   BC->deregisterUnusedSections();
 
+  // Check if the input has a space reserved for BOLT.
+  BinaryData *StartBD = BC->getBinaryDataByName(getBOLTReservedStart());
+  BinaryData *EndBD = BC->getBinaryDataByName(getBOLTReservedEnd());
+  if (StartBD) {
----------------
dcci wrote:

Can we transform this into a check that makes sure both symbols are there?
Right now you might have `__bolt_reserved_end` but not `__bolt_reserved_start`.

e.g.

```
if ((StartBD && !EndBD) || (!StartBD && EndBD)) {
        BC->errs(...);
        exit(1);
}
```

That also has the added bonus of making this code less indented/more readable.

https://github.com/llvm/llvm-project/pull/90300


More information about the llvm-commits mailing list