[ create a new paste ] login | about

Link: http://codepad.org/23jVZn0J    [ raw code | output | fork ]

C, pasted on Mar 6:
#include <stdio.h>
#include <string.h>
#include <elf.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <fcntl.h>

int main( int argc, char *argv[] ){

   Elf32_Ehdr ehdr;
   Elf32_Shdr shdr;
   int fd, i, shstrtbl;
   if( (fd = open( argv[0], O_RDONLY )) == -1 ){
      perror("open");
      return 1;
   }
   if( read( fd, &ehdr, sizeof(ehdr)) == -1 ){
      perror("read");
      close(fd);
      return 1;
   }
   printf("OS/ABI: %d\n", ehdr.e_ident[EI_OSABI] );
   printf("e_machine: %d\n", ehdr.e_machine );
   return 0;
}
   


Output:
1
2
3
OS/ABI: 0
e_machine: 3



Create a new paste based on this one


Comments: