diff options
author | Alan Modra <amodra@gmail.com> | 2023-03-08 21:26:52 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-03-09 16:02:57 +1030 |
commit | bf0e35375461ef2a17e2872e7f5c1446a5924b64 (patch) | |
tree | 7a340aae6467a79926b417febb38ab6232a20e79 /ld | |
parent | 1478a11d76dbd4de9a0de43b1ea736223b3662c2 (diff) | |
download | gdb-bf0e35375461ef2a17e2872e7f5c1446a5924b64.zip gdb-bf0e35375461ef2a17e2872e7f5c1446a5924b64.tar.gz gdb-bf0e35375461ef2a17e2872e7f5c1446a5924b64.tar.bz2 |
lddigest 32-bit support and gcc-4 compile errors
* ld.texi: Revert 2023-03-08 commit 9a534b9f8e3d.
* testsuite/ld-scripts/crc64-poly.d: Likewise.
* testsuite/ld-scripts/crc64-poly.t: Likewise.
* lddigest.c: Formatting.
(get_uint64_t): New function.
(lang_add_digest): Take etree_type* args. Replace "illegal" with
"invalid" in error message.
* lddigest.h (lang_add_digest): Update prototype.
* lddigest_tab.c (algorithms): Work around gcc-4 errors.
* ldgram.y (polynome): Adjust lang_add_digest call.
* testsuite/ld-scripts/crc64-poly-size.d: Update expected error.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ld.texi | 4 | ||||
-rw-r--r-- | ld/lddigest.c | 98 | ||||
-rwxr-xr-x | ld/lddigest.h | 5 | ||||
-rw-r--r-- | ld/lddigest_tab.c | 4 | ||||
-rw-r--r-- | ld/ldgram.y | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-scripts/crc64-poly-size.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-scripts/crc64-poly.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-scripts/crc64-poly.t | 2 |
8 files changed, 82 insertions, 49 deletions
@@ -5581,10 +5581,6 @@ The parameters are explained in detail in 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. diff --git a/ld/lddigest.c b/ld/lddigest.c index a2d7460..bd74202 100644 --- a/ld/lddigest.c +++ b/ld/lddigest.c @@ -103,10 +103,12 @@ lang_add_crc32_syndrome (algorithm_desc_t * a) static void lang_add_crc32_table (bool big_endian) { - uint32_t *crc32_table = algorithm.crc_tab; /* Use a precomputed, if it exists */ + /* Use a precomputed table, if one exists. */ + uint32_t *crc32_table = algorithm.crc_tab; bool local_table = false; if (crc32_table == NULL) - { /* No luck, create a table */ + { + /* No luck, create a table. */ crc32_table = init_crc32_tab (&algorithm); if (crc32_table == NULL) { @@ -227,14 +229,42 @@ lang_add_crc64_table (bool big_endian) /* ============ DIGEST COMMON functions ======================================*/ +static uint64_t +get_uint64 (etree_type *tree, bool *err) +{ + if (tree != NULL) + { + exp_fold_tree_no_dot (tree); + + if (expld.result.valid_p) + { + if (expld.result.str != NULL) + { + char *end; + uint64_t val = strtoull (expld.result.str, &end, 16); + if (!*end) + return val; + } + else + { + if (expld.result.section != NULL) + expld.result.value += expld.result.section->vma; + return expld.result.value; + } + } + } + *err = true; + return 0; +} + 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) +lang_add_digest (etree_type *size, + etree_type *poly, + etree_type *initial, + etree_type *xor_val, + etree_type *ireflect, + etree_type *oreflect, + etree_type *reciprocal) { if (algorithm.crc_algo != no_algo) /* We only allow one CRC <polynom> */ { @@ -242,40 +272,44 @@ lang_add_digest (bfd_vma size, return; } + bool err = false; algorithm.name = "CUSTOM"; algorithm.big_endian = digest_big_endian; - if (size == 64) + algorithm.crc_size = get_uint64 (size, &err); + algorithm.poly.d64 = get_uint64 (poly, &err); + algorithm.initial.d64 = get_uint64 (initial, &err); + algorithm.xor_val.d64 = get_uint64 (xor_val, &err); + algorithm.ireflect = get_uint64 (ireflect, &err); + algorithm.oreflect = get_uint64 (oreflect, &err); + algorithm.crc_tab = NULL; + algorithm.reciprocal = get_uint64 (reciprocal, &err); + algorithm.expected.d64 = 0; + + if (err) + { + einfo (_("%F%P: Invalid DIGEST arg\n")); + return; + } + + if (algorithm.crc_size == 64) { algorithm.crc_algo = crc_algo_64; - algorithm.crc_size = size; - algorithm.poly.d64 = poly; /* Set the polynom */ - algorithm.initial.d64 = initial; /* Set seed */ - algorithm.xor_val.d64 = xor_val; /* final XOR value */ - algorithm.ireflect = ireflect; - algorithm.oreflect = oreflect; - algorithm.crc_tab = NULL; - algorithm.reciprocal = reciprocal; - algorithm.expected.d64 = 0; - lang_add_crc64_syndrome (&algorithm); } - else if (size == 32) + else if (algorithm.crc_size == 32) { algorithm.crc_algo = crc_algo_32; - algorithm.crc_size = size; - algorithm.poly.d32._0 = poly; /* Set the polynom */ - algorithm.initial.d32._0 = initial; /* Set seed */ - algorithm.xor_val.d32._0 = xor_val; /* final XOR value */ - algorithm.ireflect = ireflect; - algorithm.oreflect = oreflect; - algorithm.crc_tab = NULL; - algorithm.reciprocal = reciprocal; - algorithm.expected.d32._0 = 0; + algorithm.poly.d32._0 = algorithm.poly.d64; + algorithm.poly.d32._1 = 0; + algorithm.initial.d32._0 = algorithm.initial.d64; + algorithm.initial.d32._1 = 0; + algorithm.xor_val.d32._0 = algorithm.xor_val.d64; + algorithm.xor_val.d32._1 = 0; lang_add_crc32_syndrome (&algorithm); } else { - einfo (_("%F%P: Illegal Size in DIGEST: %E\n")); + einfo (_("%F%P: Invalid Size in DIGEST\n")); return; } } @@ -675,7 +709,7 @@ set_crc64_checksum (uint64_t crc, bfd_vma addr) } static bool -set_crc_checksum (uint64_t crc, bfd_vma addr, bfd_vma size) +set_crc_checksum (uint64_t crc, bfd_vma addr, int size) { bool status; if (size == 64) diff --git a/ld/lddigest.h b/ld/lddigest.h index a1eeb02..8f2889f 100755 --- a/ld/lddigest.h +++ b/ld/lddigest.h @@ -173,8 +173,11 @@ extern void lang_add_crc64_syndrome (algorithm_desc_t * ); /* In lddigest.c */ +union etree_union; extern void lang_add_digest - (bfd_vma, bfd_vma, bfd_vma, bfd_vma, bfd_vma, bfd_vma, bfd_vma); + (union etree_union *, union etree_union *, union etree_union *, + union etree_union *, union etree_union *, union etree_union *, + union etree_union *); extern bool lang_set_digest (char *); extern void lang_add_digest_table diff --git a/ld/lddigest_tab.c b/ld/lddigest_tab.c index 4f5db10..b286a3c 100644 --- a/ld/lddigest_tab.c +++ b/ld/lddigest_tab.c @@ -99,9 +99,9 @@ const algorithm_desc_t algorithms[MAXALGO+1] = [CRC32] = { crc_algo_32, 32, "CRC32", - .poly.d32._0 = CRC_POLY_32, + .poly.d32 = { CRC_POLY_32, 0 }, .initial.d64 = CRC_START_32_INV, - .xor_val.d32._0 = CRC_END_32_INV, + .xor_val.d32 = { CRC_END_32_INV, 0 }, .ireflect = true, .oreflect = true, .reciprocal = false, diff --git a/ld/ldgram.y b/ld/ldgram.y index 54bf8e0..93aff6e 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -747,13 +747,13 @@ polynome: mustbe_exp ',' mustbe_exp ',' mustbe_exp ')' { lang_add_digest ( - $3->value.value, /* size */ - $5->value.value, /* polynome */ - $7->value.value, /* initial value */ - $9->value.value, /* xor value */ - $11->value.value, /* input reflected */ - $13->value.value, /* output reflected */ - $15->value.value /* reciprocal */ + $3, /* size */ + $5, /* polynome */ + $7, /* initial value */ + $9, /* xor value */ + $11, /* input reflected */ + $13, /* output reflected */ + $15 /* reciprocal */ ); polynome_valid = true; } diff --git a/ld/testsuite/ld-scripts/crc64-poly-size.d b/ld/testsuite/ld-scripts/crc64-poly-size.d index 6a3651c..1c7b3c4 100644 --- a/ld/testsuite/ld-scripts/crc64-poly-size.d +++ b/ld/testsuite/ld-scripts/crc64-poly-size.d @@ -1,5 +1,5 @@ #source: crc64-poly-size.s #ld: -T crc64-poly-size.t -# error: .*: Illegal Size in DIGEST: .* +# error: .*: Invalid Size in DIGEST #target: [is_elf_format] [is_coff_format] #skip: tic4x-*-* tic54x-*-* diff --git a/ld/testsuite/ld-scripts/crc64-poly.d b/ld/testsuite/ld-scripts/crc64-poly.d index a1e6eb8..b54ac47 100644 --- a/ld/testsuite/ld-scripts/crc64-poly.d +++ b/ld/testsuite/ld-scripts/crc64-poly.d @@ -9,7 +9,7 @@ Contents of section .text: 1200 434f4445 deadbeef 00000000 00000000 CODE............ 1210 6c40df5f 0b497347 00000000 00000000 l@._.IsG........ - 1220 ee5e1ecd 02f31206 00000000 00000000 ................ + 1220 6c40df5f 0b497347 00000000 00000000 l@._.IsG........ 1230 00000000 00000000 deadbeef 434f4445 ............CODE 1240 31323334 35363738 3900ffff ffffffff 123456789....... 1250 434f4445 00000000 00000000 00000000 CODE............ diff --git a/ld/testsuite/ld-scripts/crc64-poly.t b/ld/testsuite/ld-scripts/crc64-poly.t index 00a2155..fb357ca 100644 --- a/ld/testsuite/ld-scripts/crc64-poly.t +++ b/ld/testsuite/ld-scripts/crc64-poly.t @@ -26,7 +26,7 @@ SECTIONS QUAD(0x0); crc64 = .; - DIGEST "_CRC64#BE" POLY(64,0xA9EA3693,0,0,0,0,0)(ecc_start , ecc_end) + DIGEST "_CRC64#BE" POLY(64,0x42F0E1EBA9EA3693,0,0,0,0,0)(ecc_start , ecc_end) QUAD(0x0); INCLUDE "end_tag.inc" |