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.
This commit is contained in:
Rich Mattes 2020-08-02 17:41:59 -04:00
parent 86cb8f5316
commit f945916f43
2 changed files with 24 additions and 4 deletions

18
bloaty-1.1-longlong.patch Normal file
View File

@ -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;

View File

@ -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