merging executables
Jan Hoogerbrugge
hoogerbrugge@hotmail.com
Fri Feb 15 05:16:00 GMT 2002
More information about the Binutils mailing list
Fri Feb 15 05:16:00 GMT 2002
- Previous message (by thread): scripting apps with assembly?
- Next message (by thread): merging executables
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I want to use libbfd to merge multiple ELF executables into one. Just
copying the sections of a few input files to an output file. I wrote the
following code, which does not work for some reason. It core dumps in
bfd_copy_private_section_data. Any idea why??
Cheers,
Jan
-----
#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
#include <bfd.h>
#include <assert.h>
main(int argc, char *argv[])
{
char sec_out_name[1024];
bfd *bfd_in, *bfd_out;
asection *sec_in, *sec_out;
int i;
bfd_init();
bfd_out = bfd_openw(argv[1], "elf32-big");
assert(bfd_out != NULL);
for(i = 2; i < argc; i++)
{
bfd_in = bfd_openr(argv[i], "elf32-big");
assert(bfd_in != NULL);
bfd_check_format(bfd_in, bfd_object);
for(sec_in = bfd_in->sections; sec_in; sec_in =
sec_in->next)
{
sprintf(sec_out_name, "%s_%d", sec_in->name, i - 1);
sec_out = bfd_make_section_anyway(bfd_out,
strdup(sec_out_name));
assert(sec_out != NULL);
bfd_copy_private_section_data(bfd_in, sec_in,
bfd_out, sec_out);
}
bfd_close(bfd_in);
}
bfd_close(bfd_out);
return 0;
}
_________________________________________________________________
Join the worldÂ’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
- Previous message (by thread): scripting apps with assembly?
- Next message (by thread): merging executables
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list