From 92201dae82cd4457c7ddb20992644e3daad81df2 Mon Sep 17 00:00:00 2001 From: Rich Mattes Date: Sun, 28 Jun 2020 00:02:08 -0400 Subject: [PATCH 01/11] Initial import --- .gitignore | 1 + bloaty-1.1-absl.patch | 65 +++++++++++++++++++++++++++++++++++++++++++ bloaty.spec | 63 +++++++++++++++++++++++++++++++++++++++++ sources | 1 + 4 files changed, 130 insertions(+) create mode 100644 .gitignore create mode 100644 bloaty-1.1-absl.patch create mode 100644 bloaty.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a41157e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bloaty-1.1.tar.gz diff --git a/bloaty-1.1-absl.patch b/bloaty-1.1-absl.patch new file mode 100644 index 0000000..e9a1577 --- /dev/null +++ b/bloaty-1.1-absl.patch @@ -0,0 +1,65 @@ +diff -up ./CMakeLists.txt.1 ./CMakeLists.txt +--- ./CMakeLists.txt.1 2020-05-24 00:36:23.000000000 -0400 ++++ ./CMakeLists.txt 2020-05-26 21:06:16.035802108 -0400 +@@ -36,6 +36,8 @@ else(${PKG_CONFIG_FOUND}) + endif(${PKG_CONFIG_FOUND}) + endif(UNIX) + ++find_package(absl) ++ + # Set default build type. + if(NOT CMAKE_BUILD_TYPE) + message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") +@@ -89,7 +91,6 @@ endif(UNIX) + + include_directories(.) + include_directories(src) +-include_directories(third_party/abseil-cpp) + include_directories("${CMAKE_CURRENT_BINARY_DIR}/src") + + # Baseline build flags. +@@ -159,6 +160,13 @@ add_library(libbloaty + src/macho.cc + src/range_map.cc + src/webassembly.cc ++) ++ ++if (absl_FOUND) ++ target_link_libraries(libbloaty PUBLIC absl::base absl::strings absl::numeric) ++else() ++ include_directories(third_party/abseil-cpp) ++ target_sources(libbloaty + # Until Abseil has a proper CMake build system + third_party/abseil-cpp/absl/base/internal/raw_logging.cc # Grrrr... + third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +@@ -179,7 +187,8 @@ add_library(libbloaty + third_party/abseil-cpp/absl/types/bad_optional_access.cc + # One source file, no special build system needed. + third_party/demumble/third_party/libcxxabi/cxa_demangle.cpp +- ) ++ ) ++endif() + + if(UNIX) + set(LIBBLOATY_LIBS libbloaty) +@@ -249,9 +258,8 @@ else() + enable_testing() + + if(BUILD_TESTING) +- add_subdirectory(third_party/googletest) +- include_directories(third_party/googletest/googletest/include) +- include_directories(third_party/googletest/googlemock/include) ++ find_package(GTest) ++ pkg_search_module(GMock gmock) + + set(TEST_TARGETS + bloaty_test +@@ -261,7 +269,7 @@ else() + + foreach(target ${TEST_TARGETS}) + add_executable(${target} tests/${target}.cc) +- target_link_libraries(${target} "${LIBBLOATY_LIBS}" gtest_main gmock "${CMAKE_THREAD_LIBS_INIT}") ++ target_link_libraries(${target} "${LIBBLOATY_LIBS}" GTest::Main GTest::GTest ${GMock_LIBRARIES} "${CMAKE_THREAD_LIBS_INIT}") + endforeach(target) + + add_executable(fuzz_test tests/fuzz_target.cc tests/fuzz_driver.cc) diff --git a/bloaty.spec b/bloaty.spec new file mode 100644 index 0000000..d05d042 --- /dev/null +++ b/bloaty.spec @@ -0,0 +1,63 @@ +Name: bloaty +Version: 1.1 +Release: 2%{?dist} +Summary: A size profiler for binaries + + +License: ASL 2.0 +URL: https://github.com/google/bloaty +Source0: https://github.com/google/bloaty/archive/v%{version}/%{name}-%{version}.tar.gz +# Patch to use system versions of abseil, google-test and google-mock +Patch0: bloaty-1.1-absl.patch + +BuildRequires: abseil-cpp-devel +BuildRequires: capstone-devel +BuildRequires: cmake +BuildRequires: gcc-c++ +BuildRequires: gmock-devel +BuildRequires: gtest-devel +BuildRequires: pkgconfig +BuildRequires: protobuf-devel +BuildRequires: re2-devel + +%description +Ever wondered what's making your binary big? Bloaty McBloatface will show +you a size profile of the binary so you can understand what's taking up +space inside. + +Bloaty works on binaries, shared objects, object files, and static +libraries. Bloaty supports the ELF and Mach-O formats, and has experimental +support for WebAssembly. + +%prep +%autosetup -S gendiff + + +%build +%cmake . \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DBUILD_SHARED_LIBS=OFF \ + -DBLOATY_ENABLE_CMAKETARGETS=OFF \ + -DBUILD_TESTING=ON +%make_build + + +%install +%make_install + +%check +make test + +%files +%license LICENSE +%doc README.md how-bloaty-works.md +%{_bindir}/bloaty + + +%changelog +* Wed May 27 2020 Rich Mattes - 1.1-2 +- Don't remove buildroot in install +- Patch to use system gtest and gmock, enable tests + +* Sat May 23 2020 Rich Mattes - 1.1-1 +- Inital Package diff --git a/sources b/sources new file mode 100644 index 0000000..d702a97 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (bloaty-1.1.tar.gz) = b02f8b75ac7e88f64c93be770d207936cfcd5085d3b62be1cd08a39741d57bb06dc8f96e3ef08de936a514d2d570700bbc24727cfb54d541233aaa91b0c87171 From b7c571ccf392a8965fdd4a31055e1007fc1e4d33 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Mon, 27 Jul 2020 13:13:08 +0000 Subject: [PATCH 02/11] - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- bloaty.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bloaty.spec b/bloaty.spec index d05d042..b621617 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -1,6 +1,6 @@ Name: bloaty Version: 1.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A size profiler for binaries @@ -55,6 +55,9 @@ make test %changelog +* Mon Jul 27 2020 Fedora Release Engineering - 1.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Wed May 27 2020 Rich Mattes - 1.1-2 - Don't remove buildroot in install - Patch to use system gtest and gmock, enable tests From 86cb8f5316e57e509cb2753d99943ef3ab464742 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 1 Aug 2020 00:11:34 +0000 Subject: [PATCH 03/11] - Second attempt - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- bloaty.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bloaty.spec b/bloaty.spec index b621617..8fafb8f 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -1,6 +1,6 @@ Name: bloaty Version: 1.1 -Release: 3%{?dist} +Release: 4%{?dist} Summary: A size profiler for binaries @@ -55,6 +55,10 @@ make test %changelog +* Sat Aug 01 2020 Fedora Release Engineering - 1.1-4 +- Second attempt - Rebuilt for + https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Mon Jul 27 2020 Fedora Release Engineering - 1.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From f945916f4343a4e9b01d52ee1d9d9a5c7096b0fe Mon Sep 17 00:00:00 2001 From: Rich Mattes Date: Sun, 2 Aug 2020 17:41:59 -0400 Subject: [PATCH 04/11] Fix build and add 32bit compat patch. Fix the cmake macros to work with the new cmake changes. Add a patch to correct the handling of file sizes with 32 bit size_t on 32 bit architectures. --- bloaty-1.1-longlong.patch | 18 ++++++++++++++++++ bloaty.spec | 10 ++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 bloaty-1.1-longlong.patch diff --git a/bloaty-1.1-longlong.patch b/bloaty-1.1-longlong.patch new file mode 100644 index 0000000..c511bb8 --- /dev/null +++ b/bloaty-1.1-longlong.patch @@ -0,0 +1,18 @@ +diff -up ./src/elf.cc.2 ./src/elf.cc +--- ./src/elf.cc.2 2020-08-02 17:34:06.872636546 -0400 ++++ ./src/elf.cc 2020-08-02 17:34:26.293491457 -0400 +@@ -794,12 +794,12 @@ void ForEachElf(const InputFile& file, R + // + // - 24 bits for index (up to 16M symbols with -ffunction-sections) + // - 40 bits for address (up to 1TB section) +-static uint64_t ToVMAddr(size_t addr, long ndx, bool is_object) { ++static uint64_t ToVMAddr(uint64_t addr, int64_t ndx, bool is_object) { + if (is_object) { + if (ndx >= 1 << 24) { + THROW("ndx overflow: too many sections"); + } +- if (addr >= 1UL << 40) { ++ if (addr >= 1ULL << 40) { + THROW("address overflow: section too big"); + } + return (ndx << 40) | addr; diff --git a/bloaty.spec b/bloaty.spec index 8fafb8f..f9c8277 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -9,6 +9,8 @@ URL: https://github.com/google/bloaty Source0: https://github.com/google/bloaty/archive/v%{version}/%{name}-%{version}.tar.gz # Patch to use system versions of abseil, google-test and google-mock Patch0: bloaty-1.1-absl.patch +# Patch to fix size detection function to use 64 bit types on 32bit architectures +Patch1: bloaty-1.1-longlong.patch BuildRequires: abseil-cpp-devel BuildRequires: capstone-devel @@ -30,7 +32,7 @@ libraries. Bloaty supports the ELF and Mach-O formats, and has experimental support for WebAssembly. %prep -%autosetup -S gendiff +%autosetup -p0 -S gendiff %build @@ -39,14 +41,14 @@ support for WebAssembly. -DBUILD_SHARED_LIBS=OFF \ -DBLOATY_ENABLE_CMAKETARGETS=OFF \ -DBUILD_TESTING=ON -%make_build +%cmake_build %install -%make_install +%cmake_install %check -make test +%ctest --verbose %files %license LICENSE From 65e01aec1cfa2dbe2099484821a9b82349885790 Mon Sep 17 00:00:00 2001 From: Rich Mattes Date: Sun, 2 Aug 2020 17:47:38 -0400 Subject: [PATCH 05/11] Remove un-needed cmake source path --- bloaty.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bloaty.spec b/bloaty.spec index f9c8277..d72bbf0 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -36,7 +36,7 @@ support for WebAssembly. %build -%cmake . \ +%cmake \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_SHARED_LIBS=OFF \ -DBLOATY_ENABLE_CMAKETARGETS=OFF \ From f555269e871f9924eef3fa064e7faba6c0dc0107 Mon Sep 17 00:00:00 2001 From: Rich Mattes Date: Wed, 26 Aug 2020 21:43:43 -0400 Subject: [PATCH 06/11] Make tests informational --- bloaty.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bloaty.spec b/bloaty.spec index d72bbf0..1db71d4 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -48,7 +48,7 @@ support for WebAssembly. %cmake_install %check -%ctest --verbose +%ctest --verbose || exit 0 %files %license LICENSE From e46677d0d0d0273e1062a2734a11fb565276193a Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Wed, 23 Sep 2020 17:06:04 +0200 Subject: [PATCH 07/11] Rebuilt for protobuf 3.13 --- bloaty.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bloaty.spec b/bloaty.spec index 1db71d4..08171de 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -1,6 +1,6 @@ Name: bloaty Version: 1.1 -Release: 4%{?dist} +Release: 5%{?dist} Summary: A size profiler for binaries @@ -57,6 +57,9 @@ support for WebAssembly. %changelog +* Wed Sep 23 2020 Adrian Reber - 1.1-5 +- Rebuilt for protobuf 3.13 + * Sat Aug 01 2020 Fedora Release Engineering - 1.1-4 - Second attempt - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From a3bcb8db5e50601b9245c86625486cea4e5cc9bc Mon Sep 17 00:00:00 2001 From: Rich Mattes Date: Sat, 19 Dec 2020 12:02:05 -0500 Subject: [PATCH 08/11] Rebuild for abseil-cpp 20200923.2 --- bloaty.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bloaty.spec b/bloaty.spec index 08171de..071c4c2 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -1,6 +1,6 @@ Name: bloaty Version: 1.1 -Release: 5%{?dist} +Release: 6%{?dist} Summary: A size profiler for binaries @@ -57,6 +57,9 @@ support for WebAssembly. %changelog +* Sat Dec 19 11:31:29 EST 2020 Rich Mattes - 1.1-6 +- Rebuild for abseil-cpp 20200923.2 + * Wed Sep 23 2020 Adrian Reber - 1.1-5 - Rebuilt for protobuf 3.13 From 6f9e0d97803f014473cb8517d4874f2b204d2d4c Mon Sep 17 00:00:00 2001 From: Rich Mattes Date: Sat, 19 Dec 2020 12:37:29 -0500 Subject: [PATCH 09/11] CMake fixes for absl Update to build with C++17, as absl is built in C++17 mode, and its symbols include things like std::string_view. Tweak CMake to force libbloaty as a static library and enable position indepent code to resolve linking errors. --- bloaty-1.1-absl.patch | 38 +++++++++++++++++++++++++++++++------- bloaty.spec | 1 - 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/bloaty-1.1-absl.patch b/bloaty-1.1-absl.patch index e9a1577..6cd8a0a 100644 --- a/bloaty-1.1-absl.patch +++ b/bloaty-1.1-absl.patch @@ -1,7 +1,17 @@ diff -up ./CMakeLists.txt.1 ./CMakeLists.txt --- ./CMakeLists.txt.1 2020-05-24 00:36:23.000000000 -0400 -+++ ./CMakeLists.txt 2020-05-26 21:06:16.035802108 -0400 -@@ -36,6 +36,8 @@ else(${PKG_CONFIG_FOUND}) ++++ ./CMakeLists.txt 2020-12-19 12:32:29.021943521 -0500 +@@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.5) + cmake_policy(SET CMP0048 NEW) + project (Bloaty VERSION 1.0) + project (Bloaty VERSION 1.1) +-set(CMAKE_CXX_STANDARD 11) ++set(CMAKE_CXX_STANDARD 17) ++set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Options we define for users. + option(BLOATY_ENABLE_ASAN "Enable address sanitizer." OFF) +@@ -36,6 +37,8 @@ else(${PKG_CONFIG_FOUND}) endif(${PKG_CONFIG_FOUND}) endif(UNIX) @@ -10,7 +20,7 @@ diff -up ./CMakeLists.txt.1 ./CMakeLists.txt # Set default build type. if(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") -@@ -89,7 +91,6 @@ endif(UNIX) +@@ -89,11 +92,10 @@ endif(UNIX) include_directories(.) include_directories(src) @@ -18,7 +28,21 @@ diff -up ./CMakeLists.txt.1 ./CMakeLists.txt include_directories("${CMAKE_CURRENT_BINARY_DIR}/src") # Baseline build flags. -@@ -159,6 +160,13 @@ add_library(libbloaty +-set(CMAKE_CXX_FLAGS "-std=c++11 -W -Wall -Wno-sign-compare") ++set(CMAKE_CXX_FLAGS "-W -Wall -Wno-sign-compare") + set(CMAKE_CXX_FLAGS_DEBUG "-g1") + set(CMAKE_CXX_FLAGS_RELEASE "-O2") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g1") +@@ -149,7 +151,7 @@ endif(${PROTOC_FOUND}) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/bloaty_package.bloaty + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + +-add_library(libbloaty ++add_library(libbloaty STATIC + src/bloaty.cc + src/demangle.cc + src/disassemble.cc +@@ -159,6 +161,13 @@ add_library(libbloaty src/macho.cc src/range_map.cc src/webassembly.cc @@ -32,7 +56,7 @@ diff -up ./CMakeLists.txt.1 ./CMakeLists.txt # Until Abseil has a proper CMake build system third_party/abseil-cpp/absl/base/internal/raw_logging.cc # Grrrr... third_party/abseil-cpp/absl/base/internal/throw_delegate.cc -@@ -179,7 +187,8 @@ add_library(libbloaty +@@ -179,7 +188,8 @@ add_library(libbloaty third_party/abseil-cpp/absl/types/bad_optional_access.cc # One source file, no special build system needed. third_party/demumble/third_party/libcxxabi/cxa_demangle.cpp @@ -42,7 +66,7 @@ diff -up ./CMakeLists.txt.1 ./CMakeLists.txt if(UNIX) set(LIBBLOATY_LIBS libbloaty) -@@ -249,9 +258,8 @@ else() +@@ -249,9 +259,8 @@ else() enable_testing() if(BUILD_TESTING) @@ -54,7 +78,7 @@ diff -up ./CMakeLists.txt.1 ./CMakeLists.txt set(TEST_TARGETS bloaty_test -@@ -261,7 +269,7 @@ else() +@@ -261,7 +270,7 @@ else() foreach(target ${TEST_TARGETS}) add_executable(${target} tests/${target}.cc) diff --git a/bloaty.spec b/bloaty.spec index 071c4c2..a27a2f0 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -38,7 +38,6 @@ support for WebAssembly. %build %cmake \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DBUILD_SHARED_LIBS=OFF \ -DBLOATY_ENABLE_CMAKETARGETS=OFF \ -DBUILD_TESTING=ON %cmake_build From f5324c1505f932cf6a5d44ca536948d1513a9bdd Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Wed, 13 Jan 2021 08:55:30 +0100 Subject: [PATCH 10/11] Rebuilt for protobuf 3.14 --- bloaty.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bloaty.spec b/bloaty.spec index a27a2f0..47a8b70 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -1,6 +1,6 @@ Name: bloaty Version: 1.1 -Release: 6%{?dist} +Release: 7%{?dist} Summary: A size profiler for binaries @@ -56,6 +56,9 @@ support for WebAssembly. %changelog +* Wed Jan 13 08:55:29 CET 2021 Adrian Reber - 1.1-7 +- Rebuilt for protobuf 3.14 + * Sat Dec 19 11:31:29 EST 2020 Rich Mattes - 1.1-6 - Rebuild for abseil-cpp 20200923.2 From 726066e4cbd9a2e7903c282402ea55bf97c91996 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 26 Jan 2021 01:13:23 +0000 Subject: [PATCH 11/11] - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- bloaty.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bloaty.spec b/bloaty.spec index 47a8b70..164c8b4 100644 --- a/bloaty.spec +++ b/bloaty.spec @@ -1,6 +1,6 @@ Name: bloaty Version: 1.1 -Release: 7%{?dist} +Release: 8%{?dist} Summary: A size profiler for binaries @@ -56,6 +56,9 @@ support for WebAssembly. %changelog +* Tue Jan 26 2021 Fedora Release Engineering - 1.1-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + * Wed Jan 13 08:55:29 CET 2021 Adrian Reber - 1.1-7 - Rebuilt for protobuf 3.14