diff --git a/ELFIOTest/ELFIOTest.cpp b/ELFIOTest/ELFIOTest.cpp
index a15ad92..881a86c 100644
--- a/ELFIOTest/ELFIOTest.cpp
+++ b/ELFIOTest/ELFIOTest.cpp
@@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE( load64 )
////////////////////////////////////////////////////////////////////////////
// Check ELF header
checkHeader( reader, ELFCLASS64, ELFDATA2LSB, EV_CURRENT, ET_EXEC,
- EM_X86_64, 1, 0x4003c0, 0, 29, 8, 0, 0 );
+ EM_X86_64, 1, 0x4003c0, 0, 29, 8, 0, 0 );
////////////////////////////////////////////////////////////////////////////
// Check sections
@@ -304,22 +304,22 @@ BOOST_AUTO_TEST_CASE( load64 )
sec =reader.sections[ 1 ];
checkSection( sec, 1, ".interp", SHT_PROGBITS, SHF_ALLOC,
- 0x0000000000400200, 0x1c, 0, 0, 1, 0 );
+ 0x0000000000400200, 0x1c, 0, 0, 1, 0 );
sec =reader.sections[ 9 ];
checkSection( sec, 9, ".rela.plt", SHT_RELA, SHF_ALLOC,
- 0x0000000000400340, 0x30, 4, 11, 8, 0x18 );
+ 0x0000000000400340, 0x30, 4, 11, 8, 0x18 );
sec =reader.sections[ 20 ];
checkSection( sec, 20, ".dynamic", SHT_DYNAMIC, SHF_WRITE | SHF_ALLOC,
- 0x0000000000600698, 0x190, 5, 0, 8, 0x10 );
+ 0x0000000000600698, 0x190, 5, 0, 8, 0x10 );
sec =reader.sections[ 28 ];
checkSection( sec, 28, ".strtab", SHT_STRTAB, 0,
- 0x0, 0x23f, 0, 0, 1, 0 );
+ 0x0, 0x23f, 0, 0, 1, 0 );
const section* sec1 = reader.sections[ ".strtab" ];
BOOST_CHECK_EQUAL( sec->get_index(), sec1->get_index() );
@@ -328,15 +328,15 @@ BOOST_AUTO_TEST_CASE( load64 )
// Check segments
segment* seg = reader.segments[0];
checkSegment( seg, PT_PHDR, 0x0000000000400040, 0x0000000000400040,
- 0x00000000000001c0, 0x00000000000001c0, PF_R + PF_X, 8 );
+ 0x00000000000001c0, 0x00000000000001c0, PF_R + PF_X, 8 );
seg = reader.segments[2];
checkSegment( seg, PT_LOAD, 0x0000000000400000, 0x0000000000400000,
- 0x000000000000066c, 0x000000000000066c, PF_R + PF_X, 0x200000 );
+ 0x000000000000066c, 0x000000000000066c, PF_R + PF_X, 0x200000 );
seg = reader.segments[7];
checkSegment( seg, 0x6474E551, 0x0, 0x0,
- 0x0, 0x0, PF_R + PF_W, 8 );
+ 0x0, 0x0, PF_R + PF_W, 8 );
////////////////////////////////////////////////////////////////////////////
// Check symbol table
diff --git a/ELFIOTest/ELFIOTest.vcxproj b/ELFIOTest/ELFIOTest.vcxproj
index 0723d2a..f2cdcd6 100644
--- a/ELFIOTest/ELFIOTest.vcxproj
+++ b/ELFIOTest/ELFIOTest.vcxproj
@@ -51,10 +51,10 @@
- Level3
+ Level4
Disabled
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- ..;d:\Developer\boost_1_65_1;%(AdditionalIncludeDirectories)
+ ..;d:\Developer\boost_1_73_0;%(AdditionalIncludeDirectories)
false
@@ -62,7 +62,7 @@
true
- d:\Developer\boost_1_65_1\stage\lib
+ d:\Developer\boost_1_73_0\stage\lib
false
@@ -74,7 +74,7 @@
- Level3
+ Level4
MaxSpeed
diff --git a/ELFIOTest/ELFIOTest1.cpp b/ELFIOTest/ELFIOTest1.cpp
index d32fe2e..90d31f8 100644
--- a/ELFIOTest/ELFIOTest1.cpp
+++ b/ELFIOTest/ELFIOTest1.cpp
@@ -317,7 +317,7 @@ void checkExeAreEqual( std::string file_name1, std::string file_name2, int skipT
// truncate the data if the header and the segment table is
// part of the segment
Elf64_Off afterPHDR = file1.get_segments_offset() +
- file1.get_segment_entry_size() * file1.segments.size();
+ file1.get_segment_entry_size() * (Elf64_Off)file1.segments.size();
if( file1.segments[i]->get_offset() < afterPHDR ) {
pdata1 = pdata1.substr( (unsigned int)afterPHDR );
pdata2 = pdata2.substr( (unsigned int)afterPHDR );
diff --git a/elfio/elfio.hpp b/elfio/elfio.hpp
index e5f25c3..d74f267 100644
--- a/elfio/elfio.hpp
+++ b/elfio/elfio.hpp
@@ -176,7 +176,7 @@ class elfio
// Layout the first section right after the segment table
current_file_pos = header->get_header_size() +
- header->get_segment_entry_size() * header->get_segments_num();
+ header->get_segment_entry_size() * (Elf_Xword)header->get_segments_num();
calc_segment_alignment();
@@ -404,7 +404,7 @@ class elfio
for ( Elf_Half i = 0; i < num; ++i ) {
section* sec = create_section();
- sec->load( stream, (std::streamoff)offset + i * entry_size );
+ sec->load( stream, (std::streamoff)offset + (std::streampos)i * entry_size );
sec->set_index( i );
// To mark that the section is not permitted to reassign address
// during layout calculation
@@ -460,7 +460,7 @@ class elfio
return false;
}
- seg->load( stream, (std::streamoff)offset + i * entry_size );
+ seg->load( stream, (std::streamoff)offset + (std::streampos)i * entry_size );
seg->set_index( i );
// Add sections to the segments (similar to readelfs algorithm)
@@ -503,7 +503,7 @@ class elfio
std::streampos headerPosition =
(std::streamoff)header->get_sections_offset() +
- header->get_section_entry_size() * sec->get_index();
+ (std::streampos)header->get_section_entry_size() * sec->get_index();
sec->save(stream,headerPosition,sec->get_offset());
}
@@ -517,7 +517,7 @@ class elfio
segment *seg = segments_.at(i);
std::streampos headerPosition = header->get_segments_offset() +
- header->get_segment_entry_size()*seg->get_index();
+ (std::streampos)header->get_segment_entry_size()*seg->get_index();
seg->save( stream, headerPosition, seg->get_offset() );
}
@@ -662,7 +662,7 @@ class elfio
if ( seg->get_type() == PT_PHDR && seg->get_sections_num() == 0 ) {
seg_start_pos = header->get_segments_offset();
segment_memory = segment_filesize =
- header->get_segment_entry_size() * header->get_segments_num();
+ header->get_segment_entry_size() * (Elf_Xword)header->get_segments_num();
}
// Special case:
else if ( seg->is_offset_initialized() && seg->get_offset() == 0 ) {
diff --git a/elfio/elfio_dump.hpp b/elfio/elfio_dump.hpp
index a4d0531..7e7a916 100644
--- a/elfio/elfio_dump.hpp
+++ b/elfio/elfio_dump.hpp
@@ -629,7 +629,7 @@ class dump
//------------------------------------------------------------------------------
static void
symbol_table( std::ostream& out,
- Elf_Half no,
+ Elf_Xword no,
std::string& name,
Elf64_Addr value,
Elf_Xword size,
@@ -679,7 +679,7 @@ class dump
section* sec = reader.sections[i];
if ( SHT_NOTE == sec->get_type() ) { // Look at notes
note_section_accessor notes( reader, sec );
- int no_notes = notes.get_notes_num();
+ Elf_Word no_notes = notes.get_notes_num();
if ( no > 0 ) {
out << "Note section (" << sec->get_name() << ")" << std::endl
<< " No Type Name"
diff --git a/elfio/elfio_note.hpp b/elfio/elfio_note.hpp
index fad615e..06b2817 100644
--- a/elfio/elfio_note.hpp
+++ b/elfio/elfio_note.hpp
@@ -72,13 +72,14 @@ class note_section_accessor_template
int align = sizeof( Elf_Word );
const endianess_convertor& convertor = elf_file.get_convertor();
- type = convertor( *(const Elf_Word*)( pData + 2*align ) );
+ type = convertor( *(const Elf_Word*)( pData + 2*align ) );
Elf_Word namesz = convertor( *(const Elf_Word*)( pData ) );
descSize = convertor( *(const Elf_Word*)( pData + sizeof( namesz ) ) );
+
Elf_Xword max_name_size = note_section->get_size() - note_start_positions[index];
if ( namesz < 1 ||
namesz > max_name_size ||
- namesz + descSize > max_name_size ) {
+ (Elf_Xword)namesz + descSize > max_name_size ) {
return false;
}
name.assign( pData + 3*align, namesz - 1);
@@ -142,17 +143,17 @@ class note_section_accessor_template
return;
}
- int align = sizeof( Elf_Word );
- while ( current + 3*align <= size ) {
+ Elf_Word align = sizeof( Elf_Word );
+ while ( current + (Elf_Xword)3*align <= size ) {
note_start_positions.push_back( current );
Elf_Word namesz = convertor(
*(const Elf_Word*)( data + current ) );
Elf_Word descsz = convertor(
*(const Elf_Word*)( data + current + sizeof( namesz ) ) );
- current += 3*sizeof( Elf_Word ) +
- ( ( namesz + align - 1 ) / align ) * align +
- ( ( descsz + align - 1 ) / align ) * align;
+ current += (Elf_Xword)3*sizeof( Elf_Word ) +
+ ( ( namesz + align - 1 ) / align ) * (Elf_Xword)align +
+ ( ( descsz + align - 1 ) / align ) * (Elf_Xword)align;
}
}
diff --git a/elfio/elfio_section.hpp b/elfio/elfio_section.hpp
index 50bd884..deb98b5 100644
--- a/elfio/elfio_section.hpp
+++ b/elfio/elfio_section.hpp
@@ -79,6 +79,8 @@ class section_impl : public section
is_address_set = false;
data = 0;
data_size = 0;
+ index = 0;
+ stream_size = 0;
}
//------------------------------------------------------------------------------
diff --git a/elfio/elfio_symbols.hpp b/elfio/elfio_symbols.hpp
index 7a5d5eb..da61f55 100644
--- a/elfio/elfio_symbols.hpp
+++ b/elfio/elfio_symbols.hpp
@@ -133,7 +133,6 @@ class symbol_section_accessor_template
const endianess_convertor& convertor = elf_file.get_convertor();
- section* string_section = elf_file.sections[get_string_table_index()];
Elf_Xword idx = 0;
bool match = false;