+2005-11-23 Daniel Jacobowitz <dan@codesourcery.com>
+ Thiemo Seufer <ths@networkno.de>
+
+ * elf32-mips.c (elf_mips_howto_table_rel): Use rightshift 2 for
+ R_MIPS_PC16.
+ (mips_reloc_map): Map BFD_RELOC_16_PCREL_S2 to R_MIPS_PC16.
+ (bfd_elf32_bfd_reloc_type_lookup): Don't handle
+ BFD_RELOC_16_PCREL_S2.
+ * elf64-mips.c (mips_elf64_howto_table_rel): Use rightshift 2 for
+ R_MIPS_PC16.
+ (mips_elf64_howto_table_rela): Likewise.
+ (mips_reloc_map): Map BFD_RELOC_16_PCREL_S2 to R_MIPS_PC16.
+ (bfd_elf64_bfd_reloc_type_lookup): Don't handle
+ BFD_RELOC_16_PCREL_S2.
+ * elfn32-mips.c (elf_mips_howto_table_rel): Use rightshift 2 for
+ R_MIPS_PC16.
+ (elf_mips_howto_table_rela): Likewise.
+ (mips_reloc_map): Map BFD_RELOC_16_PCREL_S2 to R_MIPS_PC16.
+ (bfd_elf32_bfd_reloc_type_lookup): Don't handle
+ BFD_RELOC_16_PCREL_S2.
+ * elfxx-mips.c: Formatting fixes.
+ (mips_elf_calculate_relocation): Handle R_MIPS_GNU_REL16_S2
+ and R_MIPS_PC16 identically.
+
2005-11-23 Frederic Riss <frederic.riss@st.com>
* elfcode.h (elf_object_p): Delay the setting of start_address
0x0000ffff, /* dst_mask */
FALSE), /* pcrel_offset */
- /* 16 bit PC relative reference. */
+ /* 16 bit PC relative reference. Note that the ABI document has a typo
+ and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+ We do the right thing here. */
HOWTO (R_MIPS_PC16, /* type */
- 0, /* rightshift */
+ 2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
TRUE, /* pc_relative */
{ BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
{ BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
{ BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
- { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+ { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
{ BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
{ BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
{ BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
return &elf_mips_gnu_vtinherit_howto;
case BFD_RELOC_VTABLE_ENTRY:
return &elf_mips_gnu_vtentry_howto;
- case BFD_RELOC_16_PCREL_S2:
- return &elf_mips_gnu_rel16_s2;
case BFD_RELOC_32_PCREL:
return &elf_mips_gnu_pcrel32;
}
0x0000ffff, /* dst_mask */
FALSE), /* pcrel_offset */
- /* 16 bit PC relative reference. */
+ /* 16 bit PC relative reference. Note that the ABI document has a typo
+ and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+ We do the right thing here. */
HOWTO (R_MIPS_PC16, /* type */
- 0, /* rightshift */
+ 2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
TRUE, /* pc_relative */
0x0000ffff, /* dst_mask */
FALSE), /* pcrel_offset */
- /* 16 bit PC relative reference. */
+ /* 16 bit PC relative reference. Note that the ABI document has a typo
+ and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+ We do the right thing here. */
HOWTO (R_MIPS_PC16, /* type */
- 0, /* rightshift */
+ 2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
TRUE, /* pc_relative */
/* There is no BFD reloc for R_MIPS_REL32. */
{ BFD_RELOC_64, R_MIPS_64 },
{ BFD_RELOC_CTOR, R_MIPS_64 },
- { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+ { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
{ BFD_RELOC_HI16_S, R_MIPS_HI16 },
{ BFD_RELOC_LO16, R_MIPS_LO16 },
{ BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
return &elf_mips_gnu_vtinherit_howto;
case BFD_RELOC_VTABLE_ENTRY:
return &elf_mips_gnu_vtentry_howto;
- case BFD_RELOC_16_PCREL_S2:
- return &elf_mips_gnu_rela16_s2;
default:
bfd_set_error (bfd_error_bad_value);
return NULL;
0x0000ffff, /* dst_mask */
FALSE), /* pcrel_offset */
- /* 16 bit PC relative reference. */
+ /* 16 bit PC relative reference. Note that the ABI document has a typo
+ and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+ We do the right thing here. */
HOWTO (R_MIPS_PC16, /* type */
- 0, /* rightshift */
+ 2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
TRUE, /* pc_relative */
0x0000ffff, /* dst_mask */
FALSE), /* pcrel_offset */
- /* 16 bit PC relative reference. */
+ /* 16 bit PC relative reference. Note that the ABI document has a typo
+ and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
+ We do the right thing here. */
HOWTO (R_MIPS_PC16, /* type */
- 0, /* rightshift */
+ 2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
TRUE, /* pc_relative */
/* There is no BFD reloc for R_MIPS_REL32. */
{ BFD_RELOC_CTOR, R_MIPS_32 },
{ BFD_RELOC_64, R_MIPS_64 },
- { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
+ { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
{ BFD_RELOC_HI16_S, R_MIPS_HI16 },
{ BFD_RELOC_LO16, R_MIPS_LO16 },
{ BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
return &elf_mips_gnu_vtinherit_howto;
case BFD_RELOC_VTABLE_ENTRY:
return &elf_mips_gnu_vtentry_howto;
- case BFD_RELOC_16_PCREL_S2:
- return &elf_mips_gnu_rela16_s2;
default:
bfd_set_error (bfd_error_bad_value);
return NULL;
static bfd *reldyn_sorting_bfd;
/* Nonzero if ABFD is using the N32 ABI. */
-
#define ABI_N32_P(abfd) \
((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
return e1->bfd == e2->bfd;
}
-/* In a multi-got link, determine the GOT to be used for IBDF. G must
+/* In a multi-got link, determine the GOT to be used for IBFD. G must
be the master GOT data. */
static struct mips_got_info *
value &= howto->dst_mask;
break;
- case R_MIPS_GNU_REL16_S2:
- value = symbol + _bfd_mips_elf_sign_extend (addend, 18) - p;
- overflowed_p = mips_elf_overflow_p (value, 18);
- value = (value >> 2) & howto->dst_mask;
- break;
-
case R_MIPS16_26:
/* The calculation for R_MIPS16_26 is just the same as for an
R_MIPS_26. It's only the storage of the relocated field into
break;
case R_MIPS_PC16:
- value = _bfd_mips_elf_sign_extend (addend, 16) + symbol - p;
- overflowed_p = mips_elf_overflow_p (value, 16);
+ case R_MIPS_GNU_REL16_S2:
+ value = symbol + _bfd_mips_elf_sign_extend (addend, 18) - p;
+ overflowed_p = mips_elf_overflow_p (value, 18);
+ value = (value >> 2) & howto->dst_mask;
break;
case R_MIPS_GOT_HI16:
+2005-11-23 Daniel Jacobowitz <dan@codesourcery.com>
+ Thiemo Seufer <ths@networkno.de>
+
+ * config/tc-mips.c (append_insn): Handle BFD_RELOC_16_PCREL_S2.
+ (macro_build): Complain for invalid branch displacements.
+ (mips_validate_fix): Delete.
+ (md_apply_fix): Re-add pcrel support for branches. Use consistent
+ text for misaligned branch targets.
+ (tc_gen_reloc: Re-add pcrel support for branches. Handle strange
+ BFD pcrel processing. Remove error for unresolved branches.
+ * config/tc-mips.h (TC_VALIDATE_FIX, mips_validate_fix): Delete.
+
2005-11-22 James E Wilson <wilson@specifix.com>
* config/tc-ia64.c (emit_one_bundle): Perform last_slot < 0 check
break;
case BFD_RELOC_16_PCREL_S2:
- goto need_reloc;
+ if ((address_expr->X_add_number & 3) != 0)
+ as_bad (_("branch to misaligned address (0x%lx)"),
+ (unsigned long) address_expr->X_add_number);
+ if (mips_relax_branch)
+ goto need_reloc;
+ if ((address_expr->X_add_number + 0x20000) & ~0x3ffff)
+ as_bad (_("branch address range overflow (0x%lx)"),
+ (unsigned long) address_expr->X_add_number);
+ ip->insn_opcode |= (address_expr->X_add_number >> 2) & 0xffff;
+ break;
default:
internalError ();
case 'p':
assert (ep != NULL);
+
/*
* This allows macro() to pass an immediate expression for
* creating short branches without creating a symbol.
- * Note that the expression still might come from the assembly
- * input, in which case the value is not checked for range nor
- * is a relocation entry generated (yuck).
+ *
+ * We don't allow branch relaxation for these branches, as
+ * they should only appear in ".set nomacro" anyway.
*/
if (ep->X_op == O_constant)
{
+ if ((ep->X_add_number & 3) != 0)
+ as_bad (_("branch to misaligned address (0x%lx)"),
+ (unsigned long) ep->X_add_number);
+ if ((ep->X_add_number + 0x20000) & ~0x3ffff)
+ as_bad (_("branch address range overflow (0x%lx)"),
+ (unsigned long) ep->X_add_number);
insn.insn_opcode |= (ep->X_add_number >> 2) & 0xffff;
ep = NULL;
}
return 0;
}
-/* This hook is called before a fix is simplified. We don't really
- decide whether to skip a fix here. Rather, we turn global symbols
- used as branch targets into local symbols, such that they undergo
- simplification. We can only do this if the symbol is defined and
- it is in the same section as the branch. If this doesn't hold, we
- emit a better error message than just saying the relocation is not
- valid for the selected object format.
-
- FIXP is the fix-up we're going to try to simplify, SEG is the
- segment in which the fix up occurs. The return value should be
- non-zero to indicate the fix-up is valid for further
- simplifications. */
-
-int
-mips_validate_fix (struct fix *fixP, asection *seg)
-{
- /* There's a lot of discussion on whether it should be possible to
- use R_MIPS_PC16 to represent branch relocations. The outcome
- seems to be that it can, but gas/bfd are very broken in creating
- RELA relocations for this, so for now we only accept branches to
- symbols in the same section. Anything else is of dubious value,
- since there's no guarantee that at link time the symbol would be
- in range. Even for branches to local symbols this is arguably
- wrong, since it we assume the symbol is not going to be
- overridden, which should be possible per ELF library semantics,
- but then, there isn't a dynamic relocation that could be used to
- this effect, and the target would likely be out of range as well.
-
- Unfortunately, it seems that there is too much code out there
- that relies on branches to symbols that are global to be resolved
- as if they were local, like the IRIX tools do, so we do it as
- well, but with a warning so that people are reminded to fix their
- code. If we ever get back to using R_MIPS_PC16 for branch
- targets, this entire block should go away (and probably the
- whole function). */
-
- if (fixP->fx_r_type == BFD_RELOC_16_PCREL_S2
- && ((OUTPUT_FLAVOR == bfd_target_ecoff_flavour
- || OUTPUT_FLAVOR == bfd_target_elf_flavour)
- || bfd_reloc_type_lookup (stdoutput, BFD_RELOC_16_PCREL_S2) == NULL)
- && fixP->fx_addsy)
- {
- if (! S_IS_DEFINED (fixP->fx_addsy))
- {
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("Cannot branch to undefined symbol."));
- /* Avoid any further errors about this fixup. */
- fixP->fx_done = 1;
- }
- else if (S_GET_SEGMENT (fixP->fx_addsy) != seg)
- {
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("Cannot branch to symbol in another section."));
- fixP->fx_done = 1;
- }
- else if (S_IS_EXTERNAL (fixP->fx_addsy))
- {
- symbolS *sym = fixP->fx_addsy;
-
- if (mips_pic == SVR4_PIC)
- as_warn_where (fixP->fx_file, fixP->fx_line,
- _("Pretending global symbol used as branch target is local."));
-
- fixP->fx_addsy = symbol_create (S_GET_NAME (sym),
- S_GET_SEGMENT (sym),
- S_GET_VALUE (sym),
- symbol_get_frag (sym));
- copy_symbol_attributes (fixP->fx_addsy, sym);
- S_CLEAR_EXTERNAL (fixP->fx_addsy);
- assert (symbol_resolved_p (sym));
- symbol_mark_resolved (fixP->fx_addsy);
- }
- }
-
- return 1;
-}
-
/* Apply a fixup to the object file. */
void
buf = (bfd_byte *) (fixP->fx_frag->fr_literal + fixP->fx_where);
- assert (! fixP->fx_pcrel);
+ assert (! fixP->fx_pcrel || fixP->fx_r_type == BFD_RELOC_16_PCREL_S2);
/* Don't treat parts of a composite relocation as done. There are two
reasons for this:
constants. The easiest way of dealing with the pathological
exceptions is to generate a relocation against STN_UNDEF and
leave everything up to the linker. */
- if (fixP->fx_addsy == NULL && fixP->fx_tcbit == 0)
+ if (fixP->fx_addsy == NULL && ! fixP->fx_pcrel && fixP->fx_tcbit == 0)
fixP->fx_done = 1;
switch (fixP->fx_r_type)
case BFD_RELOC_MIPS16_GPREL:
case BFD_RELOC_MIPS16_HI16:
case BFD_RELOC_MIPS16_HI16_S:
- assert (! fixP->fx_pcrel);
/* Nothing needed to do. The value comes from the reloc entry */
break;
case BFD_RELOC_16_PCREL_S2:
if ((*valP & 0x3) != 0)
as_bad_where (fixP->fx_file, fixP->fx_line,
- _("Branch to odd address (%lx)"), (long) *valP);
+ _("Branch to misaligned address (%lx)"), (long) *valP);
/*
* We need to save the bits in the instruction since fixup_segment()
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
- assert (! fixp->fx_pcrel);
- reloc->addend = fixp->fx_addnumber;
+ if (fixp->fx_pcrel)
+ {
+ assert (fixp->fx_r_type == BFD_RELOC_16_PCREL_S2);
+
+ /* At this point, fx_addnumber is "symbol offset - pcrel address".
+ Relocations want only the symbol offset. */
+ reloc->addend = fixp->fx_addnumber + reloc->address;
+ if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
+ {
+ /* A gruesome hack which is a result of the gruesome gas
+ reloc handling. What's worse, for COFF (as opposed to
+ ECOFF), we might need yet another copy of reloc->address.
+ See bfd_install_relocation. */
+ reloc->addend += reloc->address;
+ }
+ }
+ else
+ reloc->addend = fixp->fx_addnumber;
/* Since the old MIPS ELF ABI uses Rel instead of Rela, encode the vtable
entry to be used in the relocation's section offset. */
code = fixp->fx_r_type;
- /* To support a PC relative reloc, we used a Cygnus extension.
- We check for that here to make sure that we don't let such a
- reloc escape normally. (FIXME: This was formerly used by
- embedded-PIC support, but is now used by branch handling in
- general. That probably should be fixed.) */
- if ((OUTPUT_FLAVOR == bfd_target_ecoff_flavour
- || OUTPUT_FLAVOR == bfd_target_elf_flavour)
- && code == BFD_RELOC_16_PCREL_S2)
- reloc->howto = NULL;
- else
- reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
-
+ reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
if (reloc->howto == NULL)
{
as_bad_where (fixp->fx_file, fixp->fx_line,
exp.X_add_number = fragp->fr_offset;
fixp = fix_new_exp (fragp, buf - (bfd_byte *)fragp->fr_literal,
- 4, &exp, 1,
- BFD_RELOC_16_PCREL_S2);
+ 4, &exp, 1, BFD_RELOC_16_PCREL_S2);
fixp->fx_file = fragp->fr_file;
fixp->fx_line = fragp->fr_line;
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
(! SEG_NORMAL (SEG) || mips_force_relocation (FIX))
-/* We use this to turn branches to global symbols into branches to
- local symbols, so that they can be simplified. */
-#define TC_VALIDATE_FIX(fixp, this_segment, skip_label) \
- do \
- if (! mips_validate_fix ((fixp), (this_segment))) \
- goto skip_label; \
- while (0)
-extern int mips_validate_fix (struct fix *, asection *);
-
/* Register mask variables. These are set by the MIPS assembly code
and used by ECOFF and possibly other object file formats. */
extern unsigned long mips_gprmask;
+2005-11-23 Daniel Jacobowitz <dan@codesourcery.com>
+ Thiemo Seufer <ths@networkno.de>
+
+ * gas/mips/bge.d, gas/mips/bge.s, gas/mips/bgeu.d, gas/mips/bgeu.s,
+ gas/mips/blt.d, gas/mips/blt.s, gas/mips/bltu.d,
+ gas/mips/bltu.s: Reactivate external branch tests.
+ * gas/mips/branch-misc-2.d, gas/mips/branch-misc-2pic.d,
+ gas/mips/branch-misc-2-64.d, gas/mips/branch-misc-2pic-64.d: New
+ tests.
+ * gas/mips/branch-misc-2.l, gas/mips/branch-misc-2pic.l,
+ gas/testsuite/gas/mips/branch-misc-2pic.s: Remove.
+ * gas/mips/mips.exp: Adjust branch-misc-2 tests. Add 64-bit
+ variants.
+
2005-11-22 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* gas/all/quad.d: Add -j "\$DATA\$". Modify regexp to check for
0+00a8 <[^>]*> slt at,a1,a0
0+00ac <[^>]*> bnezl at,0+0000 <text_label>
0+00b0 <[^>]*> nop
-#0+00b4 <[^>]*> slt at,a0,a1
-#0+00b8 <[^>]*> beqz at,000000b8 <text_label\+0xb8>
-#[ ]*b8: R_MIPS_PC16 external_label
-#0+00bc <[^>]*> nop
-#0+00c0 <[^>]*> slt at,a1,a0
-#0+00c4 <[^>]*> bnez at,000000c4 <text_label\+0xc4>
-#[ ]*c4: R_MIPS_PC16 external_label
-#0+00c8 <[^>]*> nop
-#0+00cc <[^>]*> slt at,a0,a1
-#0+00d0 <[^>]*> beqzl at,000000d0 <text_label\+0xd0>
-#[ ]*d0: R_MIPS_PC16 external_label
-#0+00d4 <[^>]*> nop
-#0+00d8 <[^>]*> slt at,a1,a0
-#0+00dc <[^>]*> bnezl at,000000dc <text_label\+0xdc>
-#[ ]*dc: R_MIPS_PC16 external_label
-#0+00e0 <[^>]*> nop
+0+00b4 <[^>]*> slt at,a0,a1
+0+00b8 <[^>]*> beqz at,000000b8 <text_label\+0xb8>
+[ ]*b8: R_MIPS_PC16 external_label
+0+00bc <[^>]*> nop
+0+00c0 <[^>]*> slt at,a1,a0
+0+00c4 <[^>]*> bnez at,000000c4 <text_label\+0xc4>
+[ ]*c4: R_MIPS_PC16 external_label
+0+00c8 <[^>]*> nop
+0+00cc <[^>]*> slt at,a0,a1
+0+00d0 <[^>]*> beqzl at,000000d0 <text_label\+0xd0>
+[ ]*d0: R_MIPS_PC16 external_label
+0+00d4 <[^>]*> nop
+0+00d8 <[^>]*> slt at,a1,a0
+0+00dc <[^>]*> bnezl at,000000dc <text_label\+0xdc>
+[ ]*dc: R_MIPS_PC16 external_label
+0+00e0 <[^>]*> nop
...
bgtl $4,$5,text_label
# Branch to an external label.
-# bge $4,$5,external_label
-# bgt $4,$5,external_label
-# bgel $4,$5,external_label
-# bgtl $4,$5,external_label
+ bge $4,$5,external_label
+ bgt $4,$5,external_label
+ bgel $4,$5,external_label
+ bgtl $4,$5,external_label
# Round to a 16 byte boundary, for ease in testing multiple targets.
nop
0+0090 <[^>]*> sltu at,a1,a0
0+0094 <[^>]*> bnezl at,0+0000 <text_label>
0+0098 <[^>]*> nop
-#0+009c <[^>]*> sltu at,a0,a1
-#0+00a0 <[^>]*> beqz at,000000a0 <text_label\+0xa0>
-#[ ]*a0: R_MIPS_PC16 external_label
-#0+00a4 <[^>]*> nop
-#0+00a8 <[^>]*> sltu at,a1,a0
-#0+00ac <[^>]*> bnez at,000000ac <text_label\+0xac>
-#[ ]*ac: R_MIPS_PC16 external_label
-#0+00b0 <[^>]*> nop
-#0+00b4 <[^>]*> sltu at,a0,a1
-#0+00b8 <[^>]*> beqzl at,000000b8 <text_label\+0xb8>
-#[ ]*b8: R_MIPS_PC16 external_label
-#0+00bc <[^>]*> nop
-#0+00c0 <[^>]*> sltu at,a1,a0
-#0+00c4 <[^>]*> bnezl at,000000c4 <text_label\+0xc4>
-#[ ]*c4: R_MIPS_PC16 external_label
-#0+00c8 <[^>]*> nop
+0+009c <[^>]*> sltu at,a0,a1
+0+00a0 <[^>]*> beqz at,000000a0 <text_label\+0xa0>
+[ ]*a0: R_MIPS_PC16 external_label
+0+00a4 <[^>]*> nop
+0+00a8 <[^>]*> sltu at,a1,a0
+0+00ac <[^>]*> bnez at,000000ac <text_label\+0xac>
+[ ]*ac: R_MIPS_PC16 external_label
+0+00b0 <[^>]*> nop
+0+00b4 <[^>]*> sltu at,a0,a1
+0+00b8 <[^>]*> beqzl at,000000b8 <text_label\+0xb8>
+[ ]*b8: R_MIPS_PC16 external_label
+0+00bc <[^>]*> nop
+0+00c0 <[^>]*> sltu at,a1,a0
+0+00c4 <[^>]*> bnezl at,000000c4 <text_label\+0xc4>
+[ ]*c4: R_MIPS_PC16 external_label
+0+00c8 <[^>]*> nop
...
bgtul $4,$5,text_label
# Branch to an external label.
-# bgeu $4,$5,external_label
-# bgtu $4,$5,external_label
-# bgeul $4,$5,external_label
-# bgtul $4,$5,external_label
+ bgeu $4,$5,external_label
+ bgtu $4,$5,external_label
+ bgeul $4,$5,external_label
+ bgtul $4,$5,external_label
# Round to a 16 byte boundary, for ease in testing multiple targets.
nop
0+00a8 <[^>]*> slt at,a1,a0
0+00ac <[^>]*> beqzl at,0+0000 <text_label>
0+00b0 <[^>]*> nop
-#0+00b4 <[^>]*> slt at,a0,a1
-#0+00b8 <[^>]*> bnez at,000000b8 <text_label\+0xb8>
-#[ ]*b8: R_MIPS_PC16 external_label
-#0+00bc <[^>]*> nop
-#0+00c0 <[^>]*> slt at,a1,a0
-#0+00c4 <[^>]*> beqz at,000000c4 <text_label\+0xc4>
-#[ ]*c4: R_MIPS_PC16 external_label
-#0+00c8 <[^>]*> nop
-#0+00cc <[^>]*> slt at,a0,a1
-#0+00d0 <[^>]*> bnezl at,000000d0 <text_label\+0xd0>
-#[ ]*d0: R_MIPS_PC16 external_label
-#0+00d4 <[^>]*> nop
-#0+00d8 <[^>]*> slt at,a1,a0
-#0+00dc <[^>]*> beqzl at,000000dc <text_label\+0xdc>
-#[ ]*dc: R_MIPS_PC16 external_label
-#0+00e0 <[^>]*> nop
+0+00b4 <[^>]*> slt at,a0,a1
+0+00b8 <[^>]*> bnez at,000000b8 <text_label\+0xb8>
+[ ]*b8: R_MIPS_PC16 external_label
+0+00bc <[^>]*> nop
+0+00c0 <[^>]*> slt at,a1,a0
+0+00c4 <[^>]*> beqz at,000000c4 <text_label\+0xc4>
+[ ]*c4: R_MIPS_PC16 external_label
+0+00c8 <[^>]*> nop
+0+00cc <[^>]*> slt at,a0,a1
+0+00d0 <[^>]*> bnezl at,000000d0 <text_label\+0xd0>
+[ ]*d0: R_MIPS_PC16 external_label
+0+00d4 <[^>]*> nop
+0+00d8 <[^>]*> slt at,a1,a0
+0+00dc <[^>]*> beqzl at,000000dc <text_label\+0xdc>
+[ ]*dc: R_MIPS_PC16 external_label
+0+00e0 <[^>]*> nop
...
blel $4,$5,text_label
# Branch to an external label.
-# blt $4,$5,external_label
-# ble $4,$5,external_label
-# bltl $4,$5,external_label
-# blel $4,$5,external_label
+ blt $4,$5,external_label
+ ble $4,$5,external_label
+ bltl $4,$5,external_label
+ blel $4,$5,external_label
# Round to a 16 byte boundary, for ease in testing multiple targets.
nop
0+0090 <[^>]*> sltu at,a1,a0
0+0094 <[^>]*> beqzl at,0+0000 <text_label>
0+0098 <[^>]*> nop
-#0+009c <[^>]*> sltu at,a0,a1
-#0+00a0 <[^>]*> bnez at,000000a0 <text_label\+0xa0>
-#[ ]*a0: R_MIPS_PC16 external_label
-#0+00a4 <[^>]*> nop
-#0+00a8 <[^>]*> sltu at,a1,a0
-#0+00ac <[^>]*> beqz at,000000ac <text_label\+0xac>
-#[ ]*ac: R_MIPS_PC16 external_label
-#0+00b0 <[^>]*> nop
-#0+00b4 <[^>]*> sltu at,a0,a1
-#0+00b8 <[^>]*> bnezl at,000000b8 <text_label\+0xb8>
-#[ ]*b8: R_MIPS_PC16 external_label
-#0+00bc <[^>]*> nop
-#0+00c0 <[^>]*> sltu at,a1,a0
-#0+00c4 <[^>]*> beqzl at,000000c4 <text_label\+0xc4>
-#[ ]*c4: R_MIPS_PC16 external_label
-#0+00c8 <[^>]*> nop
+0+009c <[^>]*> sltu at,a0,a1
+0+00a0 <[^>]*> bnez at,000000a0 <text_label\+0xa0>
+[ ]*a0: R_MIPS_PC16 external_label
+0+00a4 <[^>]*> nop
+0+00a8 <[^>]*> sltu at,a1,a0
+0+00ac <[^>]*> beqz at,000000ac <text_label\+0xac>
+[ ]*ac: R_MIPS_PC16 external_label
+0+00b0 <[^>]*> nop
+0+00b4 <[^>]*> sltu at,a0,a1
+0+00b8 <[^>]*> bnezl at,000000b8 <text_label\+0xb8>
+[ ]*b8: R_MIPS_PC16 external_label
+0+00bc <[^>]*> nop
+0+00c0 <[^>]*> sltu at,a1,a0
+0+00c4 <[^>]*> beqzl at,000000c4 <text_label\+0xc4>
+[ ]*c4: R_MIPS_PC16 external_label
+0+00c8 <[^>]*> nop
...
bleul $4,$5,text_label
# Branch to an external label.
-# bltu $4,$5,external_label
-# bleu $4,$5,external_label
-# bltul $4,$5,external_label
-# bleul $4,$5,external_label
+ bltu $4,$5,external_label
+ bleu $4,$5,external_label
+ bltul $4,$5,external_label
+ bleul $4,$5,external_label
# Round to a 16 byte boundary, for ease in testing multiple targets.
nop
--- /dev/null
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch-misc-2-64
+#source: branch-misc-2.s
+#as: -64 -non_shared
+
+# Test the backward branches to globals symbols in current file.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+ \.\.\.
+ \.\.\.
+ \.\.\.
+0+003c <[^>]*> 04110000 bal 0000000000000040 <x\+0x4>
+[ ]*3c: R_MIPS_PC16 g1\+0xfffffffffffffffc
+[ ]*3c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*3c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0040 <[^>]*> 00000000 nop
+0+0044 <[^>]*> 04110000 bal 0000000000000048 <x\+0xc>
+[ ]*44: R_MIPS_PC16 g2\+0xfffffffffffffffc
+[ ]*44: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*44: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0048 <[^>]*> 00000000 nop
+0+004c <[^>]*> 04110000 bal 0000000000000050 <x\+0x14>
+[ ]*4c: R_MIPS_PC16 g3\+0xfffffffffffffffc
+[ ]*4c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*4c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0050 <[^>]*> 00000000 nop
+0+0054 <[^>]*> 04110000 bal 0000000000000058 <x\+0x1c>
+[ ]*54: R_MIPS_PC16 g4\+0xfffffffffffffffc
+[ ]*54: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*54: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0058 <[^>]*> 00000000 nop
+0+005c <[^>]*> 04110000 bal 0000000000000060 <x\+0x24>
+[ ]*5c: R_MIPS_PC16 g5\+0xfffffffffffffffc
+[ ]*5c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*5c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0060 <[^>]*> 00000000 nop
+0+0064 <[^>]*> 04110000 bal 0000000000000068 <x\+0x2c>
+[ ]*64: R_MIPS_PC16 g6\+0xfffffffffffffffc
+[ ]*64: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*64: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0068 <[^>]*> 00000000 nop
+ \.\.\.
+ \.\.\.
+ \.\.\.
+0+00a8 <[^>]*> 10000000 b 00000000000000ac <g6\+0x4>
+[ ]*a8: R_MIPS_PC16 x1\+0xfffffffffffffffc
+[ ]*a8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*a8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+00ac <[^>]*> 00000000 nop
+0+00b0 <[^>]*> 10000000 b 00000000000000b4 <g6\+0xc>
+[ ]*b0: R_MIPS_PC16 x2\+0xfffffffffffffffc
+[ ]*b0: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*b0: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+00b4 <[^>]*> 00000000 nop
+0+00b8 <[^>]*> 10000000 b 00000000000000bc <g6\+0x14>
+[ ]*b8: R_MIPS_PC16 \.data\+0xfffffffffffffffc
+[ ]*b8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*b8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+00bc <[^>]*> 00000000 nop
+ \.\.\.
--- /dev/null
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch-misc-2
+#as: -32 -non_shared
+
+# Test the backward branches to globals symbols in current file.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+ \.\.\.
+ \.\.\.
+ \.\.\.
+0+003c <[^>]*> 0411ffff bal 0000003c <x>
+[ ]*3c: R_MIPS_PC16 g1
+0+0040 <[^>]*> 00000000 nop
+0+0044 <[^>]*> 0411ffff bal 00000044 <x\+0x8>
+[ ]*44: R_MIPS_PC16 g2
+0+0048 <[^>]*> 00000000 nop
+0+004c <[^>]*> 0411ffff bal 0000004c <x\+0x10>
+[ ]*4c: R_MIPS_PC16 g3
+0+0050 <[^>]*> 00000000 nop
+0+0054 <[^>]*> 0411ffff bal 00000054 <x\+0x18>
+[ ]*54: R_MIPS_PC16 g4
+0+0058 <[^>]*> 00000000 nop
+0+005c <[^>]*> 0411ffff bal 0000005c <x\+0x20>
+[ ]*5c: R_MIPS_PC16 g5
+0+0060 <[^>]*> 00000000 nop
+0+0064 <[^>]*> 0411ffff bal 00000064 <x\+0x28>
+[ ]*64: R_MIPS_PC16 g6
+0+0068 <[^>]*> 00000000 nop
+ \.\.\.
+ \.\.\.
+ \.\.\.
+0+00a8 <[^>]*> 1000ffff b 000000a8 <g6>
+[ ]*a8: R_MIPS_PC16 x1
+0+00ac <[^>]*> 00000000 nop
+0+00b0 <[^>]*> 1000ffff b 000000b0 <g6\+0x8>
+[ ]*b0: R_MIPS_PC16 x2
+0+00b4 <[^>]*> 00000000 nop
+0+00b8 <[^>]*> 1000ffff b 000000b8 <g6\+0x10>
+[ ]*b8: R_MIPS_PC16 \.data
+0+00bc <[^>]*> 00000000 nop
+ \.\.\.
+++ /dev/null
-.*: Assembler messages:
-.*:35: Error: Cannot branch to undefined symbol.
-.*:36: Error: Cannot branch to undefined symbol.
-.*:37: Error: Cannot branch to symbol in another section.
--- /dev/null
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch-misc-2-64
+#source: branch-misc-2.s
+#as: -64 -call_shared
+
+# Test the backward branches to globals symbols in current file.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+ \.\.\.
+ \.\.\.
+ \.\.\.
+0+003c <[^>]*> 04110000 bal 0000000000000040 <x\+0x4>
+[ ]*3c: R_MIPS_PC16 g1\+0xfffffffffffffffc
+[ ]*3c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*3c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0040 <[^>]*> 00000000 nop
+0+0044 <[^>]*> 04110000 bal 0000000000000048 <x\+0xc>
+[ ]*44: R_MIPS_PC16 g2\+0xfffffffffffffffc
+[ ]*44: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*44: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0048 <[^>]*> 00000000 nop
+0+004c <[^>]*> 04110000 bal 0000000000000050 <x\+0x14>
+[ ]*4c: R_MIPS_PC16 g3\+0xfffffffffffffffc
+[ ]*4c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*4c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0050 <[^>]*> 00000000 nop
+0+0054 <[^>]*> 04110000 bal 0000000000000058 <x\+0x1c>
+[ ]*54: R_MIPS_PC16 g4\+0xfffffffffffffffc
+[ ]*54: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*54: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0058 <[^>]*> 00000000 nop
+0+005c <[^>]*> 04110000 bal 0000000000000060 <x\+0x24>
+[ ]*5c: R_MIPS_PC16 g5\+0xfffffffffffffffc
+[ ]*5c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*5c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0060 <[^>]*> 00000000 nop
+0+0064 <[^>]*> 04110000 bal 0000000000000068 <x\+0x2c>
+[ ]*64: R_MIPS_PC16 g6\+0xfffffffffffffffc
+[ ]*64: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*64: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+0068 <[^>]*> 00000000 nop
+ \.\.\.
+ \.\.\.
+ \.\.\.
+0+00a8 <[^>]*> 10000000 b 00000000000000ac <g6\+0x4>
+[ ]*a8: R_MIPS_PC16 x1\+0xfffffffffffffffc
+[ ]*a8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*a8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+00ac <[^>]*> 00000000 nop
+0+00b0 <[^>]*> 10000000 b 00000000000000b4 <g6\+0xc>
+[ ]*b0: R_MIPS_PC16 x2\+0xfffffffffffffffc
+[ ]*b0: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*b0: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+00b4 <[^>]*> 00000000 nop
+0+00b8 <[^>]*> 10000000 b 00000000000000bc <g6\+0x14>
+[ ]*b8: R_MIPS_PC16 \.data\+0xfffffffffffffffc
+[ ]*b8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+[ ]*b8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc
+0+00bc <[^>]*> 00000000 nop
+ \.\.\.
--- /dev/null
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS branch-misc-2pic
+#source: branch-misc-2.s
+#as: -32 -call_shared
+
+# Test the backward branches to globals symbols in current file.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+ \.\.\.
+ \.\.\.
+ \.\.\.
+0+003c <[^>]*> 0411ffff bal 0000003c <x>
+[ ]*3c: R_MIPS_PC16 g1
+0+0040 <[^>]*> 00000000 nop
+0+0044 <[^>]*> 0411ffff bal 00000044 <x\+0x8>
+[ ]*44: R_MIPS_PC16 g2
+0+0048 <[^>]*> 00000000 nop
+0+004c <[^>]*> 0411ffff bal 0000004c <x\+0x10>
+[ ]*4c: R_MIPS_PC16 g3
+0+0050 <[^>]*> 00000000 nop
+0+0054 <[^>]*> 0411ffff bal 00000054 <x\+0x18>
+[ ]*54: R_MIPS_PC16 g4
+0+0058 <[^>]*> 00000000 nop
+0+005c <[^>]*> 0411ffff bal 0000005c <x\+0x20>
+[ ]*5c: R_MIPS_PC16 g5
+0+0060 <[^>]*> 00000000 nop
+0+0064 <[^>]*> 0411ffff bal 00000064 <x\+0x28>
+[ ]*64: R_MIPS_PC16 g6
+0+0068 <[^>]*> 00000000 nop
+ \.\.\.
+ \.\.\.
+ \.\.\.
+0+00a8 <[^>]*> 1000ffff b 000000a8 <g6>
+[ ]*a8: R_MIPS_PC16 x1
+0+00ac <[^>]*> 00000000 nop
+0+00b0 <[^>]*> 1000ffff b 000000b0 <g6\+0x8>
+[ ]*b0: R_MIPS_PC16 x2
+0+00b4 <[^>]*> 00000000 nop
+0+00b8 <[^>]*> 1000ffff b 000000b8 <g6\+0x10>
+[ ]*b8: R_MIPS_PC16 \.data
+0+00bc <[^>]*> 00000000 nop
+ \.\.\.
+++ /dev/null
-.*: Assembler messages:
-.*:21: Warning: Pretending global symbol used as branch target is local.
-.*:22: Warning: Pretending global symbol used as branch target is local.
-.*:23: Warning: Pretending global symbol used as branch target is local.
-.*:24: Warning: Pretending global symbol used as branch target is local.
-.*:25: Warning: Pretending global symbol used as branch target is local.
-.*:26: Warning: Pretending global symbol used as branch target is local.
-.*:35: Error: Cannot branch to undefined symbol.
-.*:36: Error: Cannot branch to undefined symbol.
-.*:37: Error: Cannot branch to symbol in another section.
+++ /dev/null
-# Source file used to test the backward branches to globals in this file.
-
- .globl g1 .text
- .globl g2 .text
- .globl g3 .text
- .globl g4 .text
- .globl g5 .text
- .globl g6 .text
-
- .globl x1 .text
-
- .text
-g1:
- .space 20
-g2:
- .space 20
-g3:
- .space 20
-
-x:
- bal g1
- bal g2
- bal g3
- bal g4
- bal g5
- bal g6
-
- .space 20
-g4:
- .space 20
-g5:
- .space 20
-g6:
-
- b x1
- b x2
- b .Ldata
-
-# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
- .space 8
-
- .data
-.Ldata:
run_dump_test_arches "blt" [mips_arch_list_matching mips2]
run_dump_test_arches "bltu" [mips_arch_list_matching mips2]
run_dump_test_arches "branch-misc-1" [mips_arch_list_matching mips1]
- run_list_test_arches "branch-misc-2" "-32 -non_shared" [mips_arch_list_matching mips1]
- run_list_test_arches "branch-misc-2pic" "-32 -call_shared" [mips_arch_list_matching mips1]
+ run_dump_test_arches "branch-misc-2" [mips_arch_list_matching mips1]
+ run_dump_test_arches "branch-misc-2pic" [mips_arch_list_matching mips1]
+ run_dump_test_arches "branch-misc-2-64" [mips_arch_list_matching mips3]
+ run_dump_test_arches "branch-misc-2pic-64" [mips_arch_list_matching mips3]
run_dump_test "branch-misc-3"
run_dump_test "branch-swap"