Esempio n. 1
0
/*
 * Print a section header info. Information is printed on 80 columns and 
 * consists of section index, name, addr, offset in file, size, flags
 * and some others.
 * The print is done on stdout.
 * 
 * @param	shr		Pointer to the section to print info about
 * @param	bin		Binary structure
 * @param	shr_index	Index of the section header in section headers
 *				table
 *
 */
void print_shr_info(Elf64_Shdr *shr, ELF *bin, int shr_index) {
	/* Section index */
	printf("  [%2i] ", shr_index);

	/* Section name */
	print_section_name(get_section_name(bin->file, shr, bin->shr[bin->ehr->e_shstrndx]->sh_offset));

	print_section_type(shr->sh_type);

	/* Section address */
	printf("%08x ", (Elf64_Word) shr->sh_addr);

	/* Section offset */
	printf("%06x ", (Elf64_Word) shr->sh_offset);

	/* Section size */
	printf("%06x ", (Elf64_Word) shr->sh_size);

	/* Entry size */
	printf("%02x ", (unsigned char) shr->sh_entsize);

	/* FLAGS */
	print_section_flags(shr->sh_flags);

	/* Link */
	printf("%2u ", shr->sh_link);

    	/* Info */
	printf("%3u ", shr->sh_info);

 	/* Align */
	printf("%2u", (unsigned char) shr->sh_addralign);

	printf("\n");
}
Esempio n. 2
0
void		print_section(t_sect *section, char *seg, char *sect, int cust)
{
	size_t	offset;
	short	count;
	char	delim;

	offset = 0;
	print_section_name(seg, sect, cust);
	if (!ft_strcmp(seg, "__TEXT") && !ft_strcmp(sect, "__text"))
		delim = ' ';
	else
		delim = '\t';
	while (section->start + offset != section->end)
	{
		count = 0;
		print_ptr_to_hex(section->offset + offset, FALSE, section->len64);
		ft_putchar(delim);
		while (count++ != 16)
		{
			print_byte_to_hex(*(section->start + offset));
			offset++;
			ft_putchar(' ');
			if (section->start + offset == section->end)
				break ;
		}
		ft_putchar('\n');
	}
}
Esempio n. 3
0
void
#line 228 "./cwebdir/ctang-w2c.ch"
 get_output P1H(void)
#line 394 "./cwebdir/ctangle.w"
{
sixteen_bits a;
restart:if(stack_ptr==stack)return;
if(cur_byte==cur_end){
cur_val= -((int)cur_section);
pop_level(1);
if(cur_val==0)goto restart;
out_char(section_number);return;
}
a= *cur_byte++;
if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
C_putc(a);
else if(a<0200)out_char(a);
else{
a= (a-0200)*0400+*cur_byte++;
switch(a/024000){
case 0:cur_val= a;out_char(identifier);break;
case 1:if(a==output_defs_flag)output_defs();
else/*33:*/
#line 423 "./cwebdir/ctangle.w"

{
a-= 024000;
if((a+name_dir)->equiv!=(char*)text_info)push_level(a+name_dir);
else if(a!=0){
printf("\n! Not present: <");
print_section_name(a+name_dir);err_print(">");

}
goto restart;
}

/*:33*/
#line 412 "./cwebdir/ctangle.w"
;
break;
default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val;
out_char(section_number);
}
}
}
Esempio n. 4
0
File: ar.c Progetto: meesokim/z88dk
void dump_code( FILE *fp, char *filename, long fp_start )
{
    int code_size;
    int org;
    char *section_name;

    fseek( fp, fp_start, SEEK_SET );

    if ( file_version >= 5 )
    {
        while (1)
        {
            code_size = xfread_long( fp, filename );
            if ( code_size < 0 )
                break;
            section_name = xfread_string( fp, filename );

            if ( file_version >= 8 )
                org = (int) xfread_long( fp, filename );
            else
                org = -1;

            printf("  Code: %d bytes", code_size );
            if ( org >= 0 )
                printf(", ORG at $%04X", org );
            print_section_name( section_name );
            printf("\n");

            dump_bytes( fp, filename, code_size );
        }
    }
    else
    {
        code_size = xfread_word( fp, filename );
        if ( code_size == 0 )
            code_size = 0x10000;
        if ( code_size > 0 )
        {
            printf("  Code: %d bytes\n", code_size );
            dump_bytes( fp, filename, code_size );
        }
    }
}
Esempio n. 5
0
File: ar.c Progetto: meesokim/z88dk
void dump_names( FILE *fp, char *filename, long fp_start, long fp_end )
{
    int scope, type;
    long value;
    char *section_name, *name;

    if ( file_version >= 5 )				/* signal end by zero type */
        fp_end = MAX_FP;

    printf("  Names:\n");
    fseek( fp, fp_start, SEEK_SET );
    while ( ftell( fp ) < fp_end )
    {
        scope = xfread_byte( fp, filename );
        if ( scope == 0 )
            break;							/* end marker */

        type  = xfread_byte( fp, filename );

        if ( file_version >= 5 )
            section_name = strdup( xfread_string( fp, filename ) );

        value = xfread_long( fp, filename );
        name  = xfread_string( fp, filename );

        if ( opt_showlocal || scope != 'L' )
        {
            printf("    %c %c $%04X %s", scope, type, value, name );
            if ( file_version >= 5 )
            {
                print_section_name( section_name );
                free( section_name );
            }
            printf("\n");
        }
    }
}
Esempio n. 6
0
name_pointer
#line 363 "./cwebdir/comm-w2c.ch"

section_lookup P3C(char*,first,char*,last,int,ispref)
#line 917 "./cwebdir/common.w"
{
int c= 0;
name_pointer p= root;
name_pointer q= NULL;
name_pointer r= NULL;
name_pointer par= NULL;

int name_len= last-first+1;
/*52:*/
#line 936 "./cwebdir/common.w"

while(p){
c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p));
if(c==less||c==greater){
if(r==NULL)
par= p;
p= (c==less?p->llink:p->rlink);
}else{
if(r!=NULL){
printf("\n! Ambiguous prefix: matches <");

print_prefix_name(p);
printf(">\n and <");
print_prefix_name(r);
err_print(">");
return name_dir;
}
r= p;
p= p->llink;
q= r->rlink;
}
if(p==NULL)
p= q,q= NULL;
}

/*:52*/
#line 926 "./cwebdir/common.w"
;
/*53:*/
#line 961 "./cwebdir/common.w"

if(r==NULL)
return add_section_name(par,c,first,last+1,ispref);

/*:53*/
#line 927 "./cwebdir/common.w"
;
/*54:*/
#line 969 "./cwebdir/common.w"

switch(section_name_cmp(&first,name_len,r)){

case prefix:
if(!ispref){
printf("\n! New name is a prefix of <");

print_section_name(r);
err_print(">");
}
else if(name_len<prefix_length(r))set_prefix_length(r,name_len);

case equal:return r;
case extension:if(!ispref||first<=last)
extend_section_name(r,first,last+1,ispref);
return r;
case bad_extension:
printf("\n! New name extends <");

print_section_name(r);
err_print(">");
return r;
default:
printf("\n! Section name incompatible with <");

print_prefix_name(r);
printf(">,\n which abbreviates <");
print_section_name(r);
err_print(">");
return r;
}

/*:54*/
#line 928 "./cwebdir/common.w"
;
}
Esempio n. 7
0
File: ar.c Progetto: meesokim/z88dk
void dump_expr( FILE *fp, char *filename, long fp_start, long fp_end )
{
    int type, asmpc, patch_ptr, end_marker;
    char *source_file, *last_source_file, *section_name, *target_name;
    long line_number;

    last_source_file = strdup("");

    if ( file_version >= 4 )				/* signal end by zero type */
        fp_end = MAX_FP;

    printf("  Expressions:\n");
    fseek( fp, fp_start, SEEK_SET );
    while ( ftell( fp ) < fp_end )
    {
        type = xfread_byte( fp, filename );
        if ( type == 0 )
            break;							/* end marker */

        printf("    E %c%c",
               type,
               type == '=' ? ' ' :
               type == 'L' ? 'l' :
               type == 'C' ? 'w' : 'b' );
        if ( file_version >= 4 )
        {
            source_file = xfread_lstring( fp, filename );
            if ( *source_file )
            {
                free( last_source_file );
                last_source_file = strdup( source_file );
            }

            line_number = xfread_long( fp, filename );
            printf(" (%s:%ld)", last_source_file, line_number );
        }

        if ( file_version >= 5 )
        {
            section_name = strdup( xfread_string( fp, filename ) );
        }

        if ( file_version >= 3 )
        {
            asmpc = xfread_word( fp, filename );
            printf(" $%04X", asmpc);
        }

        patch_ptr = xfread_word( fp, filename );
        printf(" $%04X", patch_ptr);

        printf(": ");
        if ( file_version >= 6 )
        {
            target_name = xfread_string( fp, filename );
            if ( *target_name )
                printf("%s := ", target_name );
        }

        if ( file_version >= 4 )
            printf("%s", xfread_lstring( fp, filename ) );
        else
            printf("%s", xfread_string( fp, filename ) );

        if ( file_version >= 5 )
        {
            print_section_name( section_name );
            free( section_name );
        }

        printf("\n");

        if ( file_version < 4 )
        {
            end_marker = xfread_byte( fp, filename );
            if ( end_marker != 0 )
                die("File %s: missing expression end marker\n", filename );
        }
    }

    free( last_source_file );
}