diff options
Diffstat (limited to 'binutils-2.21/ld/testsuite/ld-m68hc11')
23 files changed, 1098 insertions, 0 deletions
diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/adj-brset.d b/binutils-2.21/ld/testsuite/ld-m68hc11/adj-brset.d new file mode 100644 index 0000000..f1788f7 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/adj-brset.d @@ -0,0 +1,32 @@ +#source: adj-brset.s +#as: -m68hc11 +#ld: --relax +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: +file format elf32\-m68hc11 + +Disassembly of section .text: +0+8000 <_start> brclr 140,x \#\$c8 0+804a <L8> +0+8004 <L1> addd \*0+4 <_toto> +0+8006 <L1\+0x2> brclr 20,x \#\$03 0+8004 <L1> +0+800a <L1\+0x6> brclr 90,x \#\$63 0+801a <L3> +0+800e <L2> addd \*0+4 <_toto> +0+8010 <L2\+0x2> brclr 19,y \#\$04 0+800e <L2> +0+8015 <L2\+0x7> brclr 91,y \#\$62 0+8024 <L4> +0+801a <L3> addd \*0+4 <_toto> +0+801c <L3\+0x2> brset 18,x \#\$05 0+801a <L3> +0+8020 <L3\+0x6> brset 92,x \#\$61 0+8030 <L5> +0+8024 <L4> addd \*0+4 <_toto> +0+8026 <L4\+0x2> brset 17,y \#\$06 0+8024 <L4> +0+802b <L4\+0x7> brset 93,y \#\$60 0+8030 <L5> +0+8030 <L5> addd \*0+4 <_toto> +0+8032 <L5\+0x2> brset \*0+32 <_table> \#\$07 0+8030 <L5> +0+8036 <L5\+0x6> brset \*0+3c <_table\+0xa> \#\$5f 0+8044 <L7> +0+803a <L6> addd \*0+4 <_toto> +0+803c <L6\+0x2> brclr \*0+33 <_table\+0x1> \#\$08 0+803a <L6> +0+8040 <L6\+0x6> brset \*0+3d <_table\+0xb> \#\$5e 0+804a <L8> +0+8044 <L7> addd \*0+4 <_toto> +0+8046 <L7\+0x2> brclr \*0+33 <_table\+0x1> \#\$08 0+803a <L6> +0+804a <L8> brclr 140,x \#\$c8 0+8000 <_start> +0+804e <L8\+0x4> rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/adj-brset.s b/binutils-2.21/ld/testsuite/ld-m68hc11/adj-brset.s new file mode 100644 index 0000000..1aaff41 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/adj-brset.s @@ -0,0 +1,51 @@ +;;; Test 68HC11 linker relaxation and fixup of brclr/brset branches +;;; + .sect .text + .globl _start +_start: +start: + brclr 140,x#200,L8 ; Branch adjustment covers the whole test +;;; The 'addd' is relaxed and we win 1 byte. The next brclr/brset +;;; branch must be fixed and reduced by 1. We check for different +;;; addressing modes because the instruction has different opcode and +;;; different lengths. +L1: + addd _toto + brclr 20,x,#3,L1 + brclr 90,x,#99,L3 ; Likewise with forward branch +L2: + addd _toto + brclr 19,y,#4,L2 + brclr 91,y,#98,L4 +L3: + addd _toto + brset 18,x,#5,L3 + brset 92,x,#97,L5 +L4: + addd _toto + brset 17,y,#6,L4 + brset 93,y,#96,L5 +L5: + addd _toto + brset *_table,#7,L5 + brset *_table+10,#95,L7 +L6: + addd _toto + brclr *_table+1,#8,L6 + brset *_table+11,#94,L8 +L7: + addd _toto + brclr *_table+1,#8,L6 +L8: + brclr 140,x#200,_start ; Branch adjustment covers the whole test + rts + + .sect .page0 +_bar: + .long 0 +_toto: + .long 0 + .skip 32 +stack: + .skip 10 +_table: diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/adj-jump.d b/binutils-2.21/ld/testsuite/ld-m68hc11/adj-jump.d new file mode 100644 index 0000000..be87524 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/adj-jump.d @@ -0,0 +1,60 @@ +#source: adj-jump.s +#as: -m68hc11 +#ld: --relax +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: +file format elf32\-m68hc11 + +Disassembly of section .text: +0+8000 <_start> bra 0+8074 <L3> + ... +0+8016 <_start\+0x16> bra 0+8074 <L3> +0+8018 <L1> addd 0,x +0+801a <L1\+0x2> bne 0+8018 <L1> +0+801c <L1\+0x4> addd \*0+4 <_toto> +0+801e <L1\+0x6> beq 0+8018 <L1> +0+8020 <L1\+0x8> addd \*0+5 <_toto\+0x1> +0+8022 <L1\+0xa> bne 0+8018 <L1> +0+8024 <L1\+0xc> bgt 0+8018 <L1> +0+8026 <L1\+0xe> bge 0+8018 <L1> +0+8028 <L1\+0x10> beq 0+8018 <L1> +0+802a <L1\+0x12> ble 0+8018 <L1> +0+802c <L1\+0x14> blt 0+8018 <L1> +0+802e <L1\+0x16> bhi 0+8018 <L1> +0+8030 <L1\+0x18> bcc 0+8018 <L1> +0+8032 <L1\+0x1a> beq 0+8018 <L1> +0+8034 <L1\+0x1c> bls 0+8018 <L1> +0+8036 <L1\+0x1e> bcs 0+8018 <L1> +0+8038 <L1\+0x20> bcs 0+8018 <L1> +0+803a <L1\+0x22> bmi 0+8018 <L1> +0+803c <L1\+0x24> bvs 0+8018 <L1> +0+803e <L1\+0x26> bcc 0+8018 <L1> +0+8040 <L1\+0x28> bpl 0+8018 <L1> +0+8042 <L1\+0x2a> bvc 0+8018 <L1> +0+8044 <L1\+0x2c> bne 0+8018 <L1> +0+8046 <L1\+0x2e> brn 0+8018 <L1> +0+8048 <L1\+0x30> bra 0+8018 <L1> +0+804a <L1\+0x32> addd \*0+4 <_toto> +0+804c <L1\+0x34> addd \*0+4 <_toto> +0+804e <L1\+0x36> addd \*0+4 <_toto> +0+8050 <L1\+0x38> addd \*0+4 <_toto> +0+8052 <L1\+0x3a> addd \*0+4 <_toto> +0+8054 <L1\+0x3c> addd \*0+4 <_toto> +0+8056 <L1\+0x3e> addd \*0+4 <_toto> +0+8058 <L1\+0x40> addd \*0+4 <_toto> +0+805a <L1\+0x42> addd \*0+4 <_toto> +0+805c <L1\+0x44> addd \*0+4 <_toto> +0+805e <L1\+0x46> addd \*0+4 <_toto> +0+8060 <L1\+0x48> addd \*0+4 <_toto> +0+8062 <L1\+0x4a> addd \*0+4 <_toto> +0+8064 <L1\+0x4c> addd \*0+4 <_toto> +0+8066 <L1\+0x4e> addd \*0+4 <_toto> +0+8068 <L2> bra 0+8000 <_start> +0+806a <L2\+0x2> bne 0+8068 <L2> +0+806c <L2\+0x4> beq 0+8074 <L3> +0+806e <L2\+0x6> addd \*0+4 <_toto> +0+8070 <L2\+0x8> beq 0+8074 <L3> +0+8072 <L2\+0xa> addd \*0+4 <_toto> +0+8074 <L3> addd \*0+4 <_toto> +0+8076 <L3\+0x2> rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/adj-jump.s b/binutils-2.21/ld/testsuite/ld-m68hc11/adj-jump.s new file mode 100644 index 0000000..99b7258 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/adj-jump.s @@ -0,0 +1,74 @@ +;;; Test 68HC11 linker relaxation and fixup of bcc/bra branches +;;; + .sect .text + .globl _start +_start: + ;; Next 'bra' is assembled as a 'jmp'. It is relaxed to 'bra L3' + ;; during a second pass of relax. + bra L3 + .skip 20 + ;; Next 'jmp' must be relaxed to a 'bra' during the first pass. + ;; The branch offset must then be adjusted by consecutive relax. + jmp L3 +L1: + addd 0,x + bne L1 ; Branch not adjusted + addd _toto + beq L1 ; Backward branch, adjust -1 + addd _toto+1 + jbne L1 ; Backward branch, adjust -2 + bgt L1 ; All possible backward branchs, adjust -2 + bge L1 + beq L1 + ble L1 + blt L1 + bhi L1 + bhs L1 + beq L1 + bls L1 + blo L1 + bcs L1 + bmi L1 + bvs L1 + bcc L1 + bpl L1 + bvc L1 + bne L1 + brn L1 + bra L1 + ;; Relax several insn to reduce block by 15 + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto + addd _toto +L2: + jmp _start ; -> relax to bra _start + bne L2 ; Backward branch, adjust -1 + beq L3 ; Forward branch, adjust -2 + addd _toto + beq L3 ; Forward branch, adjust -1 + addd _toto +L3: + addd _toto + rts + + .sect .page0 +_bar: + .long 0 +_toto: + .long 0 + .skip 32 +stack: + .skip 10 +_table: diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1403.d b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1403.d new file mode 100644 index 0000000..c643cd1 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1403.d @@ -0,0 +1,12 @@ +#source: bug-1403.s +#as: -m68hc11 +#ld: --relax +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: +file format elf32-m68hc11 + +Disassembly of section .text: +0+8000 <_start> bset \*0+ <__bss_size> \#\$04 +0+8003 <L1> bra 0+8005 <toto> +0+8005 <toto> rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1403.s b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1403.s new file mode 100644 index 0000000..9c6fc9b --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1403.s @@ -0,0 +1,20 @@ +;;; Bug #1403: Branch adjustment to another section not correct when doing linker relaxation +;;; http://savannah.gnu.org/bugs/?func=detailbug&bug_id=1403&group_id=2424 +;;; + .sect .text + .globl _start +_start: + .relax L1 + ldx #table + bset 0,x #4 +L1: + bra toto ; bra is assembled as a jmp and relaxed + + .sect .page0 + .globl table +table: .long 0 + + .sect .text.toto + .globl toto +toto: + rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1417.d b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1417.d new file mode 100644 index 0000000..84b3ad4 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1417.d @@ -0,0 +1,15 @@ +#source: bug-1417.s +#as: -m68hc11 +#ld: --relax +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: +file format elf32-m68hc11 + +Disassembly of section .text: +0+8000 <_start> tst 0+ <__bss_size> +0+8003 <_start\+0x3> bne 0+8007 <L1> +0+8005 <_start\+0x5> bsr 0+800b <foo> +0+8007 <L1> bset \*0+ <__bss_size> \#\$04 +0+800a <L2> rts +0+800b <foo> rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1417.s b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1417.s new file mode 100644 index 0000000..2b3e6a1 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-1417.s @@ -0,0 +1,21 @@ +;;; Bug #1417: Branch wrong after linker relaxation +;;; http://savannah.gnu.org/bugs/?func=detailbug&bug_id=1417&group_id=2424 +;;; + .sect .text + .globl _start +_start: + tst table + bne L1 ; Branch was adjusted but it must not + jsr foo +L1: + .relax L2 + ldx #table ; Instruction removed + bset 0,x #4 ; Changed to bset *table #4 +L2: + rts +foo: + rts + + .sect .page0 + .globl table +table: .long 0 diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/bug-3331.d b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-3331.d new file mode 100644 index 0000000..91050bf --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-3331.d @@ -0,0 +1,14 @@ +#source: bug-3331.s +#as: -m68hc11 +#ld: --relax +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: +file format elf32-m68hc11 + +Disassembly of section .text: +0+8000 <_start> ldx #0+1100 <__data_section_start> +0+8003 <_start\+0x3> bset 0,x \#\$04 +0+8006 <L1> ldd \#0+2 <__bss_size\+0x2> +0+8009 <L1\+0x3> std \*0+ <__bss_size> +0+800b <L1\+0x5> rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/bug-3331.s b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-3331.s new file mode 100644 index 0000000..19a3201 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/bug-3331.s @@ -0,0 +1,23 @@ +;;; Bug #3331: Invalid group relaxation, bset uses an invalid address +;;; http://savannah.gnu.org/bugs/?func=detailbug&bug_id=3331&group_id=2424 +;;; + .sect .text + .globl _start +_start: + .relax L1 + ldx #foo ;; This relax group must not be changed. + bset 0,x #4 +L1: + ldd #2 + std table ;; This instruction uses a symbol in page0 + ;; and it triggered the relaxation of the + ;; previous relax group + rts + + .sect .page0 + .globl table +table: .long 0 + + .sect .data + .globl foo +foo: .long 0 diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc11.d b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc11.d new file mode 100644 index 0000000..e380511 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc11.d @@ -0,0 +1,73 @@ +#source: far-hc11.s +#as: -m68hc11 +#ld: -m m68hc11elf +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: file format elf32-m68hc11 + +Disassembly of section .text: +0+8000 <tramp._far_foo> pshb +0+8001 <tramp._far_foo\+0x1> ldab \#0 +0+8003 <tramp._far_foo\+0x3> ldy \#0+6c <_far_foo> +0+8007 <tramp._far_foo\+0x7> jmp 0+8056 <__far_trampoline> +0+800a <tramp._far_bar> pshb +0+800b <tramp._far_bar\+0x1> ldab \#0 +0+800d <tramp._far_bar\+0x3> ldy \#0+64 <stack> +0+8011 <tramp._far_bar\+0x7> jmp 0+8056 <__far_trampoline> +0+8014 <_start> lds \#0+64 <stack> +0+8017 <_start\+0x3> ldx \#0+abcd <__data_image\+0x2b63> +0+801a <_start\+0x6> pshx +0+801b <_start\+0x7> ldd \#0+1234 <__data_section_start\+0x134> +0+801e <_start\+0xa> ldx \#0+5678 <__data_section_start\+0x4578> +0+8021 <_start\+0xd> jsr 0+800a <tramp._far_bar> +0+8024 <_start\+0x10> cpx \#0+1234 <__data_section_start\+0x134> +0+8027 <_start\+0x13> bne 0+804e <fail> +0+8029 <_start\+0x15> cpd \#0+5678 <__data_section_start\+0x4578> +0+802d <_start\+0x19> bne 0+804e <fail> +0+802f <_start\+0x1b> pulx +0+8030 <_start\+0x1c> cpx \#0+abcd <__data_image\+0x2b63> +0+8033 <_start\+0x1f> bne 0+804e <fail> +0+8035 <_start\+0x21> ldd \#0+8000 <tramp._far_foo> +0+8038 <_start\+0x24> xgdx +0+8039 <_start\+0x25> jsr 0,x +0+803b <_start\+0x27> ldd \#0+800a <tramp._far_bar> +0+803e <_start\+0x2a> xgdy +0+8040 <_start\+0x2c> jsr 0,y +0+8043 <_start\+0x2f> ldaa \#0 +0+8045 <_start\+0x31> ldy \#0+73 <_far_no_tramp> +0+8049 <_start\+0x35> bsr 0+8066 <__call_a16> +0+804b <_start\+0x37> clra +0+804c <_start\+0x38> clrb +0+804d <_start\+0x39> wai +0+804e <fail> ldd \#0+1 <__bss_size\+0x1> +0+8051 <fail\+0x3> wai +0+8052 <fail\+0x4> bra 0+8014 <_start> +0+8054 <__return> ins +0+8055 <__return\+0x1> rts +0+8056 <__far_trampoline> psha +0+8057 <__far_trampoline\+0x1> psha +0+8058 <__far_trampoline\+0x2> pshx +0+8059 <__far_trampoline\+0x3> tsx +0+805a <__far_trampoline\+0x4> ldab 4,x +0+805c <__far_trampoline\+0x6> ldaa 2,x +0+805e <__far_trampoline\+0x8> staa 4,x +0+8060 <__far_trampoline\+0xa> pulx +0+8061 <__far_trampoline\+0xb> pula +0+8062 <__far_trampoline\+0xc> pula +0+8063 <__far_trampoline\+0xd> jmp 0,y +0+8066 <__call_a16> psha +0+8067 <__call_a16\+0x1> jmp 0,y +Disassembly of section .bank1: +0+64 <_far_bar> jsr 0+6b <local_bank1> +0+67 <_far_bar\+0x3> xgdx +0+68 <_far_bar\+0x4> jmp 0+8054 <__return> +0+6b <local_bank1> rts +Disassembly of section .bank2: +0+6c <_far_foo> jsr 0+72 <local_bank2> +0+6f <_far_foo\+0x3> jmp 0+8054 <__return> +0+72 <local_bank2> rts +Disassembly of section .bank3: +0+73 <_far_no_tramp> jsr 0+79 <local_bank3> +0+76 <_far_no_tramp\+0x3> jmp 0+8054 <__return> +0+79 <local_bank3> rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc11.s b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc11.s new file mode 100644 index 0000000..e8e63d4 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc11.s @@ -0,0 +1,105 @@ +;;; Test 68HC11 FAR trampoline generation +;;; 2 trampolines are generated: +;;; - one for '_far_bar' +;;; - one for '_far_foo' +;;; 'far_no_tramp' does not have any trampoline generated. +;;; + .sect .text + .globl _start +_start: +start: + lds #stack + ldx #0xabcd + pshx + ldd #0x1234 + ldx #0x5678 + bsr _far_bar ; Call to trampoline generated code + cpx #0x1234 + bne fail ; X and D preserved (swapped by _far_bar) + cpd #0x5678 + bne fail + pulx + cpx #0xabcd ; Stack parameter preserved + bne fail + ldd #_far_foo ; Get address of trampoline handler + xgdx + jsr 0,x + ldd #_far_bar ; Likewise (unique trampoline check) + xgdy + jsr 0,y + ldaa #%page(_far_no_tramp) + ldy #%addr(_far_no_tramp) + bsr __call_a16 ; No trampoline generated for _far_no_tramp + clra + clrb + wai +fail: + ldd #1 + wai + bra start + .global __return +__return: + ins + rts + + .sect .bank1,"ax" + .globl _far_bar + .far _far_bar ; Must mark symbol as far +_far_bar: + jsr local_bank1 + xgdx + jmp __return + +local_bank1: + rts + + .sect .bank2,"ax" + .globl _far_foo + .far _far_foo +_far_foo: + jsr local_bank2 + jmp __return + +local_bank2: + rts + + .sect .bank3,"ax" + .globl _far_no_tramp + .far _far_no_tramp +_far_no_tramp: + jsr local_bank3 + jmp __return + +local_bank3: + rts + + .sect .text + .globl __far_trampoline +__far_trampoline: + psha ; (2) Save function parameter (high) + ;; <Read current page in A> + psha ; (2) + ;; <Set currenge page from B> + pshx ; (4) + tsx ; (3) + ldab 4,x ; (4) Restore function parameter (low) + ldaa 2,x ; (4) Get saved page number + staa 4,x ; (4) Save it below return PC + pulx ; (5) + pula ; (3) + pula ; (3) Restore function parameter (high) + jmp 0,y ; (4) + + .globl __call_a16 +__call_a16: + ;; xgdx ; (3) + ;; <Read current page in A> ; (3) ldaa _current_page + psha ; (2) + ;; <Set current page from B> ; (4) staa _current_page + ;; xgdx ; (3) + jmp 0,y ; (4) + + .sect .page0 + .skip 100 +stack: + diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.d b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.d new file mode 100644 index 0000000..304ae87 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.d @@ -0,0 +1,55 @@ +#source: far-hc12.s +#as: -m68hc12 +#ld: -m m68hc12elf --script $srcdir/$subdir/far-hc12.ld +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: file format elf32\-m68hc12 + +Disassembly of section .text: +0+c000 <tramp\._far_foo> ldy \#0+8000 <__bank_start> +0+c003 <tramp\._far_foo\+0x3> call 0+c049 <__far_trampoline> \{0+c049 <__far_trampoline>, 1\} +0+c007 <tramp\._far_bar> ldy \#0+8000 <__bank_start> +0+c00a <tramp\._far_bar\+0x3> call 0+c049 <__far_trampoline> \{0+c049 <__far_trampoline>, 0\} +0+c00e <_start> lds \#0+2063 <stack-0x1> +0+c011 <_start\+0x3> ldx \#0+abcd <__bank_start\+0x2bcd> +0+c014 <_start\+0x6> pshx +0+c015 <_start\+0x7> ldd \#0+1234 <stack\-0xe30> +0+c018 <_start\+0xa> ldx \#0+5678 <__bank_size\+0x1678> +0+c01b <_start\+0xd> jsr 0+c007 <tramp._far_bar> +0+c01e <_start\+0x10> cpx \#0+1234 <stack\-0xe30> +0+c021 <_start\+0x13> bne 0+c043 <fail> +0+c023 <_start\+0x15> cpd \#0+5678 <__bank_size\+0x1678> +0+c026 <_start\+0x18> bne 0+c043 <fail> +0+c028 <_start\+0x1a> pulx +0+c029 <_start\+0x1b> cpx \#0+abcd <__bank_start\+0x2bcd> +0+c02c <_start\+0x1e> bne 0+c043 <fail> +0+c02e <_start\+0x20> ldd \#0+c000 <tramp._far_foo> +0+c031 <_start\+0x23> xgdx +0+c033 <_start\+0x25> jsr 0,X +0+c035 <_start\+0x27> ldd \#0+c007 <tramp._far_bar> +0+c038 <_start\+0x2a> xgdy +0+c03a <_start\+0x2c> jsr 0,Y +0+c03c <_start\+0x2e> call 0+18000 <_far_no_tramp> \{0+8000 <__bank_start>, 2\} +0+c040 <_start\+0x32> clra +0+c041 <_start\+0x33> clrb +0+c042 <_start\+0x34> wai +0+c043 <fail> ldd \#0+1 <stack\-0x2063> +0+c046 <fail\+0x3> wai +0+c047 <fail\+0x4> bra 0+c00e <_start> +0+c049 <__far_trampoline> movb 0,SP, 2,SP +0+c04d <__far_trampoline\+0x4> leas 2,SP +0+c04f <__far_trampoline\+0x6> jmp 0,Y +Disassembly of section .bank1: +0+10+ <_far_bar> jsr 0+10006 <local_bank1> +0+10003 <_far_bar\+0x3> xgdx +0+10005 <_far_bar\+0x5> rtc +0+10006 <local_bank1> rts +Disassembly of section .bank2: +0+14000 <_far_foo> jsr 0+14004 <local_bank2> +0+14003 <_far_foo\+0x3> rtc +0+14004 <local_bank2> rts +Disassembly of section .bank3: +0+18000 <_far_no_tramp> jsr 0+18004 <local_bank3> +0+18003 <_far_no_tramp\+0x3> rtc +0+18004 <local_bank3> rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.ld b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.ld new file mode 100644 index 0000000..78dffe6 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.ld @@ -0,0 +1,18 @@ +ENTRY(_start) +SECTIONS { + .text 0xc000 : { + *(.text) + } + .bank1 0x10000 : { + *(.bank1) + } + .bank2 0x14000 : { + *(.bank2) + } + .bank3 0x18000 : { + *(.bank3) + } + .bss 0x2000 : { + *(.bss) + } +} diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.s b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.s new file mode 100644 index 0000000..0081e38 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/far-hc12.s @@ -0,0 +1,83 @@ +;;; Test 68HC12 FAR trampoline generation +;;; 2 trampolines are generated: +;;; - one for '_far_bar' +;;; - one for '_far_foo' +;;; 'far_no_tramp' does not have any trampoline generated. +;;; + .sect .text + .globl _start +_start: +start: + lds #stack-1 + ldx #0xabcd + pshx + ldd #0x1234 + ldx #0x5678 + bsr _far_bar ; Call to trampoline generated code + cpx #0x1234 + bne fail ; X and D preserved (swapped by _far_bar) + cpd #0x5678 + bne fail + pulx + cpx #0xabcd ; Stack parameter preserved + bne fail + ldd #_far_foo ; Get address of trampoline handler + xgdx + jsr 0,x + ldd #_far_bar ; Likewise (unique trampoline check) + xgdy + jsr 0,y + call _far_no_tramp ; No trampoline generated for _far_no_tramp + clra + clrb + wai +fail: + ldd #1 + wai + bra start + + .sect .bank1,"ax" + .globl _far_bar + .far _far_bar ; Must mark symbol as far +_far_bar: + jsr local_bank1 + xgdx + rtc + +local_bank1: + rts + + .sect .bank2,"ax" + .globl _far_foo + .far _far_foo +_far_foo: + jsr local_bank2 + rtc + +local_bank2: + rts + + .sect .bank3,"ax" + .globl _far_no_tramp + .far _far_no_tramp +_far_no_tramp: + jsr local_bank3 + rtc + +local_bank3: + rts + + .sect .text + .globl __far_trampoline +__far_trampoline: + movb 0,sp, 2,sp ; Copy page register below the caller's return + leas 2,sp ; address. + jmp 0,y ; We have a 'call/rtc' stack layout now + ; and can jump to the far handler + ; (whose memory bank is mapped due to the + ; call to the trampoline). + + .sect .bss + .skip 100 +stack: + diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/link-hc12.s b/binutils-2.21/ld/testsuite/ld-m68hc11/link-hc12.s new file mode 100644 index 0000000..43b97c5 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/link-hc12.s @@ -0,0 +1,6 @@ +;;; Test 68HCS12 and 68HC12 mixes (compatible case) +;;; + .sect .text + .globl main +main: + rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/link-hcs12.d b/binutils-2.21/ld/testsuite/ld-m68hc11/link-hcs12.d new file mode 100644 index 0000000..f243da2 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/link-hcs12.d @@ -0,0 +1,24 @@ +#source: link-hcs12.s -m68hcs12 +#source: link-hc12.s -m68hc12 +#as: -mshort +#ld: -m m68hc12elf +#objdump: -p -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: file format elf32\-m68hc12 + +Program Header: + LOAD off 0x0+ vaddr 0x0+1000 paddr 0x0+1000 align 2\*\*12 + filesz 0x0+100 memsz 0x0+100 flags rw- + LOAD off 0x0+1000 vaddr 0x0+8000 paddr 0x0+8000 align 2\*\*12 + filesz 0x0+6 memsz 0x0+6 flags r-x + LOAD off 0x0+1100 vaddr 0x0+1100 paddr 0x0+8006 align 2\*\*12 + filesz 0x0+ memsz 0x0+ flags rw- +private flags = 22:\[abi=16\-bit int, 64\-bit double, cpu=HCS12\] \[memory=flat\] + +Disassembly of section .text: +0+8000 <_start> jsr 0+8005 <main> +0+8003 <_start\+0x3> bra 0+8000 <_start> +0+8005 <main> rts + + diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/link-hcs12.s b/binutils-2.21/ld/testsuite/ld-m68hc11/link-hcs12.s new file mode 100644 index 0000000..868d4cf --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/link-hcs12.s @@ -0,0 +1,7 @@ +;;; Test 68HCS12 and 68HC12 mixes (compatible case) +;;; + .sect .text + .globl _start +_start: + bsr main + bra _start diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/m68hc11.exp b/binutils-2.21/ld/testsuite/ld-m68hc11/m68hc11.exp new file mode 100644 index 0000000..103b792 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/m68hc11.exp @@ -0,0 +1,34 @@ +# Expect script for run_dump_test based ld-m68hc11 tests. +# Copyright 2002, 2005, 2007 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# Adapted from ld-sh/rd-sh.exp + +# Test 68HC11 relaxing. This tests the assembler as well as the linker. + +if { ![istarget m6811-*-*] && ![istarget m6812-*-*] } { + return +} + +set rd_test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]] +foreach shtest $rd_test_list { + # We need to strip the ".d", but can leave the dirname. + verbose [file rootname $shtest] + run_dump_test [file rootname $shtest] +} diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/relax-direct.d b/binutils-2.21/ld/testsuite/ld-m68hc11/relax-direct.d new file mode 100644 index 0000000..9bd0822 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/relax-direct.d @@ -0,0 +1,63 @@ +#source: relax-direct.s +#as: -m68hc11 +#ld: --relax +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: +file format elf32-m68hc11 + +Disassembly of section .text: +0+8000 <_start> lds \*0+28 <stack> +0+8002 <_start\+0x2> ldd \*0+ <__bss_size> +0+8004 <_start\+0x4> beq 0+800f <F1> +0+8006 <_start\+0x6> bne 0+800b <_start\+0xb> +0+8008 <_start\+0x8> jmp 0+8138 <F2> +0+800b <_start\+0xb> std \*0+ <__bss_size> +0+800d <_start\+0xd> jsr \*0+ <__bss_size> +0+800f <F1> addd \*0+4 <_toto> +0+8011 <F1\+0x2> bne 0+8000 <_start> +0+8013 <F1\+0x4> addd \*0+cc <_table\+0x9a> +0+8015 <F1\+0x6> addd 0+114 <_stack_top\+0x1a> +0+8018 <F1\+0x9> adca \*0+34 <_table\+0x2> +0+801a <F1\+0xb> adcb \*0+35 <_table\+0x3> +0+801c <F1\+0xd> adda \*0+36 <_table\+0x4> +0+801e <F1\+0xf> addb \*0+37 <_table\+0x5> +0+8020 <F1\+0x11> addd \*0+38 <_table\+0x6> +0+8022 <F1\+0x13> anda \*0+39 <_table\+0x7> +0+8024 <F1\+0x15> andb \*0+3a <_table\+0x8> +0+8026 <F1\+0x17> cmpa \*0+3b <_table\+0x9> +0+8028 <F1\+0x19> cmpb \*0+3c <_table\+0xa> +0+802a <F1\+0x1b> cpd \*0+3d <_table\+0xb> +0+802d <F1\+0x1e> cpx \*0+3e <_table\+0xc> +0+802f <F1\+0x20> cpy \*0+3f <_table\+0xd> +0+8032 <F1\+0x23> eora \*0+40 <_table\+0xe> +0+8034 <F1\+0x25> eorb \*0+41 <_table\+0xf> +0+8036 <F1\+0x27> jsr \*0+42 <_table\+0x10> +0+8038 <F1\+0x29> ldaa \*0+43 <_table\+0x11> +0+803a <F1\+0x2b> ldab \*0+44 <_table\+0x12> +0+803c <F1\+0x2d> ldd \*0+45 <_table\+0x13> +0+803e <F1\+0x2f> lds \*0+46 <_table\+0x14> +0+8040 <F1\+0x31> ldx \*0+47 <_table\+0x15> +0+8042 <F1\+0x33> ldy \*0+48 <_table\+0x16> +0+8045 <F1\+0x36> oraa \*0+49 <_table\+0x17> +0+8047 <F1\+0x38> orab \*0+4a <_table\+0x18> +0+8049 <F1\+0x3a> sbcb \*0+4b <_table\+0x19> +0+804b <F1\+0x3c> sbca \*0+4c <_table\+0x1a> +0+804d <F1\+0x3e> staa \*0+4d <_table\+0x1b> +0+804f <F1\+0x40> stab \*0+4e <_table\+0x1c> +0+8051 <F1\+0x42> std \*0+4f <_table\+0x1d> +0+8053 <F1\+0x44> sts \*0+50 <_table\+0x1e> +0+8055 <F1\+0x46> stx \*0+51 <_table\+0x1f> +0+8057 <F1\+0x48> sty \*0+52 <_table\+0x20> +0+805a <F1\+0x4b> suba \*0+53 <_table\+0x21> +0+805c <F1\+0x4d> subb \*0+54 <_table\+0x22> +0+805e <F1\+0x4f> subd \*0+55 <_table\+0x23> +0+8060 <F1\+0x51> bne 0+8000 <_start> +0+8062 <F1\+0x53> bra 0+800f <F1> +0+8064 <F1\+0x55> rts +0+8065 <no_relax> addd 0+136 <_stack_top\+0x3c> +0+8068 <no_relax\+0x3> std 0+122 <_stack_top\+0x28> +0+806b <no_relax\+0x6> tst 0+5 <_toto\+0x1> +0+806e <no_relax\+0x9> bne 0+8065 <no_relax> + ... +0+8138 <F2> jmp 0+8000 <_start> diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/relax-direct.s b/binutils-2.21/ld/testsuite/ld-m68hc11/relax-direct.s new file mode 100644 index 0000000..f449772 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/relax-direct.s @@ -0,0 +1,84 @@ +;;; Test 68HC11 linker relaxation from extended addressing to direct +;;; addressing modes +;;; + .sect .text + .globl _start +_start: +start: + lds stack + ldd _bar + beq F1 + beq F2 + std _bar + jsr _bar +F1: + addd _toto + bne start + ;; All the following instructions will be relaxed and win 1 byte + ;; for each. + addd _toto+200 + addd stack+256-20 + adca _table+2 + adcb _table+3 + adda _table+4 + addb _table+5 + addd _table+6 + anda _table+7 + andb _table+8 + cmpa _table+9 + cmpb _table+10 + cpd _table+11 + cpx _table+12 + cpy _table+13 + eora _table+14 + eorb _table+15 + jsr _table+16 + ldaa _table+17 + ldab _table+18 + ldd _table+19 + lds _table+20 + ldx _table+21 + ldy _table+22 + oraa _table+23 + orab _table+24 + sbcb _table+25 + sbca _table+26 + staa _table+27 + stab _table+28 + std _table+29 + sts _table+30 + stx _table+31 + sty _table+32 + suba _table+33 + subb _table+34 + subd _table+35 + ;; 'bne' is assembled as far branch and must relax to + ;; a relative 8-bit branch. + bne _start + ;; Likewise for next branch + bra F1 + rts + +;;; The following instructions will not be relaxed +no_relax: + addd _stack_top+60 + std _stack_top+40 + ;; 'tst' does not support direct addressing mode. + tst _toto+1 + bne no_relax + .skip 200 +F2: + bra _start + + .sect .page0 +_bar: + .long 0 +_toto: + .long 0 + .skip 32 +stack: + .skip 10 +_table: + .skip 200 +_stack_top: + diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/relax-group.d b/binutils-2.21/ld/testsuite/ld-m68hc11/relax-group.d new file mode 100644 index 0000000..baf294b --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/relax-group.d @@ -0,0 +1,63 @@ +#source: relax-group.s +#as: -m68hc11 +#ld: --relax +#objdump: -d --prefix-addresses -r +#target: m6811-*-* m6812-*-* + +.*: +file format elf32-m68hc11 + +Disassembly of section .text: +0+8000 <_start> bset \*0+ <__bss_size> #\$04 +0+8003 <L1x> bset \*0+ <__bss_size> #\$04 +0+8006 <L1y> bset \*0+3 <__bss_size\+0x3> #\$04 +0+8009 <L1y\+0x3> bset \*0+4 <table4> #\$08 +0+800c <L2x> bset \*0+3 <__bss_size\+0x3> #\$04 +0+800f <L2x\+0x3> bset \*0+4 <table4> #\$08 +0+8012 <L2y> bset \*0+6 <table4\+0x2> #\$04 +0+8015 <L2y\+0x3> bset \*0+7 <table4\+0x3> #\$08 +0+8018 <L2y\+0x6> bset \*0+8 <table8> #\$0c +0+801b <L2y\+0x9> bset \*0+9 <table8\+0x1> #\$0c +0+801e <L2y\+0xc> bset \*0+a <table8\+0x2> #\$0c +0+8021 <L2y\+0xf> bset \*0+b <table8\+0x3> #\$0c +0+8024 <L3x> bset \*0+6 <table4\+0x2> #\$04 +0+8027 <L3x\+0x3> bset \*0+7 <table4\+0x3> #\$08 +0+802a <L3x\+0x6> bset \*0+8 <table8> #\$0c +0+802d <L3x\+0x9> bset \*0+9 <table8\+0x1> #\$0c +0+8030 <L3x\+0xc> bset \*0+a <table8\+0x2> #\$0c +0+8033 <L3x\+0xf> bset \*0+b <table8\+0x3> #\$0c +0+8036 <L3y> bra 0+8000 <_start> +0+8038 <L3y\+0x2> ldx #0+fe <end_table\+0xe8> +0+803b <L3y\+0x5> bset \*0+fe <end_table\+0xe8> #\$04 +0+803e <L3y\+0x8> bset \*0+ff <end_table\+0xe9> #\$08 +0+8041 <L3y\+0xb> bset 2,x #\$0c +0+8044 <L3y\+0xe> bset 3,x #\$0c +0+8047 <L3y\+0x11> bset 4,x #\$0c +0+804a <L3y\+0x14> bset 5,x #\$0c +0+804d <L4x> ldy #0+fe <end_table\+0xe8> +0+8051 <L4x\+0x4> bset \*0+fe <end_table\+0xe8> #\$04 +0+8054 <L4x\+0x7> bset \*0+ff <end_table\+0xe9> #\$08 +0+8057 <L4x\+0xa> bset 2,y #\$0c +0+805b <L4x\+0xe> bset 3,y #\$0c +0+805f <L4x\+0x12> bset 4,y #\$0c +0+8063 <L4x\+0x16> bset 5,y #\$0c +0+8067 <L4y> bclr \*0+a <table8\+0x2> #\$04 +0+806a <L4y\+0x3> bclr \*0+b <table8\+0x3> #\$08 +0+806d <L5x> bclr \*0+1a <end_table\+0x4> #\$04 +0+8070 <L5x\+0x3> bclr \*0+1b <end_table\+0x5> #\$08 +0+8073 <L5y> brset \*0+8 <table8> #\$04 0+8073 <L5y> +0+8077 <L6x> brset \*0+8 <table8> #\$04 0+8077 <L6x> +0+807b <L7x> brset \*0+8 <table8> #\$04 0+8094 <brend> +0+807f <L8x> brset \*0+8 <table8> #\$04 0+8094 <brend> +0+8083 <L8y> brclr \*0+8 <table8> #\$04 0+8083 <L8y> +0+8087 <L9x> brclr \*0+8 <table8> #\$04 0+8087 <L9x> +0+808b <L9y> brclr \*0+8 <table8> #\$04 0+8094 <brend> +0+808f <L10x> brclr \*0+8 <table8> #\$04 0+8094 <brend> +0+8093 <L10y> nop +0+8094 <brend> bset 0,x #\$04 +0+8097 <w2> ldx #0+ <__bss_size> +0+809a <w3> ldy #0+8 <table8> +0+809e <w4> rts +0+809f <w5> ldx #0+ <__bss_size> +0+80a2 <w5\+0x3> bset 0,x #\$05 +0+80a5 <w5\+0x6> jmp 0+8000 <_start> +0+80a8 <w5\+0x9> rts diff --git a/binutils-2.21/ld/testsuite/ld-m68hc11/relax-group.s b/binutils-2.21/ld/testsuite/ld-m68hc11/relax-group.s new file mode 100644 index 0000000..41c55f5 --- /dev/null +++ b/binutils-2.21/ld/testsuite/ld-m68hc11/relax-group.s @@ -0,0 +1,161 @@ +;;; Test 68HC11 linker relaxation (group relax) +;;; + .sect .text + .globl _start +_start: +;;; +;;; The following group of instructions are adjusted. +;;; + .relax L1x + ldx #table + bset 0,x #4 +L1x: + .relax L1y + ldy #table + bset 0,y #4 +L1y: + .relax L2x + ldx #table+3 + bset 0,x #4 + bset 1,x #8 +L2x: + .relax L2y + ldy #table+3 + bset 0,y #4 + bset 1,y #8 +L2y: + .relax L3x + ldx #table+6 + bset 0,x #4 + bset 1,x #8 + bset 2,x #12 + bset 3,x #12 + bset 4,x #12 + bset 5,x #12 +L3x: + .relax L3y + ldy #table+6 + bset 0,y #4 + bset 1,y #8 + bset 2,y #12 + bset 3,y #12 + bset 4,y #12 + bset 5,y #12 +L3y: + ;; Next branch is always relative. It must be adjusted while + ;; above instructions are relaxed. + bra _start +;;; +;;; This group has the first two bset insn relaxable while the +;;; others are not. The ldx/ldy must not be removed. +;;; + .relax L4x + ldx #table+0xfe + bset 0,x #4 + bset 1,x #8 + bset 2,x #12 + bset 3,x #12 + bset 4,x #12 + bset 5,x #12 +L4x: + .relax L4y + ldy #table+0xfe + bset 0,y #4 + bset 1,y #8 + bset 2,y #12 + bset 3,y #12 + bset 4,y #12 + bset 5,y #12 +L4y: +;;; +;;; Relax group for bclr +;;; + .relax L5x + ldx #table+10 + bclr 0,x #4 + bclr 1,x #8 +L5x: + .relax L5y + ldy #table+16 + bclr 10,y #4 + bclr 11,y #8 +L5y: +;;; +;;; Relax group for brset (with backward branch) +;;; + .relax L6x + ldx #table+8 + brset 0,x #4 L5y +L6x: + .relax L7x + ldy #table+8 + brset 0,y #4 L6x +L7x: +;;; +;;; Relax group for brset (with forward branch) +;;; + .relax L8x + ldx #table+8 + brset 0,x #4 brend +L8x: + .relax L8y + ldy #table+8 + brset 0,y #4 brend +L8y: +;;; +;;; Relax group for brclr (with backward branch) +;;; + .relax L9x + ldx #table+8 + brclr 0,x #4 L8y +L9x: + .relax L9y + ldy #table+8 + brclr 0,y #4 L9x +L9y: +;;; +;;; Relax group for brclr (with forward branch) +;;; + .relax L10x + ldx #table+8 + brclr 0,x #4 brend +L10x: + .relax L10y + ldy #table+8 + brclr 0,y #4 brend +L10y: + nop +brend: +;;; +;;; The following are wrong use of .relax groups. +;;; + .relax w1 +w1: + .relax w2 + bset 0,x #4 +w2: + .relax w3 + ldx #table +w3: + .relax w4 + ldy #table+8 +w4: + .relax w5 + rts +w5: +;;; +;;; Next insn is not in a .relax group + ldx #table + bset 0,x #5 + bra _start + rts + + .sect .page0 + .globl table +table: .long 0 +table4: .long 0 +table8: .long 0 + .skip 10 +end_table: + .long 0 + |