mirror of
https://github.com/serge1/ELFIO.git
synced 2025-01-29 21:32:44 +00:00
Relocation C wrapper added
This commit is contained in:
parent
8597197741
commit
e55e5894c5
@ -19,7 +19,6 @@ int main( int argc, char* argv[] )
|
||||
|
||||
/* Uncomment a block of the interest */
|
||||
|
||||
/*
|
||||
int secno = elfio_get_sections_num( pelfio );
|
||||
printf( "\nSections No : %d\n", secno );
|
||||
|
||||
@ -27,27 +26,23 @@ int main( int argc, char* argv[] )
|
||||
psection_t psection = elfio_get_section_by_index( pelfio, i );
|
||||
char buff[128];
|
||||
elfio_section_get_name( psection, buff, 100 );
|
||||
printf( " [%02d] %s\n", i, buff );
|
||||
printf( " %08lx : %08lx\n",
|
||||
elfio_section_get_address( psection ),
|
||||
elfio_section_get_size( psection ) );
|
||||
// printf( " [%02d] %s\n", i, buff );
|
||||
// printf( " %08lx : %08lx\n",
|
||||
// elfio_section_get_address( psection ),
|
||||
// elfio_section_get_size( psection ) );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
int segno = elfio_get_segments_num( pelfio );
|
||||
printf( "\nSegments No : %d\n", segno );
|
||||
|
||||
for ( int i = 0; i < segno; i++ ) {
|
||||
psegment_t psegment = elfio_get_segment_by_index( pelfio, i );
|
||||
printf( " [%02d] %08lx : %08lx : %08lx\n", i,
|
||||
elfio_segment_get_virtual_address( psegment ),
|
||||
elfio_segment_get_memory_size( psegment ),
|
||||
elfio_segment_get_file_size( psegment ) );
|
||||
// printf( " [%02d] %08lx : %08lx : %08lx\n", i,
|
||||
// elfio_segment_get_virtual_address( psegment ),
|
||||
// elfio_segment_get_memory_size( psegment ),
|
||||
// elfio_segment_get_file_size( psegment ) );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
psection_t psection = elfio_get_section_by_name( pelfio, ".symtab" );
|
||||
psymbol_t psymbols = elfio_symbol_section_accessor_new( pelfio, psection );
|
||||
int symno = elfio_symbol_get_symbols_num( psymbols );
|
||||
@ -61,10 +56,9 @@ int main( int argc, char* argv[] )
|
||||
unsigned char other;
|
||||
elfio_symbol_get_symbol( psymbols, i, name, 128, &value, &size,
|
||||
&bind, &type, §ion_index, &other );
|
||||
printf( "[%4d] %10lu, %4lu %s\n", i, value, size, name );
|
||||
// printf( "[%4d] %10lu, %4lu %s\n", i, value, size, name );
|
||||
}
|
||||
elfio_symbol_section_accessor_delete( psymbols );
|
||||
*/
|
||||
|
||||
elfio_delete( pelfio );
|
||||
|
||||
|
@ -242,3 +242,58 @@ Elf_Xword elfio_symbol_arrange_local_symbols(
|
||||
{
|
||||
return psymbol->arrange_local_symbols( func );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// relocation
|
||||
//-----------------------------------------------------------------------------
|
||||
prelocation_t elfio_relocation_section_accessor_new( pelfio_t pelfio,
|
||||
psection_t psection )
|
||||
{
|
||||
return new relocation_section_accessor( *pelfio, psection );
|
||||
}
|
||||
|
||||
void elfio_relocation_section_accessor_delete( prelocation_t prelocation )
|
||||
{
|
||||
delete prelocation;
|
||||
}
|
||||
|
||||
Elf_Xword elfio_relocation_get_entries_num( prelocation_t prelocation )
|
||||
{
|
||||
return prelocation->get_entries_num();
|
||||
}
|
||||
|
||||
bool elfio_relocation_get_entry( prelocation_t prelocation,
|
||||
Elf_Xword index,
|
||||
Elf64_Addr* offset,
|
||||
Elf_Word* symbol,
|
||||
Elf_Word* type,
|
||||
Elf_Sxword* addend )
|
||||
{
|
||||
return prelocation->get_entry( index, *offset, *symbol, *type, *addend );
|
||||
}
|
||||
|
||||
bool elfio_relocation_set_entry( prelocation_t prelocation,
|
||||
Elf_Xword index,
|
||||
Elf64_Addr offset,
|
||||
Elf_Word symbol,
|
||||
Elf_Word type,
|
||||
Elf_Sxword addend )
|
||||
{
|
||||
return prelocation->set_entry( index, offset, symbol, type, addend );
|
||||
}
|
||||
|
||||
void elfio_relocation_add_entry( prelocation_t prelocation,
|
||||
Elf64_Addr offset,
|
||||
Elf_Word symbol,
|
||||
unsigned char type,
|
||||
Elf_Sxword addend )
|
||||
{
|
||||
return prelocation->add_entry( offset, symbol, type, addend );
|
||||
}
|
||||
|
||||
void elfio_relocation_swap_symbols( prelocation_t prelocation,
|
||||
Elf_Xword first,
|
||||
Elf_Xword second )
|
||||
{
|
||||
prelocation->swap_symbols( first, second );
|
||||
}
|
||||
|
@ -76,10 +76,11 @@ THE SOFTWARE.
|
||||
void elfio_##CLASS##_set_##NAME( p##CLASS##_t p##CLASS, TYPE value )
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef ELFIO::elfio* pelfio_t;
|
||||
typedef ELFIO::section* psection_t;
|
||||
typedef ELFIO::segment* psegment_t;
|
||||
typedef ELFIO::symbol_section_accessor* psymbol_t;
|
||||
typedef ELFIO::elfio* pelfio_t;
|
||||
typedef ELFIO::section* psection_t;
|
||||
typedef ELFIO::segment* psegment_t;
|
||||
typedef ELFIO::symbol_section_accessor* psymbol_t;
|
||||
typedef ELFIO::relocation_section_accessor* prelocation_t;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -88,6 +89,7 @@ typedef void* pelfio_t;
|
||||
typedef void* psection_t;
|
||||
typedef void* psegment_t;
|
||||
typedef void* psymbol_t;
|
||||
typedef void* prelocation_t;
|
||||
typedef int bool;
|
||||
#endif
|
||||
|
||||
@ -195,7 +197,36 @@ typedef int bool;
|
||||
unsigned char other,
|
||||
Elf_Half shndx );
|
||||
Elf_Xword elfio_symbol_arrange_local_symbols(
|
||||
psymbol_t psymbol, void (*func)( Elf_Xword first, Elf_Xword second ) );
|
||||
psymbol_t psymbol,
|
||||
void ( *func )( Elf_Xword first, Elf_Xword second ) );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// relocation
|
||||
//-----------------------------------------------------------------------------
|
||||
prelocation_t elfio_relocation_section_accessor_new( pelfio_t pelfio,
|
||||
psection_t psection );
|
||||
void elfio_relocation_section_accessor_delete( prelocation_t prelocation );
|
||||
Elf_Xword elfio_relocation_get_entries_num( prelocation_t prelocation );
|
||||
bool elfio_relocation_get_entry( prelocation_t prelocation,
|
||||
Elf_Xword index,
|
||||
Elf64_Addr* offset,
|
||||
Elf_Word* symbol,
|
||||
Elf_Word* type,
|
||||
Elf_Sxword* addend );
|
||||
bool elfio_relocation_set_entry( prelocation_t prelocation,
|
||||
Elf_Xword index,
|
||||
Elf64_Addr offset,
|
||||
Elf_Word symbol,
|
||||
Elf_Word type,
|
||||
Elf_Sxword addend );
|
||||
void elfio_relocation_add_entry( prelocation_t prelocation,
|
||||
Elf64_Addr offset,
|
||||
Elf_Word symbol,
|
||||
unsigned char type,
|
||||
Elf_Sxword addend );
|
||||
void elfio_relocation_swap_symbols( prelocation_t prelocation,
|
||||
Elf_Xword first,
|
||||
Elf_Xword second );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user