scripts/gen_offset_header/gen_offset_header.c
/**
 * @brief load the section headers
 * @param fd file descriptor of file from which to read
 *
 * @returns 0 on success, -1 on failure
 */
@brief load the section headers
@param fd file descriptor of file from which to read

@returns 0 on success, -1 on failure
@brief load the section headers @param fd file descriptor of file from which to read @returns 0 on success - 1 on failure
static int shdrsLoad(int fd)
{
	size_t    nBytes;    
	unsigned  ix;        
	shdr = malloc(ehdr.e_shnum * sizeof(Elf32_Shdr));
	if (shdr == NULL)
	{
		fprintf(stderr, "No memory for section headers!\n");
		return -1;
	}
	if (lseek(fd, ehdr.e_shoff, SEEK_SET) == -1) {
		fprintf(stderr, "Unable to seek\n");
		return -1;
	}
	for (ix = 0; ix < ehdr.e_shnum; ix++)
	{
		nBytes = read(fd, &shdr[ix], sizeof(Elf32_Shdr));
		if (nBytes != sizeof(Elf32_Shdr))
		{
			fprintf(stderr, "Unable to read entire section header (#%d)\n",
					ix);
			return -1;
		}
		swabElfSectionHdr(&shdr[ix]);   
	}
	return 0;
}
static int shdrsLoad ( int fd ) { size_t nBytes ; unsigned ix ; shdr = malloc ( ehdr . e_shnum * sizeof ( Elf32_Shdr ) ) ; if ( shdr == NULL ) { fprintf ( stderr , " \n " ) ; return -1 ; } if ( lseek ( fd , ehdr . e_shoff , SEEK_SET ) == -1 ) { fprintf ( stderr , " \n " ) ; return -1 ; } for ( ix = 0 ; ix < ehdr . e_shnum ; ix ++ ) { nBytes = read ( fd , & shdr [ ix ] , sizeof ( Elf32_Shdr ) ) ; if ( nBytes != sizeof ( Elf32_Shdr ) ) { fprintf ( stderr , " \n " , ix ) ; return -1 ; } swabElfSectionHdr ( & shdr [ ix ] ) ; } return 0 ; }
@brief load the section headers
 @param fd file descriptor of file from which to read
@brief load the section headers @param fd file descriptor of file from which to read
/* number of bytes read from file */ /* loop index */ /* Seek to the start of the table of section headers */ /* swap bytes (if required) */