Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, functions that are referred to only by section symbols were not considered address-taken, and we always rewrote endbr64s with NOPs for such functions. That caused a runtime fault when such function was called indirectly. Now, endbr64s for such symbols are retained. I tried to build clang-19 as a release build with and without `-z rewrite-endbr` and counted the number of endbr64 instructions in each binary. Here is the result: Before: 110,615 After: 91,799 So the feature reduces the number of gadgets by 17%. Both binaries worked fine with Intel SDE CPU emulator with `-cet 1 -cet_raise 1`, so I think it's finally working as expected. I also tried to build mold itself with and without the feature. Here is the result: Before: 27,430 After: 17,725 This is a 35% reduction. I confirmed that mold built with `-z rewrite-endbr` can self-host under Intel SDE. The rewrite_endbr pass is extremely fast. It took only 7 milliseconds for a ~210 MiB clang-19 binary on my Threadripper 7990X machine. We may want to consider enabling it by default at some point.
- Loading branch information