Issue 137579
Summary [BOLT] Instrumentation of LLVM driver binary segfaults
Labels BOLT
Assignees
Reporter beakthoven
    I have compiled LLVM with the following configuration:
- **Build flag**: `-DLLVM_TOOL_LLVM_DRIVER_BUILD=ON`
- **Static Linking**: Everything statically linked except glibc

### Binary Details:
```bash
file ./install-min/bin/llvm
./install-min/bin/llvm: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 4.4.0, not stripped

ldd ./install-min/bin/llvm
        linux-vdso.so.1 (0x000077f0a44ea000)
 libm.so.6 => /usr/lib/libm.so.6 (0x000077f09e308000)
        libc.so.6 => /usr/lib/libc.so.6 (0x000077f09e116000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x000077f0a44ec000)
```

### Problem:
When I attempt to run the BOLT-instrumented version of the LLVM driver binary, it **segfaults** upon execution. Additionally, the `file` command outputs an error related to the **NOTE section size** being too large.

### BOLT Command:
```bash
LD_PRELOAD=/usr/lib/libjemalloc.so ./sysroot/bin/llvm-bolt --instrument --instrumentation-file=/home/dakkshesh/tc-playground/bolt-profiles/llvm.fdata --instrumentation-file-append-pid ./install-min/bin/llvm -o ./install-min/bin/llvm.inst
```

### BOLT Log Output:
```bash
BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: Target architecture: x86_64
BOLT-INFO: BOLT version: c2d6c7cea7d857f7a9268703e30a7d1ffed7d64b
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x6200000, offset 0x6200000
BOLT-INFO: enabling relocation mode
BOLT-INFO: forcing -jump-tables=move for instrumentation
BOLT-INFO: enabling lite mode
BOLT-WARNING: 14 collisions detected while hashing binary objects. Use -v=1 to see the list.
BOLT-INFO: 0 out of 138060 functions in the binary (0.0%) have non-empty execution profile
BOLT-INFO: validate-mem-refs updated 3 object references
BOLT-INSTRUMENTER: Number of indirect call site descriptors: 72728
BOLT-INSTRUMENTER: Number of indirect call target descriptors: 137150
BOLT-INSTRUMENTER: Number of function descriptors: 137140
BOLT-INSTRUMENTER: Number of branch counters: 1805192
BOLT-INSTRUMENTER: Number of ST leaf node counters: 874477
BOLT-INSTRUMENTER: Number of direct call counters: 2524
BOLT-INSTRUMENTER: Total number of counters: 2682193
BOLT-INSTRUMENTER: Total size of counters: 21457544 bytes (static alloc memory)
BOLT-INSTRUMENTER: Total size of string table emitted: 15507201 bytes in file
BOLT-INSTRUMENTER: Total size of descriptors: 179504596 bytes in file
BOLT-INSTRUMENTER: Profile will be saved to file /home/dakkshesh/tc-playground/bolt-profiles/llvm.fdata
BOLT-INFO: 867351 instructions were shortened
BOLT-INFO: removed 9544 empty blocks
BOLT-INFO: UCE removed 97245 blocks and 5895716 bytes of code
BOLT-INFO: padding code to 0xfa00000 to accommodate hot text
BOLT-INFO: output linked against instrumentation runtime library, lib entry point is 0x11e47860
BOLT-INFO: clear procedure is 0x11e43300
BOLT-INFO: setting __bolt_runtime_start to 0x11e47860
BOLT-INFO: setting __bolt_runtime_fini to 0x11e478a0
BOLT-INFO: setting __hot_start to 0x6400000
BOLT-INFO: setting __hot_end to 0xf808bf8
```

### BOLT Instrumented Binary Segfault:
```bash
./install-min/bin/llvm.inst --help
[1]    212952 segmentation fault (core dumped)  ./install-min/bin/llvm.inst --help
```

### Error from `file` Command:
```bash
file ./install-min/bin/llvm.inst
./install-min/bin/llvm.inst: ERROR: , dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 4.4.0 Note section size too big (195011832 > 134217728) (Invalid argument)
```

### Readelf output regarding note section
```bash
llvm-readelf -SW ./install-min/bin/llvm.inst | grep '\.note'
llvm-readelf: warning: './install-min/bin/llvm.inst': DT_SYMENT value of 0xf5c1140 is not the size of a symbol (0x18)
  [ 2] .note.ABI-tag NOTE            00000000000002fc 0002fc 000020 00   A  0   0  4
  [49] .note.bolt_info   NOTE            0000000000000000 1ef8c793 000124 00      0 0  1
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to