diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2016-04-09 21:35:50 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2016-04-09 21:35:50 +0100 |
commit | 41a1578ed17cdd7c01c38389ac7c714c4f15cbf8 (patch) | |
tree | 945bc1648562062c921979ec450d66d7247eb957 | |
parent | 668c5ebc0937ab5288d831d65de3057e56e2763f (diff) | |
download | gdb-41a1578ed17cdd7c01c38389ac7c714c4f15cbf8.zip gdb-41a1578ed17cdd7c01c38389ac7c714c4f15cbf8.tar.gz gdb-41a1578ed17cdd7c01c38389ac7c714c4f15cbf8.tar.bz2 |
MIPS/GAS: Sanitize `.option picX' pseudo-op
gas/
* config/tc-mips.c (s_option): Sanitize `.option picX'
pseudo-op.
* testsuite/gas/mips/option-pic-1.d: New test.
* testsuite/gas/mips/option-pic-2.l: New list test.
* testsuite/gas/mips/option-pic-1.s: New test source.
* testsuite/gas/mips/option-pic-2.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.
-rw-r--r-- | gas/ChangeLog | 10 | ||||
-rw-r--r-- | gas/config/tc-mips.c | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips.exp | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/option-pic-1.d | 18 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/option-pic-1.s | 16 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/option-pic-2.l | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/option-pic-2.s | 4 |
7 files changed, 56 insertions, 1 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index da02325..eefeb2f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,15 @@ 2016-04-09 Maciej W. Rozycki <macro@imgtec.com> + * config/tc-mips.c (s_option): Sanitize `.option picX' + pseudo-op. + * testsuite/gas/mips/option-pic-1.d: New test. + * testsuite/gas/mips/option-pic-2.l: New list test. + * testsuite/gas/mips/option-pic-1.s: New test source. + * testsuite/gas/mips/option-pic-2.s: New test source. + * testsuite/gas/mips/mips.exp: Run the new tests. + +2016-04-09 Maciej W. Rozycki <macro@imgtec.com> + * config/tc-mips.c (s_option): Reject `.option picX' if VxWorks PIC. * testsuite/gas/mips/option-pic-vxworks-1.l: New list test. diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 7017444..db3ec67 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -15472,7 +15472,7 @@ s_option (int x ATTRIBUTE_UNUSED) { /* FIXME: What does this mean? */ } - else if (strncmp (opt, "pic", 3) == 0) + else if (strncmp (opt, "pic", 3) == 0 && ISDIGIT (opt[3]) && opt[4] == '\0') { int i; diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index 02f76cc..4d770cb 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -1474,6 +1474,9 @@ if { [istarget mips*-*-vxworks*] } { run_dump_test "li-d" + run_dump_test "option-pic-1" + run_list_test "option-pic-2" "" \ + "MIPS invalid PIC option" run_list_test "option-pic-vxworks-1" "-mvxworks-pic" \ "MIPS invalid PIC option in VxWorks PIC" run_list_test "option-pic-vxworks-2" "-mvxworks-pic" \ diff --git a/gas/testsuite/gas/mips/option-pic-1.d b/gas/testsuite/gas/mips/option-pic-1.d new file mode 100644 index 0000000..da32af6 --- /dev/null +++ b/gas/testsuite/gas/mips/option-pic-1.d @@ -0,0 +1,18 @@ +#objdump: -dr --prefix-addresses --show-raw-insn +#name: MIPS PIC option +#as: -32 + +.*: +file format .*mips.* + +Disassembly of section \.text: +[0-9a-f]+ <[^>]*> 8f820000 lw v0,0\(gp\) +[ ]*[0-9a-f]+: R_MIPS_GOT16 bar +[0-9a-f]+ <[^>]*> 3c020000 lui v0,0x0 +[ ]*[0-9a-f]+: R_MIPS_HI16 bar +[0-9a-f]+ <[^>]*> 24420000 addiu v0,v0,0 +[ ]*[0-9a-f]+: R_MIPS_LO16 bar +[0-9a-f]+ <[^>]*> 8f820000 lw v0,0\(gp\) +[ ]*[0-9a-f]+: R_MIPS_GOT16 bar +[0-9a-f]+ <[^>]*> 03e00008 jr ra +[0-9a-f]+ <[^>]*> 00000000 nop + \.\.\. diff --git a/gas/testsuite/gas/mips/option-pic-1.s b/gas/testsuite/gas/mips/option-pic-1.s new file mode 100644 index 0000000..6907049 --- /dev/null +++ b/gas/testsuite/gas/mips/option-pic-1.s @@ -0,0 +1,16 @@ + .abicalls + .text + .globl foo + .ent foo +foo: + la $2, bar + .option pic0 # Switch off! + la $2, bar + .option pic2 # Switch on! + la $2, bar + jr $ra + .end foo + +# Force some (non-delay-slot) zero bytes, to make 'objdump' print ... + .align 4, 0 + .space 16 diff --git a/gas/testsuite/gas/mips/option-pic-2.l b/gas/testsuite/gas/mips/option-pic-2.l new file mode 100644 index 0000000..c6c5994 --- /dev/null +++ b/gas/testsuite/gas/mips/option-pic-2.l @@ -0,0 +1,4 @@ +.*: Assembler messages: +.*:2: Warning: unrecognized option "picfoo" +.*:3: Warning: unrecognized option "pic0foo" +.*:4: Error: junk at end of line, first unrecognized character is `f' diff --git a/gas/testsuite/gas/mips/option-pic-2.s b/gas/testsuite/gas/mips/option-pic-2.s new file mode 100644 index 0000000..9d3a5ea --- /dev/null +++ b/gas/testsuite/gas/mips/option-pic-2.s @@ -0,0 +1,4 @@ + .abicalls + .option picfoo + .option pic0foo + .option pic0 foo |