GNU Binutils with patches for OS216
修訂 | 55ff522848fef1fc5323060fd042d0988e71d4b9 (tree) |
---|---|
時間 | 2017-02-23 12:31:06 |
作者 | Alan Modra <amodra@gmai...> |
Commiter | Alan Modra |
Correct VLE 16D and SDAREL relocations
PR 20744
bfd/
* elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask on all VLE
16D relocations.
(ppc_elf_vle_split16): Correct field mask and shift for 16D relocs.
(ppc_elf_relocate_section): Correct calculation for VLE SDAREL
relocs.
ld/
* testsuite/ld-powerpc/vle-reloc-2.s: Use r6 for last insn of
each group.
* testsuite/ld-powerpc/vle-reloc-2.d: Update for above change
and sdarel reloc fix.
@@ -1,3 +1,12 @@ | ||
1 | +2017-02-23 Alan Modra <amodra@gmail.com> | |
2 | + | |
3 | + PR 20744 | |
4 | + * elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask on all VLE | |
5 | + 16D relocations. | |
6 | + (ppc_elf_vle_split16): Correct field mask and shift for 16D relocs. | |
7 | + (ppc_elf_relocate_section): Correct calculation for VLE SDAREL | |
8 | + relocs. | |
9 | + | |
1 | 10 | 2017-02-22 Alan Modra <amodra@gmail.com> |
2 | 11 | |
3 | 12 | * elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Don't segfault |
@@ -1471,7 +1471,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { | ||
1471 | 1471 | "R_PPC_VLE_LO16D", /* name */ |
1472 | 1472 | FALSE, /* partial_inplace */ |
1473 | 1473 | 0, /* src_mask */ |
1474 | - 0x1f007ff, /* dst_mask */ | |
1474 | + 0x3e007ff, /* dst_mask */ | |
1475 | 1475 | FALSE), /* pcrel_offset */ |
1476 | 1476 | |
1477 | 1477 | /* Bits 16-31 split16a format. */ |
@@ -1501,7 +1501,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { | ||
1501 | 1501 | "R_PPC_VLE_HI16D", /* name */ |
1502 | 1502 | FALSE, /* partial_inplace */ |
1503 | 1503 | 0, /* src_mask */ |
1504 | - 0x1f007ff, /* dst_mask */ | |
1504 | + 0x3e007ff, /* dst_mask */ | |
1505 | 1505 | FALSE), /* pcrel_offset */ |
1506 | 1506 | |
1507 | 1507 | /* Bits 16-31 (High Adjusted) in split16a format. */ |
@@ -1531,7 +1531,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { | ||
1531 | 1531 | "R_PPC_VLE_HA16D", /* name */ |
1532 | 1532 | FALSE, /* partial_inplace */ |
1533 | 1533 | 0, /* src_mask */ |
1534 | - 0x1f007ff, /* dst_mask */ | |
1534 | + 0x3e007ff, /* dst_mask */ | |
1535 | 1535 | FALSE), /* pcrel_offset */ |
1536 | 1536 | |
1537 | 1537 | /* This reloc is like R_PPC_EMB_SDA21 but only applies to e_add16i |
@@ -1593,7 +1593,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { | ||
1593 | 1593 | "R_PPC_VLE_SDAREL_LO16D", /* name */ |
1594 | 1594 | FALSE, /* partial_inplace */ |
1595 | 1595 | 0, /* src_mask */ |
1596 | - 0x1f007ff, /* dst_mask */ | |
1596 | + 0x3e007ff, /* dst_mask */ | |
1597 | 1597 | FALSE), /* pcrel_offset */ |
1598 | 1598 | |
1599 | 1599 | /* Bits 16-31 relative to _SDA_BASE_ in split16a format. */ |
@@ -1623,7 +1623,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { | ||
1623 | 1623 | "R_PPC_VLE_SDAREL_HI16D", /* name */ |
1624 | 1624 | FALSE, /* partial_inplace */ |
1625 | 1625 | 0, /* src_mask */ |
1626 | - 0x1f007ff, /* dst_mask */ | |
1626 | + 0x3e007ff, /* dst_mask */ | |
1627 | 1627 | FALSE), /* pcrel_offset */ |
1628 | 1628 | |
1629 | 1629 | /* Bits 16-31 (HA) relative to _SDA_BASE split16a format. */ |
@@ -1653,7 +1653,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { | ||
1653 | 1653 | "R_PPC_VLE_SDAREL_HA16D", /* name */ |
1654 | 1654 | FALSE, /* partial_inplace */ |
1655 | 1655 | 0, /* src_mask */ |
1656 | - 0x1f007ff, /* dst_mask */ | |
1656 | + 0x3e007ff, /* dst_mask */ | |
1657 | 1657 | FALSE), /* pcrel_offset */ |
1658 | 1658 | |
1659 | 1659 | HOWTO (R_PPC_IRELATIVE, /* type */ |
@@ -4942,8 +4942,8 @@ ppc_elf_vle_split16 (bfd *input_bfd, | ||
4942 | 4942 | } |
4943 | 4943 | } |
4944 | 4944 | top5 = value & 0xf800; |
4945 | - top5 = top5 << (split16_format == split16a_type ? 5 : 9); | |
4946 | - insn &= (split16_format == split16a_type ? ~0x1f07ff : ~0x1f007ff); | |
4945 | + top5 = top5 << (split16_format == split16a_type ? 5 : 10); | |
4946 | + insn &= (split16_format == split16a_type ? ~0x1f07ff : ~0x3e007ff); | |
4947 | 4947 | insn |= top5; |
4948 | 4948 | insn |= value & 0x7ff; |
4949 | 4949 | bfd_put_32 (input_bfd, insn, loc); |
@@ -9382,7 +9382,6 @@ ppc_elf_relocate_section (bfd *output_bfd, | ||
9382 | 9382 | { |
9383 | 9383 | bfd_vma value; |
9384 | 9384 | const char *name; |
9385 | - //int reg; | |
9386 | 9385 | struct elf_link_hash_entry *sda = NULL; |
9387 | 9386 | |
9388 | 9387 | if (sec == NULL || sec->output_section == NULL) |
@@ -9394,16 +9393,10 @@ ppc_elf_relocate_section (bfd *output_bfd, | ||
9394 | 9393 | name = bfd_get_section_name (output_bfd, sec->output_section); |
9395 | 9394 | if (strcmp (name, ".sdata") == 0 |
9396 | 9395 | || strcmp (name, ".sbss") == 0) |
9397 | - { | |
9398 | - //reg = 13; | |
9399 | - sda = htab->sdata[0].sym; | |
9400 | - } | |
9396 | + sda = htab->sdata[0].sym; | |
9401 | 9397 | else if (strcmp (name, ".sdata2") == 0 |
9402 | 9398 | || strcmp (name, ".sbss2") == 0) |
9403 | - { | |
9404 | - //reg = 2; | |
9405 | - sda = htab->sdata[1].sym; | |
9406 | - } | |
9399 | + sda = htab->sdata[1].sym; | |
9407 | 9400 | else |
9408 | 9401 | { |
9409 | 9402 | _bfd_error_handler |
@@ -9420,18 +9413,12 @@ ppc_elf_relocate_section (bfd *output_bfd, | ||
9420 | 9413 | goto copy_reloc; |
9421 | 9414 | } |
9422 | 9415 | |
9423 | - if (sda != NULL) | |
9416 | + if (sda == NULL || !is_static_defined (sda)) | |
9424 | 9417 | { |
9425 | - if (!is_static_defined (sda)) | |
9426 | - { | |
9427 | - unresolved_reloc = TRUE; | |
9428 | - break; | |
9429 | - } | |
9418 | + unresolved_reloc = TRUE; | |
9419 | + break; | |
9430 | 9420 | } |
9431 | - | |
9432 | - value = (sda->root.u.def.section->output_section->vma | |
9433 | - + sda->root.u.def.section->output_offset | |
9434 | - + addend); | |
9421 | + value = relocation + addend - SYM_VAL (sda); | |
9435 | 9422 | |
9436 | 9423 | if (r_type == R_PPC_VLE_SDAREL_LO16A) |
9437 | 9424 | ppc_elf_vle_split16 (input_bfd, input_section, rel->r_offset, |
@@ -1,3 +1,11 @@ | ||
1 | +2017-02-23 Alan Modra <amodra@gmail.com> | |
2 | + | |
3 | + PR 20744 | |
4 | + * testsuite/ld-powerpc/vle-reloc-2.s: Use r6 for last insn of | |
5 | + each group. | |
6 | + * testsuite/ld-powerpc/vle-reloc-2.d: Update for above change | |
7 | + and sdarel reloc fix. | |
8 | + | |
1 | 9 | 2017-02-16 Alan Modra <amodra@gmail.com> |
2 | 10 | |
3 | 11 | * testsuite/ld-unique/unique.exp: xfail two tests for hppa. |
@@ -10,75 +10,75 @@ Disassembly of section .text: | ||
10 | 10 | .*: 70 20 c1 a2 e_or2i r1,418 |
11 | 11 | .*: 70 40 c1 81 e_or2i r2,385 |
12 | 12 | .*: 70 60 c1 81 e_or2i r3,385 |
13 | -.*: 70 80 c1 ae e_or2i r4,430 | |
14 | -.*: 70 a0 c1 80 e_or2i r5,384 | |
15 | -.*: 70 40 c1 81 e_or2i r2,385 | |
13 | +.*: 70 90 c0 00 e_or2i r4,32768 | |
14 | +.*: 70 bf c7 ff e_or2i r5,65535 | |
15 | +.*: 70 c0 c0 00 e_or2i r6,0 | |
16 | 16 | .*: 70 20 c9 a2 e_and2i\. r1,418 |
17 | 17 | .*: 70 40 c9 81 e_and2i\. r2,385 |
18 | 18 | .*: 70 60 c9 81 e_and2i\. r3,385 |
19 | -.*: 70 80 c9 ae e_and2i\. r4,430 | |
20 | -.*: 70 a0 c9 80 e_and2i\. r5,384 | |
21 | -.*: 70 40 c9 81 e_and2i\. r2,385 | |
19 | +.*: 70 90 c8 00 e_and2i\. r4,32768 | |
20 | +.*: 70 bf cf ff e_and2i\. r5,65535 | |
21 | +.*: 70 c0 c8 00 e_and2i\. r6,0 | |
22 | 22 | .*: 70 20 d1 a2 e_or2is r1,418 |
23 | 23 | .*: 70 40 d1 81 e_or2is r2,385 |
24 | 24 | .*: 70 60 d1 81 e_or2is r3,385 |
25 | -.*: 70 80 d1 ae e_or2is r4,430 | |
26 | -.*: 70 a0 d1 80 e_or2is r5,384 | |
27 | -.*: 70 40 d1 81 e_or2is r2,385 | |
25 | +.*: 70 90 d0 00 e_or2is r4,32768 | |
26 | +.*: 70 bf d7 ff e_or2is r5,65535 | |
27 | +.*: 70 c0 d0 00 e_or2is r6,0 | |
28 | 28 | .*: 70 20 e1 a2 e_lis r1,418 |
29 | 29 | .*: 70 40 e1 81 e_lis r2,385 |
30 | 30 | .*: 70 60 e1 81 e_lis r3,385 |
31 | -.*: 70 80 e1 ae e_lis r4,430 | |
32 | -.*: 70 a0 e1 80 e_lis r5,384 | |
33 | -.*: 70 40 e1 81 e_lis r2,385 | |
31 | +.*: 70 90 e0 00 e_lis r4,32768 | |
32 | +.*: 70 bf e7 ff e_lis r5,65535 | |
33 | +.*: 70 c0 e0 00 e_lis r6,0 | |
34 | 34 | .*: 70 20 e9 a2 e_and2is\. r1,418 |
35 | 35 | .*: 70 40 e9 81 e_and2is\. r2,385 |
36 | 36 | .*: 70 60 e9 81 e_and2is\. r3,385 |
37 | -.*: 70 80 e9 ae e_and2is\. r4,430 | |
38 | -.*: 70 a0 e9 80 e_and2is\. r5,384 | |
39 | -.*: 70 40 e9 81 e_and2is\. r2,385 | |
37 | +.*: 70 90 e8 00 e_and2is\. r4,32768 | |
38 | +.*: 70 bf ef ff e_and2is\. r5,65535 | |
39 | +.*: 70 c0 e8 00 e_and2is\. r6,0 | |
40 | 40 | .*: 70 01 99 a2 e_cmp16i r1,418 |
41 | 41 | .*: 70 02 99 81 e_cmp16i r2,385 |
42 | 42 | .*: 70 03 99 81 e_cmp16i r3,385 |
43 | -.*: 70 04 99 ae e_cmp16i r4,430 | |
44 | -.*: 70 05 99 80 e_cmp16i r5,384 | |
45 | -.*: 70 02 99 81 e_cmp16i r2,385 | |
43 | +.*: 72 04 98 00 e_cmp16i r4,-32768 | |
44 | +.*: 73 e5 9f ff e_cmp16i r5,-1 | |
45 | +.*: 70 06 98 00 e_cmp16i r6,0 | |
46 | 46 | .*: 70 01 a9 a2 e_cmpl16i r1,418 |
47 | 47 | .*: 70 02 a9 81 e_cmpl16i r2,385 |
48 | 48 | .*: 70 03 a9 81 e_cmpl16i r3,385 |
49 | -.*: 70 04 a9 ae e_cmpl16i r4,430 | |
50 | -.*: 70 05 a9 80 e_cmpl16i r5,384 | |
51 | -.*: 70 02 a9 81 e_cmpl16i r2,385 | |
49 | +.*: 72 04 a8 00 e_cmpl16i r4,32768 | |
50 | +.*: 73 e5 af ff e_cmpl16i r5,65535 | |
51 | +.*: 70 06 a8 00 e_cmpl16i r6,0 | |
52 | 52 | .*: 70 01 b1 a2 e_cmph16i r1,418 |
53 | 53 | .*: 70 02 b1 81 e_cmph16i r2,385 |
54 | 54 | .*: 70 03 b1 81 e_cmph16i r3,385 |
55 | -.*: 70 04 b1 ae e_cmph16i r4,430 | |
56 | -.*: 70 05 b1 80 e_cmph16i r5,384 | |
57 | -.*: 70 02 b1 81 e_cmph16i r2,385 | |
55 | +.*: 72 04 b0 00 e_cmph16i r4,-32768 | |
56 | +.*: 73 e5 b7 ff e_cmph16i r5,-1 | |
57 | +.*: 70 06 b0 00 e_cmph16i r6,0 | |
58 | 58 | .*: 70 01 b9 a2 e_cmphl16i r1,418 |
59 | 59 | .*: 70 02 b9 81 e_cmphl16i r2,385 |
60 | 60 | .*: 70 03 b9 81 e_cmphl16i r3,385 |
61 | -.*: 70 04 b9 ae e_cmphl16i r4,430 | |
62 | -.*: 70 05 b9 80 e_cmphl16i r5,384 | |
63 | -.*: 70 02 b9 81 e_cmphl16i r2,385 | |
61 | +.*: 72 04 b8 00 e_cmphl16i r4,32768 | |
62 | +.*: 73 e5 bf ff e_cmphl16i r5,65535 | |
63 | +.*: 70 06 b8 00 e_cmphl16i r6,0 | |
64 | 64 | .*: 70 01 89 a2 e_add2i\. r1,418 |
65 | 65 | .*: 70 02 89 81 e_add2i\. r2,385 |
66 | 66 | .*: 70 03 89 81 e_add2i\. r3,385 |
67 | -.*: 70 04 89 ae e_add2i\. r4,430 | |
68 | -.*: 70 05 89 80 e_add2i\. r5,384 | |
69 | -.*: 70 02 89 81 e_add2i\. r2,385 | |
67 | +.*: 72 04 88 00 e_add2i. r4,-32768 | |
68 | +.*: 73 e5 8f ff e_add2i. r5,-1 | |
69 | +.*: 70 06 88 00 e_add2i. r6,0 | |
70 | 70 | .*: 70 01 91 a2 e_add2is r1,418 |
71 | 71 | .*: 70 02 91 81 e_add2is r2,385 |
72 | 72 | .*: 70 03 91 81 e_add2is r3,385 |
73 | -.*: 70 04 91 ae e_add2is r4,430 | |
74 | -.*: 70 05 91 80 e_add2is r5,384 | |
75 | -.*: 70 02 91 81 e_add2is r2,385 | |
73 | +.*: 72 04 90 00 e_add2is r4,-32768 | |
74 | +.*: 73 e5 97 ff e_add2is r5,-1 | |
75 | +.*: 70 06 90 00 e_add2is r6,0 | |
76 | 76 | .*: 70 01 a1 a2 e_mull2i r1,418 |
77 | 77 | .*: 70 02 a1 81 e_mull2i r2,385 |
78 | 78 | .*: 70 03 a1 81 e_mull2i r3,385 |
79 | -.*: 70 04 a1 ae e_mull2i r4,430 | |
80 | -.*: 70 05 a1 80 e_mull2i r5,384 | |
81 | -.*: 70 02 a1 81 e_mull2i r2,385 | |
79 | +.*: 72 04 a0 00 e_mull2i r4,-32768 | |
80 | +.*: 73 e5 a7 ff e_mull2i r5,-1 | |
81 | +.*: 70 06 a0 00 e_mull2i r6,0 | |
82 | 82 | .* <sub3>: |
83 | 83 | .*: 00 04 se_blr |
84 | 84 | .* <sub4>: |
@@ -12,81 +12,81 @@ vle_reloc_2: | ||
12 | 12 | e_or2i 3, high_adjust@ha |
13 | 13 | e_or2i 4, low_sdarel@sdarel@l |
14 | 14 | e_or2i 5, high_sdarel@sdarel@h |
15 | - e_or2i 2, high_adjust_sdarel@sdarel@ha | |
15 | + e_or2i 6, high_adjust_sdarel@sdarel@ha | |
16 | 16 | |
17 | 17 | e_and2i. 1, low@l |
18 | 18 | e_and2i. 2, high@h |
19 | 19 | e_and2i. 3, high_adjust@ha |
20 | 20 | e_and2i. 4, low_sdarel@sdarel@l |
21 | 21 | e_and2i. 5, high_sdarel@sdarel@h |
22 | - e_and2i. 2, high_adjust_sdarel@sdarel@ha | |
22 | + e_and2i. 6, high_adjust_sdarel@sdarel@ha | |
23 | 23 | |
24 | 24 | e_or2is 1, low@l |
25 | 25 | e_or2is 2, high@h |
26 | 26 | e_or2is 3, high_adjust@ha |
27 | 27 | e_or2is 4, low_sdarel@sdarel@l |
28 | 28 | e_or2is 5, high_sdarel@sdarel@h |
29 | - e_or2is 2, high_adjust_sdarel@sdarel@ha | |
29 | + e_or2is 6, high_adjust_sdarel@sdarel@ha | |
30 | 30 | |
31 | 31 | e_lis 1, low@l |
32 | 32 | e_lis 2, high@h |
33 | 33 | e_lis 3, high_adjust@ha |
34 | 34 | e_lis 4, low_sdarel@sdarel@l |
35 | 35 | e_lis 5, high_sdarel@sdarel@h |
36 | - e_lis 2, high_adjust_sdarel@sdarel@ha | |
36 | + e_lis 6, high_adjust_sdarel@sdarel@ha | |
37 | 37 | |
38 | 38 | e_and2is. 1, low@l |
39 | 39 | e_and2is. 2, high@h |
40 | 40 | e_and2is. 3, high_adjust@ha |
41 | 41 | e_and2is. 4, low_sdarel@sdarel@l |
42 | 42 | e_and2is. 5, high_sdarel@sdarel@h |
43 | - e_and2is. 2, high_adjust_sdarel@sdarel@ha | |
43 | + e_and2is. 6, high_adjust_sdarel@sdarel@ha | |
44 | 44 | |
45 | 45 | e_cmp16i 1, low@l |
46 | 46 | e_cmp16i 2, high@h |
47 | 47 | e_cmp16i 3, high_adjust@ha |
48 | 48 | e_cmp16i 4, low_sdarel@sdarel@l |
49 | 49 | e_cmp16i 5, high_sdarel@sdarel@h |
50 | - e_cmp16i 2, high_adjust_sdarel@sdarel@ha | |
50 | + e_cmp16i 6, high_adjust_sdarel@sdarel@ha | |
51 | 51 | |
52 | 52 | e_cmpl16i 1, low@l |
53 | 53 | e_cmpl16i 2, high@h |
54 | 54 | e_cmpl16i 3, high_adjust@ha |
55 | 55 | e_cmpl16i 4, low_sdarel@sdarel@l |
56 | 56 | e_cmpl16i 5, high_sdarel@sdarel@h |
57 | - e_cmpl16i 2, high_adjust_sdarel@sdarel@ha | |
57 | + e_cmpl16i 6, high_adjust_sdarel@sdarel@ha | |
58 | 58 | |
59 | 59 | e_cmph16i 1, low@l |
60 | 60 | e_cmph16i 2, high@h |
61 | 61 | e_cmph16i 3, high_adjust@ha |
62 | 62 | e_cmph16i 4, low_sdarel@sdarel@l |
63 | 63 | e_cmph16i 5, high_sdarel@sdarel@h |
64 | - e_cmph16i 2, high_adjust_sdarel@sdarel@ha | |
64 | + e_cmph16i 6, high_adjust_sdarel@sdarel@ha | |
65 | 65 | |
66 | 66 | e_cmphl16i 1, low@l |
67 | 67 | e_cmphl16i 2, high@h |
68 | 68 | e_cmphl16i 3, high_adjust@ha |
69 | 69 | e_cmphl16i 4, low_sdarel@sdarel@l |
70 | 70 | e_cmphl16i 5, high_sdarel@sdarel@h |
71 | - e_cmphl16i 2, high_adjust_sdarel@sdarel@ha | |
71 | + e_cmphl16i 6, high_adjust_sdarel@sdarel@ha | |
72 | 72 | |
73 | 73 | e_add2i. 1, low@l |
74 | 74 | e_add2i. 2, high@h |
75 | 75 | e_add2i. 3, high_adjust@ha |
76 | 76 | e_add2i. 4, low_sdarel@sdarel@l |
77 | 77 | e_add2i. 5, high_sdarel@sdarel@h |
78 | - e_add2i. 2, high_adjust_sdarel@sdarel@ha | |
78 | + e_add2i. 6, high_adjust_sdarel@sdarel@ha | |
79 | 79 | |
80 | 80 | e_add2is 1, low@l |
81 | 81 | e_add2is 2, high@h |
82 | 82 | e_add2is 3, high_adjust@ha |
83 | 83 | e_add2is 4, low_sdarel@sdarel@l |
84 | 84 | e_add2is 5, high_sdarel@sdarel@h |
85 | - e_add2is 2, high_adjust_sdarel@sdarel@ha | |
85 | + e_add2is 6, high_adjust_sdarel@sdarel@ha | |
86 | 86 | |
87 | 87 | e_mull2i 1, low@l |
88 | 88 | e_mull2i 2, high@h |
89 | 89 | e_mull2i 3, high_adjust@ha |
90 | 90 | e_mull2i 4, low_sdarel@sdarel@l |
91 | 91 | e_mull2i 5, high_sdarel@sdarel@h |
92 | - e_mull2i 2, high_adjust_sdarel@sdarel@ha | |
92 | + e_mull2i 6, high_adjust_sdarel@sdarel@ha |