Skip to content

Commit 57af156

Browse files
authored
Merge branch 'main' into fix-lldb-dap-jit-crash
2 parents 5910663 + 1317083 commit 57af156

File tree

526 files changed

+23795
-4857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

526 files changed

+23795
-4857
lines changed

bolt/docs/CommandLineArgumentReference.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,15 @@
811811

812812
Specify file name of the runtime instrumentation library
813813

814+
- `--runtime-lib-init-hook=<value>`
815+
816+
Primary target for hooking runtime library initialization, used in
817+
fallback order of availability in input binary (entry_point -> init
818+
-> init_array) (default: entry_point)
819+
- `entry_point`: use ELF Header Entry Point
820+
- `init`: use ELF DT_INIT entry
821+
- `init_array`: use ELF .init_array entry
822+
814823
- `--sctc-mode=<value>`
815824

816825
Mode for simplify conditional tail calls

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,15 @@ class BinaryContext {
807807
/// the execution of the binary is completed.
808808
std::optional<uint64_t> FiniFunctionAddress;
809809

810+
/// DT_INIT.
811+
std::optional<uint64_t> InitAddress;
812+
813+
/// DT_INIT_ARRAY. Only used when DT_INIT is not set.
814+
std::optional<uint64_t> InitArrayAddress;
815+
816+
/// DT_INIT_ARRAYSZ. Only used when DT_INIT is not set.
817+
std::optional<uint64_t> InitArraySize;
818+
810819
/// DT_FINI.
811820
std::optional<uint64_t> FiniAddress;
812821

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,11 @@ class MCPlusBuilder {
538538
llvm_unreachable("not implemented");
539539
}
540540

541+
virtual void createDirectBranch(MCInst &Inst, const MCSymbol *Target,
542+
MCContext *Ctx) {
543+
llvm_unreachable("not implemented");
544+
}
545+
541546
virtual MCPhysReg getX86R11() const { llvm_unreachable("not implemented"); }
542547

543548
virtual unsigned getShortBranchOpcode(unsigned Opcode) const {

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,23 @@ class RewriteInstance {
9393
/// section allocations if found.
9494
void discoverBOLTReserved();
9595

96+
/// Check whether we should use DT_INIT or DT_INIT_ARRAY for instrumentation.
97+
/// DT_INIT is preferred; DT_INIT_ARRAY is only used when no DT_INIT entry was
98+
/// found.
99+
Error discoverRtInitAddress();
100+
96101
/// Check whether we should use DT_FINI or DT_FINI_ARRAY for instrumentation.
97102
/// DT_FINI is preferred; DT_FINI_ARRAY is only used when no DT_FINI entry was
98103
/// found.
99104
Error discoverRtFiniAddress();
100105

106+
/// If DT_INIT_ARRAY is used for instrumentation, update the relocation of its
107+
/// first entry to point to the instrumentation library's init address.
108+
Error updateRtInitReloc();
109+
101110
/// If DT_FINI_ARRAY is used for instrumentation, update the relocation of its
102111
/// first entry to point to the instrumentation library's fini address.
103-
void updateRtFiniReloc();
112+
Error updateRtFiniReloc();
104113

105114
/// Create and initialize metadata rewriters for this instance.
106115
void initializeMetadataManager();

bolt/lib/Passes/Instrumentation.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,12 @@ void Instrumentation::instrumentIndirectTarget(BinaryBasicBlock &BB,
305305
: IndCallHandlerExitBBFunction->getSymbol(),
306306
IndCallSiteID, &*BC.Ctx);
307307

308-
Iter = BB.eraseInstruction(Iter);
309-
Iter = insertInstructions(CounterInstrs, BB, Iter);
310-
--Iter;
308+
if (!BC.isAArch64()) {
309+
Iter = BB.eraseInstruction(Iter);
310+
Iter = insertInstructions(CounterInstrs, BB, Iter);
311+
--Iter;
312+
} else
313+
Iter = insertInstructions(CounterInstrs, BB, Iter);
311314
}
312315

313316
bool Instrumentation::instrumentOneTarget(

0 commit comments

Comments
 (0)