Implement CRC calculation for section

This commit is contained in:
2022-10-20 19:25:21 +02:00
parent 0278cb19d4
commit af785f0ef3
5 changed files with 187 additions and 17 deletions

View File

@@ -41,6 +41,8 @@ int crc_len_from_poly(uint64_t polynomial);
void crc_init(struct crc_calc *crc, const struct crc_settings *settings);
void crc_reset(struct crc_calc *crc);
void crc_destroy(struct crc_calc *crc);
void crc_push_byte(struct crc_calc *crc, uint8_t b);

View File

@@ -2,11 +2,30 @@
#define _ELFPATCH_H_
#include <stdint.h>
#include <patchelfcrc/crc.h>
#include <stdbool.h>
typedef struct elfpatch elfpatch_handle_t;
enum granularity {
GRANULARITY_BYTE = 8,
GRANULARITY_16BIT = 16,
GRANULARITY_32BIT = 32,
};
elfpatch_handle_t *elf_patch_open(const char *path);
/**
* @brief Check if a section is present in file
* @param section Section name
* @return 0 if present. Else -1. -1001 in case of pointer error
*/
int elf_patch_check_for_section(elfpatch_handle_t *ep, const char *section);
int elf_patch_compute_crc_over_section(elfpatch_handle_t *ep, const char *section, struct crc_calc *crc,
enum granularity granularity, bool little_endian);
void elf_patch_close_and_free(elfpatch_handle_t *ep);
#endif /* _ELFPATCH_H_ */