Skip to content

Commit

Permalink
Add segment free_data function
Browse files Browse the repository at this point in the history
Allow for segment data to be freed to allow for reduced memory usage
when dealing with large elf segments.
  • Loading branch information
Eugene Cohen authored and serge1 committed Oct 10, 2023
1 parent 73a2410 commit 23527bd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions elfio/elfio_segment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class segment
ELFIO_GET_ACCESS_DECL( Elf64_Off, offset );

virtual const char* get_data() const = 0;
virtual void free_data() const = 0;

virtual Elf_Half add_section( section* psec, Elf_Xword addr_align ) = 0;
virtual Elf_Half add_section_index( Elf_Half index,
Expand Down Expand Up @@ -104,6 +105,12 @@ template <class T> class segment_impl : public segment
return data.get();
}

void free_data() const override
{
data.reset(nullptr);
is_lazy = true;
}

//------------------------------------------------------------------------------
Elf_Half add_section_index( Elf_Half sec_index,
Elf_Xword addr_align ) override
Expand Down

0 comments on commit 23527bd

Please sign in to comment.