Skip to content

Instantly share code, notes, and snippets.

@merces
Created December 13, 2017 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save merces/d9188c2670caf28e70d3d3f6f6e1ceb5 to your computer and use it in GitHub Desktop.
Save merces/d9188c2670caf28e70d3d3f6f6e1ceb5 to your computer and use it in GitHub Desktop.
read a file using libbfd
#include <stdio.h>
#include <bfd.h>
struct bfd b;
int main(int argc, char* argv[]) {
struct bfd *b;
char *path = argv[1];
if (!path) {
fprintf(stderr, "deu ruim\n");
return 1;
}
bfd_init();
b = bfd_openr(path, NULL);
puts(b->filename);
printf("type: %d\n", b->format);
bfd_close(b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment