Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions bolt/lib/Rewrite/RewriteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,20 @@ void RewriteInstance::discoverFileObjects() {
continue;

MarkerSymType MarkerType = BC->getMarkerType(SymInfo.Symbol);

// Treat ST_Function as code.
Expected<object::SymbolRef::Type> TypeOrError = SymInfo.Symbol.getType();
consumeError(TypeOrError.takeError());
if (TypeOrError && *TypeOrError == SymbolRef::ST_Function) {
if (IsData) {
Expected<StringRef> NameOrError = SymInfo.Symbol.getName();
consumeError(NameOrError.takeError());
BC->errs() << "BOLT-WARNING: function symbol " << *NameOrError
<< " lacks code marker\n";
}
MarkerType = MarkerSymType::CODE;
}

if (MarkerType != MarkerSymType::NONE) {
SortedMarkerSymbols.push_back(MarkerSym{SymInfo.Address, MarkerType});
LastAddr = SymInfo.Address;
Expand Down
26 changes: 26 additions & 0 deletions bolt/test/AArch64/missing-code-marker.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Check that llvm-bolt is able to recover a missing code marker.

# RUN: %clang %cflags %s -o %t.exe -nostdlib -fuse-ld=lld -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s

# CHECK: BOLT-WARNING: function symbol foo lacks code marker

.text
.balign 4

.word 0

## Function foo starts immediately after a data object and does not have
## a matching "$x" symbol to indicate the start of code.
.global foo
.type foo, %function
foo:
.word 0xd65f03c0
.size foo, .-foo

.global _start
.type _start, %function
_start:
bl foo
ret
.size _start, .-_start
Loading