ELF-Writer
view release on metacpan or search on metacpan
lib/ELF/Writer/Section.pm view on Meta::CPAN
package ELF::Writer::Section;
use Moo 2;
use Carp;
use ELF::Writer;
use namespace::clean;
*VERSION= *ELF::Writer::VERSION;
# ABSTRACT: Object representing the fields of one section in an ELF file.
has name => ( is => 'rw' );
our (%type_to_sym, %type_from_sym);
ELF::Writer::_init_enum(\%type_to_sym, \%type_from_sym,
'null' => 0, # Ignore this section entry
'progbits' => 1, # Contents of section are program specific
'symtab' => 2, # symbol table
'strtab' => 3, # string table
'rela' => 4, # relocation table with specific addends
'hash' => 5, # symbol hash table
'dynamic' => 6, # dynamic linking information
'note' => 7, # various identification of file
'nobits' => 8, # program-specific "pointer" using offset field. has no length.
'rel' => 9, # relocation table without specific addends
'shlib' => 10, # ??
'dynsym' => 11, # symbol table
'num' => 12, # ??
);
has type => ( is => 'rw', coerce => sub {
my $x= $type_from_sym{$_[0]};
defined $x? $x
: (int($_[0]) == $_[0])? $_[0]
: croak "$_[0] is not a valid 'type'"
});
sub type_sym {
my $self= shift;
$self->type($_[0]) if @_;
my $v= $self->type;
$type_to_sym{$v} || $v
}
has flags => ( is => 'rw' );
sub flag_write {
my ($self, $value)= @_;
$self->flags( $self->flags & ~1 | ($value? 1 : 0) )
if defined $value;
$self->flags & 1;
}
sub flag_alloc {
my ($self, $value)= @_;
$self->flags( $self->flags & ~2 | ($value? 2 : 0) )
if defined $value;
$self->flags & 2;
}
sub flag_execinstr {
my ($self, $value)= @_;
$self->flags( $self->flags & ~4 | ($value? 4 : 0) )
if defined $value;
$self->flags & 4;
}
has addr => ( is => 'rw' );
has offset => ( is => 'rw' );
has size => ( is => 'rw' );
has link => ( is => 'rw' );
has info => ( is => 'rw' );
has addralign => ( is => 'rw' );
has entsize => ( is => 'rw' );
has data => ( is => 'rw' );
has data_start => ( is => 'rw', default => sub { 0 } );
sub data_offset { $_[0]->offset + $_[0]->data_start }
has _index => ( is => 'rw' );
sub _name { "segment ".shift->_index }
( run in 0.910 second using v1.01-cache-2.11-cpan-71847e10f99 )