ELF-Writer

 view release on metacpan or  search on metacpan

lib/ELF/Writer.pm  view on Meta::CPAN

	my $v= $self->osabi;
	$osabi_to_sym{$v} || $v
}


has osabi_version   => ( is => 'rw', default => sub { 0 } );

our (%type_to_sym, %type_from_sym);
_init_enum(\%type_to_sym, \%type_from_sym,
	'none'        => 0,
	'relocatable' => 1,
	'executable'  => 2,
	'shared'      => 3,
	'core'        => 4,
);

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'"

lib/ELF/Writer.pm  view on Meta::CPAN


8-bit integer, or one of: C<"SystemV">, C<"HP-UX">, C<"NetBSD">, C<"Linux">, C<"Solaris">,
C<"AIX">, C<"IRIX">, C<"FreeBSD">, C<"OpenBSD">, C<"OpenVMS">.  Must be set before writing.

=head2 osabi_version

Depends on osabi.  Not used for Linux.  Defaults to 0.

=head2 type, type_sym

16-bit integer, or one of: C<"relocatable">, C<"executable">, C<"shared">, C<"core">.
Must be set before writing.

=head2 machine, machine_sym

16-bit integer, or one of: C<"Sparc">, C<"x86">, C<"MIPS">, C<"PowerPC">, C<"ARM">, C<"SuperH">,
C<"IA-64">, C<"x86-64">, C<"AArch64">.

=head2 version

32-bit integer; defaults to C<1> for original version of ELF.

lib/ELF/Writer/Section.pm  view on Meta::CPAN



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'"

t/00-basic.t  view on Meta::CPAN

use Log::Any::Adapter 'TAP';

use ELF::Writer;
use ELF::Writer::Linux_x86;
use ELF::Writer::Linux_x86_64;

subtest enums => \&test_enums;
sub test_enums {
	my $elf;
	
	for (qw: executable shared relocatable core :) {
		$elf= ELF::Writer->new(type => $_);
		is( $elf->type_sym, $_, "enum type=$_ decoded" );
		is( $elf->type, $ELF::Writer::type_from_sym{$_}, "enum type=$_ correct value" );
	}
	$elf= ELF::Writer->new(type => 42);
	is( $elf->type, 42, "enum type=42 allowed" );
	is( $elf->type_sym, 42, "enum type=42 decoded as self" );
	
	for (qw: 32bit 64bit :) {
		$elf= ELF::Writer->new(class => $_);



( run in 1.092 second using v1.01-cache-2.11-cpan-71847e10f99 )