Skip to content

Commit 5c4e6c6

Browse files
authored
[BOLT] Don't choke on nobits symbols (#136384)
1 parent 50db7a7 commit 5c4e6c6

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,11 @@ void RewriteInstance::discoverFileObjects() {
10551055
continue;
10561056
}
10571057

1058-
if (!Section->isText()) {
1058+
if (!Section->isText() || Section->isVirtual()) {
10591059
assert(SymbolType != SymbolRef::ST_Function &&
10601060
"unexpected function inside non-code section");
1061-
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: rejecting as symbol is not in code\n");
1061+
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: rejecting as symbol is not in code or "
1062+
"is in nobits section\n");
10621063
registerName(SymbolSize);
10631064
continue;
10641065
}

bolt/test/X86/nobits-symbol.s

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Check that llvm-bolt doesn't choke on symbols defined in nobits sections.
2+
3+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
4+
# RUN: %clang %cflags %t.o -o %t.exe
5+
# RUN: llvm-bolt %t.exe -o %t
6+
#
7+
8+
.type symbol_in_nobits,@object
9+
.section .my.nobits.section,"awx",@nobits
10+
.globl symbol_in_nobits
11+
.p2align 4, 0x0
12+
symbol_in_nobits:
13+
.zero 0x100000
14+
.size symbol_in_nobits, 0x100000
15+
16+
.text
17+
.globl main
18+
.type main, %function
19+
main:
20+
.cfi_startproc
21+
.LBB06:
22+
retq
23+
.cfi_endproc
24+
.size main, .-main

0 commit comments

Comments
 (0)