diff options
author | Evan Lojewski <github@meklort.com> | 2020-10-01 17:58:23 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 17:58:23 -0600 |
commit | 93e2cd20348d46d51cb6cab5353962afeb1a22c6 (patch) | |
tree | 7c24032e1974060c317c99f730f4b97ea1a0d5ae | |
parent | 93f10e40a087329503bf747aeccb088754b1f668 (diff) | |
download | bcm5719-ortega-93e2cd20348d46d51cb6cab5353962afeb1a22c6.tar.gz bcm5719-ortega-93e2cd20348d46d51cb6cab5353962afeb1a22c6.zip |
utils: Disable RTTI and exception to reduce utility compile size. (#122)
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/simulator.cmake | 4 | ||||
-rw-r--r-- | libs/elfio/elfio/elfio_section.hpp | 41 | ||||
-rw-r--r-- | libs/elfio/elfio/elfio_segment.hpp | 14 |
4 files changed, 30 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 31ac9de..41bc149 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,8 @@ SET(CMAKE_C_COMPILER ${COMPILER_BASE}/bin/clang) SET(CMAKE_CXX_COMPILER ${COMPILER_BASE}/bin/clang++) SET(CMAKE_ASM_COMPILER ${COMPILER_BASE}/bin/clang) +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") + include(cmake/version.cmake) cmake_minimum_required(VERSION 3.5.1) diff --git a/cmake/simulator.cmake b/cmake/simulator.cmake index 3e766a4..b97275f 100644 --- a/cmake/simulator.cmake +++ b/cmake/simulator.cmake @@ -2,7 +2,7 @@ ### ### @file simulator.cmake ### -### @project +### @project bcm5719-fw ### ### @brief Simulator specific configurations ### @@ -42,7 +42,7 @@ ### @endcond ################################################################################ -SET(SIMULATOR_COMPILE_OPTIONS -DCXX_SIMULATOR -x c++ ) +SET(SIMULATOR_COMPILE_OPTIONS -DCXX_SIMULATOR -x c++ -fno-rtti -fno-exceptions) SET(SIMULATOR_LINK_OPTIONS ) # MIPS-specific executables diff --git a/libs/elfio/elfio/elfio_section.hpp b/libs/elfio/elfio/elfio_section.hpp index 43c41f4..e02b06b 100644 --- a/libs/elfio/elfio/elfio_section.hpp +++ b/libs/elfio/elfio/elfio_section.hpp @@ -66,7 +66,7 @@ class section protected: ELFIO_SET_ACCESS_DECL( Elf64_Off, offset ); ELFIO_SET_ACCESS_DECL( Elf_Half, index ); - + virtual void load( std::istream& stream, std::streampos header_offset ) = 0; virtual void save( std::ostream& stream, @@ -158,17 +158,18 @@ class section_impl : public section { if ( get_type() != SHT_NOBITS ) { delete [] data; - try { - data = new char[size]; - } catch (const std::bad_alloc&) { - data = 0; - data_size = 0; - size = 0; - } + data = new char[size]; + if ( 0 != data && 0 != raw_data ) { data_size = size; std::copy( raw_data, raw_data + size, data ); } + else + { + data_size = 0; + size = 0; + } + } set_size( size ); @@ -192,18 +193,18 @@ class section_impl : public section else { data_size = 2*( data_size + size); char* new_data; - try { - new_data = new char[data_size]; - } catch (const std::bad_alloc&) { - new_data = 0; - size = 0; - } + new_data = new char[data_size]; if ( 0 != new_data ) { std::copy( data, data + get_size(), new_data ); std::copy( raw_data, raw_data + size, new_data + get_size() ); delete [] data; data = new_data; } + else + { + size = 0; + } + } set_size( get_size() + size ); } @@ -244,12 +245,7 @@ class section_impl : public section Elf_Xword size = get_size(); if ( 0 == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() && size < get_stream_size()) { - try { - data = new char[size + 1]; - } catch (const std::bad_alloc&) { - data = 0; - data_size = 0; - } + data = new char[size + 1]; if ( ( 0 != size ) && ( 0 != data ) ) { stream.seekg( (*convertor)( header.sh_offset ) ); @@ -257,6 +253,11 @@ class section_impl : public section data[size] = 0; // Ensure data is ended with 0 to avoid oob read data_size = size; } + else + { + data_size = 0; + } + } } diff --git a/libs/elfio/elfio/elfio_segment.hpp b/libs/elfio/elfio/elfio_segment.hpp index 642fd29..f27b395 100644 --- a/libs/elfio/elfio/elfio_segment.hpp +++ b/libs/elfio/elfio/elfio_segment.hpp @@ -54,7 +54,7 @@ class segment protected: ELFIO_SET_ACCESS_DECL( Elf64_Off, offset ); ELFIO_SET_ACCESS_DECL( Elf_Half, index ); - + virtual const std::vector<Elf_Half>& get_sections() const = 0; virtual void load( std::istream& stream, std::streampos header_offset ) = 0; virtual void save( std::ostream& stream, std::streampos header_offset, @@ -101,7 +101,7 @@ class segment_impl : public segment } //------------------------------------------------------------------------------ - void + void set_stream_size(size_t value) { stream_size = value; @@ -177,7 +177,7 @@ class segment_impl : public segment { return sections; } - + //------------------------------------------------------------------------------ void set_index( Elf_Half value ) @@ -206,12 +206,8 @@ class segment_impl : public segment data = 0; } else { - try { - data = new char[size + 1]; - } catch (const std::bad_alloc&) { - data = 0; - } - + data = new char[size + 1]; + if ( 0 != data ) { stream.read( data, size ); data[size] = 0; |