GNU Binutils with patches for OS216
修订版 | 3050b43068674882b01a51351c5c39e950f0ee41 (tree) |
---|---|
时间 | 2018-11-26 21:54:10 |
作者 | H.J. Lu <hjl.tools@gmai...> |
Commiter | H.J. Lu |
x86: Disable GOT relaxation with data prefix
Since linker GOT relaxation isn't valid for 16-bit GOT access, we should
disable GOT relaxation with data prefix.
gas/
PR gas/23854
* config/tc-i386.c (output_disp): Disable GOT relaxation with
data prefix.
* testsuite/gas/i386/mixed-mode-reloc32.d: Updated.
ld/
PR gas/23854
* testsuite/ld-i386/i386.exp: Run pr23854.
* testsuite/ld-x86-64/x86-64.exp: Likewwise.
* testsuite/ld-i386/pr23854.d: New file.
* testsuite/ld-i386/pr23854.s: Likewwise.
* testsuite/ld-i386/pr23854.d: Likewwise.
* testsuite/ld-x86-64/pr23854.d: Likewwise.
* testsuite/ld-x86-64/pr23854.s: Likewwise.
(cherry picked from commit e60f4d3bdac25f02875afe36b7436bc2dfbbb978)
@@ -1,5 +1,12 @@ | ||
1 | 1 | 2018-11-26 H.J. Lu <hongjiu.lu@intel.com> |
2 | 2 | |
3 | + PR gas/23854 | |
4 | + * config/tc-i386.c (output_disp): Disable GOT relaxation with | |
5 | + data prefix. | |
6 | + * testsuite/gas/i386/mixed-mode-reloc32.d: Updated. | |
7 | + | |
8 | +2018-11-26 H.J. Lu <hongjiu.lu@intel.com> | |
9 | + | |
3 | 10 | * testsuite/gas/i386/evex-no-scale.s: Removed. |
4 | 11 | * testsuite/gas/i386/evex-no-scale-32.d: Don't use |
5 | 12 | evex-no-scale.s. |
@@ -7504,12 +7504,13 @@ output_disp (fragS *insn_start_frag, offsetT insn_start_off) | ||
7504 | 7504 | /* Check for "call/jmp *mem", "mov mem, %reg", |
7505 | 7505 | "test %reg, mem" and "binop mem, %reg" where binop |
7506 | 7506 | is one of adc, add, and, cmp, or, sbb, sub, xor |
7507 | - instructions. Always generate R_386_GOT32X for | |
7508 | - "sym*GOT" operand in 32-bit mode. */ | |
7509 | - if ((generate_relax_relocations | |
7510 | - || (!object_64bit | |
7511 | - && i.rm.mode == 0 | |
7512 | - && i.rm.regmem == 5)) | |
7507 | + instructions without data prefix. Always generate | |
7508 | + R_386_GOT32X for "sym*GOT" operand in 32-bit mode. */ | |
7509 | + if (i.prefix[DATA_PREFIX] == 0 | |
7510 | + && (generate_relax_relocations | |
7511 | + || (!object_64bit | |
7512 | + && i.rm.mode == 0 | |
7513 | + && i.rm.regmem == 5)) | |
7513 | 7514 | && (i.rm.mode == 2 |
7514 | 7515 | || (i.rm.mode == 0 && i.rm.regmem == 5)) |
7515 | 7516 | && ((i.operands == 1 |
@@ -7,7 +7,7 @@ | ||
7 | 7 | |
8 | 8 | RELOCATION RECORDS FOR \[.text\]: |
9 | 9 | OFFSET[ ]+TYPE[ ]+VALUE[ ]* |
10 | -[0-9a-f]+[ ]+R_386_GOT32X[ ]+xtrn[ ]* | |
10 | +[0-9a-f]+[ ]+R_386_GOT32[ ]+xtrn[ ]* | |
11 | 11 | [0-9a-f]+[ ]+R_386_PLT32[ ]+xtrn[ ]* |
12 | 12 | [0-9a-f]+[ ]+R_386_GOT32X[ ]+xtrn[ ]* |
13 | 13 | [0-9a-f]+[ ]+R_386_PLT32[ ]+xtrn[ ]* |
@@ -1,3 +1,14 @@ | ||
1 | +2018-11-26 H.J. Lu <hongjiu.lu@intel.com> | |
2 | + | |
3 | + PR gas/23854 | |
4 | + * testsuite/ld-i386/i386.exp: Run pr23854. | |
5 | + * testsuite/ld-x86-64/x86-64.exp: Likewwise. | |
6 | + * testsuite/ld-i386/pr23854.d: New file. | |
7 | + * testsuite/ld-i386/pr23854.s: Likewwise. | |
8 | + * testsuite/ld-i386/pr23854.d: Likewwise. | |
9 | + * testsuite/ld-x86-64/pr23854.d: Likewwise. | |
10 | + * testsuite/ld-x86-64/pr23854.s: Likewwise. | |
11 | + | |
1 | 12 | 2018-07-04 H.J. Lu <hongjiu.lu@intel.com> |
2 | 13 | |
3 | 14 | PR ld/23324 |
@@ -453,6 +453,7 @@ run_dump_test "pr22135" | ||
453 | 453 | run_dump_test "pr22782" |
454 | 454 | run_dump_test "pr23189" |
455 | 455 | run_dump_test "pr23194" |
456 | +run_dump_test "pr23854" | |
456 | 457 | |
457 | 458 | if { !([istarget "i?86-*-linux*"] |
458 | 459 | || [istarget "i?86-*-gnu*"] |
@@ -0,0 +1,28 @@ | ||
1 | +#as: --32 -mrelax-relocations=yes | |
2 | +#ld: -melf_i386 | |
3 | +#objdump: -dw | |
4 | + | |
5 | +.*: +file format .* | |
6 | + | |
7 | +Disassembly of section .text: | |
8 | + | |
9 | +[a-f0-9]+ <_start>: | |
10 | + +[a-f0-9]+: 66 13 81 f8 ff ff ff adc -0x8\(%ecx\),%ax | |
11 | + +[a-f0-9]+: 66 03 99 f8 ff ff ff add -0x8\(%ecx\),%bx | |
12 | + +[a-f0-9]+: 66 23 89 f8 ff ff ff and -0x8\(%ecx\),%cx | |
13 | + +[a-f0-9]+: 66 3b 91 f8 ff ff ff cmp -0x8\(%ecx\),%dx | |
14 | + +[a-f0-9]+: 66 0b b9 f8 ff ff ff or -0x8\(%ecx\),%di | |
15 | + +[a-f0-9]+: 66 1b b1 f8 ff ff ff sbb -0x8\(%ecx\),%si | |
16 | + +[a-f0-9]+: 66 2b a9 f8 ff ff ff sub -0x8\(%ecx\),%bp | |
17 | + +[a-f0-9]+: 66 33 a1 f8 ff ff ff xor -0x8\(%ecx\),%sp | |
18 | + +[a-f0-9]+: 66 85 89 f8 ff ff ff test %cx,-0x8\(%ecx\) | |
19 | + +[a-f0-9]+: 66 13 81 fc ff ff ff adc -0x4\(%ecx\),%ax | |
20 | + +[a-f0-9]+: 66 03 99 fc ff ff ff add -0x4\(%ecx\),%bx | |
21 | + +[a-f0-9]+: 66 23 89 fc ff ff ff and -0x4\(%ecx\),%cx | |
22 | + +[a-f0-9]+: 66 3b 91 fc ff ff ff cmp -0x4\(%ecx\),%dx | |
23 | + +[a-f0-9]+: 66 0b b9 fc ff ff ff or -0x4\(%ecx\),%di | |
24 | + +[a-f0-9]+: 66 1b b1 fc ff ff ff sbb -0x4\(%ecx\),%si | |
25 | + +[a-f0-9]+: 66 2b a9 fc ff ff ff sub -0x4\(%ecx\),%bp | |
26 | + +[a-f0-9]+: 66 33 a1 fc ff ff ff xor -0x4\(%ecx\),%sp | |
27 | + +[a-f0-9]+: 66 85 89 fc ff ff ff test %cx,-0x4\(%ecx\) | |
28 | +#pass |
@@ -0,0 +1,33 @@ | ||
1 | + .data | |
2 | + .type bar, @object | |
3 | +bar: | |
4 | + .byte 1 | |
5 | + .size bar, .-bar | |
6 | + .globl foo | |
7 | + .type foo, @object | |
8 | +foo: | |
9 | + .byte 1 | |
10 | + .size foo, .-foo | |
11 | + .text | |
12 | + .globl _start | |
13 | + .type _start, @function | |
14 | +_start: | |
15 | + adcw bar@GOT(%ecx), %ax | |
16 | + addw bar@GOT(%ecx), %bx | |
17 | + andw bar@GOT(%ecx), %cx | |
18 | + cmpw bar@GOT(%ecx), %dx | |
19 | + orw bar@GOT(%ecx), %di | |
20 | + sbbw bar@GOT(%ecx), %si | |
21 | + subw bar@GOT(%ecx), %bp | |
22 | + xorw bar@GOT(%ecx), %sp | |
23 | + testw %cx, bar@GOT(%ecx) | |
24 | + adcw foo@GOT(%ecx), %ax | |
25 | + addw foo@GOT(%ecx), %bx | |
26 | + andw foo@GOT(%ecx), %cx | |
27 | + cmpw foo@GOT(%ecx), %dx | |
28 | + orw foo@GOT(%ecx), %di | |
29 | + sbbw foo@GOT(%ecx), %si | |
30 | + subw foo@GOT(%ecx), %bp | |
31 | + xorw foo@GOT(%ecx), %sp | |
32 | + testw %cx, foo@GOT(%ecx) | |
33 | + .size _start, .-_start |
@@ -0,0 +1,28 @@ | ||
1 | +#as: --64 -mrelax-relocations=yes | |
2 | +#ld: -melf_x86_64 | |
3 | +#objdump: -dw | |
4 | + | |
5 | +.*: +file format .* | |
6 | + | |
7 | +Disassembly of section .text: | |
8 | + | |
9 | +[a-f0-9]+ <_start>: | |
10 | + +[a-f0-9]+: 66 13 05 ([0-9a-f]{2} ){4} * adc 0x[a-f0-9]+\(%rip\),%ax # [a-f0-9]+ <.got> | |
11 | + +[a-f0-9]+: 66 03 1d ([0-9a-f]{2} ){4} * add 0x[a-f0-9]+\(%rip\),%bx # [a-f0-9]+ <.got> | |
12 | + +[a-f0-9]+: 66 23 0d ([0-9a-f]{2} ){4} * and 0x[a-f0-9]+\(%rip\),%cx # [a-f0-9]+ <.got> | |
13 | + +[a-f0-9]+: 66 3b 15 ([0-9a-f]{2} ){4} * cmp 0x[a-f0-9]+\(%rip\),%dx # [a-f0-9]+ <.got> | |
14 | + +[a-f0-9]+: 66 0b 3d ([0-9a-f]{2} ){4} * or 0x[a-f0-9]+\(%rip\),%di # [a-f0-9]+ <.got> | |
15 | + +[a-f0-9]+: 66 1b 35 ([0-9a-f]{2} ){4} * sbb 0x[a-f0-9]+\(%rip\),%si # [a-f0-9]+ <.got> | |
16 | + +[a-f0-9]+: 66 2b 2d ([0-9a-f]{2} ){4} * sub 0x[a-f0-9]+\(%rip\),%bp # [a-f0-9]+ <.got> | |
17 | + +[a-f0-9]+: 66 44 33 05 ([0-9a-f]{2} ){4} * xor 0x[a-f0-9]+\(%rip\),%r8w # [a-f0-9]+ <.got> | |
18 | + +[a-f0-9]+: 66 85 0d ([0-9a-f]{2} ){4} * test %cx,0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <.got> | |
19 | + +[a-f0-9]+: 66 13 05 ([0-9a-f]{2} ){4} * adc 0x[a-f0-9]+\(%rip\),%ax # [a-f0-9]+ <.got\+0x8> | |
20 | + +[a-f0-9]+: 66 03 1d ([0-9a-f]{2} ){4} * add 0x[a-f0-9]+\(%rip\),%bx # [a-f0-9]+ <.got\+0x8> | |
21 | + +[a-f0-9]+: 66 23 0d ([0-9a-f]{2} ){4} * and 0x[a-f0-9]+\(%rip\),%cx # [a-f0-9]+ <.got\+0x8> | |
22 | + +[a-f0-9]+: 66 3b 15 ([0-9a-f]{2} ){4} * cmp 0x[a-f0-9]+\(%rip\),%dx # [a-f0-9]+ <.got\+0x8> | |
23 | + +[a-f0-9]+: 66 0b 3d ([0-9a-f]{2} ){4} * or 0x[a-f0-9]+\(%rip\),%di # [a-f0-9]+ <.got\+0x8> | |
24 | + +[a-f0-9]+: 66 1b 35 ([0-9a-f]{2} ){4} * sbb 0x[a-f0-9]+\(%rip\),%si # [a-f0-9]+ <.got\+0x8> | |
25 | + +[a-f0-9]+: 66 2b 2d ([0-9a-f]{2} ){4} * sub 0x[a-f0-9]+\(%rip\),%bp # [a-f0-9]+ <.got\+0x8> | |
26 | + +[a-f0-9]+: 66 44 33 05 ([0-9a-f]{2} ){4} * xor 0x[a-f0-9]+\(%rip\),%r8w # [a-f0-9]+ <.got\+0x8> | |
27 | + +[a-f0-9]+: 66 85 0d ([0-9a-f]{2} ){4} * test %cx,0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <.got\+0x8> | |
28 | +#pass |
@@ -0,0 +1,33 @@ | ||
1 | + .data | |
2 | + .type bar, @object | |
3 | +bar: | |
4 | + .byte 1 | |
5 | + .size bar, .-bar | |
6 | + .globl foo | |
7 | + .type foo, @object | |
8 | +foo: | |
9 | + .byte 1 | |
10 | + .size foo, .-foo | |
11 | + .text | |
12 | + .globl _start | |
13 | + .type _start, @function | |
14 | +_start: | |
15 | + adcw bar@GOTPCREL(%rip), %ax | |
16 | + addw bar@GOTPCREL(%rip), %bx | |
17 | + andw bar@GOTPCREL(%rip), %cx | |
18 | + cmpw bar@GOTPCREL(%rip), %dx | |
19 | + orw bar@GOTPCREL(%rip), %di | |
20 | + sbbw bar@GOTPCREL(%rip), %si | |
21 | + subw bar@GOTPCREL(%rip), %bp | |
22 | + xorw bar@GOTPCREL(%rip), %r8w | |
23 | + testw %cx, bar@GOTPCREL(%rip) | |
24 | + adcw foo@GOTPCREL(%rip), %ax | |
25 | + addw foo@GOTPCREL(%rip), %bx | |
26 | + andw foo@GOTPCREL(%rip), %cx | |
27 | + cmpw foo@GOTPCREL(%rip), %dx | |
28 | + orw foo@GOTPCREL(%rip), %di | |
29 | + sbbw foo@GOTPCREL(%rip), %si | |
30 | + subw foo@GOTPCREL(%rip), %bp | |
31 | + xorw foo@GOTPCREL(%rip), %r8w | |
32 | + testw %cx, foo@GOTPCREL(%rip) | |
33 | + .size _start, .-_start |
@@ -385,6 +385,7 @@ run_dump_test "pr23189" | ||
385 | 385 | run_dump_test "pr23194" |
386 | 386 | run_dump_test "pr23324a" |
387 | 387 | run_dump_test "pr23324b" |
388 | +run_dump_test "pr23854" | |
388 | 389 | |
389 | 390 | if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { |
390 | 391 | return |