Comments (14)
Some extra information: MySQL builds with -fPIC, and doesn't have much choice since plugins effectively link to the server. readelf -e outputs:
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0xc63960
Start of program headers: 64 (bytes into file)
Start of section headers: 1998116240 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 10
Size of section headers: 64 (bytes)
Number of section headers: 57
Section header string table index: 56
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .interp PROGBITS 0000000000000270 00000270
000000000000001c 0000000000000000 A 0 0 1
[ 2] .note.ABI-tag NOTE 000000000000028c 0000028c
0000000000000020 0000000000000000 A 0 0 4
[ 3] .note.gnu.build-i NOTE 00000000000002ac 000002ac
0000000000000024 0000000000000000 A 0 0 4
[ 4] .dynsym DYNSYM 00000000000002d0 000002d0
000000000015bd48 0000000000000018 A 5 1 8
[ 5] .dynstr STRTAB 000000000015c018 0015c018
0000000000549383 0000000000000000 A 0 0 1
[ 6] .gnu.hash GNU_HASH 00000000006a53a0 006a53a0
00000000000692a4 0000000000000000 A 4 0 8
[ 7] .gnu.version VERSYM 000000000070e644 0070e644
000000000001cfc6 0000000000000002 A 4 0 2
[ 8] .gnu.version_r VERNEED 000000000072b60c 0072b60c
0000000000000330 0000000000000000 A 5 13 4
[ 9] .rela.dyn RELA 000000000072b940 0072b940
00000000004671f0 0000000000000018 A 4 0 8
[10] .rela.plt RELA 0000000000b92b30 00b92b30
0000000000004470 0000000000000018 AI 4 12 8
[11] .init PROGBITS 0000000000b96fa0 00b96fa0
0000000000000017 0000000000000000 AX 0 0 4
[12] .plt PROGBITS 0000000000b96fc0 00b96fc0
0000000000002db0 0000000000000010 AX 0 0 16
[13] .text PROGBITS 0000000000b99d70 00b99d70
00000000015d2eee 0000000000000000 AX 0 0 16
[14] .fini PROGBITS 000000000216cc60 0216cc60
0000000000000009 0000000000000000 AX 0 0 4
[15] .rodata PROGBITS 000000000216cc80 0216cc80
0000000000d76060 0000000000000000 A 0 0 32
[16] .gcc_except_table PROGBITS 0000000002ee2ce0 02ee2ce0
000000000007f2c6 0000000000000000 A 0 0 4
[17] .eh_frame PROGBITS 0000000002f61fa8 02f61fa8
000000000020d514 0000000000000000 A 0 0 8
[18] .eh_frame_hdr PROGBITS 000000000316f4bc 0316f4bc
000000000006a97c 0000000000000000 A 0 0 4
[19] .tbss NOBITS 00000000031daee0 031d9ee0
00000000000000d1 0000000000000000 WAT 0 0 16
[20] .data.rel.ro.loca PROGBITS 00000000031daee0 031d9ee0
000000000002f750 0000000000000000 WA 0 0 32
[21] .fini_array FINI_ARRAY 000000000320a630 03209630
0000000000000008 0000000000000008 WA 0 0 8
[22] .init_array INIT_ARRAY 000000000320a638 03209638
0000000000000ee8 0000000000000008 WA 0 0 8
[23] .data.rel.ro PROGBITS 000000000320b520 0320a520
000000000010ca50 0000000000000000 WA 0 0 32
[24] .dynamic DYNAMIC 0000000003317f70 03316f70
0000000000000320 0000000000000010 WA 5 0 8
[25] .got PROGBITS 00000000033182a8 033172a8
0000000000001d40 0000000000000000 WA 0 0 8
[26] .got.plt PROGBITS 0000000003319fe8 03318fe8
00000000000016e8 0000000000000000 WA 0 0 8
[27] .data PROGBITS 000000000331b6e0 0331a6e0
000000000022ed60 0000000000000000 WA 0 0 32
[28] .tm_clone_table PROGBITS 000000000354a440 03549440
0000000000000000 0000000000000000 WA 0 0 8
[29] .bss NOBITS 000000000354a440 03549440
0000000000114540 0000000000000000 WA 0 0 64
[30] .rela.text RELA 0000000000000000 03549440
0000000000d7e3f8 0000000000000018 I 54 13 8
[31] .rela.eh_frame RELA 0000000000000000 042c7838
00000000001a8cc8 0000000000000018 I 54 17 8
[32] .rela.init RELA 0000000000000000 04470500
0000000000000018 0000000000000018 I 54 11 8
[33] .comment PROGBITS 0000000000000000 04470518
000000000000001d 0000000000000001 MS 0 0 1
[34] .rela.data RELA 0000000000000000 04470538
0000000000104e08 0000000000000018 I 54 27 8
readelf: Warning: [35]: Info field (21) should index a relocatable section.
[35] .rela.fini_array RELA 0000000000000000 04575340
0000000000000018 0000000000000018 I 54 21 8
[36] .rela.init_array RELA 0000000000000000 04575358
0000000000002cb8 0000000000000018 I 54 22 8
[37] .debug_info PROGBITS 0000000000000000 04578010
000000001ae38b02 0000000000000000 0 0 1
[38] .debug_abbrev PROGBITS 0000000000000000 1f3b0b12
000000000068019d 0000000000000000 0 0 1
[39] .debug_loc PROGBITS 0000000000000000 1fa30caf
000000000cbeec73 0000000000000000 0 0 1
[40] .debug_aranges PROGBITS 0000000000000000 2c61f922
0000000000123220 0000000000000000 0 0 1
[41] .debug_ranges PROGBITS 0000000000000000 2c742b42
0000000002918310 0000000000000000 0 0 1
[42] .debug_line PROGBITS 0000000000000000 2f05ae52
00000000027e5761 0000000000000000 0 0 1
[43] .debug_str PROGBITS 0000000000000000 318405b3
0000000005ba556c 0000000000000001 MS 0 0 1
[44] .rela.debug_info RELA 0000000000000000 373e5b20
0000000029f37c30 0000000000000018 I 54 37 8
[45] .rela.debug_loc RELA 0000000000000000 6131d750
00000000103d3118 0000000000000018 I 54 39 8
[46] .rela.debug_arang RELA 0000000000000000 716f0868
000000000013b0d8 0000000000000018 I 54 40 8
[47] .rela.debug_range RELA 0000000000000000 7182b940
0000000004a91930 0000000000000018 I 54 41 8
[48] .rela.debug_line RELA 0000000000000000 762bd270
0000000000133f80 0000000000000018 I 54 42 8
[49] .rela.rodata RELA 0000000000000000 763f11f0
0000000000070a88 0000000000000018 I 54 15 8
[50] .rela.data.rel.ro RELA 0000000000000000 76461c78
00000000002e9740 0000000000000018 I 54 23 8
[51] .rela.data.rel.ro RELA 0000000000000000 7674b3b8
0000000000070818 0000000000000018 I 54 20 8
[52] .rela.gcc_except_ RELA 0000000000000000 767bbbd0
0000000000001aa0 0000000000000018 I 54 16 8
[53] .note.gnu.gold-ve NOTE 0000000000000000 767bd670
000000000000001c 0000000000000000 0 0 4
[54] .symtab SYMTAB 0000000000000000 767bd690
000000000027ceb8 0000000000000018 55 49339 8
[55] .strtab STRTAB 0000000000000000 76a3a548
0000000000752e3c 0000000000000000 0 0 1
[56] .shstrtab STRTAB 0000000000000000 7718d384
0000000000000206 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
l (large), p (processor specific)
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040
0x0000000000000230 0x0000000000000230 R 0x8
INTERP 0x0000000000000270 0x0000000000000270 0x0000000000000270
0x000000000000001c 0x000000000000001c R 0x1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000031d9e38 0x00000000031d9e38 R E 0x1000
LOAD 0x00000000031d9ee0 0x00000000031daee0 0x00000000031daee0
0x000000000036f560 0x0000000000483aa0 RW 0x1000
DYNAMIC 0x0000000003316f70 0x0000000003317f70 0x0000000003317f70
0x0000000000000320 0x0000000000000320 RW 0x8
NOTE 0x000000000000028c 0x000000000000028c 0x000000000000028c
0x0000000000000044 0x0000000000000044 R 0x4
GNU_EH_FRAME 0x000000000316f4bc 0x000000000316f4bc 0x000000000316f4bc
0x000000000006a97c 0x000000000006a97c R 0x4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
TLS 0x00000000031d9ee0 0x00000000031daee0 0x00000000031daee0
0x0000000000000000 0x00000000000000e0 R 0x10
GNU_RELRO 0x00000000031d9ee0 0x00000000031daee0 0x00000000031daee0
0x000000000013f120 0x000000000013f120 RW 0x20
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.build-id .dynsym .dynstr .gnu.hash .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .gcc_except_table .eh_frame .eh_frame_hdr
03 .data.rel.ro.local .fini_array .init_array .data.rel.ro .dynamic .got .got.plt .data .bss
04 .dynamic
05 .note.ABI-tag .note.gnu.build-id
06 .eh_frame_hdr
07
08 .tbss
09 .data.rel.ro.local .fini_array .init_array .data.rel.ro .dynamic .got
from bolt.
Thank you for reporting. Could you share what version of mysql is this and the compiler that you used to build it?
from bolt.
It's current trunk (which isn't public yet, but the published 8.0 branch should be really close), GCC 8.
I also hacked up a build that doesn't use -fPIC (and thus doesn't support any plugins), but perf2bolt seemingly still thinks there's PIC jump tables, and crashes in the same way.
from bolt.
Thanks. I believe it's related to GCC 8. I'll take a look.
from bolt.
Well, with GCC 7, it stopped crashing, but it output a zero-byte file:
atum17:~/mysql/obj> perf2bolt -p ./perf.data -o perf.fdata ./bin/mysqld
PERF2BOLT: Starting data aggregation job for ./perf.data
PERF2BOLT: Spawning perf-script job to read branch events
PERF2BOLT: Spawning perf-script job to read mem events
PERF2BOLT: Spawning perf-script job to read tasks
BOLT-INFO: Target architecture: x86_64
BOLT-INFO: binary build-id is: 6a455e327e54ac3e90ea9da972f070bb6ece5c8f
PERF2BOLT: matched build-id and file name
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x3600000, offset 0x3600000
BOLT-INFO: enabling relocation mode
BOLT-INFO: forcing -jump-tables=move as PIC jump table was detected
PERF2BOLT: Waiting for perf tasks collection to finish...
PERF2BOLT: Parsing perf-script tasks output
PERF2BOLT: Input binary is associated with 1 PID(s)
PERF2BOLT: Waiting for perf events collection to finish...
PERF2BOLT: Aggregating branch events...
PERF2BOLT: Read 239569 samples and 7631637 LBR entries
PERF2BOLT: Traces mismatching disassembled function contents: 0 (0.0%)
PERF2BOLT: Out of range traces involving unknown regions: 7392068 (100.0%)
PERF2BOLT: Wrote 0 objects and 0 memory objects to perf.fdata
atum17:~/mysql/obj> ls -l perf.fdata
-rw-r--r-- 1 sgunders common 0 juni 29 20:48 perf.fdata
from bolt.
Pretty sure it's because the binary is PIE (file
should say it's a "shared object"). Position-independent code should be okay (save the issue with GCC8), but position-independent executables are not yet supported. The workaround is to drop -pie
flag during link time.
from bolt.
I'm fairly certain we don't link with -pie.
from bolt.
I built now with GCC 7 and without -fPIC, and it crashes with a different message:
PERF2BOLT: Starting data aggregation job for ./perf.data
PERF2BOLT: Spawning perf-script job to read branch events
PERF2BOLT: Spawning perf-script job to read mem events
PERF2BOLT: Spawning perf-script job to read tasks
BOLT-INFO: Target architecture: x86_64
BOLT-INFO: binary build-id is: 06d664e86ad4086287b94019df8936b12d17dd3a
PERF2BOLT: matched build-id and file name
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x3400000, offset 0x3400000
BOLT-INFO: enabling relocation mode
perf2bolt: /srv/sesse/nmu/BOLT/llvm/tools/llvm-bolt/src/RewriteInstance.cpp:1978: bool llvm::bolt::RewriteInstance::analyzeRelocation(const llvm::object::RelocationRef&, llvm::object::SectionRef, std::__cxx11::string&, uint64_t&, int64_t&, uint64_t&) const: Assertion `(IsAArch64 || Relocation::isTLS(Rel.getType()) || SymbolName == "__hot_start" || SymbolName == "__hot_end" || truncateToSize(ExtractedValue, RelSize) == truncateToSize(SymbolAddress + Addend - PCRelOffset, RelSize)) && "extracted relocation value should match relocation components"' failed.
LLVMSymbolizer: error reading file: No such file or directory
#0 0x000055ff37fb7582 (perf2bolt+0x2374582)
#1 0x000055ff37fb7615 (perf2bolt+0x2374615)
#2 0x000055ff37fb5aba (perf2bolt+0x2372aba)
#3 0x000055ff37fb6ef7 (perf2bolt+0x2373ef7)
#4 0x00007f1c73d47f50 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11f50)
#5 0x00007f1c7282de7b gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x34e7b)
#6 0x00007f1c7282f231 abort (/lib/x86_64-linux-gnu/libc.so.6+0x36231)
#7 0x00007f1c728269da (/lib/x86_64-linux-gnu/libc.so.6+0x2d9da)
#8 0x00007f1c72826a52 (/lib/x86_64-linux-gnu/libc.so.6+0x2da52)
#9 0x000055ff36163272 (perf2bolt+0x520272)
#10 0x000055ff36164b8a (perf2bolt+0x521b8a)
#11 0x000055ff3615fdfb (perf2bolt+0x51cdfb)
#12 0x000055ff3615c12c (perf2bolt+0x51912c)
#13 0x000055ff3615c4a9 (perf2bolt+0x5194a9)
#14 0x000055ff3600635e (perf2bolt+0x3c335e)
#15 0x00007f1c7281aa87 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21a87)
#16 0x000055ff36004fea (perf2bolt+0x3c1fea)
Stack dump:
0. Program arguments: perf2bolt -p ./perf.data -o perf.fdata ./bin/mysqld
zsh: abort (core dumped) perf2bolt -p ./perf.data -o perf.fdata ./bin/mysqld
from bolt.
The current workaround for GCC 8 is to use -fno-reorder-blocks-and-partition
option.
from bolt.
Turned out GCC 8 will generate jump tables with just 2 entries. Not sure if it's a feature or a bug, but I've adjusted our assertion.
With the fix I was able to build mysql-8.0.11
using GCC 8 and -fno-reorder-blocks-and-partition
option. No workaround for -fPIC
was required. Also removed --gc-sections
from CMakeLists.txt
to workaround ld.gold
bug to allow --emit-relocs,-znow
.
Hope it will work for you now.
from bolt.
Alas, no:
atum17:~/mysql/obj> perf2bolt -p perf.data -o perf.fdata -ignore-build-id ./bin/mysqld
PERF2BOLT: Starting data aggregation job for perf.data
PERF2BOLT: Spawning perf-script job to read branch events
PERF2BOLT: Spawning perf-script job to read mem events
PERF2BOLT: Spawning perf-script job to read tasks
BOLT-INFO: Target architecture: x86_64
BOLT-INFO: binary build-id is: fa196dbe0d63db4c
PERF2BOLT-ERROR: failed to match build-id from perf output. This indicates the input binary supplied for data aggregation is not the same recorded by perf when collecting profiling data. Use -ignore-build-id option to override.
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x3600000, offset 0x3600000
BOLT-INFO: disabling -align-macro-fusion in non-relocation mode
BOLT-INFO: forcing -jump-tables=move as PIC jump table was detected
PERF2BOLT: Waiting for perf tasks collection to finish...
PERF2BOLT: Parsing perf-script tasks output
PERF2BOLT: Input binary is associated with 1 PID(s)
PERF2BOLT: Waiting for perf events collection to finish...
PERF2BOLT: Aggregating branch events...
PERF2BOLT: Read 239482 samples and 7627200 LBR entries
PERF2BOLT: Traces mismatching disassembled function contents: 0 (0.0%)
PERF2BOLT: Out of range traces involving unknown regions: 7387718 (100.0%)
PERF2BOLT: Wrote 0 objects and 0 memory objects to perf.fdata
I'm letting this be for the moment. Perhaps we'll revisit at a later stage.
from bolt.
Notice the line:
PERF2BOLT-ERROR: failed to match build-id from perf output. This indicates the input binary supplied for data aggregation is not the same recorded by perf when collecting profiling data
It means you collected data on a different binary than the one you are using for aggregation. You should use the same binary.
from bolt.
It's the same binary—I don't know why it thinks it's not. But I've left this for other issues for now.
from bolt.
Oh. I think RewriteInstance::getBuildID() is failing to parse the correct build id for your binary, but that's not the most critical issue. The problem is that it seems all the activity we are getting from LBR are somehow not happening inside any function we were able to read from the binary.
from bolt.
Related Issues (20)
- A dump about function cannot be properly disassembled when use -use-old-text HOT 2
- perf2bolt: crashes with assertion. HOT 5
- A NullPtrException after BOLT on libart.so HOT 2
- BOLT/LLVM? does not preserve prefixes on conditional branches HOT 2
- Assert error in resolveAArch64Relocation HOT 15
- ELF32 support HOT 1
- BOLT only failed with --hugify HOT 13
- Why skip-function when it jump to itself? HOT 7
- Why Is registerName Executed Twice for a Symbol? HOT 1
- How do I run BOLT on a benchmark of HHVM? HOT 1
- A Problem About .got Table Updates HOT 4
- Promote BOLT to the chromium team HOT 11
- A Problem about IsSimple be used in disassemble
- Any ideas to support riscv architecture? HOT 5
- clang14 build with -update-debug-sections rewrite debug info core HOT 14
- A fatal error about -update-debug-sections HOT 3
- Any suggest to couple two functions? HOT 11
- How to use --hugify option? HOT 20
- Failed to BOLT HOT 2
- [C++] Exceptions catch leads to Segmentation fault
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bolt.