├── .clang-format ├── .github └── workflows │ ├── build.yml │ └── cifuzz.yml ├── .gitignore ├── .gitmodules ├── CHANGES.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── config.bloaty ├── custom_sources.bloaty ├── doc ├── how-bloaty-works.md └── using.md ├── make-release-tarball.sh ├── regen-readme.py ├── src ├── bloaty.cc ├── bloaty.h ├── bloaty.proto ├── bloaty_package.bloaty ├── disassemble.cc ├── dwarf.cc ├── dwarf │ ├── attr.cc │ ├── attr.h │ ├── debug_info.cc │ ├── debug_info.h │ ├── dwarf_util.cc │ ├── dwarf_util.h │ ├── line_info.cc │ └── line_info.h ├── dwarf_constants.h ├── eh_frame.cc ├── elf.cc ├── macho.cc ├── main.cc ├── pe.cc ├── range_map.cc ├── range_map.h ├── re.h ├── source_map.cc ├── source_map.h ├── util.cc ├── util.h └── webassembly.cc ├── tests ├── PE │ └── sections │ │ ├── empty-pe32-dll.test │ │ ├── empty-pe32-exe.test │ │ ├── empty-pe64-dll.test │ │ ├── empty-pe64-exe.test │ │ ├── simple-pe32-dll.test │ │ ├── simple-pe32-exe.test │ │ ├── simple-pe64-dll.test │ │ └── simple-pe64-exe.test ├── README.md ├── bloaty_misc_test.cc ├── bloaty_test.cc ├── bloaty_test_pe.cc ├── dwarf │ ├── debug_info │ │ ├── dw_form_line_strp.test │ │ ├── gnu-split-dwarf.test │ │ ├── ignore-declarations.test │ │ ├── pcpair-incomplete.test │ │ └── pcpair.test │ └── range_lists │ │ └── base-addr-selection.test ├── elf │ └── sections │ │ ├── empty-bin-64.test │ │ ├── empty-obj-64.test │ │ ├── musl-static-bin.test │ │ ├── normal-obj.test │ │ ├── segment-offset-larger-than-file-size.test │ │ └── shn-xindex.test ├── fuzz_driver.cc ├── fuzz_target.cc ├── lit.cfg ├── lit.site.cfg.in ├── range_map_test.cc ├── strarr.h ├── test.h ├── testdata │ ├── PE │ │ ├── x64 │ │ │ ├── msvc-15.0-foo-bar-main-cv.bin │ │ │ ├── msvc-15.0-foo-bar-main-cv.bin.seg.txt │ │ │ ├── msvc-15.0-foo-bar-main-cv.bin.txt │ │ │ ├── msvc-15.0-foo-bar-main-cv.pdb │ │ │ ├── msvc-15.0-foo-bar.dll │ │ │ ├── msvc-15.0-foo-bar.dll.seg.txt │ │ │ ├── msvc-15.0-foo-bar.dll.txt │ │ │ ├── msvc-16.0-foo-bar-main-cv.bin │ │ │ ├── msvc-16.0-foo-bar-main-cv.bin.seg.txt │ │ │ ├── msvc-16.0-foo-bar-main-cv.bin.txt │ │ │ ├── msvc-16.0-foo-bar-main-cv.pdb │ │ │ ├── msvc-16.0-foo-bar.dll │ │ │ ├── msvc-16.0-foo-bar.dll.seg.txt │ │ │ └── msvc-16.0-foo-bar.dll.txt │ │ └── x86 │ │ │ ├── msvc-15.0-foo-bar-main-cv.bin │ │ │ ├── msvc-15.0-foo-bar-main-cv.bin.seg.txt │ │ │ ├── msvc-15.0-foo-bar-main-cv.bin.txt │ │ │ ├── msvc-15.0-foo-bar-main-cv.pdb │ │ │ ├── msvc-15.0-foo-bar.dll │ │ │ ├── msvc-15.0-foo-bar.dll.seg.txt │ │ │ ├── msvc-15.0-foo-bar.dll.txt │ │ │ ├── msvc-16.0-foo-bar-main-cv.bin │ │ │ ├── msvc-16.0-foo-bar-main-cv.bin.seg.txt │ │ │ ├── msvc-16.0-foo-bar-main-cv.bin.txt │ │ │ ├── msvc-16.0-foo-bar-main-cv.pdb │ │ │ ├── msvc-16.0-foo-bar.dll │ │ │ ├── msvc-16.0-foo-bar.dll.seg.txt │ │ │ └── msvc-16.0-foo-bar.dll.txt │ ├── bar.c │ ├── foo.c │ ├── fuzz_corpus │ │ ├── 0034ecacd5427aafc6b97413da2053b36de5059f │ │ ├── 0153168d08d78a4eb486cdd421b3efd6a4e12844 │ │ ├── 04deff284542b1271c7ed6da11b4389342793f4d │ │ ├── 0512fc56ee361da71476c098b91d1081e5dbc4ad │ │ ├── 0c7d074fcd0d6863b497f6137c6cacffc59c2ae8 │ │ ├── 0efb04f81a05b500031405eccae9d7e8ea0721c5 │ │ ├── 0f6736109fcd5db53450385486c4586f884feb23 │ │ ├── 110a37d69bfc8f6da2f8180e907d7d2f12da1eb2 │ │ ├── 14f1751b6ceb6aa262bced1c928c11d565c3d913 │ │ ├── 15c502b13029920e528a2982fc1559689764aaf8 │ │ ├── 1846aea81a4e97327d5e82c8ab9e6d4c43bffee3 │ │ ├── 1930321f0302e111b64e38b8456ef8473f3e71d8 │ │ ├── 1bfe776624349462cb1d818443af106215021470 │ │ ├── 2215ecf59e25dfb7b946e25bf9cbb9b6c862563f │ │ ├── 22a284684c8b3f13e6070870dfb21d6453c7819e │ │ ├── 23350c9dafa9b9a1e2a2524a2b173fdec00037ab │ │ ├── 270dcbc8975aaff7d869faa520be996460e6f7be │ │ ├── 2877069c49bf5773d158de6911842a58768b74c3 │ │ ├── 28d7fbe0ff87b53a011656f9e3c9c3aeb2ce2018 │ │ ├── 2eb47f37b3b0b4bb84cc55d0125d9bb7d176b1c5 │ │ ├── 2f6f7647f2e81f50a3f787dda064cffe03354aa8 │ │ ├── 2fd5be6e7a99d71434a756a4d59a8d44db4942bb │ │ ├── 3115b1163086c5904008b9a5d17a761863910214 │ │ ├── 327c150b2d13636bb3ea5129cb58af30675e5599 │ │ ├── 37209ceacf21ce2796c98824dc9be60b876274a2 │ │ ├── 3e96523b6d0025b39ddd0a771fc9f99dd1590877 │ │ ├── 3f3c4745b7053aca15608204a7592bac44d690cb │ │ ├── 412f1573ff1a9675377481456d8809a850d03f1b │ │ ├── 42f2cd88cae45b6add339ed2c2a9074ff55d9db0 │ │ ├── 459ef92fc33d1d9fc6048f293bab5ddb584f94a4 │ │ ├── 48c3f1ae3089b0644c6af799af2ae94ee1c5ad30 │ │ ├── 4e6b7729619f66a429dd9ef88d186dd37c42d8ca │ │ ├── 53a2d35a2dfe33981111fce5c8fb6514dd9570cb │ │ ├── 57354041fcdfcc3613a0762adfd5189ca60abc80 │ │ ├── 5a90c59187664f79cdf1ded1a6eef6854ddd9a07 │ │ ├── 5b69d5a1654e6f7a84538fa8af16414ea44a00f5 │ │ ├── 5e8ec9cbd600dcc8f6dc5eafaf34226706378b60 │ │ ├── 64779227c42248607f46879f9e4007e66ee68269 │ │ ├── 6511ded4f638705a5cdd071d7e21cb4febb7234c │ │ ├── 66845a4bce637e02379f5dbf1b860ceb7725a96d │ │ ├── 67630fad767a6918501667f56f09793d399a104a │ │ ├── 6b45a7d45ef354eb2d549918a804abc1e6d42d05 │ │ ├── 6d2975ba5e8ad75fb4e743d96a279001b9ecd0e3 │ │ ├── 6d385d65872fa08e194a8b806ccfd87e49f5a554 │ │ ├── 6d7db4d97103830cd33688f18b7c6944218b58f8 │ │ ├── 6ecf640685258c2bc0960ab1a797ba2db10ffd63 │ │ ├── 6f0a1ec2ebc980c9296486ad1a5b8a564549aa9a │ │ ├── 6fa62db4fbfc54538513558d0886ff8ae74e58ed │ │ ├── 70619c7a97d684b6dd6dddfb62782ae40bc91370 │ │ ├── 7069a01603ddcf775682ee40d6814f4e5559bb5a │ │ ├── 739b5ce9def832d301c95cfa6d1a9c6e9d46c73d │ │ ├── 7b06150aa15f8aed1abd7a93f1772b893efc150e │ │ ├── 7c06c448cd75d4af6621f578d6d8cb35d2e5279e │ │ ├── 7d09e7259aa0fb3da736b98b94211f71a5e513e6 │ │ ├── 7e290e80959e9f3b045387f7ec257182cb23721d │ │ ├── 827e96b748c33f032574b9f2b7f084920feb76ab │ │ ├── 84675e905d3771b59fd51f606bc2a14f549aba43 │ │ ├── 8631458a27f52b7e3cdfb06a6bde899901bfd3ac │ │ ├── 86a3d4b71ee172cd476d035fb9445bcbb835d92a │ │ ├── 8be73e77c819315082ac4f40acc964ddfa7be6fa │ │ ├── 8fc314d43f2d412e20a822b5f595bf61005342a9 │ │ ├── 91acbe9b1ef167d88e8a57f16db2aa740865accd │ │ ├── 922103ecc5f70b4235b20e30ce0a2e895ead8251 │ │ ├── 9b5a5fa4a46bcca17df149785daf9cd14f1c0443 │ │ ├── 9e079b888e5d223ef0bebf13ce1e26ebdd82752a │ │ ├── a22fdce1317617bf89f3283cbd44ef490a57b5e2 │ │ ├── a493f77d0d04aaed2e2dca8256c9a5cc591aa8fa │ │ ├── a4d1a2b246e0a1f133774daa28328c0d7ce5c3e5 │ │ ├── a4da3e6bc07539aece56d12b2e15b89edd842fd8 │ │ ├── a64d39a8957a4f4c7012f78b41caa8e5f3f4e484 │ │ ├── a69662c2423b5a1d1859f7981c9e88c4f821b0b7 │ │ ├── a743522a548f6321b69ee5081ce898ec5e4b9c23 │ │ ├── af0df3abd6ff306ca9161b6f6ebc96f21c6dfa98 │ │ ├── b3a904cebb1d3070ca96cf70ec0b9ef5d1612a45 │ │ ├── bf2cb5de1de6ca492f159dc3cce67cf88a6244aa │ │ ├── c121e995dd4575473e468801b301da0f219f5de7 │ │ ├── c561ab1d99f16a04898518914dd1cea4afa7e358 │ │ ├── c98c037db24035a40d40f91084a56f470bb6fbc5 │ │ ├── cd838035892825e361fe0f936f93fa62aaf2fab1 │ │ ├── cdeac0baddcbd150bfec97b7b88bff74f73e99f5 │ │ ├── clusterfuzz-testcase-minimized-fuzz_target-4796943898771456 │ │ ├── clusterfuzz-testcase-minimized-fuzz_target-4987539889979392 │ │ ├── clusterfuzz-testcase-minimized-fuzz_target-5640071541161984 │ │ ├── clusterfuzz-testcase-minimized-fuzz_target-5711765729443840 │ │ ├── clusterfuzz-testcase-minimized-fuzz_target-6500838179733504 │ │ ├── clusterfuzz-testcase-minimized-fuzz_target-6527509465268224 │ │ ├── d1128451375207da064d0f332e840af933280610 │ │ ├── d3cc4e4dddf87cb0d41135b7a22d03fc4ec11bbc │ │ ├── daebef8f49a59b71cf57d4771b09f9f8545b83d8 │ │ ├── dda6875f2313476f402e9a283ecaf2b50cfae316 │ │ ├── df7a639969efbe5943b6a7fa5eff4f732a50a4f6 │ │ ├── e08b7c26f946f4761f2cecdc81f4e5e7651db9a7 │ │ ├── e33d3e649729bea900f870b0cd5335f312d9ed42 │ │ ├── e4a3653bac41c8f39cc625286daa813e0ce603b0 │ │ ├── e4c4e1789c10bbfe8ed1c05522483332bf2538f8 │ │ ├── f0ac70f708130bb9cc4aba5ebe1a3c500c4ea11a │ │ ├── f5d4fb20f43ef7131ed49ff29f5c1bee69070ff2 │ │ ├── fc88742708813d5dd57936fad4c6e9bd6ed125ac │ │ ├── testcase-4665949898276864 │ │ ├── testcase-5207237867470848 │ │ └── testcase-5896363763695616 │ ├── linux-x86 │ │ ├── 01-empty.o │ │ ├── 02-simple.o │ │ ├── 03-simple.a │ │ ├── 04-simple.so │ │ ├── 05-binary.bin │ │ ├── 06-diff.a │ │ └── 07-binary-stripped.bin │ ├── linux-x86_64 │ │ ├── 01-empty.o │ │ ├── 02-simple.o │ │ ├── 03-simple.a │ │ ├── 04-simple.so │ │ ├── 05-binary.bin │ │ ├── 06-diff.a │ │ ├── 07-binary-stripped.bin │ │ └── oldbloaty.bin │ ├── main.c │ ├── make_all_msvc_test_files.bat │ ├── make_msvc_test_files.bat │ ├── make_test_files.sh │ └── misc │ │ ├── 01-no-sections.bin │ │ ├── 02-section-count-overflow.o │ │ ├── 03-small-binary-that-crashed-inlines.bin │ │ ├── 04-go-binary-with-ref-addr.bin │ │ └── 05-implicit-const-and-line-strp.bin └── wasm │ ├── active_seg.test │ ├── sections.test │ ├── sourcemap_compileunits.test │ ├── sourcemap_diff.test │ ├── sourcemap_inlines.test │ └── symbol_test.test └── third_party ├── darwin_xnu_macho ├── LICENSE ├── METADATA ├── mach-o │ ├── fat.h │ ├── loader.h │ ├── nlist.h │ └── reloc.h └── mach │ ├── machine.h │ └── vm_prot.h ├── freebsd_elf ├── LICENSE ├── METADATA ├── elf.h ├── elf32.h ├── elf64.h └── elf_common.h └── lief_pe ├── LICENSE ├── METADATA ├── pe_enums.h └── pe_structures.h /.clang-format: -------------------------------------------------------------------------------- 1 | 2 | BasedOnStyle: google 3 | -------------------------------------------------------------------------------- /.github/workflows/cifuzz.yml: -------------------------------------------------------------------------------- 1 | name: CIFuzz 2 | on: [pull_request] 3 | jobs: 4 | Fuzzing: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | fail-fast: false 8 | matrix: 9 | sanitizer: [address, undefined] 10 | steps: 11 | - name: Build Fuzzers (${{ matrix.sanitizer }}) 12 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 13 | with: 14 | oss-fuzz-project-name: 'bloaty' 15 | dry-run: false 16 | sanitizer: ${{ matrix.sanitizer }} 17 | - name: Run Fuzzers (${{ matrix.sanitizer }}) 18 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 19 | with: 20 | oss-fuzz-project-name: 'bloaty' 21 | fuzz-seconds: 600 22 | dry-run: false 23 | sanitizer: ${{ matrix.sanitizer }} 24 | - name: Upload Crash 25 | uses: actions/upload-artifact@v1 26 | if: failure() 27 | with: 28 | name: ${{ matrix.sanitizer }}-artifacts 29 | path: ./out/artifacts 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.o 3 | .*.sw? 4 | /bloaty 5 | !tests/testdata/** 6 | *.dSYM 7 | build 8 | build-* 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/re2"] 2 | path = third_party/re2 3 | url = https://github.com/google/re2 4 | [submodule "third_party/googletest"] 5 | path = third_party/googletest 6 | url = https://github.com/google/googletest.git 7 | [submodule "third_party/abseil-cpp"] 8 | path = third_party/abseil-cpp 9 | url = https://github.com/abseil/abseil-cpp.git 10 | [submodule "third_party/protobuf"] 11 | path = third_party/protobuf 12 | url = https://github.com/protocolbuffers/protobuf.git 13 | [submodule "third_party/capstone"] 14 | path = third_party/capstone 15 | url = https://github.com/aquynh/capstone.git 16 | [submodule "third_party/demumble"] 17 | path = third_party/demumble 18 | url = https://github.com/nico/demumble.git 19 | [submodule "third_party/zlib"] 20 | path = third_party/zlib 21 | url = https://github.com/madler/zlib 22 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [Bloaty McBloatface v1.1](https://github.com/google/bloaty/releases/tag/v1.1) (2020-05-23) 4 | 5 | ### Added 6 | 7 | * **Source Filtering**: Bloaty can now filter the results based on a regex 8 | match. See "Source filter" in [README.md](README.md) for details. (#177) 9 | * **Show only File or VM**: It is possible to restrict the output to show only 10 | "VM SIZE" or "FILE SIZE" by passing `--domain=vm` or `--domain=file`. (#165) 11 | 12 | ### Fixed 13 | 14 | * **Use system deps in CMake build**: The CMake build can now use system deps 15 | for protobuf, capstone, and re2 if they are present. Hopefully this will make 16 | Bloaty easier to package in package managers. (#155) 17 | * **DWARF 4 Support**: Fixed one place in Bloaty that was not accepting DWARF 4. 18 | (#166) 19 | * **DWARF fix**: Added support for `DW_FORM_ref_udata`. (#197) 20 | * **Big-endian fix**: Added missing byte swapping when getting the build ID for 21 | a big-endian binary. (#182) 22 | * **WASM demangling**: WASM symbols are now properly demangled. (#149) 23 | * **New WASM sections**: Added support for new DataCount and Event sections 24 | in WASM. (#178) 25 | * **Scaling fixes**: Fixed integer overflow in 32-bit builds, and other issues 26 | that arise when using Bloaty with many files and/or large files. (#193) 27 | * **Improved coverage**: Bloaty now properly attributes `.eh_frame` in object 28 | files, and attributes ELF headers to the corresponding section. (#168) 29 | * **CSV escaping**: Bloaty now properly escapes CSV output when a field contains 30 | a comma or double quote. (#174) 31 | 32 | ### Changed 33 | 34 | * **File size column moved left**: In the default output, the file size now 35 | appears on the left. This means that all numbers are now on the left, which 36 | leads to more readable output when viewing in a proportional font or in a 37 | limited-width window. 38 | 39 | Old: 40 | ``` 41 | VM SIZE FILE SIZE 42 | -------------- -------------- 43 | 0.0% 0 .debug_info 7.97Mi 29.5% 44 | 0.0% 0 .debug_loc 6.40Mi 23.7% 45 | ``` 46 | 47 | New: 48 | ``` 49 | FILE SIZE VM SIZE 50 | -------------- -------------- 51 | 30.0% 8.85Mi 0.0% 0 .debug_info 52 | 24.7% 7.29Mi 0.0% 0 .debug_loc 53 | ``` 54 | 55 | This shouldn't cause breakage, as anything consuming Bloaty's output 56 | programmatically should be using `--csv` or `--tsv`. (#165) 57 | * **ELF Segment labels now contain index**: Previously ELF segment labels looked 58 | like `LOAD [RW]` with segment flags only. Now they also contain the segment 59 | index, eg. `LOAD #1 [RW]`, so the output can distinguish between different 60 | segments with the same flags. (#159) 61 | 62 | ### Security 63 | 64 | Bloaty should not be considered fully hardened against malicious binaries. This 65 | is one of the major reasons why Bloaty is not offered as an in-process library, 66 | and should only be used through its command-line interface in a dedicated 67 | address space. If you do not trust the input, further process sandboxing is 68 | advisable. 69 | 70 | However we do perform fuzzing of the parsers, and fix and crash bugs that are 71 | found by fuzzing. 72 | 73 | * **Fixed crash bugs found by fuzzing** (#173, #175) 74 | 75 | ## [Bloaty McBloatface v1.0](https://github.com/google/bloaty/releases/tag/v1.0) (2018-08-07) 76 | 77 | This is the first formal release of Bloaty. 78 | 79 | Changes since Bloaty was [first announced in Nov 80 | 2016](http://blog.reverberate.org/2016/11/07/introducing-bloaty-mcbloatface.html): 81 | 82 | * **Much better coverage / data quality**: Bloaty now properly attributes 83 | sections of the binary like the symbol table, debugging information, 84 | relocations, and frame unwinding info. We even disassemble the binary looking 85 | for references to anonymous data members that do not have symbol table 86 | entries. This all means higher quality output, and much less of the binary is 87 | attributed to `[None]`. 88 | * **Native Mach-O support**: Bloaty can now parse Mach-O files directly, 89 | instead of shelling out to other programs. The result is much faster and 90 | higher-quality output for Mach-O. Also the data sources that require debug 91 | info (like `-d compileunits`) now work with Mach-O. 92 | * **WebAssembly support (EXPERIMENTAL)**: Bloaty can analyze sections and 93 | symbols in binary WebAssembly files. 94 | * **Native C++ Demangling**: Bloaty can now demangle C++ symbols without 95 | shelling out to `c++filt`. There are two separate demangling modes, one which 96 | strips all template parameters and parameter/return types (`shortsymbols`) and 97 | one that returns full demangled names (`fullsymbols`). 98 | * **Profiling stripped binaries**: Bloaty can read symbols and debug info from 99 | separate files. This allows you to profile stripped binaries. 100 | * **Parallel file parsing**: If you pass multiple files to Bloaty, it will 101 | scan them in parallel. If you are parsing lots of files and have lots of CPUs, 102 | this can save a lot of time. 103 | * **Configuration files**: All options you can specify on the command-line can 104 | be put in a configuration file instead (and vice versa). This is helpful if 105 | the options might otherwise overflow the command-line (for example, if you 106 | are parsing thousands of files). It also lets you save bits of configuration 107 | to a file for reuse. 108 | * **Custom data sources**: you can create your own data sources by applying 109 | regexes to the built-in sources. This lets you bucket symbols, source files, 110 | etc. in ways that make sense for your project. 111 | * **CSV/TSV output**: this is a robust way to parse Bloaty's output and use it 112 | in other programs. (The default, human-readable output is not designed to be 113 | parsed and its format may change in backward-incompatible ways). 114 | * **Lots of bugfixes**: Fixed lots of bugs that people reported in various 115 | platforms and configurations. Bloaty is fuzzed regularly now, and this has 116 | led to many bugfixes also. 117 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including 2 | the small print at the end). 3 | 4 | ### Get in touch 5 | 6 | If your idea will take you more than, say, 30 minutes to 7 | implement, please get in touch first via the issue tracker 8 | to touch base about your plan. That will give an 9 | opportunity for early feedback and help avoid wasting your 10 | time. 11 | 12 | ### Add tests 13 | 14 | Please add tests for any new features or bugfixes. Bloaty 15 | has a lot of functionality (different data sources, file 16 | formats, diff mode, hierarchical reports, etc). Having 17 | tests helps ensure that we don't regress any of these 18 | features. 19 | 20 | ### Coding style 21 | 22 | Please follow the [Google C++ Style 23 | Guide](https://google.github.io/styleguide/cppguide.html). I 24 | recommend using `clang-format`, [which has a preset for the 25 | Google Style 26 | Guide](http://clang.llvm.org/docs/ClangFormatStyleOptions.html) 27 | 28 | ### Code reviews 29 | 30 | All submissions, including submissions by project members, 31 | require review. We use Github pull requests for this 32 | purpose. 33 | 34 | ### Legal Requirements 35 | Before we can use your code, you must sign the [Google 36 | Individual Contributor License 37 | Agreement](https://cla.developers.google.com/about/google-individual) 38 | (CLA), which you can do online. The CLA is necessary mainly 39 | because you own the copyright to your changes, even after 40 | your contribution becomes part of our codebase, so we need 41 | your permission to use and distribute your code. We also 42 | need to be sure of various other things—for instance that 43 | you'll tell us if you know that your code infringes on other 44 | people's patents. You don't have to sign the CLA until after 45 | you've submitted your code for review and a member has 46 | approved it, but you must do it before we can put your code 47 | into our codebase. 48 | 49 | ### The small print 50 | Contributions made by corporations are covered by a 51 | different agreement than the one above, the [Software Grant 52 | and Corporate Contributor License 53 | Agreement](https://cla.developers.google.com/about/google-corporate). 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Bloaty: a size profiler for binaries 3 | 4 | [![build](https://github.com/google/bloaty/actions/workflows/build.yml/badge.svg)](https://github.com/google/bloaty/actions/workflows/build.yml) 5 | 6 | Ever wondered what's making your binary big? Bloaty will 7 | show you a size profile of the binary so you can understand 8 | what's taking up space inside. 9 | 10 | ```cmdoutput 11 | $ ./bloaty bloaty -d compileunits 12 | FILE SIZE VM SIZE 13 | -------------- -------------- 14 | 34.8% 10.2Mi 43.4% 2.91Mi [163 Others] 15 | 17.2% 5.08Mi 4.3% 295Ki third_party/protobuf/src/google/protobuf/descriptor.cc 16 | 7.3% 2.14Mi 2.6% 179Ki third_party/protobuf/src/google/protobuf/descriptor.pb.cc 17 | 4.6% 1.36Mi 1.1% 78.4Ki third_party/protobuf/src/google/protobuf/text_format.cc 18 | 3.7% 1.10Mi 4.5% 311Ki third_party/capstone/arch/ARM/ARMDisassembler.c 19 | 1.3% 399Ki 15.9% 1.07Mi third_party/capstone/arch/M68K/M68KDisassembler.c 20 | 3.2% 980Ki 1.1% 75.3Ki third_party/protobuf/src/google/protobuf/generated_message_reflection.cc 21 | 3.2% 965Ki 0.6% 40.7Ki third_party/protobuf/src/google/protobuf/descriptor_database.cc 22 | 2.8% 854Ki 12.0% 819Ki third_party/capstone/arch/X86/X86Mapping.c 23 | 2.8% 846Ki 1.0% 66.4Ki third_party/protobuf/src/google/protobuf/extension_set.cc 24 | 2.7% 800Ki 0.6% 41.2Ki third_party/protobuf/src/google/protobuf/generated_message_util.cc 25 | 2.3% 709Ki 0.7% 50.7Ki third_party/protobuf/src/google/protobuf/wire_format.cc 26 | 2.1% 637Ki 1.7% 117Ki third_party/demumble/third_party/libcxxabi/cxa_demangle.cpp 27 | 1.8% 549Ki 1.7% 114Ki src/bloaty.cc 28 | 1.7% 503Ki 0.7% 48.1Ki third_party/protobuf/src/google/protobuf/repeated_field.cc 29 | 1.6% 469Ki 6.2% 427Ki third_party/capstone/arch/X86/X86DisassemblerDecoder.c 30 | 1.4% 434Ki 0.2% 15.9Ki third_party/protobuf/src/google/protobuf/message.cc 31 | 1.4% 422Ki 0.3% 23.4Ki third_party/re2/re2/dfa.cc 32 | 1.3% 407Ki 0.4% 24.9Ki third_party/re2/re2/regexp.cc 33 | 1.3% 407Ki 0.4% 29.9Ki third_party/protobuf/src/google/protobuf/map_field.cc 34 | 1.3% 397Ki 0.4% 24.8Ki third_party/re2/re2/re2.cc 35 | 100.0% 29.5Mi 100.0% 6.69Mi TOTAL 36 | ``` 37 | 38 | Bloaty performs a deep analysis of the binary. Using custom 39 | ELF, DWARF, and Mach-O parsers, Bloaty aims to accurately 40 | attribute every byte of the binary to the symbol or 41 | compileunit that produced it. It will even disassemble the 42 | binary looking for references to anonymous data. 43 | 44 | Bloaty supports many features: 45 | 46 | - **file formats:** ELF, Mach-O, PE/COFF (experimental), WebAssembly (experimental) 47 | - **data sources:** compileunit (shown above), symbol, section, segment, etc. 48 | - **hierarchical profiles:** combine multiple data sources into a single report 49 | - **size diffs:** see where the binary grew, perfect for CI tests 50 | - **separate debug files:** strip the binary under test, while making debug data available for analysis 51 | - **flexible demangling:** demangle C++ symbols, optionally discarding function/template parameters 52 | - **custom data sources:** regex rewrites of built-in data sources, for custom munging/bucketing 53 | - **regex filtering:** filter out parts of the binary that do or don't match a given regex 54 | - **easy to deploy:** statically-linked C++ binary, easy to copy around 55 | 56 | For detailed info on all of Bloaty's features, see the [User 57 | Documentation](doc/using.md). 58 | 59 | For more information about the analysis performed by Bloaty, 60 | please see [How Bloaty Works](doc/how-bloaty-works.md). 61 | 62 | 63 | ## Install 64 | 65 | To build, use `cmake`. For example: 66 | 67 | ``` 68 | $ cmake -B build -G Ninja -S . 69 | $ cmake --build build 70 | $ cmake --build build --target install 71 | ``` 72 | 73 | Bloaty bundles ``libprotobuf``, ``re2``, ``capstone``, and 74 | ``pkg-config`` as Git submodules, and uses ``protoc`` build 75 | from libprotobuf, but it will prefer the system's versions 76 | of those dependencies if available. All other dependencies 77 | are included as Git submodules. 78 | 79 | If the Git repository hasn't been cloned with the 80 | `--recursive`, the submodules can be checked out with: 81 | 82 | ``` 83 | $ git submodule update --init --recursive 84 | ``` 85 | 86 | To run the tests, see the info in 87 | [tests/README.md](tests/README.md). 88 | 89 | ## Support 90 | 91 | GitHub issues and PRs welcome. Please include tests when possible, see: 92 | [tests/README.md](tests/README.md). 93 | 94 | This is not an official Google product. 95 | -------------------------------------------------------------------------------- /config.bloaty: -------------------------------------------------------------------------------- 1 | custom_data_source: { 2 | name: "bloaty_package" 3 | base_data_source: "compileunits" 4 | 5 | rewrite: { 6 | pattern: "^(\\.\\./)?src" 7 | replacement: "src" 8 | } 9 | rewrite: { 10 | pattern: "^(\\.\\./)?(third_party/\\w+)" 11 | replacement: "\\2" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /custom_sources.bloaty: -------------------------------------------------------------------------------- 1 | 2 | # Custom data sources that are generally useful, so we ship them 3 | # with Bloaty. 4 | 5 | ## 6 | # class_or_namespace: grabs everything up until the last "::". 7 | # 8 | # This is especially useful when paired with shortsymbols, eg. 9 | # 10 | # VM SIZE FILE SIZE 11 | # -------------- -------------- 12 | # 37.6% 4.18Mi [None] 4.17Mi 37.6% 13 | # 30.9% 3.44Mi [Other] 3.44Mi 30.9% 14 | # 5.7% 648Ki insns 648Ki 5.7% 15 | # 2.9% 330Ki printAliasInstr 330Ki 2.9% 16 | # 2.9% 326Ki __cxxabiv1::(anonymous namespace) 326Ki 2.9% 17 | # 23.6% 77.1Ki [Other] 77.1Ki 23.6% 18 | # 12.7% 41.5Ki __cxxabiv1::(anonymous namespace)::parse_type<>() 41.5Ki 12.7% 19 | # 10.1% 32.9Ki __cxxabiv1::(anonymous namespace)::parse_expression<>() 32.9Ki 10.1% 20 | # <...> 21 | # 2.7% 306Ki std::__1::__tree<> 306Ki 2.7% 22 | # 27.2% 83.3Ki std::__1::__tree<>::__find_equal<>() 83.3Ki 27.2% 23 | # 20.9% 64.0Ki std::__1::__tree<>::__construct_node() 64.0Ki 20.9% 24 | # 12.6% 38.8Ki std::__1::__tree<>::find<>() 38.8Ki 12.6% 25 | # <...> 26 | # 2.2% 247Ki std::__1::__hash_table<> 247Ki 2.2% 27 | # 23.6% 58.5Ki std::__1::__hash_table<>::__rehash() 58.5Ki 23.6% 28 | # 20.3% 50.2Ki std::__1::__hash_table<>::__construct_node_hash() 50.2Ki 20.3% 29 | # 15.4% 38.2Ki std::__1::__hash_table<>::find<>() 38.2Ki 15.4% 30 | # <...> 31 | # 1.8% 208Ki google::protobuf 207Ki 1.8% 32 | # 35.2% 73.2Ki google::protobuf::InsertIfNotPresent<>() 73.2Ki 35.2% 33 | # 25.8% 53.7Ki [Other] 53.4Ki 25.7% 34 | # 6.1% 12.7Ki google::protobuf::StrCat() 12.7Ki 6.1% 35 | # <...> 36 | # 37 | # etc. 38 | 39 | custom_data_source: { 40 | name: "class_or_namespace" 41 | base_data_source: "shortsymbols" 42 | 43 | rewrite: { 44 | pattern: "^(.*)::[^:]+$" 45 | replacement: "\\1" 46 | } 47 | } 48 | 49 | ## 50 | # stripped_sections: the base section name 51 | # 52 | # This is useful when you are profiling object files that you have compiled 53 | # with -ffunction-sections/-fdata-sections. Normally this makes "-d sections" 54 | # very noisy, because every function has a distinct section name. This 55 | # removes the noise and gives you a base section name. 56 | custom_data_source: { 57 | name: "stripped_sections" 58 | base_data_source: "sections" 59 | 60 | rewrite: { 61 | pattern: "^\\.text" 62 | replacement: ".text" 63 | } 64 | rewrite: { 65 | pattern: "^\\.data.rel.ro" 66 | replacement: ".data.rel.ro" 67 | } 68 | rewrite: { 69 | pattern: "^\\.data" 70 | replacement: ".data" 71 | } 72 | rewrite: { 73 | pattern: "^\\.rela\\.text" 74 | replacement: ".rela.text" 75 | } 76 | rewrite: { 77 | pattern: "^.rela.data.rel.ro" 78 | replacement: ".rela.data.rel.ro" 79 | } 80 | rewrite: { 81 | pattern: "^.rela.rodata" 82 | replacement: ".rela.rodata" 83 | } 84 | rewrite: { 85 | pattern: "^.rela.data" 86 | replacement: ".rela.data" 87 | } 88 | rewrite: { 89 | pattern: "^.tdata" 90 | replacement: ".tdata" 91 | } 92 | rewrite: { 93 | pattern: "^.rodata" 94 | replacement: ".rodata" 95 | } 96 | rewrite: { 97 | pattern: "^.bss" 98 | replacement: ".bss" 99 | } 100 | rewrite: { 101 | pattern: "^.tbss" 102 | replacement: ".tbss" 103 | } 104 | } 105 | 106 | custom_data_source: { 107 | name: "section_prefix" 108 | base_data_source: "sections" 109 | rewrite: { 110 | pattern: "^(\\.[^.]+)" 111 | replacement: "\\1" 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /make-release-tarball.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Makes a release tarball. We include our dependencies/submodules, 4 | # but we heavily prune their file lists to avoid including lots of 5 | # extraneous baggage. We also leave out Bloaty's tests, especially 6 | # because some of the test data is large. 7 | 8 | set -e 9 | 10 | if [ "$#" -ne 1 ]; then 11 | echo "Usage: make-release.tarball.sh VERSION" 12 | exit 1 13 | fi 14 | 15 | VERSION=$1 16 | 17 | FILES=$(git ls-files --exclude-standard --recurse-submodules | 18 | grep -v googletest | 19 | grep -v ^tests | 20 | grep -v third_party/protobuf | 21 | grep -v 'third_party/capstone/\(suite\|bindings\|xcode\|msvc\|contrib\)' | 22 | grep -v third_party/abseil-cpp/absl/time/internal/cctz/testdata | 23 | grep -v ^.git) 24 | FILES="$FILES $(git ls-files --exclude-standard --recurse-submodules | 25 | grep 'third_party/protobuf/\(src\|cmake\|configure.ac\)')" 26 | 27 | # Unfortunately tar on Mac doesn't support --transform, so we have to 28 | # actually move our files to a different directory to get the prefix. 29 | DIR=/tmp/bloaty-$VERSION 30 | rm -rf $DIR 31 | mkdir $DIR 32 | rsync -R $FILES $DIR 33 | 34 | BASE=$PWD 35 | cd /tmp 36 | OUT=bloaty-$VERSION.tar.bz2 37 | tar cjf $BASE/$OUT bloaty-$VERSION 38 | 39 | echo "Created $OUT" 40 | 41 | -------------------------------------------------------------------------------- /regen-readme.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import subprocess 4 | import os 5 | import sys 6 | 7 | basedir = os.path.dirname(sys.argv[0]) 8 | readme = os.path.join(basedir, "doc/using.md") 9 | 10 | with open(readme) as f: 11 | inp = f.read() 12 | 13 | out = "" 14 | 15 | it = iter(inp.splitlines(True)) 16 | 17 | for line in it: 18 | out += line 19 | if line.startswith("```cmdoutput"): 20 | # Get command. 21 | cmd = next(it) 22 | assert cmd.startswith("$ "), cmd 23 | real_cmd = cmd[2:].strip() 24 | out += cmd 25 | 26 | print("Running: " + real_cmd) 27 | out += subprocess.check_output(real_cmd, shell=True) 28 | 29 | # Skip pre-existing command output. 30 | line = next(it) 31 | while not line.startswith("```"): 32 | line = next(it) 33 | out += line 34 | 35 | with open(readme, "w") as f: 36 | f.write(out) 37 | -------------------------------------------------------------------------------- /src/bloaty.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto2"; 16 | 17 | package bloaty; 18 | 19 | message Options { 20 | // The files to analyze. At least one file must be provided. 21 | repeated string filename = 1; 22 | 23 | // If non-empty, we are in diff mode and these files should provide the 24 | // baseline. 25 | repeated string base_filename = 2; 26 | 27 | // Files to use for debug information. We will match these to files from 28 | // filename or base_filename by build id. Files that are only in 29 | // debug_filename will *not* have their file size counted. 30 | repeated string debug_filename = 10; 31 | 32 | // Build id to source map file names, delimited by '='. 33 | repeated string source_map = 15; 34 | 35 | // The data sources to scan in each file. At least one data source must be 36 | // specified. If more than one source is specified, the output is 37 | // hierarchical. 38 | // 39 | // These can be built-in data sources or custom data sources. 40 | repeated string data_source = 3; 41 | 42 | // The maximum number of rows to show at each level before collapsing the rest 43 | // into '[Other]'. 44 | optional int64 max_rows_per_level = 4 [default = 20]; 45 | 46 | enum Demangle { 47 | DEMANGLE_SHORT = 0; 48 | DEMANGLE_FULL = 1; 49 | DEMANGLE_NONE = 2; 50 | } 51 | optional Demangle demangle = 5 [default = DEMANGLE_SHORT]; 52 | 53 | // What to sort the output by. 54 | enum SortBy { 55 | SORTBY_BOTH = 0; 56 | SORTBY_VMSIZE = 1; 57 | SORTBY_FILESIZE = 2; 58 | } 59 | optional SortBy sort_by = 6 [default = SORTBY_BOTH]; 60 | 61 | // When greater than zero, Bloaty will print verbose output to stdout. 62 | // TODO(haberman): should this be in the output object instead? 63 | optional int32 verbose_level = 7; 64 | 65 | // If set, these will print verbose information pertaining to the given 66 | // vm address and/or file offset. 67 | optional uint64 debug_vmaddr = 11; 68 | optional uint64 debug_fileoff = 12; 69 | 70 | // Custom data sources for this analysis. 71 | repeated CustomDataSource custom_data_source = 8; 72 | 73 | // Disassemble this function. 74 | optional string disassemble_function = 9; 75 | 76 | // Regex with which to filter names in the data sources. 77 | optional string source_filter = 13; 78 | 79 | // Dump raw memory map instead of printing normal output. 80 | optional bool dump_raw_map = 14; 81 | } 82 | 83 | // A custom data source allows users to create their own label space by 84 | // rewriting a set of existing labels according to a set of regexes. 85 | message CustomDataSource { 86 | // The name of this data source. 87 | optional string name = 1; 88 | 89 | // The underlying data source. We will scan this data source and apply 90 | // rewrites to define the new data source. This must be a built-in data 91 | // source, not another custom data source. 92 | optional string base_data_source = 2; 93 | 94 | // The rewrites that we will apply to the underlying labels to define the new 95 | // data source. 96 | repeated Regex rewrite = 3; 97 | } 98 | 99 | // For rewriting labels from a data source. If the regex matches, then the 100 | // entire string is replaced with the replacement. Any groups captured from the 101 | // pattern can be substituted into the replacement with \1, \2, etc. and \0 102 | // refers to the entire match. 103 | message Regex { 104 | optional string pattern = 1; 105 | optional string replacement = 2; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /src/bloaty_package.bloaty: -------------------------------------------------------------------------------- 1 | custom_data_source: { 2 | name: "bloaty_package" 3 | base_data_source: "compileunits" 4 | 5 | rewrite: { 6 | pattern: "^(\\.\\./)?src" 7 | replacement: "src" 8 | } 9 | rewrite: { 10 | pattern: "^(\\.\\./)?(third_party/\\w+)" 11 | replacement: "\\2" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/dwarf/attr.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BLOATY_DWARF_ATTR_H_ 16 | #define BLOATY_DWARF_ATTR_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "absl/types/optional.h" 22 | 23 | namespace bloaty { 24 | namespace dwarf { 25 | 26 | class CU; 27 | 28 | class AttrValue { 29 | public: 30 | static AttrValue ParseAttr(const CU& cu, uint16_t form, std::string_view* data); 31 | 32 | AttrValue(const AttrValue &) = default; 33 | AttrValue &operator=(const AttrValue &) = default; 34 | 35 | uint16_t form() const { return form_; } 36 | 37 | bool IsUint() const { 38 | return type_ == Type::kUint || type_ == Type::kUnresolvedUint; 39 | } 40 | 41 | bool IsString() const { 42 | return type_ == Type::kString || type_ == Type::kUnresolvedString; 43 | } 44 | 45 | // Attempts to coerce to uint, returning nullopt if this is not possible. 46 | absl::optional ToUint(const CU& cu) const; 47 | 48 | // REQUIRES: IsUint() && form() != DW_FORM_implicit_const. 49 | uint64_t GetUint(const CU& cu) const; 50 | 51 | // REQUIRES: IsString(). 52 | std::string_view GetString(const CU& cu) const; 53 | 54 | private: 55 | explicit AttrValue(uint16_t form, uint64_t val) 56 | : uint_(val), form_(form), type_(Type::kUint) {} 57 | explicit AttrValue(uint16_t form, std::string_view val) 58 | : string_(val), form_(form), type_(Type::kString) {} 59 | 60 | // We delay the resolution of indirect strings and addresses, both to avoid 61 | // unnecessary work and because they may depend on base values that occur 62 | // after them in the sequence of attributes, eg. 63 | // 64 | // $ dwarfdump -i bloaty 65 | // COMPILE_UNIT
: 66 | // < 0><0x0000000c> DW_TAG_compile_unit 67 | // DW_AT_producer (indexed string: 0x00000000)Debian clang version 11.0.1-2 68 | // DW_AT_language DW_LANG_C_plus_plus_14 69 | // DW_AT_name (indexed string: 0x00000001)../src/main.cc 70 | // DW_AT_str_offsets_base 0x00000008 71 | // 72 | // Note that DW_AT_name comes before DW_AT_str_offset_base, but the latter 73 | // value is required to resolve the name attribute. 74 | enum class Type { 75 | kUint, 76 | kString, 77 | kUnresolvedUint, 78 | kUnresolvedString 79 | }; 80 | 81 | Type type() const { return type_; } 82 | 83 | static AttrValue UnresolvedUint(uint16_t form, uint64_t val) { 84 | AttrValue ret(form, val); 85 | ret.type_ = Type::kUnresolvedUint; 86 | return ret; 87 | } 88 | 89 | static AttrValue UnresolvedString(uint16_t form, uint64_t val) { 90 | AttrValue ret(form, val); 91 | ret.type_ = Type::kUnresolvedString; 92 | return ret; 93 | } 94 | 95 | union { 96 | uint64_t uint_; 97 | std::string_view string_; 98 | }; 99 | 100 | uint16_t form_; 101 | Type type_; 102 | 103 | template 104 | static std::string_view ReadBlock(std::string_view* data); 105 | static std::string_view ReadVariableBlock(std::string_view* data); 106 | template 107 | static std::string_view ReadIndirectString(const CU& cu, 108 | std::string_view* data); 109 | static std::string_view ResolveIndirectString(const CU& cu, uint64_t ofs); 110 | template 111 | static std::string_view ReadIndirectLineString(const CU& cu, 112 | std::string_view* data); 113 | static std::string_view ResolveIndirectLineString(const CU& cu, uint64_t ofs); 114 | 115 | std::string_view ResolveDoubleIndirectString(const CU &cu) const; 116 | uint64_t ResolveIndirectAddress(const CU& cu) const; 117 | }; 118 | 119 | } // namespace dwarf 120 | } // namespace bloaty 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /src/dwarf/dwarf_util.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dwarf/dwarf_util.h" 16 | 17 | using string_view = std::string_view; 18 | 19 | namespace bloaty { 20 | namespace dwarf { 21 | 22 | // uint64/32 max is a tombstone value added by https://reviews.llvm.org/D81784. 23 | bool IsValidDwarfAddress(uint64_t addr, uint8_t address_size) { 24 | if (addr == 0) 25 | return false; 26 | if (address_size == 4 && addr == std::numeric_limits::max()) 27 | return false; 28 | if (address_size == 8 && addr == std::numeric_limits::max()) 29 | return false; 30 | return true; 31 | } 32 | 33 | uint64_t ReadLEB128Internal(bool is_signed, string_view* data) { 34 | uint64_t ret = 0; 35 | int shift = 0; 36 | int maxshift = 70; 37 | const char* ptr = data->data(); 38 | const char* limit = ptr + data->size(); 39 | 40 | while (ptr < limit && shift < maxshift) { 41 | char byte = *(ptr++); 42 | ret |= static_cast(byte & 0x7f) << shift; 43 | shift += 7; 44 | if ((byte & 0x80) == 0) { 45 | data->remove_prefix(ptr - data->data()); 46 | if (is_signed && shift < 64 && (byte & 0x40)) { 47 | ret |= -(1ULL << shift); 48 | } 49 | return ret; 50 | } 51 | } 52 | 53 | THROW("corrupt DWARF data, unterminated LEB128"); 54 | } 55 | 56 | void SkipLEB128(string_view* data) { 57 | size_t limit = 58 | std::min(static_cast(data->size()), static_cast(10)); 59 | for (size_t i = 0; i < limit; i++) { 60 | if (((*data)[i] & 0x80) == 0) { 61 | data->remove_prefix(i + 1); 62 | return; 63 | } 64 | } 65 | 66 | THROW("corrupt DWARF data, unterminated LEB128"); 67 | } 68 | 69 | std::string_view ReadDebugStrEntry(std::string_view section, size_t ofs) { 70 | SkipBytes(ofs, §ion); 71 | return ReadNullTerminated(§ion); 72 | } 73 | 74 | } // namespace dwarf 75 | } // namespace bloaty 76 | -------------------------------------------------------------------------------- /src/dwarf/dwarf_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BLOATY_DWARF_UTIL_H_ 16 | #define BLOATY_DWARF_UTIL_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "util.h" 23 | 24 | namespace bloaty { 25 | namespace dwarf { 26 | 27 | uint64_t ReadLEB128Internal(bool is_signed, std::string_view* data); 28 | 29 | // Reads a DWARF LEB128 varint, where high bits indicate continuation. 30 | template 31 | T ReadLEB128(std::string_view* data) { 32 | typedef typename std::conditional::value, int64_t, 33 | uint64_t>::type Int64Type; 34 | Int64Type val = ReadLEB128Internal(std::is_signed::value, data); 35 | if (val > std::numeric_limits::max() || 36 | val < std::numeric_limits::min()) { 37 | THROW("DWARF data contained larger LEB128 than we were expecting"); 38 | } 39 | return static_cast(val); 40 | } 41 | 42 | void SkipLEB128(std::string_view* data); 43 | 44 | bool IsValidDwarfAddress(uint64_t addr, uint8_t address_size); 45 | 46 | inline int DivRoundUp(int n, int d) { 47 | return (n + (d - 1)) / d; 48 | } 49 | 50 | std::string_view ReadDebugStrEntry(std::string_view section, size_t ofs); 51 | 52 | } // namepsace dwarf 53 | } // namepsace bloaty 54 | 55 | #endif // BLOATY_DWARF_UTIL_H_ 56 | -------------------------------------------------------------------------------- /src/dwarf/line_info.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BLOATY_DWARF_LINE_INFO_H_ 16 | #define BLOATY_DWARF_LINE_INFO_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "dwarf/debug_info.h" 22 | 23 | // Code to read the .line_info programs in a DWARF file. Currently we use this 24 | // for the "inlines" data source, but I think we should probably use the 25 | // inlining info in debug_info instead. 26 | // 27 | // Usage overview: 28 | // dwarf::LineInfoReader reader(file); 29 | // 30 | // reader.SeekToOffset(ofs, cu.unit_sizes().address_size()); 31 | // while (reader->ReadLineInfo()) { 32 | // const dwarf::LineInfo& info = reader->lineinfo(); 33 | // // ... 34 | // } 35 | 36 | namespace bloaty { 37 | namespace dwarf { 38 | 39 | class LineInfoReader { 40 | public: 41 | LineInfoReader(const File& file) : file_(file), info_(0) {} 42 | 43 | struct LineInfo { 44 | LineInfo(bool default_is_stmt) : is_stmt(default_is_stmt) {} 45 | uint64_t address = 0; 46 | uint32_t file = 1; 47 | uint32_t line = 1; 48 | uint32_t column = 0; 49 | uint32_t discriminator = 0; 50 | bool end_sequence = false; 51 | bool basic_block = false; 52 | bool prologue_end = false; 53 | bool epilogue_begin = false; 54 | bool is_stmt; 55 | uint8_t op_index = 0; 56 | uint8_t isa = 0; 57 | }; 58 | 59 | struct FileName { 60 | std::string_view name; 61 | uint32_t directory_index; 62 | uint64_t modified_time; 63 | uint64_t file_size; 64 | }; 65 | 66 | void SeekToOffset(uint64_t offset, uint8_t address_size); 67 | bool ReadLineInfo(); 68 | const LineInfo& lineinfo() const { return info_; } 69 | const FileName& filename(size_t i) const { return filenames_[i]; } 70 | std::string_view include_directory(size_t i) const { 71 | return include_directories_[i]; 72 | } 73 | 74 | const std::string& GetExpandedFilename(size_t index); 75 | 76 | private: 77 | struct Params { 78 | uint8_t minimum_instruction_length; 79 | uint8_t maximum_operations_per_instruction; 80 | uint8_t default_is_stmt; 81 | int8_t line_base; 82 | uint8_t line_range; 83 | uint8_t opcode_base; 84 | } params_; 85 | 86 | const File& file_; 87 | 88 | CompilationUnitSizes sizes_; 89 | std::vector include_directories_; 90 | std::vector filenames_; 91 | std::vector standard_opcode_lengths_; 92 | std::vector expanded_filenames_; 93 | 94 | std::string_view remaining_; 95 | 96 | // Whether we are in a "shadow" part of the bytecode program. Sometimes 97 | // parts of the line info program make it into the final binary even though 98 | // the corresponding code was stripped. We can tell when this happened by 99 | // looking for DW_LNE_set_address ops where the operand is 0. This 100 | // indicates that a relocation for that argument never got applied, which 101 | // probably means that the code got stripped. 102 | // 103 | // While this is true, we don't yield any LineInfo entries, because the 104 | // "address" value is garbage. 105 | bool shadow_; 106 | 107 | LineInfo info_; 108 | 109 | void DoAdvance(uint64_t advance, uint8_t max_per_instr); 110 | void Advance(uint64_t amount); 111 | uint8_t AdjustedOpcode(uint8_t op); 112 | void SpecialOpcodeAdvance(uint8_t op); 113 | }; 114 | 115 | } // namespace dwarf 116 | } // namespace bloaty 117 | 118 | #endif // BLOATY_DWARF_LINE_INFO_H_ 119 | -------------------------------------------------------------------------------- /src/main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "bloaty.h" 16 | #include "bloaty.pb.h" 17 | 18 | #include 19 | 20 | int main(int argc, char *argv[]) { 21 | bloaty::Options options; 22 | bloaty::OutputOptions output_options; 23 | std::string error; 24 | if (!bloaty::ParseOptions(false, &argc, &argv, &options, &output_options, 25 | &error)) { 26 | if (!error.empty()) { 27 | fprintf(stderr, "bloaty: %s\n", error.c_str()); 28 | return 1; 29 | } else { 30 | return 0; // --help or similar. 31 | } 32 | } 33 | 34 | bloaty::RollupOutput output; 35 | bloaty::MmapInputFileFactory mmap_factory; 36 | if (!bloaty::BloatyMain(options, mmap_factory, &output, &error)) { 37 | if (!error.empty()) { 38 | fprintf(stderr, "bloaty: %s\n", error.c_str()); 39 | } 40 | return 1; 41 | } 42 | 43 | if (!options.dump_raw_map()) { 44 | output.Print(output_options, &std::cout); 45 | } 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /src/re.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BLOATY_RE_H_ 16 | #define BLOATY_RE_H_ 17 | 18 | #include 19 | 20 | #ifdef USE_RE2 21 | #include "re2/re2.h" 22 | #endif 23 | 24 | #include "absl/base/attributes.h" 25 | 26 | namespace bloaty { 27 | 28 | #ifdef USE_RE2 29 | class ReImpl { 30 | public: 31 | ReImpl(const char* pattern) : re2_(pattern){}; 32 | ReImpl(const std::string& pattern) : re2_(pattern){}; 33 | bool ok() { return re2_.ok(); } 34 | 35 | static bool Extract(std::string text, const ReImpl& re, std::string rewrite, 36 | std::string* out) { 37 | return RE2::Extract(text, re.re2_, rewrite, out); 38 | } 39 | template 40 | static bool PartialMatch(const std::string& text, const ReImpl& re, 41 | A&&... a) { 42 | return RE2::PartialMatch(text, re.re2_, a...); 43 | } 44 | 45 | static int GlobalReplace(std::string* str, const ReImpl& re, 46 | std::string rewrite) { 47 | return RE2::GlobalReplace(str, re.re2_, rewrite); 48 | } 49 | static bool Replace(std::string* str, const ReImpl& re, std::string rewrite) { 50 | return RE2::Replace(str, re.re2_, rewrite); 51 | } 52 | 53 | private: 54 | RE2 re2_; 55 | }; 56 | #else 57 | } 58 | 59 | ABSL_ATTRIBUTE_NORETURN 60 | static void _abort() { throw "No support for regular expressions"; } 61 | 62 | namespace bloaty { 63 | class ReImpl { 64 | public: 65 | ReImpl(const char*) { _abort(); } 66 | ReImpl(const std::string&) { _abort(); } 67 | bool ok() { _abort(); } 68 | 69 | ABSL_ATTRIBUTE_NORETURN 70 | static bool Extract(std::string, const ReImpl&, std::string, std::string*) { 71 | _abort(); 72 | } 73 | template 74 | ABSL_ATTRIBUTE_NORETURN static bool PartialMatch(const std::string&, 75 | const ReImpl&, A&&...) { 76 | _abort(); 77 | } 78 | ABSL_ATTRIBUTE_NORETURN 79 | static int GlobalReplace(std::string*, const ReImpl&, std::string) { 80 | _abort(); 81 | } 82 | ABSL_ATTRIBUTE_NORETURN 83 | static bool Replace(std::string*, const ReImpl&, std::string) { _abort(); } 84 | 85 | private: 86 | }; 87 | #endif 88 | 89 | } // namespace bloaty 90 | 91 | #endif // BLOATY_RE_H_ 92 | -------------------------------------------------------------------------------- /src/source_map.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BLOATY_SOURCE_MAP_H_ 16 | #define BLOATY_SOURCE_MAP_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "bloaty.h" 25 | #include "util.h" 26 | 27 | namespace bloaty { 28 | namespace sourcemap { 29 | 30 | class SourceMapObjectFile : public ObjectFile { 31 | public: 32 | SourceMapObjectFile(std::unique_ptr file_data, 33 | std::string build_id) 34 | : ObjectFile(std::move(file_data)), build_id_(build_id) {} 35 | 36 | std::string GetBuildId() const override { 37 | return build_id_; 38 | } 39 | 40 | void ProcessFile(const std::vector& sinks) const override { 41 | WARN("General processing not supported for source map files"); 42 | } 43 | 44 | bool GetDisassemblyInfo(std::string_view /*symbol*/, 45 | DataSource /*symbol_source*/, 46 | DisassemblyInfo* /*info*/) const override { 47 | WARN("Disassembly not supported for source map files"); 48 | return false; 49 | } 50 | 51 | void ProcessFileToSink(RangeSink* sink) const; 52 | 53 | private: 54 | std::string build_id_; 55 | }; 56 | 57 | } // namespace sourcemap 58 | } // namespace bloaty 59 | 60 | #endif // BLOATY_SOURCE_MAP_H_ 61 | 62 | -------------------------------------------------------------------------------- /src/util.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "util.h" 16 | 17 | using std::string_view; 18 | 19 | namespace bloaty { 20 | 21 | ABSL_ATTRIBUTE_NORETURN 22 | void Throw(const char *str, int line) { 23 | throw bloaty::Error(str, __FILE__, line); 24 | } 25 | 26 | std::string_view ReadUntilConsuming(std::string_view* data, char c) { 27 | std::string_view ret = ReadUntil(data, c); 28 | 29 | if (data->empty() || data->front() != c) { 30 | // Nothing left, meaning we didn't find the terminating character. 31 | if (c == '\0') { 32 | THROW("string is not NULL-terminated"); 33 | } 34 | THROWF("could not find terminating character '$0'", c); 35 | } 36 | 37 | data->remove_prefix(1); // Remove the terminating character also. 38 | return ret; 39 | } 40 | 41 | std::string_view ReadUntil(std::string_view* data, char c) { 42 | const char* found = 43 | static_cast(memchr(data->data(), c, data->size())); 44 | 45 | size_t len = (found == NULL) ? data->size() : (found - data->data()); 46 | std::string_view val = data->substr(0, len); 47 | data->remove_prefix(len); 48 | return val; 49 | } 50 | 51 | void SkipWhitespace(std::string_view* data) { 52 | const char* c = data->data(); 53 | const char* limit = c + data->size(); 54 | while (c < limit) { 55 | if (*c == ' ' || *c == '\t' || *c == '\n' || *c == '\r') { 56 | c++; 57 | } else { 58 | break; 59 | } 60 | } 61 | data->remove_prefix(c - data->data()); 62 | } 63 | 64 | } // namespace bloaty 65 | -------------------------------------------------------------------------------- /src/util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BLOATY_UTIL_H_ 16 | #define BLOATY_UTIL_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "absl/numeric/int128.h" 22 | #include "absl/strings/substitute.h" 23 | 24 | namespace bloaty { 25 | 26 | class Error : public std::runtime_error { 27 | public: 28 | Error(const char* msg, const char* file, int line) 29 | : std::runtime_error(msg), file_(file), line_(line) {} 30 | 31 | // TODO(haberman): add these to Bloaty's error message when verbose is 32 | // enabled. 33 | const char* file() const { return file_; } 34 | int line() const { return line_; } 35 | 36 | private: 37 | const char* file_; 38 | int line_; 39 | }; 40 | 41 | // Throwing emits a lot of code, so we do it out-of-line. 42 | ABSL_ATTRIBUTE_NORETURN 43 | void Throw(const char *str, int line); 44 | 45 | #define THROW(msg) Throw(msg, __LINE__) 46 | #define THROWF(...) Throw(absl::Substitute(__VA_ARGS__).c_str(), __LINE__) 47 | #define WARN(...) \ 48 | if (verbose_level > 0) { \ 49 | printf("WARNING: %s\n", absl::Substitute(__VA_ARGS__).c_str()); \ 50 | } 51 | 52 | #if !defined(_MSC_VER) 53 | #define BLOATY_UNREACHABLE() do { \ 54 | assert(false); \ 55 | __builtin_unreachable(); \ 56 | } while (0) 57 | #else 58 | #define BLOATY_UNREACHABLE() do { \ 59 | assert(false); \ 60 | __assume(0); \ 61 | } while (0) 62 | #endif 63 | 64 | #ifdef NDEBUG 65 | // Prevent "unused variable" warnings. 66 | #define BLOATY_ASSERT(expr) do {} while (false && (expr)) 67 | #else 68 | #define BLOATY_ASSERT(expr) assert(expr) 69 | #endif 70 | 71 | inline uint64_t CheckedAdd(uint64_t a, uint64_t b) { 72 | absl::uint128 a_128(a), b_128(b); 73 | absl::uint128 c_128 = a_128 + b_128; 74 | if (c_128 > UINT64_MAX) { 75 | THROW("integer overflow in addition"); 76 | } 77 | return static_cast(c_128); 78 | } 79 | 80 | inline uint64_t CheckedMul(uint64_t a, uint64_t b) { 81 | absl::uint128 a_128(a), b_128(b); 82 | absl::uint128 c = a_128 * b_128; 83 | if (c > UINT64_MAX) { 84 | THROW("integer overflow in multiply"); 85 | } 86 | return static_cast(c); 87 | } 88 | 89 | inline std::string_view StrictSubstr(std::string_view data, size_t off, 90 | size_t n) { 91 | uint64_t end = CheckedAdd(off, n); 92 | if (end > data.size()) { 93 | THROW("region out-of-bounds"); 94 | } 95 | return data.substr(off, n); 96 | } 97 | 98 | inline std::string_view StrictSubstr(std::string_view data, size_t off) { 99 | if (off > data.size()) { 100 | THROW("region out-of-bounds"); 101 | } 102 | return data.substr(off); 103 | } 104 | 105 | inline size_t AlignUp(size_t offset, size_t granularity) { 106 | // Granularity must be a power of two. 107 | BLOATY_ASSERT((granularity & (granularity - 1)) == 0); 108 | return (offset + granularity - 1) & ~(granularity - 1); 109 | } 110 | 111 | // Endianness utilities //////////////////////////////////////////////////////// 112 | 113 | enum class Endian { kBig, kLittle }; 114 | 115 | inline Endian GetMachineEndian() { 116 | int x = 1; 117 | return *(char *)&x == 1 ? Endian::kLittle : Endian::kBig; 118 | } 119 | 120 | // Generic algorithm for byte-swapping an integer of arbitrary size. 121 | // 122 | // With modern GCC/Clang this optimizes to a "bswap" instruction. 123 | template constexpr T _BS(T val) { 124 | if constexpr (N == 1) { 125 | return val & 0xff; 126 | } else { 127 | size_t bits = 8 * (N / 2); 128 | return (_BS(val) << bits) | _BS(val >> bits); 129 | } 130 | }; 131 | 132 | // Byte swaps the given integer, and returns the byte-swapped value. 133 | template constexpr T ByteSwap(T val) { 134 | return _BS(val); 135 | } 136 | 137 | template T ReadFixed(std::string_view *data) { 138 | static_assert(N <= sizeof(T), "N too big for this data type"); 139 | T val = 0; 140 | if (data->size() < N) { 141 | THROW("premature EOF reading fixed-length data"); 142 | } 143 | memcpy(&val, data->data(), N); 144 | data->remove_prefix(N); 145 | return val; 146 | } 147 | 148 | template T ReadEndian(std::string_view *data, Endian endian) { 149 | T val = ReadFixed(data); 150 | return endian == GetMachineEndian() ? val : ByteSwap(val); 151 | } 152 | 153 | template T ReadLittleEndian(std::string_view *data) { 154 | return ReadEndian(data, Endian::kLittle); 155 | } 156 | 157 | template T ReadBigEndian(std::string_view *data) { 158 | return ReadEndian(data, Endian::kBig); 159 | } 160 | 161 | // General data reading /////////////////////////////////////////////////////// 162 | 163 | std::string_view ReadUntil(std::string_view* data, char c); 164 | 165 | std::string_view ReadUntilConsuming(std::string_view* data, char c); 166 | 167 | inline std::string_view ReadNullTerminated(std::string_view* data) { 168 | return ReadUntilConsuming(data, '\0'); 169 | } 170 | 171 | inline std::string_view ReadBytes(size_t bytes, std::string_view* data) { 172 | if (data->size() < bytes) { 173 | THROW("premature EOF reading variable-length DWARF data"); 174 | } 175 | std::string_view ret = data->substr(0, bytes); 176 | data->remove_prefix(bytes); 177 | return ret; 178 | } 179 | 180 | inline void RequireChar(std::string_view* data, char c) { 181 | if (data->empty() || data->front() != c) { 182 | THROWF("unexpected '$0', expected '$1'", 183 | data->empty() ? "EOF" : data->substr(0, 1), c); 184 | } 185 | data->remove_prefix(1); 186 | } 187 | 188 | inline void SkipBytes(size_t bytes, std::string_view* data) { 189 | ReadBytes(bytes, data); // Discard result. 190 | } 191 | 192 | void SkipWhitespace(std::string_view* data); 193 | 194 | } // namespace bloaty 195 | 196 | #endif // BLOATY_UTIL_H_ 197 | -------------------------------------------------------------------------------- /tests/PE/sections/empty-pe32-dll.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail 3 | 4 | --- !COFF 5 | OptionalHeader: 6 | AddressOfEntryPoint: 4096 7 | ImageBase: 268435456 8 | SectionAlignment: 4096 9 | FileAlignment: 512 10 | MajorOperatingSystemVersion: 4 11 | MinorOperatingSystemVersion: 0 12 | MajorImageVersion: 0 13 | MinorImageVersion: 0 14 | MajorSubsystemVersion: 4 15 | MinorSubsystemVersion: 0 16 | Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI 17 | DLLCharacteristics: [ ] 18 | SizeOfStackReserve: 1048576 19 | SizeOfStackCommit: 4096 20 | SizeOfHeapReserve: 1048576 21 | SizeOfHeapCommit: 4096 22 | ExportTable: 23 | RelativeVirtualAddress: 0 24 | Size: 0 25 | ImportTable: 26 | RelativeVirtualAddress: 0 27 | Size: 0 28 | ResourceTable: 29 | RelativeVirtualAddress: 0 30 | Size: 0 31 | ExceptionTable: 32 | RelativeVirtualAddress: 0 33 | Size: 0 34 | CertificateTable: 35 | RelativeVirtualAddress: 0 36 | Size: 0 37 | BaseRelocationTable: 38 | RelativeVirtualAddress: 0 39 | Size: 0 40 | Debug: 41 | RelativeVirtualAddress: 0 42 | Size: 0 43 | Architecture: 44 | RelativeVirtualAddress: 0 45 | Size: 0 46 | GlobalPtr: 47 | RelativeVirtualAddress: 0 48 | Size: 0 49 | TlsTable: 50 | RelativeVirtualAddress: 0 51 | Size: 0 52 | LoadConfigTable: 53 | RelativeVirtualAddress: 0 54 | Size: 0 55 | BoundImport: 56 | RelativeVirtualAddress: 0 57 | Size: 0 58 | IAT: 59 | RelativeVirtualAddress: 0 60 | Size: 0 61 | DelayImportDescriptor: 62 | RelativeVirtualAddress: 0 63 | Size: 0 64 | ClrRuntimeHeader: 65 | RelativeVirtualAddress: 0 66 | Size: 0 67 | header: 68 | Machine: IMAGE_FILE_MACHINE_I386 69 | Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE, IMAGE_FILE_DEBUG_STRIPPED, IMAGE_FILE_DLL ] 70 | sections: 71 | - Name: .text 72 | Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] 73 | VirtualAddress: 4096 74 | VirtualSize: 24 75 | SectionData: 5589E581EC0000000090B801000000E900000000C9C20C00 76 | symbols: [] 77 | ... 78 | 79 | # CHECK: FILE MAP: 80 | # CHECK: 000-178 376 [PE Headers] 81 | # CHECK: 178-1a0 40 [PE Section Headers] 82 | # CHECK: 1a0-200 96 [Unmapped] 83 | # CHECK: 200-400 512 .text 84 | 85 | # CHECK: VM MAP: 86 | # CHECK: 0000-0178 376 [PE Headers] 87 | # CHECK: 0178-01a0 40 [PE Section Headers] 88 | # CHECK: 01a0-1000 3680 [-- Nothing mapped --] 89 | # CHECK: 1000-1018 24 .text 90 | 91 | -------------------------------------------------------------------------------- /tests/PE/sections/empty-pe32-exe.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail 3 | 4 | --- !COFF 5 | OptionalHeader: 6 | AddressOfEntryPoint: 4096 7 | ImageBase: 4194304 8 | SectionAlignment: 4096 9 | FileAlignment: 512 10 | MajorOperatingSystemVersion: 4 11 | MinorOperatingSystemVersion: 0 12 | MajorImageVersion: 0 13 | MinorImageVersion: 0 14 | MajorSubsystemVersion: 4 15 | MinorSubsystemVersion: 0 16 | Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI 17 | DLLCharacteristics: [ ] 18 | SizeOfStackReserve: 1048576 19 | SizeOfStackCommit: 4096 20 | SizeOfHeapReserve: 1048576 21 | SizeOfHeapCommit: 4096 22 | ExportTable: 23 | RelativeVirtualAddress: 0 24 | Size: 0 25 | ImportTable: 26 | RelativeVirtualAddress: 0 27 | Size: 0 28 | ResourceTable: 29 | RelativeVirtualAddress: 0 30 | Size: 0 31 | ExceptionTable: 32 | RelativeVirtualAddress: 0 33 | Size: 0 34 | CertificateTable: 35 | RelativeVirtualAddress: 0 36 | Size: 0 37 | BaseRelocationTable: 38 | RelativeVirtualAddress: 0 39 | Size: 0 40 | Debug: 41 | RelativeVirtualAddress: 0 42 | Size: 0 43 | Architecture: 44 | RelativeVirtualAddress: 0 45 | Size: 0 46 | GlobalPtr: 47 | RelativeVirtualAddress: 0 48 | Size: 0 49 | TlsTable: 50 | RelativeVirtualAddress: 0 51 | Size: 0 52 | LoadConfigTable: 53 | RelativeVirtualAddress: 0 54 | Size: 0 55 | BoundImport: 56 | RelativeVirtualAddress: 0 57 | Size: 0 58 | IAT: 59 | RelativeVirtualAddress: 0 60 | Size: 0 61 | DelayImportDescriptor: 62 | RelativeVirtualAddress: 0 63 | Size: 0 64 | ClrRuntimeHeader: 65 | RelativeVirtualAddress: 0 66 | Size: 0 67 | header: 68 | Machine: IMAGE_FILE_MACHINE_I386 69 | Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE, IMAGE_FILE_DEBUG_STRIPPED ] 70 | sections: 71 | - Name: .text 72 | Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] 73 | VirtualAddress: 4096 74 | VirtualSize: 24 75 | SectionData: 5589E581EC0000000090B800000000E900000000C9C30000 76 | symbols: [] 77 | ... 78 | 79 | # CHECK: FILE MAP: 80 | # CHECK: 000-178 376 [PE Headers] 81 | # CHECK: 178-1a0 40 [PE Section Headers] 82 | # CHECK: 1a0-200 96 [Unmapped] 83 | # CHECK: 200-400 512 .text 84 | 85 | # CHECK: VM MAP: 86 | # CHECK: 0000-0178 376 [PE Headers] 87 | # CHECK: 0178-01a0 40 [PE Section Headers] 88 | # CHECK: 01a0-1000 3680 [-- Nothing mapped --] 89 | # CHECK: 1000-1018 24 .text 90 | 91 | -------------------------------------------------------------------------------- /tests/PE/sections/empty-pe64-dll.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail 3 | 4 | --- !COFF 5 | OptionalHeader: 6 | AddressOfEntryPoint: 4096 7 | ImageBase: 268435456 8 | SectionAlignment: 4096 9 | FileAlignment: 512 10 | MajorOperatingSystemVersion: 4 11 | MinorOperatingSystemVersion: 0 12 | MajorImageVersion: 0 13 | MinorImageVersion: 0 14 | MajorSubsystemVersion: 4 15 | MinorSubsystemVersion: 0 16 | Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI 17 | DLLCharacteristics: [ ] 18 | SizeOfStackReserve: 1048576 19 | SizeOfStackCommit: 4096 20 | SizeOfHeapReserve: 1048576 21 | SizeOfHeapCommit: 4096 22 | ExportTable: 23 | RelativeVirtualAddress: 0 24 | Size: 0 25 | ImportTable: 26 | RelativeVirtualAddress: 0 27 | Size: 0 28 | ResourceTable: 29 | RelativeVirtualAddress: 0 30 | Size: 0 31 | ExceptionTable: 32 | RelativeVirtualAddress: 8192 33 | Size: 12 34 | CertificateTable: 35 | RelativeVirtualAddress: 0 36 | Size: 0 37 | BaseRelocationTable: 38 | RelativeVirtualAddress: 0 39 | Size: 0 40 | Debug: 41 | RelativeVirtualAddress: 0 42 | Size: 0 43 | Architecture: 44 | RelativeVirtualAddress: 0 45 | Size: 0 46 | GlobalPtr: 47 | RelativeVirtualAddress: 0 48 | Size: 0 49 | TlsTable: 50 | RelativeVirtualAddress: 0 51 | Size: 0 52 | LoadConfigTable: 53 | RelativeVirtualAddress: 0 54 | Size: 0 55 | BoundImport: 56 | RelativeVirtualAddress: 0 57 | Size: 0 58 | IAT: 59 | RelativeVirtualAddress: 0 60 | Size: 0 61 | DelayImportDescriptor: 62 | RelativeVirtualAddress: 0 63 | Size: 0 64 | ClrRuntimeHeader: 65 | RelativeVirtualAddress: 0 66 | Size: 0 67 | header: 68 | Machine: IMAGE_FILE_MACHINE_AMD64 69 | Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DEBUG_STRIPPED, IMAGE_FILE_DLL ] 70 | sections: 71 | - Name: .text 72 | Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] 73 | VirtualAddress: 4096 74 | VirtualSize: 32 75 | SectionData: 554889E54881EC00000000B801000000E900000000C9C3000104020504030150 76 | - Name: .pdata 77 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] 78 | VirtualAddress: 8192 79 | VirtualSize: 12 80 | SectionData: 0B1000001710000018100000 81 | symbols: [] 82 | ... 83 | 84 | # CHECK: FILE MAP: 85 | # CHECK: 000-188 392 [PE Headers] 86 | # CHECK: 188-1d8 80 [PE Section Headers] 87 | # CHECK: 1d8-200 40 [Unmapped] 88 | # CHECK: 200-400 512 .text 89 | # CHECK: 400-600 512 .pdata 90 | 91 | # CHECK: VM MAP: 92 | # CHECK: 0000-0188 392 [PE Headers] 93 | # CHECK: 0188-01d8 80 [PE Section Headers] 94 | # CHECK: 01d8-1000 3624 [-- Nothing mapped --] 95 | # CHECK: 1000-1020 32 .text 96 | # CHECK: 1020-2000 4064 [-- Nothing mapped --] 97 | # CHECK: 2000-200c 12 .pdata 98 | 99 | -------------------------------------------------------------------------------- /tests/PE/sections/empty-pe64-exe.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail 3 | 4 | --- !COFF 5 | OptionalHeader: 6 | AddressOfEntryPoint: 4096 7 | ImageBase: 4194304 8 | SectionAlignment: 4096 9 | FileAlignment: 512 10 | MajorOperatingSystemVersion: 4 11 | MinorOperatingSystemVersion: 0 12 | MajorImageVersion: 0 13 | MinorImageVersion: 0 14 | MajorSubsystemVersion: 4 15 | MinorSubsystemVersion: 0 16 | Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI 17 | DLLCharacteristics: [ ] 18 | SizeOfStackReserve: 1048576 19 | SizeOfStackCommit: 4096 20 | SizeOfHeapReserve: 1048576 21 | SizeOfHeapCommit: 4096 22 | ExportTable: 23 | RelativeVirtualAddress: 0 24 | Size: 0 25 | ImportTable: 26 | RelativeVirtualAddress: 0 27 | Size: 0 28 | ResourceTable: 29 | RelativeVirtualAddress: 0 30 | Size: 0 31 | ExceptionTable: 32 | RelativeVirtualAddress: 8192 33 | Size: 12 34 | CertificateTable: 35 | RelativeVirtualAddress: 0 36 | Size: 0 37 | BaseRelocationTable: 38 | RelativeVirtualAddress: 0 39 | Size: 0 40 | Debug: 41 | RelativeVirtualAddress: 0 42 | Size: 0 43 | Architecture: 44 | RelativeVirtualAddress: 0 45 | Size: 0 46 | GlobalPtr: 47 | RelativeVirtualAddress: 0 48 | Size: 0 49 | TlsTable: 50 | RelativeVirtualAddress: 0 51 | Size: 0 52 | LoadConfigTable: 53 | RelativeVirtualAddress: 0 54 | Size: 0 55 | BoundImport: 56 | RelativeVirtualAddress: 0 57 | Size: 0 58 | IAT: 59 | RelativeVirtualAddress: 0 60 | Size: 0 61 | DelayImportDescriptor: 62 | RelativeVirtualAddress: 0 63 | Size: 0 64 | ClrRuntimeHeader: 65 | RelativeVirtualAddress: 0 66 | Size: 0 67 | header: 68 | Machine: IMAGE_FILE_MACHINE_AMD64 69 | Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DEBUG_STRIPPED ] 70 | sections: 71 | - Name: .text 72 | Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] 73 | VirtualAddress: 4096 74 | VirtualSize: 32 75 | SectionData: 554889E54881EC00000000B800000000E900000000C9C3000104020504030150 76 | - Name: .pdata 77 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] 78 | VirtualAddress: 8192 79 | VirtualSize: 12 80 | SectionData: 0B1000001710000018100000 81 | symbols: [] 82 | ... 83 | 84 | # CHECK: FILE MAP: 85 | # CHECK: 000-188 392 [PE Headers] 86 | # CHECK: 188-1d8 80 [PE Section Headers] 87 | # CHECK: 1d8-200 40 [Unmapped] 88 | # CHECK: 200-400 512 .text 89 | # CHECK: 400-600 512 .pdata 90 | 91 | # CHECK: VM MAP: 92 | # CHECK: 0000-0188 392 [PE Headers] 93 | # CHECK: 0188-01d8 80 [PE Section Headers] 94 | # CHECK: 01d8-1000 3624 [-- Nothing mapped --] 95 | # CHECK: 1000-1020 32 .text 96 | # CHECK: 1020-2000 4064 [-- Nothing mapped --] 97 | # CHECK: 2000-200c 12 .pdata 98 | 99 | -------------------------------------------------------------------------------- /tests/PE/sections/simple-pe32-dll.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail 3 | 4 | --- !COFF 5 | OptionalHeader: 6 | AddressOfEntryPoint: 4160 7 | ImageBase: 268435456 8 | SectionAlignment: 4096 9 | FileAlignment: 512 10 | MajorOperatingSystemVersion: 4 11 | MinorOperatingSystemVersion: 0 12 | MajorImageVersion: 0 13 | MinorImageVersion: 0 14 | MajorSubsystemVersion: 4 15 | MinorSubsystemVersion: 0 16 | Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI 17 | DLLCharacteristics: [ ] 18 | SizeOfStackReserve: 1048576 19 | SizeOfStackCommit: 4096 20 | SizeOfHeapReserve: 1048576 21 | SizeOfHeapCommit: 4096 22 | ExportTable: 23 | RelativeVirtualAddress: 8304 24 | Size: 366 25 | ImportTable: 26 | RelativeVirtualAddress: 8224 27 | Size: 40 28 | ResourceTable: 29 | RelativeVirtualAddress: 0 30 | Size: 0 31 | ExceptionTable: 32 | RelativeVirtualAddress: 0 33 | Size: 0 34 | CertificateTable: 35 | RelativeVirtualAddress: 0 36 | Size: 0 37 | BaseRelocationTable: 38 | RelativeVirtualAddress: 12288 39 | Size: 16 40 | Debug: 41 | RelativeVirtualAddress: 0 42 | Size: 0 43 | Architecture: 44 | RelativeVirtualAddress: 0 45 | Size: 0 46 | GlobalPtr: 47 | RelativeVirtualAddress: 0 48 | Size: 0 49 | TlsTable: 50 | RelativeVirtualAddress: 0 51 | Size: 0 52 | LoadConfigTable: 53 | RelativeVirtualAddress: 0 54 | Size: 0 55 | BoundImport: 56 | RelativeVirtualAddress: 0 57 | Size: 0 58 | IAT: 59 | RelativeVirtualAddress: 8264 60 | Size: 8 61 | DelayImportDescriptor: 62 | RelativeVirtualAddress: 0 63 | Size: 0 64 | ClrRuntimeHeader: 65 | RelativeVirtualAddress: 0 66 | Size: 0 67 | header: 68 | Machine: IMAGE_FILE_MACHINE_I386 69 | Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE, IMAGE_FILE_DEBUG_STRIPPED, IMAGE_FILE_DLL ] 70 | sections: 71 | - Name: .text 72 | Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] 73 | VirtualAddress: 4096 74 | VirtualSize: 160 75 | SectionData: 5589E581EC0000000090B80020001050E88300000083C404C9C35589E581EC0000000090B80920001050E86900000083C404B800000000E900000000C9C210005589E581EC04000000908B4510508B450C508B450850E8250000008945FC8B45FCE900000000C9C20C00000000000000000000000000000000000000000000005589E581EC0000000090B801000000E900000000C9C20C00FF25482000100000 76 | - Name: .data 77 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] 78 | VirtualAddress: 8192 79 | VirtualSize: 480 80 | SectionData: 637572696F757321004D61726B204A616E73656E00000000000000000000000050200000000000000000000058200000482000000000000000000000000000000000000000000000632000000000000063200000000000006D73766372742E646C6C00000070757473000000000000000000000000000000000000001A210000010000000D0000000D00000098200000CC20000000210000801000001A1000004010000000300000003000000030000000300000003000000030000020200000E0210000981000000010000027210000332100003F2100004D2100005E210000712100008221000095210000A9210000BF210000C6210000CB210000D221000000000100020003000400050006000700080009000A000B000C00706533325F7374642E646C6C005F446C6C4D61696E403132005F446C6C4D61696E403136005F5F646C6C7374617274403132005F5F66696E695F61727261795F656E64005F5F66696E695F61727261795F7374617274005F5F696E69745F61727261795F656E64005F5F696E69745F61727261795F7374617274005F5F707265696E69745F61727261795F656E64005F5F707265696E69745F61727261795F7374617274005F6564617461005F656E64005F65746578740068656C6C6F5F7468657265000000 81 | - Name: .reloc 82 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] 83 | VirtualAddress: 12288 84 | VirtualSize: 16 85 | SectionData: 00100000100000000B3025309A300000 86 | symbols: [] 87 | ... 88 | 89 | # CHECK: FILE MAP: 90 | # CHECK: 000-178 376 [PE Headers] 91 | # CHECK: 178-1f0 120 [PE Section Headers] 92 | # CHECK: 1f0-200 16 [Unmapped] 93 | # CHECK: 200-400 512 .text 94 | # CHECK: 400-600 512 .data 95 | # CHECK: 600-800 512 .reloc 96 | 97 | # CHECK: VM MAP: 98 | # CHECK: 0000-0178 376 [PE Headers] 99 | # CHECK: 0178-01f0 120 [PE Section Headers] 100 | # CHECK: 01f0-1000 3600 [-- Nothing mapped --] 101 | # CHECK: 1000-10a0 160 .text 102 | # CHECK: 10a0-2000 3936 [-- Nothing mapped --] 103 | # CHECK: 2000-21e0 480 .data 104 | # CHECK: 21e0-3000 3616 [-- Nothing mapped --] 105 | # CHECK: 3000-3010 16 .reloc 106 | 107 | -------------------------------------------------------------------------------- /tests/PE/sections/simple-pe32-exe.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail 3 | 4 | --- !COFF 5 | OptionalHeader: 6 | AddressOfEntryPoint: 4160 7 | ImageBase: 4194304 8 | SectionAlignment: 4096 9 | FileAlignment: 512 10 | MajorOperatingSystemVersion: 4 11 | MinorOperatingSystemVersion: 0 12 | MajorImageVersion: 0 13 | MinorImageVersion: 0 14 | MajorSubsystemVersion: 4 15 | MinorSubsystemVersion: 0 16 | Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI 17 | DLLCharacteristics: [ ] 18 | SizeOfStackReserve: 1048576 19 | SizeOfStackCommit: 4096 20 | SizeOfHeapReserve: 1048576 21 | SizeOfHeapCommit: 4096 22 | ExportTable: 23 | RelativeVirtualAddress: 0 24 | Size: 0 25 | ImportTable: 26 | RelativeVirtualAddress: 8224 27 | Size: 40 28 | ResourceTable: 29 | RelativeVirtualAddress: 0 30 | Size: 0 31 | ExceptionTable: 32 | RelativeVirtualAddress: 0 33 | Size: 0 34 | CertificateTable: 35 | RelativeVirtualAddress: 0 36 | Size: 0 37 | BaseRelocationTable: 38 | RelativeVirtualAddress: 0 39 | Size: 0 40 | Debug: 41 | RelativeVirtualAddress: 0 42 | Size: 0 43 | Architecture: 44 | RelativeVirtualAddress: 0 45 | Size: 0 46 | GlobalPtr: 47 | RelativeVirtualAddress: 0 48 | Size: 0 49 | TlsTable: 50 | RelativeVirtualAddress: 0 51 | Size: 0 52 | LoadConfigTable: 53 | RelativeVirtualAddress: 0 54 | Size: 0 55 | BoundImport: 56 | RelativeVirtualAddress: 0 57 | Size: 0 58 | IAT: 59 | RelativeVirtualAddress: 8264 60 | Size: 36 61 | DelayImportDescriptor: 62 | RelativeVirtualAddress: 0 63 | Size: 0 64 | ClrRuntimeHeader: 65 | RelativeVirtualAddress: 0 66 | Size: 0 67 | header: 68 | Machine: IMAGE_FILE_MACHINE_I386 69 | Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE, IMAGE_FILE_DEBUG_STRIPPED ] 70 | sections: 71 | - Name: .text 72 | Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] 73 | VirtualAddress: 4096 74 | VirtualSize: 464 75 | SectionData: 5589E581EC0000000090B80020400050E87B01000083C404B800000000E900000000C9C3000000000000000000000000000000000000000000000000000000005589E581EC2C000000908D45E850E8FE00000083C404B8000000008945D4B80000030050B80000010050E82901000083C408B80100000050E82301000083C4048D45D450B800000000508D45DC508D45E0508D45E450E80D01000083C4148B45DC508B45E0508B45E450E851FFFFFF83C40C8945D88B45D850E8F200000083C404C9C30000000000000000000000000000000000000000000000000000000000872C24558D6C24045189E981E90010000085012D001000003D001000007DEC29C1850189E089CC8B08FF60048B45ECC3E8F7FFFFFF8B008B00C3E8EDFFFFFF50E8EBFFFFFF50E88D00000081C408000000C38B65E8E8D6FFFFFF50E880000000FFFFFFFF1A11400032114000E977000000558B6C24088D44240C89450031C089450464A100000000894508B84C11400089450CB84011400089451031C08945148D450864A3000000005DC30000000000FF25482040000000FF254C2040000000FF25502040000000FF25542040000000FF25582040000000FF255C2040000000FF25602040000000FF25642040000000 76 | - Name: .data 77 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] 78 | VirtualAddress: 8192 79 | VirtualSize: 256 80 | SectionData: 4D61726B204A616E73656E0000000000000000000000000000000000000000006C2000000000000000000000902000004820000000000000000000000000000000000000000000009B200000A2200000AF200000C0200000D0200000D7200000E5200000ED200000000000009B200000A2200000AF200000C0200000D0200000D7200000E5200000ED200000000000006D73766372742E646C6C000000707574730000005F636F6E74726F6C66700000005F5F7365745F6170705F747970650000005F5F6765746D61696E61726773000000657869740000005F5863707446696C7465720000005F657869740000005F6578636570745F68616E646C65723300 81 | symbols: [] 82 | ... 83 | 84 | # CHECK: FILE MAP: 85 | # CHECK: 000-178 376 [PE Headers] 86 | # CHECK: 178-1c8 80 [PE Section Headers] 87 | # CHECK: 1c8-200 56 [Unmapped] 88 | # CHECK: 200-400 512 .text 89 | # CHECK: 400-600 512 .data 90 | 91 | # CHECK: VM MAP: 92 | # CHECK: 0000-0178 376 [PE Headers] 93 | # CHECK: 0178-01c8 80 [PE Section Headers] 94 | # CHECK: 01c8-1000 3640 [-- Nothing mapped --] 95 | # CHECK: 1000-11d0 464 .text 96 | # CHECK: 11d0-2000 3632 [-- Nothing mapped --] 97 | # CHECK: 2000-2100 256 .data 98 | 99 | -------------------------------------------------------------------------------- /tests/PE/sections/simple-pe64-dll.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail 3 | 4 | --- !COFF 5 | OptionalHeader: 6 | AddressOfEntryPoint: 4192 7 | ImageBase: 268435456 8 | SectionAlignment: 4096 9 | FileAlignment: 512 10 | MajorOperatingSystemVersion: 4 11 | MinorOperatingSystemVersion: 0 12 | MajorImageVersion: 0 13 | MinorImageVersion: 0 14 | MajorSubsystemVersion: 4 15 | MinorSubsystemVersion: 0 16 | Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI 17 | DLLCharacteristics: [ ] 18 | SizeOfStackReserve: 1048576 19 | SizeOfStackCommit: 4096 20 | SizeOfHeapReserve: 1048576 21 | SizeOfHeapCommit: 4096 22 | ExportTable: 23 | RelativeVirtualAddress: 8320 24 | Size: 336 25 | ImportTable: 26 | RelativeVirtualAddress: 8224 27 | Size: 40 28 | ResourceTable: 29 | RelativeVirtualAddress: 0 30 | Size: 0 31 | ExceptionTable: 32 | RelativeVirtualAddress: 12288 33 | Size: 36 34 | CertificateTable: 35 | RelativeVirtualAddress: 0 36 | Size: 0 37 | BaseRelocationTable: 38 | RelativeVirtualAddress: 0 39 | Size: 0 40 | Debug: 41 | RelativeVirtualAddress: 0 42 | Size: 0 43 | Architecture: 44 | RelativeVirtualAddress: 0 45 | Size: 0 46 | GlobalPtr: 47 | RelativeVirtualAddress: 0 48 | Size: 0 49 | TlsTable: 50 | RelativeVirtualAddress: 0 51 | Size: 0 52 | LoadConfigTable: 53 | RelativeVirtualAddress: 0 54 | Size: 0 55 | BoundImport: 56 | RelativeVirtualAddress: 0 57 | Size: 0 58 | IAT: 59 | RelativeVirtualAddress: 8264 60 | Size: 16 61 | DelayImportDescriptor: 62 | RelativeVirtualAddress: 0 63 | Size: 0 64 | ClrRuntimeHeader: 65 | RelativeVirtualAddress: 0 66 | Size: 0 67 | header: 68 | Machine: IMAGE_FILE_MACHINE_AMD64 69 | Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DEBUG_STRIPPED, IMAGE_FILE_DLL ] 70 | sections: 71 | - Name: .text 72 | Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] 73 | VirtualAddress: 4096 74 | VirtualSize: 168 75 | SectionData: 554889E54881EC20000000488D0DEE0F0000E889000000C9C30000000104020504030150554889E54881EC2000000048894D10488955184C8945204C894D28488D0DC30F0000E855000000B800000000E900000000C9C3000000000000000000554889E54881EC3000000048894D10488955184C894520488B45204989C08B5518488B4D10E89AFFFFFF8945FC8B45FCE900000000C9C3000104020504030150FF25A20F00000000 76 | - Name: .data 77 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] 78 | VirtualAddress: 8192 79 | VirtualSize: 480 80 | SectionData: 637572696F757321004D61726B204A616E73656E0000000000000000000000005820000000000000000000006820000048200000000000000000000000000000000000000000000073200000000000000000000000000000732000000000000000000000000000006D73766372742E646C6C000000707574730000000000000000000000000000000000000020210000010000000C0000000C000000A8200000D820000008210000241000000040000000400000004000000040000000400000004000006010000020200000E0210000A0100000001000002D2100003521000046210000592100006A2100007D21000091210000A7210000B1210000B8210000BD210000C421000000000100020003000400050006000700080009000A000B00706536345F7374642E646C6C00446C6C4D61696E005F5F66696E695F61727261795F656E64005F5F66696E695F61727261795F7374617274005F5F696E69745F61727261795F656E64005F5F696E69745F61727261795F7374617274005F5F707265696E69745F61727261795F656E64005F5F707265696E69745F61727261795F7374617274005F646C6C7374617274005F6564617461005F656E64005F65746578740068656C6C6F5F74686572650000000000000000000000000000000000 81 | - Name: .pdata 82 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] 83 | VirtualAddress: 12288 84 | VirtualSize: 36 85 | SectionData: 0B100000191000001C1000002F100000571000001C1000006B1000009710000098100000 86 | symbols: [] 87 | ... 88 | 89 | # CHECK: FILE MAP: 90 | # CHECK: 000-188 392 [PE Headers] 91 | # CHECK: 188-200 120 [PE Section Headers] 92 | # CHECK: 200-400 512 .text 93 | # CHECK: 400-600 512 .data 94 | # CHECK: 600-800 512 .pdata 95 | 96 | # CHECK: VM MAP: 97 | # CHECK: 0000-0188 392 [PE Headers] 98 | # CHECK: 0188-0200 120 [PE Section Headers] 99 | # CHECK: 0200-1000 3584 [-- Nothing mapped --] 100 | # CHECK: 1000-10a8 168 .text 101 | # CHECK: 10a8-2000 3928 [-- Nothing mapped --] 102 | # CHECK: 2000-21e0 480 .data 103 | # CHECK: 21e0-3000 3616 [-- Nothing mapped --] 104 | # CHECK: 3000-3024 36 .pdata 105 | 106 | -------------------------------------------------------------------------------- /tests/PE/sections/simple-pe64-exe.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail 3 | 4 | --- !COFF 5 | OptionalHeader: 6 | AddressOfEntryPoint: 4160 7 | ImageBase: 4194304 8 | SectionAlignment: 4096 9 | FileAlignment: 512 10 | MajorOperatingSystemVersion: 4 11 | MinorOperatingSystemVersion: 0 12 | MajorImageVersion: 0 13 | MinorImageVersion: 0 14 | MajorSubsystemVersion: 4 15 | MinorSubsystemVersion: 0 16 | Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI 17 | DLLCharacteristics: [ ] 18 | SizeOfStackReserve: 1048576 19 | SizeOfStackCommit: 4096 20 | SizeOfHeapReserve: 1048576 21 | SizeOfHeapCommit: 4096 22 | ExportTable: 23 | RelativeVirtualAddress: 0 24 | Size: 0 25 | ImportTable: 26 | RelativeVirtualAddress: 8224 27 | Size: 40 28 | ResourceTable: 29 | RelativeVirtualAddress: 0 30 | Size: 0 31 | ExceptionTable: 32 | RelativeVirtualAddress: 12288 33 | Size: 24 34 | CertificateTable: 35 | RelativeVirtualAddress: 0 36 | Size: 0 37 | BaseRelocationTable: 38 | RelativeVirtualAddress: 0 39 | Size: 0 40 | Debug: 41 | RelativeVirtualAddress: 0 42 | Size: 0 43 | Architecture: 44 | RelativeVirtualAddress: 0 45 | Size: 0 46 | GlobalPtr: 47 | RelativeVirtualAddress: 0 48 | Size: 0 49 | TlsTable: 50 | RelativeVirtualAddress: 0 51 | Size: 0 52 | LoadConfigTable: 53 | RelativeVirtualAddress: 0 54 | Size: 0 55 | BoundImport: 56 | RelativeVirtualAddress: 0 57 | Size: 0 58 | IAT: 59 | RelativeVirtualAddress: 8264 60 | Size: 48 61 | DelayImportDescriptor: 62 | RelativeVirtualAddress: 0 63 | Size: 0 64 | ClrRuntimeHeader: 65 | RelativeVirtualAddress: 0 66 | Size: 0 67 | header: 68 | Machine: IMAGE_FILE_MACHINE_AMD64 69 | Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DEBUG_STRIPPED ] 70 | sections: 71 | - Name: .text 72 | Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] 73 | VirtualAddress: 4096 74 | VirtualSize: 232 75 | SectionData: 554889E54881EC20000000488D0DEE0F0000E8A9000000B800000000E900000000C9C30001040205040301500000000000000000000000000000000000000000554889E54881EC50000000B8000000008945E0BA00000300B900000100E866000000B901000000E864000000488D45E04889442420B8000000004989C1488D45E84989C0488D55F0488D4DFCE847000000488B45E84989C0488B55F08B4DFCE85CFFFFFF8945E48B4DE4E831000000C9C3000000010402050403015000000000FF25820F00000000FF25820F00000000FF25820F00000000FF25820F00000000FF25820F00000000 76 | - Name: .data 77 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] 78 | VirtualAddress: 8192 79 | VirtualSize: 256 80 | SectionData: 4D61726B204A616E73656E000000000000000000000000000000000000000000782000000000000000000000A8200000482000000000000000000000000000000000000000000000B320000000000000BA20000000000000C720000000000000D820000000000000E8200000000000000000000000000000B320000000000000BA20000000000000C720000000000000D820000000000000E82000000000000000000000000000006D73766372742E646C6C000000707574730000005F636F6E74726F6C66700000005F5F7365745F6170705F747970650000005F5F6765746D61696E6172677300000065786974000000000000000000000000000000000000 81 | - Name: .pdata 82 | Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] 83 | VirtualAddress: 12288 84 | VirtualSize: 24 85 | SectionData: 0B10000023100000241000004B100000B1100000B4100000 86 | symbols: [] 87 | ... 88 | 89 | # CHECK: FILE MAP: 90 | # CHECK: 000-188 392 [PE Headers] 91 | # CHECK: 188-200 120 [PE Section Headers] 92 | # CHECK: 200-400 512 .text 93 | # CHECK: 400-600 512 .data 94 | # CHECK: 600-800 512 .pdata 95 | 96 | # CHECK: VM MAP: 97 | # CHECK: 0000-0188 392 [PE Headers] 98 | # CHECK: 0188-0200 120 [PE Section Headers] 99 | # CHECK: 0200-1000 3584 [-- Nothing mapped --] 100 | # CHECK: 1000-10e8 232 .text 101 | # CHECK: 10e8-2000 3864 [-- Nothing mapped --] 102 | # CHECK: 2000-2100 256 .data 103 | # CHECK: 2100-3000 3840 [-- Nothing mapped --] 104 | # CHECK: 3000-3018 24 .pdata 105 | 106 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Bloaty Tests 3 | 4 | Bloaty has two sets of tests: 5 | 6 | - C++ tests in `tests/*.cc` 7 | - `lit` tests in `tests/**/*.test` 8 | 9 | We are in the process of migrating existing tests to `lit` where possible (see: https://github.com/google/bloaty/issues/221). 10 | 11 | ## `lit` tests 12 | 13 | These tests use the `lit` and `yaml2obj` tools from LLVM: 14 | - `yaml2obj` allows us to generate very specific ELF/Mach-O/PE files from a 15 | text-based YAML format. 16 | - `lit` lets us intermix this YAML with commands to run Bloaty and make 17 | assertions about its output. 18 | 19 | This is ideal for testing Bloaty's parsers, because 20 | `yaml2obj` is a precise and readable way of constructing 21 | input payloads. 22 | 23 | To run these tests via CMake, a few additional parameters 24 | must be specified currently: 25 | - `-DLIT_EXECUTABLE=`: specifies where to find the lit tool 26 | - `-DFILECHECK_EXECUTABLE=`: specifies where to find the FileCheck tool 27 | - `-DYAML2OBJ_EXECUTABLE=`: specifies where to find the yaml2obj tool 28 | 29 | You can install lit via pip: 30 | ```sh 31 | pip install --user lit 32 | ``` 33 | 34 | The FileCheck utility and yaml2obj currently need to be provided by the user. 35 | These are part of the LLVM toolchain and require a very recent build 36 | (development release from the main branch) to run the tests. 37 | 38 | ```sh 39 | cmake -B build -G Ninja -S . -DLIT_EXECUTABLE=${HOME}/Library/Python/3.8/bin/lit -DFILECHECK_EXECUTABLE=${HOME}/BinaryCache/llvm.org/bin/FileCheck -DYAML2OBJ_EXECUTABLE=${HOME}/BinaryCache/llvm.org/bin/yaml2obj 40 | cmake --build build --config Debug 41 | cmake --build build --target check-bloaty 42 | ``` 43 | 44 | 45 | ## C++ Tests 46 | 47 | The C++ tests are conventional C++ unit tests that use https://github.com/google/googletest. 48 | 49 | Going forward, C++ should only be used for tests that do not 50 | parse binary input files. For example, C++ is good for 51 | testing Bloaty's data structures and aggregation/reporting 52 | logic. 53 | 54 | To run the C++ tests (Git only, these are not included in the release tarball), type: 55 | 56 | ``` 57 | $ cmake --build build --config Debug --target test 58 | ``` 59 | -------------------------------------------------------------------------------- /tests/bloaty_misc_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "test.h" 16 | 17 | TEST_F(BloatyTest, NoSections) { 18 | RunBloaty({"bloaty", "01-no-sections.bin"}); 19 | } 20 | 21 | TEST_F(BloatyTest, SectionCountOverflow) { 22 | RunBloaty({"bloaty", "02-section-count-overflow.o"}); 23 | } 24 | 25 | TEST_F(BloatyTest, InlinesOnSmallFile) { 26 | RunBloaty( 27 | {"bloaty", "-d", "compileunits", "03-small-binary-that-crashed-inlines.bin"}); 28 | RunBloaty( 29 | {"bloaty", "-d", "inlines", "03-small-binary-that-crashed-inlines.bin"}); 30 | EXPECT_EQ(top_row_->size.vm, 2340); 31 | } 32 | 33 | TEST_F(BloatyTest, GoBinary) { 34 | RunBloaty( 35 | {"bloaty", "-d", "compileunits", "04-go-binary-with-ref-addr.bin"}); 36 | RunBloaty( 37 | {"bloaty", "-d", "inlines", "04-go-binary-with-ref-addr.bin"}); 38 | } 39 | 40 | TEST_F(BloatyTest, ImplicitConstAndLineStrp) { 41 | RunBloaty( 42 | {"bloaty", "-d", "compileunits", "05-implicit-const-and-line-strp.bin"}); 43 | RunBloaty( 44 | {"bloaty", "-d", "inlines", "05-implicit-const-and-line-strp.bin"}); 45 | } 46 | 47 | TEST_F(BloatyTest, MultiThreaded) { 48 | RunBloaty({"bloaty", "02-section-count-overflow.o"}); 49 | size_t file_size = top_row_->size.file; 50 | 51 | // Bloaty doesn't know or care that you are passing the same file multiple 52 | // times. 53 | std::vector args{"bloaty"}; 54 | const int count = 100; 55 | for (int i = 0; i < count; i++) { 56 | args.push_back("02-section-count-overflow.o"); 57 | } 58 | RunBloaty(args); // Heavily multithreaded test. 59 | EXPECT_EQ(top_row_->size.file, file_size * 100); 60 | } 61 | -------------------------------------------------------------------------------- /tests/bloaty_test_pe.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "test.h" 16 | 17 | struct BloatyTestEntry 18 | { 19 | std::string name; 20 | std::vector commandline; 21 | std::string input_file; 22 | std::string result_file; 23 | }; 24 | 25 | std::string TestEntryName(const testing::TestParamInfo& entry) { 26 | return entry.param.name; 27 | } 28 | 29 | std::ostream& operator<<(std::ostream& os, const BloatyTestEntry& entry) { 30 | os << "{ "; 31 | for (const auto& str: entry.commandline) { 32 | os << str << ", "; 33 | } 34 | os << entry.input_file << ", " << entry.result_file << " }"; 35 | return os; 36 | } 37 | 38 | // Strip all trailing whitespace (including \r) 39 | void Normalize(std::string& contents) { 40 | std::stringstream buffer(contents); 41 | contents.clear(); 42 | std::string tmp; 43 | while (std::getline(buffer, tmp)) { 44 | auto end = tmp.find_last_not_of("\t \r"); 45 | if (end != std::string::npos) { 46 | tmp = tmp.substr(0, end + 1); 47 | } 48 | else { 49 | tmp.clear(); 50 | } 51 | if (!contents.empty()) { 52 | contents += "\n"; 53 | } 54 | contents += tmp; 55 | } 56 | } 57 | 58 | inline bool GetFileContents(const std::string& filename, std::string& contents) { 59 | FILE* file = fopen(filename.c_str(), "rb"); 60 | if (!file) { 61 | std::cerr << "Couldn't get file size for: " << filename << "\n"; 62 | return false; 63 | } 64 | fseek(file, 0L, SEEK_END); 65 | size_t size = ftell(file); 66 | fseek(file, 0L, SEEK_SET); 67 | contents.resize(size); 68 | size_t result = fread(&contents[0], 1, size, file); 69 | fclose(file); 70 | contents.resize(result); 71 | Normalize(contents); 72 | return result == size; 73 | } 74 | 75 | class BloatyOutputTest: public BloatyTest, 76 | public testing::WithParamInterface 77 | { 78 | public: 79 | BloatyOutputTest() 80 | : commandline(GetParam().commandline) 81 | , input_file(GetParam().input_file) 82 | , result_file(GetParam().result_file) 83 | { 84 | } 85 | 86 | const std::vector& commandline; 87 | const std::string& input_file; 88 | const std::string& result_file; 89 | }; 90 | 91 | 92 | TEST_P(BloatyOutputTest, CheckOutput) { 93 | uint64_t size; 94 | ASSERT_TRUE(GetFileSize(input_file, &size)); 95 | std::string expect_result; 96 | ASSERT_TRUE(GetFileContents(result_file, expect_result)); 97 | 98 | std::vector cmdline = { "bloaty" }; 99 | cmdline.insert(cmdline.end(), commandline.begin(), commandline.end()); 100 | cmdline.push_back(input_file); 101 | RunBloaty(cmdline); 102 | 103 | bloaty::OutputOptions output_options; 104 | std::stringstream output_stream; 105 | output_options.output_format = bloaty::OutputFormat::kTSV; 106 | output_->Print(output_options, &output_stream); 107 | std::string tmp = output_stream.str(); 108 | Normalize(tmp); 109 | EXPECT_EQ(tmp, expect_result); 110 | } 111 | 112 | static BloatyTestEntry tests[] = { 113 | { "MSVCR15DLL", {}, "msvc-15.0-foo-bar.dll", "msvc-15.0-foo-bar.dll.txt" }, 114 | { "MSVCR15DLLSEG", {"-d", "segments"}, "msvc-15.0-foo-bar.dll", "msvc-15.0-foo-bar.dll.seg.txt" }, 115 | { "MSVC15EXE", {}, "msvc-15.0-foo-bar-main-cv.bin", "msvc-15.0-foo-bar-main-cv.bin.txt" }, 116 | { "MSVC15EXESEG", {"-d", "segments"}, "msvc-15.0-foo-bar-main-cv.bin", "msvc-15.0-foo-bar-main-cv.bin.seg.txt" }, 117 | 118 | { "MSVCR16DLL", {}, "msvc-16.0-foo-bar.dll", "msvc-16.0-foo-bar.dll.txt" }, 119 | { "MSVCR16DLLSEG", {"-d", "segments"}, "msvc-16.0-foo-bar.dll", "msvc-16.0-foo-bar.dll.seg.txt" }, 120 | { "MSVC16EXE", {}, "msvc-16.0-foo-bar-main-cv.bin", "msvc-16.0-foo-bar-main-cv.bin.txt" }, 121 | { "MSVC16EXESEG", {"-d", "segments"}, "msvc-16.0-foo-bar-main-cv.bin", "msvc-16.0-foo-bar-main-cv.bin.seg.txt" }, 122 | }; 123 | 124 | INSTANTIATE_TEST_SUITE_P(BloatyTest, 125 | BloatyOutputTest, 126 | testing::ValuesIn(tests), 127 | TestEntryName); 128 | -------------------------------------------------------------------------------- /tests/dwarf/debug_info/dw_form_line_strp.test: -------------------------------------------------------------------------------- 1 | # Test that we can access DW_FORM_line_strp strings in the DWARF 5 debug_line_str section. 2 | 3 | # RUN: %yaml2obj %s --docnum=1 -o %t.obj 4 | # RUN: %yaml2obj %s --docnum=2 -o %t.dwo 5 | # RUN: %bloaty %t.obj --debug-file %t.dwo -d compileunits --raw-map --domain=vm | %FileCheck %s 6 | 7 | --- !ELF 8 | FileHeader: 9 | Class: ELFCLASS64 10 | Data: ELFDATA2LSB 11 | Type: ET_DYN 12 | Machine: EM_X86_64 13 | Entry: 0x1040 14 | ProgramHeaders: 15 | - Type: PT_LOAD 16 | Flags: [ PF_X, PF_R ] 17 | FirstSec: .text 18 | LastSec: .text 19 | VAddr: 0x1000 20 | Align: 0x1000 21 | Sections: 22 | - Name: .note.gnu.build-id 23 | Type: SHT_NOTE 24 | Notes: 25 | - Name: GNU 26 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 27 | Type: 0x3 # NT_GNU_BUILD_ID 28 | - Name: .text 29 | Type: SHT_PROGBITS 30 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 31 | Address: 0x1000 32 | AddressAlign: 0x10 33 | Size: 0x10 34 | - Name: .debug_line_str 35 | Type: SHT_PROGBITS 36 | Flags: [ ] 37 | Content: "666f6f2e6300" #foo.c 38 | ... 39 | 40 | --- !ELF 41 | FileHeader: 42 | Class: ELFCLASS64 43 | Data: ELFDATA2LSB 44 | Type: ET_DYN 45 | Machine: EM_X86_64 46 | Entry: 0x1040 47 | Sections: 48 | - Name: .note.gnu.build-id 49 | Type: SHT_NOTE 50 | Notes: 51 | - Name: GNU 52 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 53 | Type: 0x3 # NT_GNU_BUILD_ID 54 | - Name: .debug_line_str 55 | Type: SHT_PROGBITS 56 | Flags: [ ] 57 | Content: "666f6f2e6300" #foo.c 58 | DWARF: 59 | # debug_line_str: # <---- yaml2obj-15 "unknown key" error. instead, we use the section 60 | # # above similarly to: 61 | # # https://github.com/llvm/llvm-project/blob/8ce23b8e5c91c530d25c13f97b6f4cbacfe34b3c/llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-line-str.test#L2 62 | # - foo.c 63 | debug_abbrev: 64 | - ID: 0 65 | Table: 66 | - Code: 0x1 67 | Tag: DW_TAG_compile_unit 68 | Children: DW_CHILDREN_yes 69 | Attributes: 70 | - Attribute: DW_AT_name 71 | Form: DW_FORM_line_strp 72 | - Code: 0x2 73 | Tag: DW_TAG_subprogram 74 | Children: DW_CHILDREN_no 75 | Attributes: 76 | - Attribute: DW_AT_low_pc 77 | Form: DW_FORM_addr 78 | - Attribute: DW_AT_high_pc 79 | Form: DW_FORM_data4 80 | debug_info: 81 | # 0x0000000b: DW_TAG_compile_unit 82 | # DW_AT_name ("foo.c") 83 | # 84 | # 0x00000010: DW_TAG_subprogram 85 | # DW_AT_low_pc (0x0000000000001000) 86 | # DW_AT_high_pc (0x0000000000001010) 87 | - Version: 5 88 | UnitType: 0x01 # DW_UT_compile 89 | AbbrevTableID: 0 90 | AbbrOffset: 0x0 91 | AddrSize: 8 92 | Entries: 93 | - AbbrCode: 0x1 94 | Values: 95 | - Value: 0x0 96 | - AbbrCode: 0x2 97 | Values: 98 | - Value: 0x1000 99 | - Value: 0x10 100 | ... 101 | 102 | # CHECK: VM MAP: 103 | # CHECK: 0000-1000 4096 [-- Nothing mapped --] 104 | # CHECK: 1000-1010 16 foo.c -------------------------------------------------------------------------------- /tests/dwarf/debug_info/gnu-split-dwarf.test: -------------------------------------------------------------------------------- 1 | # Tests that we can find .dwo files based on the DW_AT_GNU_dwo_name attribute. 2 | # Output of this sort will be produced by using -gsplit-dwarf with gcc or clang. 3 | 4 | # RUN: mkdir -p %/t 5 | # RUN: cat %s | sed "s|__PWD__|%/t|" | %yaml2obj --docnum=1 -o %t.obj 6 | # RUN: %yaml2obj %s --docnum=2 -o %/t/foo.dwo 7 | # RUN: %yaml2obj %s --docnum=3 -o %/t/bar.dwo 8 | # RUN: %bloaty %t.obj -d compileunits --raw-map --domain=vm | %FileCheck %s 9 | 10 | --- !ELF 11 | FileHeader: 12 | Class: ELFCLASS64 13 | Data: ELFDATA2LSB 14 | Type: ET_DYN 15 | Machine: EM_X86_64 16 | Entry: 0x1040 17 | ProgramHeaders: 18 | - Type: PT_LOAD 19 | Flags: [ PF_X, PF_R ] 20 | FirstSec: .text 21 | LastSec: .text 22 | VAddr: 0x400000 23 | Align: 0x1000 24 | Sections: 25 | - Name: .text 26 | Type: SHT_PROGBITS 27 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 28 | Address: 0x400000 29 | AddressAlign: 0x10 30 | Size: 0x1100 31 | - Name: .debug_addr 32 | Type: SHT_PROGBITS 33 | AddressAlign: 0x1 34 | Content: '00004000000000000001400000000000' 35 | DWARF: 36 | debug_str: 37 | # We don't expect DW_AT_comp_dir to contain '.' in real life, 38 | # but using it here lets our test data work from any filesystem 39 | # location 40 | - foo.dwo 41 | - bar.dwo 42 | - __PWD__ 43 | debug_abbrev: 44 | - ID: 0 45 | Table: 46 | - Code: 0x1 47 | Tag: DW_TAG_compile_unit 48 | Children: DW_CHILDREN_no 49 | Attributes: 50 | - Attribute: DW_AT_comp_dir 51 | Form: DW_FORM_strp 52 | - Attribute: DW_AT_GNU_dwo_name 53 | Form: DW_FORM_strp 54 | - Attribute: DW_AT_GNU_dwo_id 55 | Form: DW_FORM_data8 56 | - Attribute: DW_AT_GNU_addr_base 57 | Form: DW_FORM_sec_offset 58 | debug_info: 59 | - Version: 4 60 | AbbrevTableID: 0 61 | AbbrOffset: 0x0 62 | AddrSize: 8 63 | Entries: 64 | - AbbrCode: 0x1 65 | Values: 66 | - Value: 0x10 67 | - Value: 0x0 68 | - Value: 0xdeaddeaddeadbeef 69 | - Value: 0x0 70 | - Version: 4 71 | AbbrevTableID: 0 72 | AbbrOffset: 0x0 73 | AddrSize: 8 74 | Entries: 75 | - AbbrCode: 0x1 76 | Values: 77 | - Value: 0x10 78 | - Value: 0x8 79 | - Value: 0xbeefbeefbeefbeef 80 | - Value: 0x8 81 | ... 82 | 83 | --- !ELF 84 | FileHeader: 85 | Class: ELFCLASS64 86 | Data: ELFDATA2LSB 87 | Type: ET_REL 88 | Machine: EM_X86_64 89 | DWARF: 90 | debug_abbrev: 91 | - ID: 0 92 | Table: 93 | - Code: 0x1 94 | Tag: DW_TAG_compile_unit 95 | Children: DW_CHILDREN_no 96 | Attributes: 97 | - Attribute: DW_AT_name 98 | Form: DW_FORM_strp 99 | - Attribute: DW_AT_GNU_dwo_id 100 | Form: DW_FORM_data8 101 | - Attribute: DW_AT_low_pc 102 | Form: DW_FORM_GNU_addr_index 103 | - Attribute: DW_AT_high_pc 104 | Form: DW_FORM_data4 105 | debug_str: 106 | - foo.c 107 | debug_info: 108 | - Version: 4 109 | AbbrevTableID: 0 110 | AbbrOffset: 0x0 111 | AddrSize: 8 112 | Entries: 113 | - AbbrCode: 0x1 114 | Values: 115 | - Value: 0x0 116 | - Value: 0xdeaddeaddeadbeef 117 | - Value: 0x0 118 | - Value: 0x100 119 | 120 | --- !ELF 121 | FileHeader: 122 | Class: ELFCLASS64 123 | Data: ELFDATA2LSB 124 | Type: ET_REL 125 | Machine: EM_X86_64 126 | DWARF: 127 | debug_abbrev: 128 | - ID: 0 129 | Table: 130 | - Code: 0x1 131 | Tag: DW_TAG_compile_unit 132 | Children: DW_CHILDREN_no 133 | Attributes: 134 | - Attribute: DW_AT_name 135 | Form: DW_FORM_strp 136 | - Attribute: DW_AT_GNU_dwo_id 137 | Form: DW_FORM_data8 138 | - Attribute: DW_AT_low_pc 139 | Form: DW_FORM_GNU_addr_index 140 | - Attribute: DW_AT_high_pc 141 | Form: DW_FORM_data4 142 | debug_str: 143 | - bar.c 144 | # XXX: In a real file this section would be named debug_info.dwo. 145 | # But currently obj2yaml doesn't have any way of specifying a section name 146 | # other than debug_info. This means we don't currently have testing of 147 | # the code that strips .dwo from the end of section names. 148 | debug_info: 149 | - Version: 4 150 | AbbrevTableID: 0 151 | AbbrOffset: 0x0 152 | AddrSize: 8 153 | Entries: 154 | - AbbrCode: 0x1 155 | Values: 156 | - Value: 0x0 157 | - Value: 0xbeefbeefbeefbeef 158 | - Value: 0x0 159 | - Value: 0x1000 160 | 161 | ... 162 | 163 | # CHECK: VM MAP: 164 | # CHECK: 000000-400000 4194304 [-- Nothing mapped --] 165 | # CHECK: 400000-400100 256 foo.c 166 | # CHECK: 400100-401100 4096 bar.c 167 | -------------------------------------------------------------------------------- /tests/dwarf/debug_info/ignore-declarations.test: -------------------------------------------------------------------------------- 1 | # Test that we properly ignore DIEs that have DW_AT_declaration=true. 2 | # This indicates a function that was declared, but not defined. 3 | # We don't want to register declarations, only definitions. 4 | # 5 | # This test is somewhat unrealistic, as it contains DIEs we would 6 | # probably never see in the real world (specifically, DIEs that have 7 | # both DW_AT_declaration and DW_AT_low_pc). However this may be the 8 | # only way of testing that we are truly skipping declarations, since 9 | # the skipping of declarations may not have any actual observable 10 | # effect on real-world data. 11 | 12 | # RUN: %yaml2obj %s --docnum=1 -o %t.obj 13 | # RUN: %yaml2obj %s --docnum=2 -o %t.dwo 14 | # RUN: %bloaty %t.obj --debug-file %t.dwo -d compileunits --raw-map --domain=vm | %FileCheck %s 15 | 16 | --- !ELF 17 | FileHeader: 18 | Class: ELFCLASS64 19 | Data: ELFDATA2LSB 20 | Type: ET_DYN 21 | Machine: EM_X86_64 22 | Entry: 0x1040 23 | ProgramHeaders: 24 | - Type: PT_LOAD 25 | Flags: [ PF_X, PF_R ] 26 | FirstSec: .text 27 | LastSec: .text 28 | VAddr: 0x1000 29 | Align: 0x1000 30 | Sections: 31 | - Name: .note.gnu.build-id 32 | Type: SHT_NOTE 33 | Notes: 34 | - Name: GNU 35 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 36 | Type: 0x3 # NT_GNU_BUILD_ID 37 | - Name: .text 38 | Type: SHT_PROGBITS 39 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 40 | Address: 0x1000 41 | AddressAlign: 0x10 42 | Size: 0x20 43 | ... 44 | 45 | --- !ELF 46 | FileHeader: 47 | Class: ELFCLASS64 48 | Data: ELFDATA2LSB 49 | Type: ET_DYN 50 | Machine: EM_X86_64 51 | Entry: 0x1040 52 | Sections: 53 | - Name: .note.gnu.build-id 54 | Type: SHT_NOTE 55 | Notes: 56 | - Name: GNU 57 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 58 | Type: 0x3 # NT_GNU_BUILD_ID 59 | DWARF: 60 | debug_str: 61 | - foo.c 62 | - bar.c 63 | debug_abbrev: 64 | - ID: 0 65 | Table: 66 | - Code: 0x1 67 | Tag: DW_TAG_compile_unit 68 | Children: DW_CHILDREN_yes 69 | Attributes: 70 | - Attribute: DW_AT_name 71 | Form: DW_FORM_strp 72 | - Code: 0x2 73 | Tag: DW_TAG_subprogram 74 | Children: DW_CHILDREN_no 75 | Attributes: 76 | - Attribute: DW_AT_low_pc 77 | Form: DW_FORM_addr 78 | - Attribute: DW_AT_high_pc 79 | Form: DW_FORM_data4 80 | - Attribute: DW_AT_declaration 81 | Form: DW_FORM_flag_present 82 | - Code: 0x3 83 | Tag: DW_TAG_subprogram 84 | Children: DW_CHILDREN_no 85 | Attributes: 86 | - Attribute: DW_AT_low_pc 87 | Form: DW_FORM_addr 88 | - Attribute: DW_AT_high_pc 89 | Form: DW_FORM_data4 90 | debug_info: 91 | # 0x0000000b: DW_TAG_compile_unit 92 | # DW_AT_name ("foo.c") 93 | # 94 | # 0x00000010: DW_TAG_subprogram 95 | # DW_AT_low_pc (0x0000000000001000) 96 | # DW_AT_high_pc (0x0000000000001010) 97 | # # This entry should be ignored because declaration=true. 98 | # DW_AT_declaration (true) 99 | # 100 | # 0x0000001d: DW_TAG_subprogram 101 | # DW_AT_low_pc (0x0000000000001010) 102 | # DW_AT_high_pc (0x0000000000001020) 103 | - Version: 4 104 | AbbrevTableID: 0 105 | AbbrOffset: 0x0 106 | AddrSize: 8 107 | Entries: 108 | - AbbrCode: 0x1 109 | Values: 110 | - Value: 0x0 111 | - AbbrCode: 0x2 112 | Values: 113 | - Value: 0x1000 114 | - Value: 0x10 115 | - AbbrCode: 0x3 116 | Values: 117 | - Value: 0x1010 118 | - Value: 0x10 119 | - AbbrCode: 0x0 120 | # 0x00000036: DW_TAG_compile_unit 121 | # DW_AT_name ("bar.c") 122 | # 123 | # 0x0000003b: DW_TAG_subprogram 124 | # DW_AT_low_pc (0x0000000000001000) 125 | # DW_AT_high_pc (0x0000000000001010) 126 | - Version: 4 127 | AbbrevTableID: 0 128 | AbbrOffset: 0x0 129 | AddrSize: 8 130 | Entries: 131 | - AbbrCode: 0x1 132 | Values: 133 | - Value: 0x6 134 | - AbbrCode: 0x3 135 | Values: 136 | - Value: 0x1000 137 | - Value: 0x10 138 | - AbbrCode: 0x0 139 | ... 140 | 141 | # CHECK: VM MAP: 142 | # CHECK: 0000-1000 4096 [-- Nothing mapped --] 143 | # CHECK: 1000-1010 16 bar.c 144 | # CHECK: 1010-1020 16 foo.c 145 | -------------------------------------------------------------------------------- /tests/dwarf/debug_info/pcpair-incomplete.test: -------------------------------------------------------------------------------- 1 | # Test that incomplete entries for pcpair are ignored. 2 | # There are several kinds of incomplete entries: 3 | # - contains low_pc or high_pc, but not both. 4 | # - low_pc is not a valid dwarf address (0 or max) 5 | 6 | # RUN: %yaml2obj %s --docnum=1 -o %t.obj 7 | # RUN: %yaml2obj %s --docnum=2 -o %t.dwo 8 | # RUN: %bloaty %t.obj --debug-file %t.dwo -d compileunits --raw-map --domain=vm | %FileCheck %s 9 | 10 | --- !ELF 11 | FileHeader: 12 | Class: ELFCLASS64 13 | Data: ELFDATA2LSB 14 | Type: ET_DYN 15 | Machine: EM_X86_64 16 | Entry: 0x1040 17 | ProgramHeaders: 18 | - Type: PT_LOAD 19 | Flags: [ PF_X, PF_R ] 20 | FirstSec: .text 21 | LastSec: .text 22 | VAddr: 0x1000 23 | Align: 0x1000 24 | Sections: 25 | - Name: .note.gnu.build-id 26 | Type: SHT_NOTE 27 | Notes: 28 | - Name: GNU 29 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 30 | Type: 0x3 # NT_GNU_BUILD_ID 31 | - Name: .text 32 | Type: SHT_PROGBITS 33 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 34 | Address: 0x1000 35 | AddressAlign: 0x10 36 | Size: 0x20 37 | ... 38 | 39 | --- !ELF 40 | FileHeader: 41 | Class: ELFCLASS64 42 | Data: ELFDATA2LSB 43 | Type: ET_DYN 44 | Machine: EM_X86_64 45 | Entry: 0x1040 46 | Sections: 47 | - Name: .note.gnu.build-id 48 | Type: SHT_NOTE 49 | Notes: 50 | - Name: GNU 51 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 52 | Type: 0x3 # NT_GNU_BUILD_ID 53 | DWARF: 54 | debug_str: 55 | - foo.c 56 | - bar.c 57 | debug_abbrev: 58 | - ID: 0 59 | Table: 60 | - Code: 0x1 61 | Tag: DW_TAG_compile_unit 62 | Children: DW_CHILDREN_yes 63 | Attributes: 64 | - Attribute: DW_AT_name 65 | Form: DW_FORM_strp 66 | - Code: 0x2 67 | Tag: DW_TAG_subprogram 68 | Children: DW_CHILDREN_no 69 | Attributes: 70 | - Attribute: DW_AT_low_pc 71 | Form: DW_FORM_addr 72 | - Attribute: DW_AT_high_pc 73 | Form: DW_FORM_data4 74 | # Incomplete: low_pc but no high_pc 75 | - Code: 0x3 76 | Tag: DW_TAG_subprogram 77 | Children: DW_CHILDREN_no 78 | Attributes: 79 | - Attribute: DW_AT_low_pc 80 | Form: DW_FORM_addr 81 | # Incomplete: high_pc but no low_pc 82 | - Code: 0x4 83 | Tag: DW_TAG_subprogram 84 | Children: DW_CHILDREN_no 85 | Attributes: 86 | - Attribute: DW_AT_high_pc 87 | Form: DW_FORM_data4 88 | debug_info: 89 | # 0x0000000b: DW_TAG_compile_unit 90 | # DW_AT_name [DW_FORM_strp] ("foo.c") 91 | # 92 | # 0x00000010: DW_TAG_subprogram 93 | # DW_AT_low_pc [DW_FORM_addr] (0x0000000000001000) 94 | # 95 | # 0x00000019: DW_TAG_subprogram 96 | # DW_AT_high_pc [DW_FORM_data4] (0x00000010) 97 | # 98 | # 0x0000001e: DW_TAG_subprogram 99 | # DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000) 100 | # DW_AT_high_pc [DW_FORM_data4] (0x00000020) 101 | # 102 | # 0x0000002b: DW_TAG_subprogram 103 | # DW_AT_low_pc [DW_FORM_addr] (0xffffffffffffffff) 104 | # DW_AT_high_pc [DW_FORM_data4] (0x00000020) 105 | # 106 | # 0x00000038: DW_TAG_subprogram 107 | # DW_AT_low_pc [DW_FORM_addr] (0x0000000000001010) 108 | # DW_AT_high_pc [DW_FORM_data4] (0x00000010) 109 | - Version: 4 110 | AbbrevTableID: 0 111 | AbbrOffset: 0x0 112 | AddrSize: 8 113 | Entries: 114 | - AbbrCode: 0x1 115 | Values: 116 | - Value: 0x0 117 | - AbbrCode: 0x3 118 | Values: 119 | - Value: 0x1000 120 | - AbbrCode: 0x4 121 | Values: 122 | - Value: 0x10 123 | - AbbrCode: 0x2 124 | Values: 125 | - Value: 0x0 # Incomplete, 0 address 126 | - Value: 0x20 127 | - AbbrCode: 0x2 128 | Values: 129 | - Value: 0xffffffffffffffff # Incomplete, max address 130 | - Value: 0x20 131 | - AbbrCode: 0x2 132 | Values: 133 | - Value: 0x1010 134 | - Value: 0x10 135 | - AbbrCode: 0x0 136 | # 0x00000051: DW_TAG_compile_unit 137 | # DW_AT_name [DW_FORM_strp] ("bar.c") 138 | # 139 | # 0x00000056: DW_TAG_subprogram 140 | # DW_AT_low_pc [DW_FORM_addr] (0x0000000000001000) 141 | # DW_AT_high_pc [DW_FORM_data4] (0x00000010) 142 | - Version: 4 143 | AbbrevTableID: 0 144 | AbbrOffset: 0x0 145 | AddrSize: 8 146 | Entries: 147 | - AbbrCode: 0x1 148 | Values: 149 | - Value: 0x6 150 | - AbbrCode: 0x2 151 | Values: 152 | - Value: 0x1000 153 | - Value: 0x10 154 | - AbbrCode: 0x0 155 | ... 156 | 157 | # CHECK: VM MAP: 158 | # CHECK: 0000-1000 4096 [-- Nothing mapped --] 159 | # CHECK: 1000-1010 16 bar.c 160 | # CHECK: 1010-1020 16 foo.c 161 | -------------------------------------------------------------------------------- /tests/dwarf/debug_info/pcpair.test: -------------------------------------------------------------------------------- 1 | # Test that we report pcpair ranges from DIEs that have: 2 | # 0x00000010: DW_TAG_subprogram 3 | # DW_AT_low_pc (0x0000000000001000) 4 | # DW_AT_high_pc (0x0000000000001010) 5 | # 6 | # This is the most common way of getting data for the compileunits 7 | # data source. 8 | 9 | # RUN: %yaml2obj %s --docnum=1 -o %t.obj 10 | # RUN: %yaml2obj %s --docnum=2 -o %t.dwo 11 | # RUN: %bloaty %t.obj --debug-file %t.dwo -d compileunits --raw-map --domain=vm | %FileCheck %s 12 | 13 | --- !ELF 14 | FileHeader: 15 | Class: ELFCLASS64 16 | Data: ELFDATA2LSB 17 | Type: ET_DYN 18 | Machine: EM_X86_64 19 | Entry: 0x1040 20 | ProgramHeaders: 21 | - Type: PT_LOAD 22 | Flags: [ PF_X, PF_R ] 23 | FirstSec: .text 24 | LastSec: .text 25 | VAddr: 0x1000 26 | Align: 0x1000 27 | Sections: 28 | - Name: .note.gnu.build-id 29 | Type: SHT_NOTE 30 | Notes: 31 | - Name: GNU 32 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 33 | Type: 0x3 # NT_GNU_BUILD_ID 34 | - Name: .text 35 | Type: SHT_PROGBITS 36 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 37 | Address: 0x1000 38 | AddressAlign: 0x10 39 | Size: 0x20 40 | ... 41 | 42 | --- !ELF 43 | FileHeader: 44 | Class: ELFCLASS64 45 | Data: ELFDATA2LSB 46 | Type: ET_DYN 47 | Machine: EM_X86_64 48 | Entry: 0x1040 49 | Sections: 50 | - Name: .note.gnu.build-id 51 | Type: SHT_NOTE 52 | Notes: 53 | - Name: GNU 54 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 55 | Type: 0x3 # NT_GNU_BUILD_ID 56 | DWARF: 57 | debug_str: 58 | - foo.c 59 | - bar.c 60 | debug_abbrev: 61 | - ID: 0 62 | Table: 63 | - Code: 0x1 64 | Tag: DW_TAG_compile_unit 65 | Children: DW_CHILDREN_yes 66 | Attributes: 67 | - Attribute: DW_AT_name 68 | Form: DW_FORM_strp 69 | - Code: 0x2 70 | Tag: DW_TAG_subprogram 71 | Children: DW_CHILDREN_no 72 | Attributes: 73 | - Attribute: DW_AT_low_pc 74 | Form: DW_FORM_addr 75 | - Attribute: DW_AT_high_pc 76 | Form: DW_FORM_data4 # high_pc as size 77 | - Code: 0x3 78 | Tag: DW_TAG_subprogram 79 | Children: DW_CHILDREN_no 80 | Attributes: 81 | - Attribute: DW_AT_low_pc 82 | Form: DW_FORM_addr 83 | - Attribute: DW_AT_high_pc 84 | Form: DW_FORM_addr # high_pc as addr 85 | debug_info: 86 | # 0x0000000b: DW_TAG_compile_unit 87 | # DW_AT_name [DW_FORM_strp] ("foo.c") 88 | # 89 | # 0x00000010: DW_TAG_subprogram 90 | # DW_AT_low_pc [DW_FORM_addr] (0x0000000000001010) 91 | # DW_AT_high_pc [DW_FORM_data4] (0x00000010) 92 | - Version: 4 93 | AbbrevTableID: 0 94 | AbbrOffset: 0x0 95 | AddrSize: 8 96 | Entries: 97 | - AbbrCode: 0x1 98 | Values: 99 | - Value: 0x0 100 | - AbbrCode: 0x2 101 | Values: 102 | - Value: 0x1010 103 | - Value: 0x10 104 | - AbbrCode: 0x0 105 | # 0x00000029: DW_TAG_compile_unit 106 | # DW_AT_name [DW_FORM_strp] ("bar.c") 107 | # 108 | # 0x0000002e: DW_TAG_subprogram 109 | # DW_AT_low_pc [DW_FORM_addr] (0x0000000000001000) 110 | # DW_AT_high_pc [DW_FORM_addr] (0x0000000000001010) 111 | - Version: 4 112 | AbbrevTableID: 0 113 | AbbrOffset: 0x0 114 | AddrSize: 8 115 | Entries: 116 | - AbbrCode: 0x1 117 | Values: 118 | - Value: 0x6 119 | - AbbrCode: 0x3 120 | Values: 121 | - Value: 0x1000 122 | - Value: 0x1010 123 | - AbbrCode: 0x0 124 | ... 125 | 126 | # CHECK: VM MAP: 127 | # CHECK: 0000-1000 4096 [-- Nothing mapped --] 128 | # CHECK: 1000-1010 16 bar.c 129 | # CHECK: 1010-1020 16 foo.c 130 | -------------------------------------------------------------------------------- /tests/dwarf/range_lists/base-addr-selection.test: -------------------------------------------------------------------------------- 1 | # Test for range list that contains a "base address selection" entry. 2 | # When the start address is the max address (eg. UINT64_MAX), it signals 3 | # a special kind of entry where the end address signifies the new base 4 | # address. 5 | 6 | # RUN: %yaml2obj %s --docnum=1 -o %t.obj 7 | # RUN: %yaml2obj %s --docnum=2 -o %t.dwo 8 | # RUN: %bloaty %t.obj --debug-file %t.dwo -d compileunits --raw-map --domain=vm | %FileCheck %s 9 | 10 | --- !ELF 11 | FileHeader: 12 | Class: ELFCLASS64 13 | Data: ELFDATA2LSB 14 | Type: ET_DYN 15 | Machine: EM_X86_64 16 | Entry: 0x1040 17 | ProgramHeaders: 18 | - Type: PT_LOAD 19 | Flags: [ PF_X, PF_R ] 20 | FirstSec: .text 21 | LastSec: .text 22 | VAddr: 0x1000 23 | Align: 0x1000 24 | Sections: 25 | - Name: .note.gnu.build-id 26 | Type: SHT_NOTE 27 | Notes: 28 | - Name: GNU 29 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 30 | Type: 0x3 # NT_GNU_BUILD_ID 31 | - Name: .text 32 | Type: SHT_PROGBITS 33 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 34 | Address: 0x1000 35 | AddressAlign: 0x10 36 | Content: 31ED4989D15E4889E24883E4F050544C8D053A010000488D0DD3000000488D3DC1000000FF15762F0000F40F1F440000488D3DB12F0000488D05AA2F00004839F87415488B054E2F00004885C07409FFE00F1F8000000000C30F1F8000000000488D3D812F0000488D357A2F00004829FE4889F048C1EE3F48C1F8034801C648D1FE7414488B05252F00004885C07408FFE0660F1F440000C30F1F8000000000803D412F000000752F5548833D062F0000004889E5740C488B3D222F0000E82DFFFFFFE868FFFFFFC605192F0000015DC30F1F8000000000C30F1F8000000000E97BFFFFFF554889E5B8010000005DC341574C8D3DDF2C000041564989D641554989F541544189FC55488D2DD02C0000534C29FD4883EC08E8A3FEFFFF48C1FD03741B31DB0F1F004C89F24C89EE4489E741FF14DF4883C3014839DD75EA4883C4085B5D415C415D415E415FC30F1F00C3 37 | ... 38 | 39 | --- !ELF 40 | FileHeader: 41 | Class: ELFCLASS64 42 | Data: ELFDATA2LSB 43 | Type: ET_DYN 44 | Machine: EM_X86_64 45 | Entry: 0x1040 46 | Sections: 47 | - Name: .note.gnu.build-id 48 | Type: SHT_NOTE 49 | Notes: 50 | - Name: GNU 51 | Desc: 6CF422D909772A0FB5400518A689D9F15F14BF57 52 | Type: 0x3 # NT_GNU_BUILD_ID 53 | DWARF: 54 | debug_str: 55 | - test.c 56 | debug_abbrev: 57 | - ID: 0 58 | Table: 59 | - Code: 0x1 60 | Tag: DW_TAG_compile_unit 61 | Children: DW_CHILDREN_yes 62 | Attributes: 63 | - Attribute: DW_AT_name 64 | Form: DW_FORM_strp 65 | - Attribute: DW_AT_ranges 66 | Form: DW_FORM_sec_offset 67 | - Attribute: DW_AT_low_pc 68 | Form: DW_FORM_addr 69 | debug_ranges: 70 | - Offset: 0x0 71 | AddrSize: 0x8 72 | Entries: 73 | # This is the "base address selection" entry! 74 | - LowOffset: 0xffffffffffffffff # UINT64_MAX 75 | HighOffset: 0x1020 76 | # Now these addresses are relative to 0x1020 77 | - LowOffset: 0x22 78 | HighOffset: 0x27 79 | debug_info: 80 | - Version: 4 81 | AbbrevTableID: 0 82 | AbbrOffset: 0x0 83 | AddrSize: 8 84 | Entries: 85 | - AbbrCode: 0x1 86 | Values: 87 | - Value: 0x0 88 | - Value: 0x0 89 | - Value: 0x0 90 | - AbbrCode: 0x0 91 | ... 92 | 93 | # CHECK: VM MAP: 94 | # CHECK: 0000-1000 4096 [-- Nothing mapped --] 95 | # CHECK: 1000-1042 66 [section .text] 96 | # CHECK: 1042-1047 5 test.c 97 | # CHECK: 1047-1151 266 [section .text] 98 | -------------------------------------------------------------------------------- /tests/elf/sections/empty-bin-64.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s 3 | 4 | --- !ELF 5 | FileHeader: 6 | Class: ELFCLASS64 7 | Data: ELFDATA2LSB 8 | Type: ET_EXEC 9 | Machine: EM_X86_64 10 | Sections: 11 | - Name: .text 12 | Type: SHT_PROGBITS 13 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 14 | AddressAlign: 0x1 15 | - Name: .data 16 | Type: SHT_PROGBITS 17 | Flags: [ SHF_WRITE, SHF_ALLOC ] 18 | AddressAlign: 0x1 19 | - Name: .bss 20 | Type: SHT_NOBITS 21 | Flags: [ SHF_WRITE, SHF_ALLOC ] 22 | AddressAlign: 0x1 23 | - Name: .comment 24 | Type: SHT_PROGBITS 25 | Flags: [ SHF_MERGE, SHF_STRINGS ] 26 | AddressAlign: 0x1 27 | EntSize: 0x1 28 | Content: 004743433A202844656269616E2031302E322E312D362B6275696C6432292031302E322E3120323032313031313000 29 | - Name: .note.GNU-stack 30 | Type: SHT_PROGBITS 31 | AddressAlign: 0x1 32 | Symbols: 33 | - Name: 'null' 34 | Type: STT_FILE 35 | Index: SHN_ABS 36 | - Name: .text 37 | Type: STT_SECTION 38 | Section: .text 39 | - Name: .data 40 | Type: STT_SECTION 41 | Section: .data 42 | - Name: .bss 43 | Type: STT_SECTION 44 | Section: .bss 45 | - Name: .note.GNU-stack 46 | Type: STT_SECTION 47 | Section: .note.GNU-stack 48 | - Name: .comment 49 | Type: STT_SECTION 50 | Section: .comment 51 | ... 52 | 53 | # CHECK: FILE MAP: 54 | # CHECK: 000-040 64 [ELF Header] 55 | # CHECK: 040-070 48 .comment 56 | # CHECK: 070-118 168 .symtab 57 | # CHECK: 118-148 48 .strtab 58 | # CHECK: 148-190 72 .shstrtab 59 | # CHECK: 190-3d0 576 [ELF Section Headers] 60 | 61 | # CHECK: VM MAP: 62 | -------------------------------------------------------------------------------- /tests/elf/sections/empty-obj-64.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s 3 | 4 | --- !ELF 5 | FileHeader: 6 | Class: ELFCLASS64 7 | Data: ELFDATA2LSB 8 | Type: ET_REL 9 | Machine: EM_X86_64 10 | Sections: 11 | - Name: .text 12 | Type: SHT_PROGBITS 13 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 14 | AddressAlign: 0x1 15 | - Name: .data 16 | Type: SHT_PROGBITS 17 | Flags: [ SHF_WRITE, SHF_ALLOC ] 18 | AddressAlign: 0x1 19 | - Name: .bss 20 | Type: SHT_NOBITS 21 | Flags: [ SHF_WRITE, SHF_ALLOC ] 22 | AddressAlign: 0x1 23 | - Name: .comment 24 | Type: SHT_PROGBITS 25 | Flags: [ SHF_MERGE, SHF_STRINGS ] 26 | AddressAlign: 0x1 27 | EntSize: 0x1 28 | Content: 004743433A202844656269616E2031302E322E312D362B6275696C6432292031302E322E3120323032313031313000 29 | - Name: .note.GNU-stack 30 | Type: SHT_PROGBITS 31 | AddressAlign: 0x1 32 | Symbols: 33 | - Name: 'null' 34 | Type: STT_FILE 35 | Index: SHN_ABS 36 | - Name: .text 37 | Type: STT_SECTION 38 | Section: .text 39 | - Name: .data 40 | Type: STT_SECTION 41 | Section: .data 42 | - Name: .bss 43 | Type: STT_SECTION 44 | Section: .bss 45 | - Name: .note.GNU-stack 46 | Type: STT_SECTION 47 | Section: .note.GNU-stack 48 | - Name: .comment 49 | Type: STT_SECTION 50 | Section: .comment 51 | ... 52 | 53 | # CHECK: FILE MAP: 54 | # CHECK: 000-040 64 [ELF Header] 55 | # CHECK: 040-070 48 .comment 56 | # CHECK: 070-118 168 .symtab 57 | # CHECK: 118-148 48 .strtab 58 | # CHECK: 148-190 72 .shstrtab 59 | # CHECK: 190-3d0 576 [ELF Section Headers] 60 | 61 | # CHECK: VM MAP: 62 | -------------------------------------------------------------------------------- /tests/elf/sections/segment-offset-larger-than-file-size.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s 3 | 4 | --- !ELF 5 | FileHeader: 6 | Class: ELFCLASS64 7 | Data: ELFDATA2LSB 8 | Type: ET_EXEC 9 | Machine: EM_X86_64 10 | Sections: 11 | - Name: .text 12 | Type: SHT_PROGBITS 13 | Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 14 | AddressAlign: 0x1 15 | - Name: .data 16 | Type: SHT_PROGBITS 17 | Flags: [ SHF_WRITE, SHF_ALLOC ] 18 | AddressAlign: 0x1 19 | - Name: .bss 20 | Type: SHT_NOBITS 21 | Flags: [ SHF_WRITE, SHF_ALLOC ] 22 | AddressAlign: 0x1 23 | - Name: .comment 24 | Type: SHT_PROGBITS 25 | Flags: [ SHF_MERGE, SHF_STRINGS ] 26 | AddressAlign: 0x1 27 | EntSize: 0x1 28 | Content: 004743433A202844656269616E2031302E322E312D362B6275696C6432292031302E322E3120323032313031313000 29 | - Name: .note.GNU-stack 30 | Type: SHT_PROGBITS 31 | AddressAlign: 0x1 32 | ProgramHeaders: 33 | - Type: PT_LOAD 34 | Flags: [ PF_W, PF_R ] 35 | VAddr: 0x20000000 36 | Align: 0x00010000 37 | FileSize: 0x0 38 | MemSize: 0x08010000 39 | Offset: 0x00690000 40 | Symbols: 41 | - Name: 'null' 42 | Type: STT_FILE 43 | Index: SHN_ABS 44 | - Name: .text 45 | Type: STT_SECTION 46 | Section: .text 47 | - Name: .data 48 | Type: STT_SECTION 49 | Section: .data 50 | - Name: .bss 51 | Type: STT_SECTION 52 | Section: .bss 53 | - Name: .note.GNU-stack 54 | Type: STT_SECTION 55 | Section: .note.GNU-stack 56 | - Name: .comment 57 | Type: STT_SECTION 58 | Section: .comment 59 | ... 60 | 61 | # CHECK: FILE MAP: 62 | # CHECK: 000-040 64 [ELF Header] 63 | # CHECK: 040-078 56 [ELF Program Headers] 64 | # CHECK: 078-0a8 48 .comment 65 | # CHECK: 0a8-150 168 .symtab 66 | # CHECK: 150-180 48 .strtab 67 | # CHECK: 180-1c8 72 .shstrtab 68 | # CHECK: 1c8-408 576 [ELF Section Headers] 69 | # CHECK: VM MAP: 70 | # CHECK: 00000000-20000000 536870912 [-- Nothing mapped --] 71 | # CHECK: 20000000-28010000 134283264 [LOAD #0 [RW]] 72 | -------------------------------------------------------------------------------- /tests/elf/sections/shn-xindex.test: -------------------------------------------------------------------------------- 1 | # Tests two special cases for the ELF format: 2 | # - If the section count in the ELF headers is 0, then, the true value 3 | # is read out of section 0. 4 | # - If the section string index in the ELF headers is SHN_XINDEX, the 5 | # true value is read out of section 0. 6 | # 7 | # These special cases are documented here: 8 | # https://docs.oracle.com/cd/E19683-01/817-3677/chapter6-94076/index.html 9 | 10 | # RUN: %yaml2obj %s -o %t.obj 11 | # RUN: %bloaty --raw-map %t.obj | %FileCheck %s 12 | 13 | --- !ELF 14 | FileHeader: 15 | Class: ELFCLASS64 16 | Data: ELFDATA2LSB 17 | Type: ET_REL 18 | Machine: EM_X86_64 19 | EShNum: 0 20 | EShStrNdx: 0xffff ## SHN_XINDEX 21 | Sections: 22 | - Type: SHT_NULL 23 | Link: .shstrtab 24 | Size: 0x3 25 | ... 26 | 27 | # CHECK: FILE MAP: 28 | # CHECK: 000-040 64 [ELF Header] 29 | # CHECK: 040-041 1 .strtab 30 | # CHECK: 041-058 23 .shstrtab 31 | # CHECK: 058-118 192 [ELF Section Headers] 32 | 33 | # CHECK: VM MAP: 34 | -------------------------------------------------------------------------------- /tests/fuzz_driver.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); 22 | 23 | int main(int argc, char **argv) { 24 | for (int i = 1; i < argc; i++) { 25 | std::ifstream in(argv[i], std::ios_base::in | std::ios_base::binary); 26 | in.seekg(0, in.end); 27 | size_t length = in.tellg(); 28 | in.seekg (0, in.beg); 29 | std::cout << "Reading " << length << " bytes from " << argv[i] << std::endl; 30 | // Allocate exactly length bytes so that we reliably catch buffer overflows. 31 | std::vector bytes(length); 32 | in.read(bytes.data(), bytes.size()); 33 | assert(in); 34 | LLVMFuzzerTestOneInput(reinterpret_cast(bytes.data()), 35 | bytes.size()); 36 | std::cout << "Execution successful" << std::endl; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/fuzz_target.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "bloaty.h" 18 | #include "bloaty.pb.h" 19 | #include "strarr.h" 20 | 21 | using std::string_view; 22 | 23 | namespace bloaty { 24 | 25 | class StringPieceInputFile : public InputFile { 26 | public: 27 | StringPieceInputFile(string_view data) 28 | : InputFile("fake_StringPieceInputFile_file") { 29 | data_ = data; 30 | } 31 | 32 | bool TryOpen(std::string_view /* filename */, 33 | std::unique_ptr& file) override { 34 | file.reset(new StringPieceInputFile(data_)); 35 | return true; 36 | } 37 | }; 38 | 39 | class StringPieceInputFileFactory : public InputFileFactory { 40 | public: 41 | StringPieceInputFileFactory(string_view data) : data_(data) {} 42 | private: 43 | string_view data_; 44 | std::unique_ptr OpenFile( 45 | const std::string& /* filename */) const override { 46 | return std::unique_ptr(new StringPieceInputFile(data_)); 47 | } 48 | }; 49 | 50 | void RunBloaty(const InputFileFactory& factory, 51 | const std::string& data_source) { 52 | bloaty::RollupOutput output; 53 | bloaty::Options options; 54 | std::string error; 55 | options.add_data_source(data_source); 56 | options.add_filename("dummy_filename"); 57 | bloaty::BloatyMain(options, factory, &output, &error); 58 | } 59 | 60 | } // namespace bloaty 61 | 62 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 63 | const char *data2 = reinterpret_cast(data); 64 | bloaty::StringPieceInputFileFactory factory(string_view(data2, size)); 65 | 66 | // Try all of the data sources. 67 | RunBloaty(factory, "segments"); 68 | RunBloaty(factory, "sections"); 69 | RunBloaty(factory, "symbols"); 70 | RunBloaty(factory, "compileunits"); 71 | RunBloaty(factory, "inlines"); 72 | RunBloaty(factory, "armembers"); 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /tests/lit.cfg: -------------------------------------------------------------------------------- 1 | # -*- Python -*- 2 | 3 | import os 4 | import platform 5 | import subprocess 6 | 7 | import lit 8 | import lit.formats 9 | import lit.util 10 | 11 | ### Helper Functions 12 | 13 | def make_path(*args): 14 | return os.path.normpath(os.path.join(*args)) 15 | 16 | kIsWindows = platform.system() == 'Windows' 17 | 18 | ### 19 | 20 | config.name = 'bloaty' 21 | 22 | bloaty_src_root = getattr(config, 'bloaty_src_root', None) 23 | if not bloaty_src_root: 24 | lit_config.fatal("missing 'bloaty_src_root' key in the site specific config") 25 | bloaty_src_root = os.path.normpath(bloaty_src_root) 26 | 27 | bloaty_obj_root = getattr(config, 'bloaty_obj_root', None) 28 | if not bloaty_obj_root: 29 | lit_config.fatal("missing 'bloaty_obj_root' key in the site specific config") 30 | bloaty_obj_root = os.path.normpath(bloaty_obj_root) 31 | 32 | if not lit_config.params.get('bloaty', None): 33 | lit_config.fatal("missing parameter 'bloaty'") 34 | 35 | lit_config.note('Using bloaty: {}'.format(lit_config.params['bloaty'])) 36 | lit_config.note('Using FileCheck: {}'.format(config.filecheck_path)) 37 | lit_config.note('Using yaml2obj: {}'.format(config.yaml2obj_path)) 38 | 39 | use_lit_shell = os.environ.get('LIT_USE_INTERNAL_SHELL', kIsWindows) 40 | if not use_lit_shell: 41 | config.available_features.add('shell') 42 | 43 | config.test_format = lit.formats.ShTest(execute_external = False) 44 | 45 | config.suffixes = ['.test'] 46 | config.excludes = ['testdata'] 47 | 48 | config.test_source_root = os.path.join(bloaty_src_root, 'tests') 49 | config.test_exec_root = os.path.join(bloaty_obj_root, 'tests') 50 | 51 | config.substitutions.append(('%FileCheck', config.filecheck_path)) 52 | config.substitutions.append(('%yaml2obj', config.yaml2obj_path)) 53 | config.substitutions.append(('%bloaty', lit_config.params['bloaty'])) 54 | -------------------------------------------------------------------------------- /tests/lit.site.cfg.in: -------------------------------------------------------------------------------- 1 | # -*- Python -*- 2 | 3 | import os 4 | 5 | config.bloaty_src_root = "@BLOATY_SRC_DIR@" 6 | config.bloaty_obj_root = "@BLOATY_OBJ_DIR@" 7 | 8 | config.filecheck_path = "@FILECHECK_EXECUTABLE@" 9 | config.yaml2obj_path = "@YAML2OBJ_EXECUTABLE@" 10 | 11 | if not config.test_exec_root: 12 | config.test_exec_root = os.path.dirname(os.path.realpath(__file__)) 13 | lit_config.load_config(config, "@BLOATY_SRC_DIR@/tests/lit.cfg") 14 | -------------------------------------------------------------------------------- /tests/strarr.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BLOATY_TESTS_STRARR_H_ 16 | #define BLOATY_TESTS_STRARR_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | // For constructing arrays of strings in the slightly peculiar format 23 | // required by execve(). 24 | class StrArr { 25 | public: 26 | explicit StrArr(const std::vector& strings) 27 | : size_(strings.size()), array_(new char*[size_ + 1]) { 28 | array_[size_] = NULL; 29 | for (size_t i = 0; i < strings.size(); i++) { 30 | // Can't use c_str() directly because array_ is not const char*. 31 | array_[i] = strdup(strings[i].c_str()); 32 | } 33 | } 34 | 35 | ~StrArr() { 36 | // unique_ptr frees the array of pointers but not the pointed-to strings. 37 | for (int i = 0; i < size_; i++) { 38 | free(array_[i]); 39 | } 40 | } 41 | 42 | char **get() const { return array_.get(); } 43 | 44 | size_t size() const { return size_; } 45 | 46 | private: 47 | size_t size_; 48 | // Can't use vector because execve() takes ptr to non-const array. 49 | std::unique_ptr array_; 50 | }; 51 | 52 | #endif // BLOATY_TESTS_STRARR_H_ 53 | -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt: -------------------------------------------------------------------------------- 1 | segments vmsize filesize 2 | .rdata 7840 8192 3 | .data 5608 512 4 | .text 5000 5120 5 | .pdata 552 1024 6 | .reloc 40 512 7 | [PE Headers] 496 496 8 | [Unmapped] 0 328 9 | [PE Section Headers] 200 200 10 | -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt: -------------------------------------------------------------------------------- 1 | sections vmsize filesize 2 | .rdata 7840 8192 3 | .data 5608 512 4 | .text 5000 5120 5 | .pdata 552 1024 6 | .reloc 40 512 7 | [PE Headers] 496 496 8 | [Unmapped] 0 328 9 | [PE Section Headers] 200 200 10 | -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.pdb -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-15.0-foo-bar.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt: -------------------------------------------------------------------------------- 1 | segments vmsize filesize 2 | .text 3587 4096 3 | .rdata 2520 2560 4 | .data 1592 512 5 | .pdata 408 512 6 | .reloc 24 512 7 | [PE Headers] 496 496 8 | [Unmapped] 0 328 9 | [PE Section Headers] 200 200 10 | -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt: -------------------------------------------------------------------------------- 1 | sections vmsize filesize 2 | .text 3587 4096 3 | .rdata 2520 2560 4 | .data 1592 512 5 | .pdata 408 512 6 | .reloc 24 512 7 | [PE Headers] 496 496 8 | [Unmapped] 0 328 9 | [PE Section Headers] 200 200 10 | -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt: -------------------------------------------------------------------------------- 1 | segments vmsize filesize 2 | .rdata 8236 8704 3 | .text 5340 5632 4 | .data 5624 512 5 | .pdata 588 1024 6 | .reloc 52 512 7 | [PE Headers] 496 496 8 | [Unmapped] 0 328 9 | [PE Section Headers] 200 200 10 | -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt: -------------------------------------------------------------------------------- 1 | sections vmsize filesize 2 | .rdata 8236 8704 3 | .text 5340 5632 4 | .data 5624 512 5 | .pdata 588 1024 6 | .reloc 52 512 7 | [PE Headers] 496 496 8 | [Unmapped] 0 328 9 | [PE Section Headers] 200 200 10 | -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.pdb -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-16.0-foo-bar.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt: -------------------------------------------------------------------------------- 1 | segments vmsize filesize 2 | .text 3592 4096 3 | .rdata 2680 3072 4 | .data 1608 512 5 | .pdata 432 512 6 | .reloc 36 512 7 | [PE Headers] 496 496 8 | [Unmapped] 0 328 9 | [PE Section Headers] 200 200 10 | -------------------------------------------------------------------------------- /tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt: -------------------------------------------------------------------------------- 1 | sections vmsize filesize 2 | .text 3592 4096 3 | .rdata 2680 3072 4 | .data 1608 512 5 | .pdata 432 512 6 | .reloc 36 512 7 | [PE Headers] 496 496 8 | [Unmapped] 0 328 9 | [PE Section Headers] 200 200 10 | -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt: -------------------------------------------------------------------------------- 1 | segments vmsize filesize 2 | .rdata 6724 7168 3 | .data 4912 512 4 | .text 4268 4608 5 | .reloc 488 512 6 | [PE Headers] 480 480 7 | [Unmapped] 0 384 8 | [PE Section Headers] 160 160 9 | -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt: -------------------------------------------------------------------------------- 1 | sections vmsize filesize 2 | .rdata 6724 7168 3 | .data 4912 512 4 | .text 4268 4608 5 | .reloc 488 512 6 | [PE Headers] 480 480 7 | [Unmapped] 0 384 8 | [PE Section Headers] 160 160 9 | -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.pdb -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-15.0-foo-bar.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt: -------------------------------------------------------------------------------- 1 | segments vmsize filesize 2 | .text 3172 3584 3 | .rdata 1772 2048 4 | .data 908 512 5 | .reloc 296 512 6 | [PE Headers] 496 496 7 | [Unmapped] 0 368 8 | [PE Section Headers] 160 160 9 | -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt: -------------------------------------------------------------------------------- 1 | sections vmsize filesize 2 | .text 3172 3584 3 | .rdata 1772 2048 4 | .data 908 512 5 | .reloc 296 512 6 | [PE Headers] 496 496 7 | [Unmapped] 0 368 8 | [PE Section Headers] 160 160 9 | -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt: -------------------------------------------------------------------------------- 1 | segments vmsize filesize 2 | .rdata 6944 7168 3 | .text 4716 5120 4 | .data 4912 512 5 | .reloc 544 1024 6 | [PE Headers] 488 488 7 | [Unmapped] 0 376 8 | [PE Section Headers] 160 160 9 | -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt: -------------------------------------------------------------------------------- 1 | sections vmsize filesize 2 | .rdata 6944 7168 3 | .text 4716 5120 4 | .data 4912 512 5 | .reloc 544 1024 6 | [PE Headers] 488 488 7 | [Unmapped] 0 376 8 | [PE Section Headers] 160 160 9 | -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.pdb -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-16.0-foo-bar.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt: -------------------------------------------------------------------------------- 1 | segments vmsize filesize 2 | .text 3360 3584 3 | .rdata 1812 2048 4 | .data 912 512 5 | .reloc 312 512 6 | [PE Headers] 488 488 7 | [Unmapped] 0 376 8 | [PE Section Headers] 160 160 9 | -------------------------------------------------------------------------------- /tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt: -------------------------------------------------------------------------------- 1 | sections vmsize filesize 2 | .text 3360 3584 3 | .rdata 1812 2048 4 | .data 912 512 5 | .reloc 312 512 6 | [PE Headers] 488 488 7 | [Unmapped] 0 376 8 | [PE Section Headers] 160 160 9 | -------------------------------------------------------------------------------- /tests/testdata/bar.c: -------------------------------------------------------------------------------- 1 | 2 | int bar_x[1000] = {1}; 3 | int bar_y = 1; 4 | int bar_z = 0; 5 | int bar_func() { return bar_y / 17; } 6 | -------------------------------------------------------------------------------- /tests/testdata/foo.c: -------------------------------------------------------------------------------- 1 | 2 | int foo_x[1000] = {0}; 3 | int foo_y = 0; 4 | int foo_func() { return foo_y / 17; } 5 | -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/0034ecacd5427aafc6b97413da2053b36de5059f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/0034ecacd5427aafc6b97413da2053b36de5059f -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/0153168d08d78a4eb486cdd421b3efd6a4e12844: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/0153168d08d78a4eb486cdd421b3efd6a4e12844 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/04deff284542b1271c7ed6da11b4389342793f4d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/04deff284542b1271c7ed6da11b4389342793f4d -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/0512fc56ee361da71476c098b91d1081e5dbc4ad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/0512fc56ee361da71476c098b91d1081e5dbc4ad -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/0c7d074fcd0d6863b497f6137c6cacffc59c2ae8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/0c7d074fcd0d6863b497f6137c6cacffc59c2ae8 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/0efb04f81a05b500031405eccae9d7e8ea0721c5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/0efb04f81a05b500031405eccae9d7e8ea0721c5 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/0f6736109fcd5db53450385486c4586f884feb23: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/0f6736109fcd5db53450385486c4586f884feb23 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/110a37d69bfc8f6da2f8180e907d7d2f12da1eb2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/110a37d69bfc8f6da2f8180e907d7d2f12da1eb2 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/14f1751b6ceb6aa262bced1c928c11d565c3d913: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/14f1751b6ceb6aa262bced1c928c11d565c3d913 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/15c502b13029920e528a2982fc1559689764aaf8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/15c502b13029920e528a2982fc1559689764aaf8 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/1846aea81a4e97327d5e82c8ab9e6d4c43bffee3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/1846aea81a4e97327d5e82c8ab9e6d4c43bffee3 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/1930321f0302e111b64e38b8456ef8473f3e71d8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/1930321f0302e111b64e38b8456ef8473f3e71d8 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/1bfe776624349462cb1d818443af106215021470: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/1bfe776624349462cb1d818443af106215021470 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/2215ecf59e25dfb7b946e25bf9cbb9b6c862563f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/2215ecf59e25dfb7b946e25bf9cbb9b6c862563f -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/22a284684c8b3f13e6070870dfb21d6453c7819e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/22a284684c8b3f13e6070870dfb21d6453c7819e -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/23350c9dafa9b9a1e2a2524a2b173fdec00037ab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/23350c9dafa9b9a1e2a2524a2b173fdec00037ab -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/270dcbc8975aaff7d869faa520be996460e6f7be: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/270dcbc8975aaff7d869faa520be996460e6f7be -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/2877069c49bf5773d158de6911842a58768b74c3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/2877069c49bf5773d158de6911842a58768b74c3 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/28d7fbe0ff87b53a011656f9e3c9c3aeb2ce2018: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/28d7fbe0ff87b53a011656f9e3c9c3aeb2ce2018 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/2eb47f37b3b0b4bb84cc55d0125d9bb7d176b1c5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/2eb47f37b3b0b4bb84cc55d0125d9bb7d176b1c5 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/2f6f7647f2e81f50a3f787dda064cffe03354aa8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/2f6f7647f2e81f50a3f787dda064cffe03354aa8 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/2fd5be6e7a99d71434a756a4d59a8d44db4942bb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/2fd5be6e7a99d71434a756a4d59a8d44db4942bb -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/3115b1163086c5904008b9a5d17a761863910214: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/3115b1163086c5904008b9a5d17a761863910214 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/327c150b2d13636bb3ea5129cb58af30675e5599: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/327c150b2d13636bb3ea5129cb58af30675e5599 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/37209ceacf21ce2796c98824dc9be60b876274a2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/37209ceacf21ce2796c98824dc9be60b876274a2 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/3e96523b6d0025b39ddd0a771fc9f99dd1590877: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/3e96523b6d0025b39ddd0a771fc9f99dd1590877 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/3f3c4745b7053aca15608204a7592bac44d690cb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/3f3c4745b7053aca15608204a7592bac44d690cb -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/412f1573ff1a9675377481456d8809a850d03f1b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/412f1573ff1a9675377481456d8809a850d03f1b -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/42f2cd88cae45b6add339ed2c2a9074ff55d9db0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/42f2cd88cae45b6add339ed2c2a9074ff55d9db0 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/459ef92fc33d1d9fc6048f293bab5ddb584f94a4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/459ef92fc33d1d9fc6048f293bab5ddb584f94a4 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/48c3f1ae3089b0644c6af799af2ae94ee1c5ad30: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/48c3f1ae3089b0644c6af799af2ae94ee1c5ad30 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/4e6b7729619f66a429dd9ef88d186dd37c42d8ca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/4e6b7729619f66a429dd9ef88d186dd37c42d8ca -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/53a2d35a2dfe33981111fce5c8fb6514dd9570cb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/53a2d35a2dfe33981111fce5c8fb6514dd9570cb -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/57354041fcdfcc3613a0762adfd5189ca60abc80: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/57354041fcdfcc3613a0762adfd5189ca60abc80 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/5a90c59187664f79cdf1ded1a6eef6854ddd9a07: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/5a90c59187664f79cdf1ded1a6eef6854ddd9a07 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/5b69d5a1654e6f7a84538fa8af16414ea44a00f5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/5b69d5a1654e6f7a84538fa8af16414ea44a00f5 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/5e8ec9cbd600dcc8f6dc5eafaf34226706378b60: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/5e8ec9cbd600dcc8f6dc5eafaf34226706378b60 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/64779227c42248607f46879f9e4007e66ee68269: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/64779227c42248607f46879f9e4007e66ee68269 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/6511ded4f638705a5cdd071d7e21cb4febb7234c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/6511ded4f638705a5cdd071d7e21cb4febb7234c -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/66845a4bce637e02379f5dbf1b860ceb7725a96d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/66845a4bce637e02379f5dbf1b860ceb7725a96d -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/67630fad767a6918501667f56f09793d399a104a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/67630fad767a6918501667f56f09793d399a104a -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/6b45a7d45ef354eb2d549918a804abc1e6d42d05: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/6b45a7d45ef354eb2d549918a804abc1e6d42d05 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/6d2975ba5e8ad75fb4e743d96a279001b9ecd0e3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/6d2975ba5e8ad75fb4e743d96a279001b9ecd0e3 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/6d385d65872fa08e194a8b806ccfd87e49f5a554: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/6d385d65872fa08e194a8b806ccfd87e49f5a554 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/6d7db4d97103830cd33688f18b7c6944218b58f8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/6d7db4d97103830cd33688f18b7c6944218b58f8 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/6ecf640685258c2bc0960ab1a797ba2db10ffd63: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/6ecf640685258c2bc0960ab1a797ba2db10ffd63 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/6f0a1ec2ebc980c9296486ad1a5b8a564549aa9a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/6f0a1ec2ebc980c9296486ad1a5b8a564549aa9a -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/6fa62db4fbfc54538513558d0886ff8ae74e58ed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/6fa62db4fbfc54538513558d0886ff8ae74e58ed -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/70619c7a97d684b6dd6dddfb62782ae40bc91370: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/70619c7a97d684b6dd6dddfb62782ae40bc91370 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/7069a01603ddcf775682ee40d6814f4e5559bb5a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/7069a01603ddcf775682ee40d6814f4e5559bb5a -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/739b5ce9def832d301c95cfa6d1a9c6e9d46c73d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/739b5ce9def832d301c95cfa6d1a9c6e9d46c73d -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/7b06150aa15f8aed1abd7a93f1772b893efc150e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/7b06150aa15f8aed1abd7a93f1772b893efc150e -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/7c06c448cd75d4af6621f578d6d8cb35d2e5279e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/7c06c448cd75d4af6621f578d6d8cb35d2e5279e -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/7d09e7259aa0fb3da736b98b94211f71a5e513e6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/7d09e7259aa0fb3da736b98b94211f71a5e513e6 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/7e290e80959e9f3b045387f7ec257182cb23721d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/7e290e80959e9f3b045387f7ec257182cb23721d -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/827e96b748c33f032574b9f2b7f084920feb76ab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/827e96b748c33f032574b9f2b7f084920feb76ab -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/84675e905d3771b59fd51f606bc2a14f549aba43: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/84675e905d3771b59fd51f606bc2a14f549aba43 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/8631458a27f52b7e3cdfb06a6bde899901bfd3ac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/8631458a27f52b7e3cdfb06a6bde899901bfd3ac -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/86a3d4b71ee172cd476d035fb9445bcbb835d92a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/86a3d4b71ee172cd476d035fb9445bcbb835d92a -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/8be73e77c819315082ac4f40acc964ddfa7be6fa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/8be73e77c819315082ac4f40acc964ddfa7be6fa -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/8fc314d43f2d412e20a822b5f595bf61005342a9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/8fc314d43f2d412e20a822b5f595bf61005342a9 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/91acbe9b1ef167d88e8a57f16db2aa740865accd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/91acbe9b1ef167d88e8a57f16db2aa740865accd -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/922103ecc5f70b4235b20e30ce0a2e895ead8251: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/922103ecc5f70b4235b20e30ce0a2e895ead8251 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/9b5a5fa4a46bcca17df149785daf9cd14f1c0443: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/9b5a5fa4a46bcca17df149785daf9cd14f1c0443 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/9e079b888e5d223ef0bebf13ce1e26ebdd82752a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/9e079b888e5d223ef0bebf13ce1e26ebdd82752a -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/a22fdce1317617bf89f3283cbd44ef490a57b5e2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/a22fdce1317617bf89f3283cbd44ef490a57b5e2 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/a493f77d0d04aaed2e2dca8256c9a5cc591aa8fa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/a493f77d0d04aaed2e2dca8256c9a5cc591aa8fa -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/a4d1a2b246e0a1f133774daa28328c0d7ce5c3e5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/a4d1a2b246e0a1f133774daa28328c0d7ce5c3e5 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/a4da3e6bc07539aece56d12b2e15b89edd842fd8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/a4da3e6bc07539aece56d12b2e15b89edd842fd8 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/a64d39a8957a4f4c7012f78b41caa8e5f3f4e484: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/a64d39a8957a4f4c7012f78b41caa8e5f3f4e484 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/a69662c2423b5a1d1859f7981c9e88c4f821b0b7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/a69662c2423b5a1d1859f7981c9e88c4f821b0b7 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/a743522a548f6321b69ee5081ce898ec5e4b9c23: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/a743522a548f6321b69ee5081ce898ec5e4b9c23 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/af0df3abd6ff306ca9161b6f6ebc96f21c6dfa98: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/af0df3abd6ff306ca9161b6f6ebc96f21c6dfa98 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/b3a904cebb1d3070ca96cf70ec0b9ef5d1612a45: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/b3a904cebb1d3070ca96cf70ec0b9ef5d1612a45 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/bf2cb5de1de6ca492f159dc3cce67cf88a6244aa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/bf2cb5de1de6ca492f159dc3cce67cf88a6244aa -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/c121e995dd4575473e468801b301da0f219f5de7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/c121e995dd4575473e468801b301da0f219f5de7 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/c561ab1d99f16a04898518914dd1cea4afa7e358: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/c561ab1d99f16a04898518914dd1cea4afa7e358 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/c98c037db24035a40d40f91084a56f470bb6fbc5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/c98c037db24035a40d40f91084a56f470bb6fbc5 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/cd838035892825e361fe0f936f93fa62aaf2fab1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/cd838035892825e361fe0f936f93fa62aaf2fab1 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/cdeac0baddcbd150bfec97b7b88bff74f73e99f5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/cdeac0baddcbd150bfec97b7b88bff74f73e99f5 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-4796943898771456: -------------------------------------------------------------------------------- 1 | asm -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-4987539889979392: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-4987539889979392 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-5640071541161984: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-5640071541161984 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-5711765729443840: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-5711765729443840 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-6500838179733504: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-6500838179733504 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-6527509465268224: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/clusterfuzz-testcase-minimized-fuzz_target-6527509465268224 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/d1128451375207da064d0f332e840af933280610: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/d1128451375207da064d0f332e840af933280610 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/d3cc4e4dddf87cb0d41135b7a22d03fc4ec11bbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/d3cc4e4dddf87cb0d41135b7a22d03fc4ec11bbc -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/daebef8f49a59b71cf57d4771b09f9f8545b83d8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/daebef8f49a59b71cf57d4771b09f9f8545b83d8 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/dda6875f2313476f402e9a283ecaf2b50cfae316: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/dda6875f2313476f402e9a283ecaf2b50cfae316 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/df7a639969efbe5943b6a7fa5eff4f732a50a4f6: -------------------------------------------------------------------------------- 1 | tt; -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/e08b7c26f946f4761f2cecdc81f4e5e7651db9a7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/e08b7c26f946f4761f2cecdc81f4e5e7651db9a7 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/e33d3e649729bea900f870b0cd5335f312d9ed42: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/e33d3e649729bea900f870b0cd5335f312d9ed42 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/e4a3653bac41c8f39cc625286daa813e0ce603b0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/e4a3653bac41c8f39cc625286daa813e0ce603b0 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/e4c4e1789c10bbfe8ed1c05522483332bf2538f8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/e4c4e1789c10bbfe8ed1c05522483332bf2538f8 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/f0ac70f708130bb9cc4aba5ebe1a3c500c4ea11a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/f0ac70f708130bb9cc4aba5ebe1a3c500c4ea11a -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/f5d4fb20f43ef7131ed49ff29f5c1bee69070ff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/f5d4fb20f43ef7131ed49ff29f5c1bee69070ff2 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/fc88742708813d5dd57936fad4c6e9bd6ed125ac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/fc88742708813d5dd57936fad4c6e9bd6ed125ac -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/testcase-4665949898276864: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/testcase-4665949898276864 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/testcase-5207237867470848: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/testcase-5207237867470848 -------------------------------------------------------------------------------- /tests/testdata/fuzz_corpus/testcase-5896363763695616: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/fuzz_corpus/testcase-5896363763695616 -------------------------------------------------------------------------------- /tests/testdata/linux-x86/01-empty.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86/01-empty.o -------------------------------------------------------------------------------- /tests/testdata/linux-x86/02-simple.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86/02-simple.o -------------------------------------------------------------------------------- /tests/testdata/linux-x86/03-simple.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86/03-simple.a -------------------------------------------------------------------------------- /tests/testdata/linux-x86/04-simple.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86/04-simple.so -------------------------------------------------------------------------------- /tests/testdata/linux-x86/05-binary.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86/05-binary.bin -------------------------------------------------------------------------------- /tests/testdata/linux-x86/06-diff.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86/06-diff.a -------------------------------------------------------------------------------- /tests/testdata/linux-x86/07-binary-stripped.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86/07-binary-stripped.bin -------------------------------------------------------------------------------- /tests/testdata/linux-x86_64/01-empty.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86_64/01-empty.o -------------------------------------------------------------------------------- /tests/testdata/linux-x86_64/02-simple.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86_64/02-simple.o -------------------------------------------------------------------------------- /tests/testdata/linux-x86_64/03-simple.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86_64/03-simple.a -------------------------------------------------------------------------------- /tests/testdata/linux-x86_64/04-simple.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86_64/04-simple.so -------------------------------------------------------------------------------- /tests/testdata/linux-x86_64/05-binary.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86_64/05-binary.bin -------------------------------------------------------------------------------- /tests/testdata/linux-x86_64/06-diff.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86_64/06-diff.a -------------------------------------------------------------------------------- /tests/testdata/linux-x86_64/07-binary-stripped.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86_64/07-binary-stripped.bin -------------------------------------------------------------------------------- /tests/testdata/linux-x86_64/oldbloaty.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/linux-x86_64/oldbloaty.bin -------------------------------------------------------------------------------- /tests/testdata/main.c: -------------------------------------------------------------------------------- 1 | int main() {} -------------------------------------------------------------------------------- /tests/testdata/make_all_msvc_test_files.bat: -------------------------------------------------------------------------------- 1 | 2 | @if not defined _echo echo off 3 | 4 | set VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" 5 | 6 | for /f "usebackq delims=" %%i in (`%VSWHERE% -version [15.0^,17.0^) -property installationPath`) do ( 7 | if exist "%%i\Common7\Tools\vsdevcmd.bat" ( 8 | for %%A in (x86 x64) do ( 9 | SETLOCAL 10 | call "%%i\Common7\Tools\vsdevcmd.bat" -arch=%%A 11 | ECHO Building VS %VisualStudioVersion% %%A 12 | call make_msvc_test_files.bat PE\%%A 13 | ENDLOCAL 14 | ) 15 | ) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /tests/testdata/make_msvc_test_files.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%1"=="" goto noargs 4 | 5 | pushd %1 6 | 7 | @REM /Gm- disables minimal rebuild, /O1 favor size, /MD selects external runtime, 8 | @REM /GL enable cross-module optimization 9 | set CL_COMMON_FLAGS=/nologo /Gm- /O1 /MD /GL 10 | 11 | 12 | call :make_obj ..\..\foo.c 13 | call :make_obj ..\..\bar.c 14 | call :make_obj ..\..\main.c 15 | 16 | call :make_dll msvc-%VisualStudioVersion%-foo-bar.dll foo.obj bar.obj 17 | call :make_binary_with_pdb msvc-%VisualStudioVersion%-foo-bar-main-cv.bin msvc-%VisualStudioVersion%-foo-bar-main-cv.pdb foo.obj bar.obj main.obj 18 | 19 | goto cleanup 20 | 21 | :make_dll: 22 | for /f "tokens=1,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b 23 | cl %CL_COMMON_FLAGS% /LD %ALL_BUT_FIRST% /link /OUT:%1 24 | exit /B 0 25 | 26 | :make_binary_with_pdb: 27 | for /f "tokens=2,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b 28 | cl %CL_COMMON_FLAGS% %ALL_BUT_FIRST% /link /OUT:%1 /PDB:%2 /DEBUG 29 | exit /B 0 30 | 31 | :make_obj: 32 | cl %CL_COMMON_FLAGS% /c %1 33 | exit /B 0 34 | 35 | :noargs: 36 | echo Usage: make_test_files.bat ^ 37 | 38 | :cleanup: 39 | 40 | del foo.obj 41 | del bar.obj 42 | del main.obj 43 | 44 | popd 45 | -------------------------------------------------------------------------------- /tests/testdata/make_test_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2016 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | if [ "$#" == "0" ] ; then 17 | echo "Usage: make_test_files.sh " 18 | exit 1 19 | fi 20 | 21 | cd $1 22 | OUTPUT_DIR=`pwd` 23 | TMP=`mktemp -d` 24 | CC="${CC:-cc}" 25 | echo Writing output to $OUTPUT_DIR 26 | echo Working in $TMP 27 | cd $TMP 28 | 29 | function publish() { 30 | echo $1 31 | cp $1 $OUTPUT_DIR 32 | } 33 | 34 | function make_tmp_obj() { 35 | FILE=$1 36 | CONTENTS="$2" 37 | CFILE=`basename $1`.c 38 | echo "$CONTENTS" > $CFILE 39 | $CC -g -fPIC -o $FILE -c $CFILE 40 | } 41 | 42 | function make_obj() { 43 | FILE=$1 44 | CONTENTS="$2" 45 | make_tmp_obj $FILE "$CONTENTS" 46 | publish $FILE 47 | } 48 | 49 | function make_ar() { 50 | FILE=$1 51 | shift 52 | ar rcs $FILE "$@" 53 | publish $FILE 54 | } 55 | 56 | function make_so() { 57 | FILE=$1 58 | shift 59 | $CC -g -shared -o $FILE "$@" 60 | publish $FILE 61 | } 62 | 63 | function make_binary() { 64 | FILE=$1 65 | shift 66 | $CC -o $FILE "$@" 67 | publish $FILE 68 | } 69 | 70 | make_obj "01-empty.o" "" 71 | 72 | make_obj "02-simple.o" " 73 | #include 74 | uint64_t bss_a = 0; 75 | uint32_t bss_b = 0; 76 | uint64_t data_a = 1; 77 | uint32_t data_b = 2; 78 | const uint64_t rodata_a = 1; 79 | const uint32_t rodata_b = 2; 80 | uint32_t func1() { return bss_b / 17; } 81 | uint32_t func2() { return data_b / 17; }" 82 | 83 | make_tmp_obj "foo.o" " 84 | int foo_x[1000] = {0}; 85 | int foo_y = 0; 86 | int foo_func() { return foo_y / 17; } 87 | " 88 | 89 | make_tmp_obj "bar.o" " 90 | int bar_x[1000] = {1}; 91 | int bar_y = 1; 92 | int bar_z = 0; 93 | int bar_func() { return bar_y / 17; } 94 | " 95 | 96 | make_tmp_obj "a_filename_longer_than_sixteen_chars.o" " 97 | int long_filename_x[3] = {1}; 98 | int long_filename_y = 2; 99 | " 100 | 101 | make_ar "03-simple.a" "foo.o" "bar.o" "a_filename_longer_than_sixteen_chars.o" 102 | make_so "04-simple.so" "foo.o" "bar.o" 103 | 104 | make_tmp_obj "main.o" "int main() {}" 105 | 106 | make_binary "05-binary.bin" "foo.o" "bar.o" "main.o" 107 | 108 | # Make an object like foo.o but with different sizes. 109 | 110 | make_tmp_obj "foo2.o" " 111 | int foo_x[500] = {0}; 112 | long long foo_y = 0; 113 | int foo_func() { return foo_y / 17 * 37 / 21; } 114 | " 115 | 116 | make_ar "06-diff.a" "foo2.o" "bar.o" "a_filename_longer_than_sixteen_chars.o" 117 | 118 | cp "05-binary.bin" "07-binary-stripped.bin" 119 | strip "07-binary-stripped.bin" 120 | publish "07-binary-stripped.bin" 121 | -------------------------------------------------------------------------------- /tests/testdata/misc/01-no-sections.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/misc/01-no-sections.bin -------------------------------------------------------------------------------- /tests/testdata/misc/02-section-count-overflow.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/misc/02-section-count-overflow.o -------------------------------------------------------------------------------- /tests/testdata/misc/03-small-binary-that-crashed-inlines.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/misc/03-small-binary-that-crashed-inlines.bin -------------------------------------------------------------------------------- /tests/testdata/misc/04-go-binary-with-ref-addr.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/misc/04-go-binary-with-ref-addr.bin -------------------------------------------------------------------------------- /tests/testdata/misc/05-implicit-const-and-line-strp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/bloaty/3f36edba803388e98de51647ca0a23e174dc316f/tests/testdata/misc/05-implicit-const-and-line-strp.bin -------------------------------------------------------------------------------- /tests/wasm/active_seg.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: %bloaty -d symbols --raw-map %t.obj | %FileCheck %s 3 | 4 | --- !WASM 5 | FileHeader: 6 | Version: 0x1 7 | Sections: 8 | - Type: MEMORY 9 | Memories: 10 | - Flags: [ HAS_MAX ] 11 | Minimum: 0x2 12 | Maximum: 0x2 13 | - Type: EXPORT 14 | Exports: 15 | - Name: memory 16 | Kind: MEMORY 17 | Index: 0 18 | - Type: DATA 19 | Segments: 20 | - SectionOffset: 3 21 | InitFlags: 1 22 | Content: '03000000' 23 | - SectionOffset: 9 24 | InitFlags: 1 25 | Content: EFBEADDE 26 | - SectionOffset: 15 27 | InitFlags: 1 28 | Content: '05000000' 29 | - Type: CUSTOM 30 | Name: name 31 | DataSegmentNames: 32 | - Index: 0 33 | Name: .data.global2 34 | - Index: 1 35 | Name: .data.global3 36 | - Index: 2 37 | Name: .data.global4 38 | 39 | ... 40 | 41 | # Check output for active data segments 42 | 43 | # Data section 44 | # CHECK: 29-2f 6 .data.global2 45 | # CHECK: 2f-35 6 .data.global3 46 | # CHECK: 35-3b 6 .data.global4 47 | -------------------------------------------------------------------------------- /tests/wasm/sourcemap_compileunits.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: echo "{\"version\": 3, \"sources\": [\"test1.java\",\"test2.java\"], \"names\": [], \"mappings\": \"QAEI,Y,QACF,Y,oBACA,Y,QCFE,Y\"}" > %t.map 3 | # RUN: %bloaty --raw-map %t.obj --source-map=./sourcemap.wasm.map=%t.map -d compileunits | %FileCheck %s 4 | 5 | --- !WASM 6 | FileHeader: 7 | Version: 0x1 8 | Sections: 9 | - Type: CODE 10 | Functions: 11 | - Index: 0 12 | Locals: 13 | - Type: I32 14 | Count: 13 15 | Body: 41002100200028028880808000210141052102200120026A210341002104200428028C808080002105200320056A2106410021072007280280808080002108200820066A21094100210A200A200936028080808000418480808000210B200B210C200C0F0B 16 | - Type: CUSTOM 17 | Name: sourceMappingURL 18 | # ./sourcemap.wasm.map 19 | Payload: 142E2F736F757263656D61702E7761736D2E6D6170 20 | 21 | # CHECK: FILE MAP: 22 | # CHECK: 00-08 8 [WASM Header] 23 | # Note: Due to IsShortFallback, the 8 byte fallback (from mapping 'Y' to 'QACF') is considered part of the following file. 24 | # This actually covers 3 segment ranges: QAEI->Y, Y->QACF (short fallback), and QACF->Y. 25 | # CHECK: 08-28 32 test1.java 26 | # CHECK: 28-3c 20 [section Code] 27 | # CHECK: 3c-50 20 test1.java 28 | # CHECK: 50-5c 12 test2.java 29 | # CHECK: 5c-78 28 [section Code] 30 | # CHECK: 78-a4 44 [section sourceMappingURL] 31 | 32 | -------------------------------------------------------------------------------- /tests/wasm/sourcemap_diff.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # Make a copy of the same Wasm binary, with the same sourceMappingURL. This case 3 | # tests that we can handle multiple source maps keyed by file name. 4 | # RUN: cp %t.obj %t2.obj 5 | # RUN: echo "{\"version\": 3, \"sources\": [\"test1.java\"], \"names\": [], \"mappings\": \"QAEI,gC\"}" > %t.map 6 | # RUN: echo "{\"version\": 3, \"sources\": [\"test2.java\"], \"names\": [], \"mappings\": \"QAEI,gC\"}" > %t2.map 7 | # RUN: %bloaty --raw-map %t.obj --source-map=%t.obj=%t.map --source-map=%t2.obj=%t2.map -- %t2.obj -d compileunits | %FileCheck %s 8 | 9 | --- !WASM 10 | FileHeader: 11 | Version: 0x1 12 | Sections: 13 | - Type: CODE 14 | Functions: 15 | - Index: 0 16 | Locals: 17 | - Type: I32 18 | Count: 13 19 | Body: 41002100200028028880808000210141052102200120026A210341002104200428028C808080002105200320056A2106410021072007280280808080002108200820066A21094100210A200A200936028080808000418480808000210B200B210C200C0F0B 20 | - Type: CUSTOM 21 | Name: sourceMappingURL 22 | # ./sourcemap.wasm.map 23 | Payload: 142E2F736F757263656D61702E7761736D2E6D6170 24 | 25 | # CHECK: FILE MAP: 26 | # CHECK: 00-08 8 [WASM Header] 27 | # CHECK: 08-28 32 test1.java 28 | # CHECK: 28-78 80 [section Code] 29 | # CHECK: 78-a4 44 [section sourceMappingURL] 30 | 31 | # CHECK: FILE MAP: 32 | # CHECK: 00-08 8 [WASM Header] 33 | # CHECK: 08-28 32 test2.java 34 | # CHECK: 28-78 80 [section Code] 35 | # CHECK: 78-a4 44 [section sourceMappingURL] 36 | 37 | -------------------------------------------------------------------------------- /tests/wasm/sourcemap_inlines.test: -------------------------------------------------------------------------------- 1 | # RUN: %yaml2obj %s -o %t.obj 2 | # RUN: echo "{\"version\": 3, \"sources\": [\"test1.java\",\"test2.java\"], \"names\": [], \"mappings\": \"QAEI,Y,QACF,Y,oBACA,Y,QCFE,Y\"}" > %t.map 3 | # RUN: %bloaty --raw-map %t.obj --source-map=./sourcemap.wasm.map=%t.map -d inlines | %FileCheck %s 4 | 5 | --- !WASM 6 | FileHeader: 7 | Version: 0x1 8 | Sections: 9 | - Type: CODE 10 | Functions: 11 | - Index: 0 12 | Locals: 13 | - Type: I32 14 | Count: 13 15 | Body: 41002100200028028880808000210141052102200120026A210341002104200428028C808080002105200320056A2106410021072007280280808080002108200820066A21094100210A200A200936028080808000418480808000210B200B210C200C0F0B 16 | - Type: CUSTOM 17 | Name: sourceMappingURL 18 | # ./sourcemap.wasm.map 19 | Payload: 142E2F736F757263656D61702E7761736D2E6D6170 20 | 21 | # CHECK: FILE MAP: 22 | # CHECK: 00-08 8 [WASM Header] 23 | # Note: Due to IsShortFallback, the 8 byte fallback (from mapping 'Y' to 'QACF') is considered part of the following line. 24 | # This line covers 2 segment ranges: QAEI->Y and Y->QACF (short fallback). 25 | # CHECK: 08-1c 20 test1.java:2 26 | # CHECK: 1c-28 12 test1.java:3 27 | # CHECK: 28-3c 20 [section Code] 28 | # CHECK: 3c-50 20 test1.java:4 29 | # CHECK: 50-5c 12 test2.java:2 30 | # CHECK: 5c-78 28 [section Code] 31 | # CHECK: 78-a4 44 [section sourceMappingURL] 32 | 33 | -------------------------------------------------------------------------------- /third_party/darwin_xnu_macho/METADATA: -------------------------------------------------------------------------------- 1 | name: "Darwin XNU Mach-O headers" 2 | description: 3 | "A few header files from the Darwin XNU project. These define the Mach-O format." 4 | "They only contain struct and constant definitions (no code)." 5 | 6 | third_party { 7 | url { 8 | type: HOMEPAGE 9 | value: "https://opensource.apple.com/source/xnu/" 10 | } 11 | url { 12 | type: GIT 13 | value: "https://github.com/apple/darwin-xnu" 14 | } 15 | version: "0a798f6738bc1db01281fc08ae024145e84df927" 16 | last_upgrade_date { 17 | year: 2017 18 | month: 11 19 | day: 11 20 | } 21 | local_modifications: 22 | "Removed some includes and definitions not related to the Mach-O file format." 23 | } 24 | -------------------------------------------------------------------------------- /third_party/darwin_xnu_macho/mach-o/fat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #ifndef _MACH_O_FAT_H_ 24 | #define _MACH_O_FAT_H_ 25 | /* 26 | * This header file describes the structures of the file format for "fat" 27 | * architecture specific file (wrapper design). At the begining of the file 28 | * there is one fat_header structure followed by a number of fat_arch 29 | * structures. For each architecture in the file, specified by a pair of 30 | * cputype and cpusubtype, the fat_header describes the file offset, file 31 | * size and alignment in the file of the architecture specific member. 32 | * The padded bytes in the file to place each member on it's specific alignment 33 | * are defined to be read as zeros and can be left as "holes" if the file system 34 | * can support them as long as they read as zeros. 35 | * 36 | * All structures defined here are always written and read to/from disk 37 | * in big-endian order. 38 | */ 39 | 40 | /* 41 | * is needed here for the cpu_type_t and cpu_subtype_t types 42 | * and contains the constants for the possible values of these types. 43 | */ 44 | #include 45 | #include "third_party/darwin_xnu_macho/mach/machine.h" 46 | 47 | #define FAT_MAGIC 0xcafebabe 48 | #define FAT_CIGAM 0xbebafeca /* NXSwapLong(FAT_MAGIC) */ 49 | 50 | struct fat_header { 51 | uint32_t magic; /* FAT_MAGIC */ 52 | uint32_t nfat_arch; /* number of structs that follow */ 53 | }; 54 | 55 | struct fat_arch { 56 | cpu_type_t cputype; /* cpu specifier (int) */ 57 | cpu_subtype_t cpusubtype; /* machine specifier (int) */ 58 | uint32_t offset; /* file offset to this object file */ 59 | uint32_t size; /* size of this object file */ 60 | uint32_t align; /* alignment as a power of 2 */ 61 | }; 62 | 63 | #endif /* _MACH_O_FAT_H_ */ 64 | -------------------------------------------------------------------------------- /third_party/darwin_xnu_macho/mach/vm_prot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | /* 29 | * @OSF_COPYRIGHT@ 30 | */ 31 | /* 32 | * Mach Operating System 33 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 | * All Rights Reserved. 35 | * 36 | * Permission to use, copy, modify and distribute this software and its 37 | * documentation is hereby granted, provided that both the copyright 38 | * notice and this permission notice appear in all copies of the 39 | * software, derivative works or modified versions, and any portions 40 | * thereof, and that both notices appear in supporting documentation. 41 | * 42 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 | * 46 | * Carnegie Mellon requests users of this software to return to 47 | * 48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 | * School of Computer Science 50 | * Carnegie Mellon University 51 | * Pittsburgh PA 15213-3890 52 | * 53 | * any improvements or extensions that they make and grant Carnegie Mellon 54 | * the rights to redistribute these changes. 55 | */ 56 | /* 57 | */ 58 | /* 59 | * File: mach/vm_prot.h 60 | * Author: Avadis Tevanian, Jr., Michael Wayne Young 61 | * 62 | * Virtual memory protection definitions. 63 | * 64 | */ 65 | 66 | #ifndef _MACH_VM_PROT_H_ 67 | #define _MACH_VM_PROT_H_ 68 | 69 | /* 70 | * Types defined: 71 | * 72 | * vm_prot_t VM protection values. 73 | */ 74 | 75 | typedef int vm_prot_t; 76 | 77 | /* 78 | * Protection values, defined as bits within the vm_prot_t type 79 | */ 80 | 81 | #define VM_PROT_NONE ((vm_prot_t) 0x00) 82 | 83 | #define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */ 84 | #define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */ 85 | #define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */ 86 | 87 | /* 88 | * The default protection for newly-created virtual memory 89 | */ 90 | 91 | #define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE) 92 | 93 | /* 94 | * The maximum privileges possible, for parameter checking. 95 | */ 96 | 97 | #define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) 98 | 99 | /* 100 | * An invalid protection value. 101 | * Used only by memory_object_lock_request to indicate no change 102 | * to page locks. Using -1 here is a bad idea because it 103 | * looks like VM_PROT_ALL and then some. 104 | */ 105 | 106 | #define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08) 107 | 108 | /* 109 | * When a caller finds that he cannot obtain write permission on a 110 | * mapped entry, the following flag can be used. The entry will 111 | * be made "needs copy" effectively copying the object (using COW), 112 | * and write permission will be added to the maximum protections 113 | * for the associated entry. 114 | */ 115 | 116 | #define VM_PROT_COPY ((vm_prot_t) 0x10) 117 | 118 | 119 | /* 120 | * Another invalid protection value. 121 | * Used only by memory_object_data_request upon an object 122 | * which has specified a copy_call copy strategy. It is used 123 | * when the kernel wants a page belonging to a copy of the 124 | * object, and is only asking the object as a result of 125 | * following a shadow chain. This solves the race between pages 126 | * being pushed up by the memory manager and the kernel 127 | * walking down the shadow chain. 128 | */ 129 | 130 | #define VM_PROT_WANTS_COPY ((vm_prot_t) 0x10) 131 | 132 | #ifdef PRIVATE 133 | /* 134 | * The caller wants this memory region treated as if it had a valid 135 | * code signature. 136 | */ 137 | 138 | #define VM_PROT_TRUSTED ((vm_prot_t) 0x20) 139 | #endif /* PRIVATE */ 140 | 141 | /* 142 | * Another invalid protection value. 143 | * Indicates that the other protection bits are to be applied as a mask 144 | * against the actual protection bits of the map entry. 145 | */ 146 | #define VM_PROT_IS_MASK ((vm_prot_t) 0x40) 147 | 148 | /* 149 | * Another invalid protection value to support execute-only protection. 150 | * VM_PROT_STRIP_READ is a special marker that tells mprotect to not 151 | * set VM_PROT_READ. We have to do it this way because existing code 152 | * expects the system to set VM_PROT_READ if VM_PROT_EXECUTE is set. 153 | * VM_PROT_EXECUTE_ONLY is just a convenience value to indicate that 154 | * the memory should be executable and explicitly not readable. It will 155 | * be ignored on platforms that do not support this type of protection. 156 | */ 157 | #define VM_PROT_STRIP_READ ((vm_prot_t) 0x80) 158 | #define VM_PROT_EXECUTE_ONLY (VM_PROT_EXECUTE|VM_PROT_STRIP_READ) 159 | 160 | #endif /* _MACH_VM_PROT_H_ */ 161 | -------------------------------------------------------------------------------- /third_party/freebsd_elf/METADATA: -------------------------------------------------------------------------------- 1 | name: "FreeBSD ELF headers" 2 | description: 3 | "A few header files from the FreeBSD project. These define the ELF format." 4 | "They only contain struct and constant definitions (no code) and their" 5 | "contents are almost entirely derivable from the ELF standard." 6 | 7 | third_party { 8 | url { 9 | type: HOMEPAGE 10 | value: "https://www.freebsd.org" 11 | } 12 | url { 13 | type: GIT 14 | value: "https://github.com/freebsd/freebsd" 15 | } 16 | version: "303d759f5bc75c9f96d98b44b797faadb4a6a1c6" 17 | last_upgrade_date { 18 | year: 2016 19 | month: 10 20 | day: 27 21 | } 22 | local_modifications: 23 | "Uniquified header guards and fixed up include paths. " 24 | "Also changed to use stdint.h integer types. Removed any " 25 | "machine-specific definitions for now." 26 | } 27 | -------------------------------------------------------------------------------- /third_party/freebsd_elf/elf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 David E. O'Brien. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD$ 27 | */ 28 | 29 | /* 30 | * This is a Solaris compatibility header 31 | */ 32 | 33 | #ifndef _FREEBSD_ELF_SYS_ELF_H_ 34 | #define _FREEBSD_ELF_SYS_ELF_H_ 35 | 36 | /* Google-specific modifications follow. */ 37 | 38 | /* We'll use stdint.h for fixed-size integers. */ 39 | /* #include */ 40 | 41 | /* If we need any machine-specific definitions later we can import them here. */ 42 | /* #include */ 43 | 44 | #include "third_party/freebsd_elf/elf32.h" 45 | #include "third_party/freebsd_elf/elf64.h" 46 | 47 | #endif /* !_FREEBSD_ELF_SYS_ELF_H_ */ 48 | -------------------------------------------------------------------------------- /third_party/lief_pe/METADATA: -------------------------------------------------------------------------------- 1 | name: "LIEF: Library to Instrument Executable Formats (PE header)" 2 | description: 3 | "This contains structures as defined by the LIEF project to parse PE headers." 4 | "They only contain struct and constant definitions (no code) and their" 5 | "contents are almost entirely derivable from the PE standard." 6 | 7 | third_party { 8 | url { 9 | type: HOMEPAGE 10 | value: "https://lief.quarkslab.com/" 11 | } 12 | url { 13 | type: GIT 14 | value: "https://github.com/lief-project/LIEF" 15 | } 16 | version: "1a4a93c36fab9b0d198e85459b6afe0fb2b0157b" 17 | last_upgrade_date { 18 | year: 2021 19 | month: 4 20 | day: 3 21 | } 22 | local_modifications: 23 | "Renamed include/LIEF/PE/structures.inc to third_party/lief_pe/pe_structures.h" 24 | "Manually extracted some enums from include/LIEF/PE/enums.hpp.in to third_party/lief_pe/pe_enums.h" 25 | "Added license header to the file." 26 | } 27 | -------------------------------------------------------------------------------- /third_party/lief_pe/pe_enums.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 - 2021 R. Thomas 2 | * Copyright 2017 - 2021 Quarkslab 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | enum class PE_SECTION_TYPES : uint8_t { 19 | TEXT = 0, 20 | TLS = 1, 21 | IMPORT = 2, 22 | DATA = 3, 23 | BSS = 4, 24 | RESOURCE = 5, 25 | RELOCATION = 6, 26 | EXPORT = 7, 27 | DEBUG = 8, 28 | LOAD_CONFIG = 9, 29 | UNKNOWN = 10 30 | }; 31 | 32 | enum class PE_TYPE : uint16_t { 33 | PE32 = 0x10b, ///< 32bits 34 | PE32_PLUS = 0x20b ///< 64 bits 35 | }; 36 | 37 | --------------------------------------------------------------------------------