linker: Speed up relocation with an 1-entry symbol cache
When relocating a DSO, it is not unusual to have consecutive
relocations using the same symbol. In this case, it is wasteful to
perform the same symbol lookup. This change implements an 1-entry
symbol cache so that symbol lookup results are reused in such scenario.
Test: On cuttlefish, enable STATS in linker_debug.h. Boot and see RELO
STATS in logcat showing cache hits. Hit rate seen is mostly
within 15% to 45%.
Change-Id: I84783d3b9a6ac9e39ed7fb45e58f6b3c012478d0
diff --git a/linker/linker.h b/linker/linker.h
index a26b79d..782da1c 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -94,6 +94,7 @@
kRelocRelative,
kRelocCopy,
kRelocSymbol,
+ kRelocSymbolCached,
kRelocMax
};