Some of the predefined polynomes are the same, but differs in the other
parameters.
+
+Note - the generation of 64-bit polynomes on 32-bit hosts for 32-bit
+targets is not supported.
+
@page
The 32-bit <polynome> command defines the following global symbols.
}
local_table = true;
}
- for (bfd_vma i = 0; i < 256; i++)
+ for (int i = 0; i < 256; i++)
{
uint32_t elem = crc32_table[i];
if (big_endian)
CRC_START = CRC64_START;
CRC_END = CRC64_END;
CRC_TABLE = CRC64_TABLE;
- lang_add_data (QUAD, exp_intop (0)); /* Reserve room for the ECC value */
+
+ /* Reserve room for the ECC value. */
+ lang_add_data (QUAD, exp_intop (0));
+
a->crc_tab = init_crc64_tab (a);
if (a->crc_tab == NULL)
{
static void
lang_add_crc64_table (bool big_endian)
{
- bfd_vma *crc64_table = algorithm.crc_tab; /* Use a precomputed, if it exists */
+ /* Use a precomputed table, if one exists. */
+ uint64_t *crc64_table = algorithm.crc_tab;
bool local_table = false;
+
if (crc64_table == NULL)
- { /* No luck, create a table */
+ {
+ /* No luck, create a table. */
crc64_table = init_crc64_tab (&algorithm);
if (crc64_table == NULL)
{
}
local_table = true;
}
+
print_hash64_table (&algorithm);
- for (bfd_vma i = 0; i < 256; i++)
+
+ for (int i = 0; i < 256; i++)
{
- bfd_vma elem = crc64_table[i];
+ uint64_t elem = crc64_table[i];
+
if (big_endian)
- {
- elem = __builtin_bswap64 (elem);
- }
+ elem = __builtin_bswap64 (elem);
+
if (link_info.big_endian)
+ elem = __builtin_bswap64 (elem);
+
+ if (sizeof (bfd_vma) >= QUAD_SIZE)
+ lang_add_data (QUAD, exp_intop (elem));
+ else
{
- elem = __builtin_bswap64 (elem);
+ lang_add_data (LONG, exp_intop (elem >> 32));
+ lang_add_data (LONG, exp_intop (elem));
}
-
- lang_add_data (QUAD, exp_intop (elem));
}
+
if (local_table)
free (crc64_table);
}
bfd_vma poly,
bfd_vma initial,
bfd_vma xor_val,
- bfd_vma ireflect, bfd_vma oreflect, bfd_vma reciprocal)
+ bfd_vma ireflect,
+ bfd_vma oreflect,
+ bfd_vma reciprocal)
{
if (algorithm.crc_algo != no_algo) /* We only allow one CRC <polynom> */
{
text_section->output_section,
(bfd_byte **) & text_contents))
{
- einfo (_("%X%P: '&s' section contents unavailable\n"
+ einfo (_("%X%P: '%s' section contents unavailable\n"
"CRC generation aborted\n"), digest_section);
return false;
}
}
static bool
-set_crc_checksum (bfd_vma crc, bfd_vma addr, bfd_vma size)
+set_crc_checksum (uint64_t crc, bfd_vma addr, bfd_vma size)
{
bool status;
if (size == 64)
* Multiplexing function for calculating CRC with different algorithms
* 'algorithm.crc_algo'
*/
-static bfd_vma
+static uint64_t
calculate_crc (const unsigned char *input_str, size_t num_bytes)
{
if (algorithm.crc_algo == crc_algo_64)
static bool
invalid_crc_parameters (bfd_vma crc_addr,
- bfd_vma crc_area_start, bfd_vma crc_area_end)
+ bfd_vma crc_area_start,
+ bfd_vma crc_area_end)
{
bool crc_in_section;
bfd_vma crc_size = algorithm.crc_size / 8;
lang_generate_crc (void)
{
bfd_vma crc_addr, crc_area_start, crc_area_end;
- bfd_vma crc;
+ uint64_t crc;
bool can_do_crc;
/* Return immediately, if CRC is not requested */
extern bool digest_big_endian;
extern bool polynome_valid;
-/* CRC-32 */
-extern uint32_t *init_crc32_tab (algorithm_desc_t * dsc);
+/* In ldcrc32.c. */
+extern uint32_t * init_crc32_tab
+ (algorithm_desc_t *);
extern uint32_t calc_crc32
- (algorithm_desc_t * dsc, const unsigned char *input_str, size_t num_bytes);
-extern void lang_add_crc32_syndrome (algorithm_desc_t * a);
-
-/* CR-64 */
-extern bfd_vma *init_crc64_tab (algorithm_desc_t * dsc);
-extern bfd_vma calc_crc64
- (algorithm_desc_t * dsc, const unsigned char *input_str, size_t num_bytes);
-extern void lang_add_crc64_syndrome (algorithm_desc_t * a);
-
-extern void lang_add_digest (bfd_vma size,
- bfd_vma poly,
- bfd_vma initial,
- bfd_vma xor_val,
- bfd_vma ireflect,
- bfd_vma oreflect, bfd_vma reciprocal);
-extern bool lang_set_digest (char *digest);
-extern void lang_add_digest_table (bool big_endian);
-extern const char *lang_get_label (const char *label, bool *big_endian);
-extern void lang_generate_crc (void);
-extern void lang_generate_digest (void);
+ (algorithm_desc_t *, const unsigned char *, size_t);
+extern void lang_add_crc32_syndrome
+ (algorithm_desc_t *);
+
+/* In ldcrc64.c. */
+extern uint64_t * init_crc64_tab
+ (algorithm_desc_t *);
+extern uint64_t calc_crc64
+ (algorithm_desc_t *, const unsigned char *, size_t);
+extern void lang_add_crc64_syndrome
+ (algorithm_desc_t * );
+
+/* In lddigest.c */
+extern void lang_add_digest
+ (bfd_vma, bfd_vma, bfd_vma, bfd_vma, bfd_vma, bfd_vma, bfd_vma);
+extern bool lang_set_digest
+ (char *);
+extern void lang_add_digest_table
+ (bool);
+extern const char * lang_get_label
+ (const char *, bool *);
+extern void lang_generate_crc
+ (void);
+extern void lang_generate_digest
+ (void);
#endif /* LDDIGEST_H */
}
| DIGEST NAME
{ /* CRC_ADDRESS is set in <polynome>, but polynome reserves space, so we use a temporary */
- digest_label = lang_get_label($2, &digest_big_endian);
+ digest_label = lang_get_label ($2, &digest_big_endian);
lang_add_assignment (exp_assign (digest_label, exp_nameop (NAME, "."), false));
}
polynome '(' mustbe_exp ',' mustbe_exp ')'
polynome:
NAME
{
- polynome_valid = lang_set_digest($1);
+ polynome_valid = lang_set_digest ($1);
}
| POLY '(' mustbe_exp ','
mustbe_exp ',' mustbe_exp ',' mustbe_exp ','
Contents of section .text:
1200 434f4445 deadbeef 00000000 00000000 CODE............
1210 6c40df5f 0b497347 00000000 00000000 l@._.IsG........
- 1220 6c40df5f 0b497347 00000000 00000000 l@._.IsG........
+ 1220 ee5e1ecd 02f31206 00000000 00000000 ................
1230 00000000 00000000 deadbeef 434f4445 ............CODE
1240 31323334 35363738 3900ffff ffffffff 123456789.......
1250 434f4445 00000000 00000000 00000000 CODE............
QUAD(0x0);
crc64 = .;
- DIGEST "_CRC64#BE" POLY(64,0x42F0E1EBA9EA3693,0,0,0,0,0)(ecc_start , ecc_end)
+ DIGEST "_CRC64#BE" POLY(64,0xA9EA3693,0,0,0,0,0)(ecc_start , ecc_end)
QUAD(0x0);
INCLUDE "end_tag.inc"