mirror of
https://github.com/rui314/mold.git
synced 2026-11-08 17:48:41 -10:00
Skip an unnecessary layout pass for non-Android links
After fix_synthetic_symbols, we re-ran set_osec_offsets unconditionally. That pass is needed only under --pack-dyn-relocs=android, whose packed relocation format encodes addends in variable-length SLEB128, so fixing synthetic-symbol values can change the encoded size of .rela.dyn. No other mode emits anything whose size depends on addends; in particular, RELR's size depends only on relocation locations, which are fixed by this point. Make the pass conditional on the Android mode. On the Firefox release benchmark with 32 threads and --no-fork, this shortens the link from 0.44 s to 0.41 s. Outputs are byte-for-byte identical before and after for both a RELR workload (Firefox) and a RELA workload (Chromium release). Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
5e33441a0d
commit
64b92151a0
1 file changed
+6
-3
+6
-3
@@ -689,9 +689,12 @@ int mold_main(int argc, char **argv) {
|
||||
|
||||
// Re-finalize layout. fix_synthetic_symbols above may have changed
|
||||
// addends for dynamic relocations referencing synthetic symbols, which
|
||||
// can shift the encoded size of .rela.dyn under --pack-dyn-relocs=android.
|
||||
// For other modes this is a cheap no-op convergence.
|
||||
filesize = set_osec_offsets(ctx);
|
||||
// can shift the encoded size of .rela.dyn under --pack-dyn-relocs=android
|
||||
// because Android's packed format encodes addends in variable-length
|
||||
// SLEB128. Other modes, including ordinary RELR, encode nothing whose
|
||||
// size depends on addends, so they do not need this pass.
|
||||
if (ctx.arg.pack_dyn_relocs_android)
|
||||
filesize = set_osec_offsets(ctx);
|
||||
|
||||
// At this point, both memory and file layouts are fixed.
|
||||
|
||||
|
||||
Reference in new issue
Block a user