File tree 2 files changed +24
-0
lines changed 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1582,6 +1582,12 @@ void RewriteInstance::adjustFunctionBoundaries() {
1582
1582
if (!Function.isSymbolValidInScope (Symbol, SymbolSize))
1583
1583
break ;
1584
1584
1585
+ // Ignore unnamed symbols. Used, for example, by debugging info on RISC-V.
1586
+ if (BC->isRISCV () && cantFail (Symbol.getName ()).empty ()) {
1587
+ ++NextSymRefI;
1588
+ continue ;
1589
+ }
1590
+
1585
1591
// Skip basic block labels. This happens on RISC-V with linker relaxation
1586
1592
// enabled because every branch needs a relocation and corresponding
1587
1593
// symbol. We don't want to add such symbols as entry points.
Original file line number Diff line number Diff line change
1
+ /// Verify that unnamed symbols are not added as function entry points. Such
2
+ /// symbols are used by relocations in debugging sections.
3
+
4
+ // clang-format off
5
+
6
+ // RUN: %clang %cflags -g -Wl,-q -o %t %s
7
+
8
+ /// Verify that the binary indeed contains an unnamed symbol at _start
9
+ // RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=CHECK-ELF
10
+ // CHECK-ELF-DAG: [[#%x,START:]] {{.*}} FUNC GLOBAL DEFAULT [[#%d,SECTION:]] _start{{$}}
11
+ // CHECK-ELF-DAG: [[#%x,START]] {{.*}} NOTYPE LOCAL DEFAULT [[#SECTION]] {{$}}
12
+
13
+ /// Verify that BOLT did not create an extra entry point for the unnamed symbol
14
+ // RUN: llvm-bolt -o %t.bolt %t --print-cfg | FileCheck %s
15
+ // CHECK: Binary Function "_start" after building cfg {
16
+ // CHECK: IsMultiEntry: 0
17
+
18
+ void _start () {}
You can’t perform that action at this time.
0 commit comments