diff --git a/include/patchelfcrc/crc-output-struct.h b/include/patchelfcrc/crc-output-struct.h index 34ed808..4fddc03 100644 --- a/include/patchelfcrc/crc-output-struct.h +++ b/include/patchelfcrc/crc-output-struct.h @@ -3,14 +3,30 @@ #include +/** + * @brief Expected size of @ref crc_out_struct_32bit. + * @note If the size of the structure does not match this number, structure padding occured which should not happen. + */ #define CRC_OUT_STRUCT_SIZE_32BIT 12u + +/** + * @brief output structure of CRCs in a 32bit executable +*/ struct crc_out_struct_32bit { uint32_t start_address; /**< @brief Start address of struct*/ uint32_t length; /**< @brief Length of section in bytes */ uint32_t crc; /**< @brief LSB aligned CRC */ }; +/** + * @brief Expected size of @ref crc_out_struct_64bit. + * @note If the size of the structure does not match this number, structure padding occured which should not happen. + */ #define CRC_OUT_STRUCT_SIZE_64BIT 24u + +/** + * @brief output structure of CRCs in a 64bit executable + */ struct crc_out_struct_64bit { uint64_t start_address; /**< @brief Start address of struct*/ uint64_t length; /**< @brief Length of section in bytes */ @@ -18,6 +34,9 @@ struct crc_out_struct_64bit { uint32_t _unused_dummy; /**< @brief Dummy. Do not use, it prevents misalignments */ }; +/** + * @brief Trigger compile error if condition is false + */ #define BUILD_ASSERT(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) /** diff --git a/main.c b/main.c index c95093d..256f32a 100644 --- a/main.c +++ b/main.c @@ -117,6 +117,15 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) case 'O': args->output_section = arg; break; + case 'r': + args->crc.rev = true; + break; + case 's': + args->crc.start_value = strtoul(arg, NULL, 0); + break; + case 'x': + args->crc.xor = strtoul(arg, NULL, 0); + break; case ARGP_KEY_ARG: if (state->arg_num >= 1) argp_usage(state);