+2018-04-09 Andrew Sadek <andrew.sadek.se@gmail.com>
+
+ Microblaze Target: PIC data text relative
+
+ * bfd/reloc.c (2 new BFD relocations):
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL &
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL
+ * bfd/bfd-in2.h: Regenerate
+ * bfd/libbfd.h: Regenerate
+ * bfd/elf32-microblaze.c (Handle new relocs): define 'HOWTO' of 3
+ new relocs and handle them in both relocate and relax functions.
+ (microblaze_elf_reloc_type_lookup): add mapping between for new
+ bfd relocs.
+ (microblaze_elf_relocate_section): Handle new relocs in case of
+ elf relocation.
+ (microblaze_elf_relax_section): Handle new relocs for elf relaxation.
+
2018-04-17 Nick Clifton <nickc@redhat.com>
PR 23055
to two words (uses imm instruction). */
BFD_RELOC_MICROBLAZE_64_TLSTPREL,
+/* This is a 64 bit reloc that stores the 32 bit pc relative
+value in two words (with an imm instruction). The relocation is
+PC-relative offset from start of TEXT. */
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL,
+
+/* This is a 64 bit reloc that stores the 32 bit offset
+value in two words (with an imm instruction). The relocation is
+relative offset from start of TEXT. */
+ BFD_RELOC_MICROBLAZE_64_TEXTREL,
+
/* AArch64 pseudo relocation code to mark the start of the AArch64
relocation enumerators. N.B. the order of the enumerators is
important as several tables in the AArch64 bfd backend are indexed
0x0000ffff, /* Dest Mask. */
TRUE), /* PC relative offset? */
+ /* A 64 bit TEXTPCREL relocation. Table-entry not really used. */
+ HOWTO (R_MICROBLAZE_TEXTPCREL_64, /* Type. */
+ 0, /* Rightshift. */
+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
+ 16, /* Bitsize. */
+ TRUE, /* PC_relative. */
+ 0, /* Bitpos. */
+ complain_overflow_dont, /* Complain on overflow. */
+ bfd_elf_generic_reloc, /* Special Function. */
+ "R_MICROBLAZE_TEXTPCREL_64", /* Name. */
+ FALSE, /* Partial Inplace. */
+ 0, /* Source Mask. */
+ 0x0000ffff, /* Dest Mask. */
+ TRUE), /* PC relative offset? */
+
/* A 64 bit GOT relocation. Table-entry not really used. */
HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
0, /* Rightshift. */
0x0000ffff, /* Dest Mask. */
FALSE), /* PC relative offset? */
+ /* A 64 bit TEXTREL relocation. Table-entry not really used. */
+ HOWTO (R_MICROBLAZE_TEXTREL_64, /* Type. */
+ 0, /* Rightshift. */
+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
+ 16, /* Bitsize. */
+ FALSE, /* PC_relative. */
+ 0, /* Bitpos. */
+ complain_overflow_dont, /* Complain on overflow. */
+ bfd_elf_generic_reloc,/* Special Function. */
+ "R_MICROBLAZE_TEXTREL_64",/* Name. */
+ FALSE, /* Partial Inplace. */
+ 0, /* Source Mask. */
+ 0x0000ffff, /* Dest Mask. */
+ FALSE), /* PC relative offset? */
+
/* A 64 bit PLT relocation. Table-entry not really used. */
HOWTO (R_MICROBLAZE_PLT_64, /* Type. */
0, /* Rightshift. */
case BFD_RELOC_MICROBLAZE_64_GOT:
microblaze_reloc = R_MICROBLAZE_GOT_64;
break;
+ case BFD_RELOC_MICROBLAZE_64_TEXTPCREL:
+ microblaze_reloc = R_MICROBLAZE_TEXTPCREL_64;
+ break;
+ case BFD_RELOC_MICROBLAZE_64_TEXTREL:
+ microblaze_reloc = R_MICROBLAZE_TEXTREL_64;
+ break;
case BFD_RELOC_MICROBLAZE_64_PLT:
microblaze_reloc = R_MICROBLAZE_PLT_64;
break;
contents + offset + endian + INST_WORD_SIZE);
break;
+ case (int) R_MICROBLAZE_TEXTPCREL_64:
+ relocation = input_section->output_section->vma;
+ relocation -= (input_section->output_section->vma
+ + input_section->output_offset
+ + offset + INST_WORD_SIZE);
+ relocation += addend;
+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
+ contents + offset + endian);
+ bfd_put_16 (input_bfd, relocation & 0xffff,
+ contents + offset + endian + INST_WORD_SIZE);
+ break;
+
case (int) R_MICROBLAZE_PLT_64:
{
bfd_vma immediate;
bfd_put_16 (input_bfd, relocation & 0xffff,
contents + offset + 2 + INST_WORD_SIZE);
break;
+ case (int) R_MICROBLAZE_TEXTREL_64:
+ case (int) R_MICROBLAZE_TEXTREL_32_LO:
case (int) R_MICROBLAZE_64_PCREL :
case (int) R_MICROBLAZE_64:
case (int) R_MICROBLAZE_32:
relocation -= (input_section->output_section->vma
+ input_section->output_offset
+ offset + INST_WORD_SIZE);
- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
+ else if (r_type == R_MICROBLAZE_TEXTREL_64
+ || r_type == R_MICROBLAZE_TEXTREL_32_LO)
+ relocation -= input_section->output_section->vma;
+
+ if (r_type == R_MICROBLAZE_TEXTREL_32_LO)
+ bfd_put_16 (input_bfd, relocation & 0xffff,
+ contents + offset + endian);
+
+ else
+ {
+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
contents + offset + endian);
- bfd_put_16 (input_bfd, relocation & 0xffff,
+ bfd_put_16 (input_bfd, relocation & 0xffff,
contents + offset + endian + INST_WORD_SIZE);
}
+ }
break;
}
relocation -= (input_section->output_section->vma
+ input_section->output_offset
+ offset + INST_WORD_SIZE);
- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
- contents + offset + endian);
- bfd_put_16 (input_bfd, relocation & 0xffff,
- contents + offset + endian + INST_WORD_SIZE);
- }
+ else if (r_type == R_MICROBLAZE_TEXTREL_64
+ || r_type == R_MICROBLAZE_TEXTREL_32_LO)
+ relocation -= input_section->output_section->vma;
+
+ if (r_type == R_MICROBLAZE_TEXTREL_32_LO)
+ {
+ bfd_put_16 (input_bfd, relocation & 0xffff,
+ contents + offset + endian);
+ }
+ else
+ {
+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
+ contents + offset + endian);
+ bfd_put_16 (input_bfd, relocation & 0xffff,
+ contents + offset + endian
+ + INST_WORD_SIZE);
+ }
+ }
break;
}
}
{
bfd_vma symval;
if ((ELF32_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64_PCREL)
- && (ELF32_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64 ))
+ && (ELF32_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64)
+ && (ELF32_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_TEXTREL_64))
continue; /* Can't delete this reloc. */
/* Get the section contents. */
+ sec->output_section->vma
+ sec->output_offset);
}
+ else if (ELF32_R_TYPE (irel->r_info) == (int) R_MICROBLAZE_TEXTREL_64)
+ {
+ symval = symval + irel->r_addend - (sec->output_section->vma);
+ }
else
symval += irel->r_addend;
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
(int) R_MICROBLAZE_32_LO);
break;
+ case R_MICROBLAZE_TEXTREL_64:
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ (int) R_MICROBLAZE_TEXTREL_32_LO);
+ break;
default:
/* Cannot happen. */
BFD_ASSERT (FALSE);
break;
case R_MICROBLAZE_64_PCREL:
break;
+ case R_MICROBLAZE_TEXTREL_64:
+ case R_MICROBLAZE_TEXTREL_32_LO:
case R_MICROBLAZE_64:
case R_MICROBLAZE_32_LO:
/* If this reloc is against a symbol defined in this
}
}
else if ((ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_PCREL_LO)
- || (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_LO))
+ || (ELF32_R_TYPE (irelscan->r_info)
+ == (int) R_MICROBLAZE_32_LO)
+ || (ELF32_R_TYPE (irelscan->r_info)
+ == (int) R_MICROBLAZE_TEXTREL_32_LO))
{
isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
}
}
- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64)
+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64
+ || (ELF32_R_TYPE (irelscan->r_info)
+ == (int) R_MICROBLAZE_TEXTREL_64))
{
isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
"BFD_RELOC_MICROBLAZE_64_TLSDTPREL",
"BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL",
"BFD_RELOC_MICROBLAZE_64_TLSTPREL",
+ "BFD_RELOC_MICROBLAZE_64_TEXTPCREL",
+ "BFD_RELOC_MICROBLAZE_64_TEXTREL",
"BFD_RELOC_AARCH64_RELOC_START",
"BFD_RELOC_AARCH64_NULL",
"BFD_RELOC_AARCH64_NONE",
ENUMDOC
This is a 64 bit reloc that stores 32-bit thread pointer relative offset
to two words (uses imm instruction).
+ENUM
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL
+ENUMDOC
+ This is a 64 bit reloc that stores the 32 bit pc relative
+ value in two words (with an imm instruction). The relocation is
+ PC-relative offset from start of TEXT.
+ENUM
+ BFD_RELOC_MICROBLAZE_64_TEXTREL
+ENUMDOC
+ This is a 64 bit reloc that stores the 32 bit offset
+ value in two words (with an imm instruction). The relocation is
+ relative offset from start of TEXT.
ENUM
BFD_RELOC_AARCH64_RELOC_START
+2018-04-09 Andrew Sadek <andrew.sadek.se@gmail.com>
+
+ Microblaze Target: PIC data text relative
+
+ * gas/config/tc-microblaze.c (Handle new relocs directives in
+ assembler): Handle new relocs from compiler output.
+ (imm_types): add new imm types for data text relative addressing
+ TEXT_OFFSET, TEXT_PC_OFFSET
+ (md_convert_frag): conversion for BFD_RELOC_MICROBLAZE_64_TEXTPCREL,
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL
+ (md_apply_fix): apply fix for BFD_RELOC_MICROBLAZE_64_TEXTPCREL,
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL
+ (md_estimate_size_before_relax): estimate size for
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL,
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL
+ (tc_gen_reloc): generate relocations for
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL,
+ BFD_RELOC_MICROBLAZE_64_TEXTPCREL
+
2018-04-17 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
* testsuite/gas/i386/nops.s: Revert back deleted lines and
#define TLSDTPREL_OFFSET 14
#define TLSGOTTPREL_OFFSET 15
#define TLSTPREL_OFFSET 16
+#define TEXT_OFFSET 17
+#define TEXT_PC_OFFSET 18
/* Initialize the relax table. */
const relax_typeS md_relax_table[] =
{ 0x7fffffff, 0x80000000, INST_WORD_SIZE*1, 0 }, /* 13: TLSDTPMOD_OFFSET. */
{ 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 14: TLSDTPREL_OFFSET. */
{ 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 15: TLSGOTTPREL_OFFSET. */
- { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 16: TLSTPREL_OFFSET. */
+ { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 16: TLSTPREL_OFFSET. */
+ { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 17: TEXT_OFFSET. */
+ { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */
};
static struct hash_control * opcode_hash_control; /* Opcode mnemonics. */
#define IMM_TLSDTPMOD 6
#define IMM_TLSDTPREL 7
#define IMM_TLSTPREL 8
-#define IMM_MAX 9
+#define IMM_TXTREL 9
+#define IMM_TXTPCREL 10
+#define IMM_MAX 11
struct imm_type {
const char *isuffix; /* Suffix String */
{ "TLSLDM", IMM_TLSLD, TLSLD_OFFSET },
{ "TLSDTPMOD", IMM_TLSDTPMOD, TLSDTPMOD_OFFSET },
{ "TLSDTPREL", IMM_TLSDTPREL, TLSDTPREL_OFFSET },
- { "TLSTPREL", IMM_TLSTPREL, TLSTPREL_OFFSET }
+ { "TLSTPREL", IMM_TLSTPREL, TLSTPREL_OFFSET },
+ { "TXTREL", IMM_TXTREL, TEXT_OFFSET },
+ { "TXTPCREL", IMM_TXTPCREL, TEXT_PC_OFFSET }
};
static int
if (check_spl_reg (& reg2))
as_fatal (_("Cannot use special register with this instruction"));
- if (exp.X_op != O_constant)
+ if (exp.X_op != O_constant || exp.X_md == IMM_TXTPCREL)
{
const char *opc;
relax_substateT subtype;
fragP->fr_fix += INST_WORD_SIZE * 2;
fragP->fr_var = 0;
break;
+ case TEXT_OFFSET:
+ fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
+ fragP->fr_offset, FALSE, BFD_RELOC_MICROBLAZE_64_TEXTREL);
+ fragP->fr_fix += INST_WORD_SIZE * 2;
+ fragP->fr_var = 0;
+ break;
+ case TEXT_PC_OFFSET:
+ fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
+ fragP->fr_offset, FALSE, BFD_RELOC_MICROBLAZE_64_TEXTPCREL);
+ fragP->fr_fix += INST_WORD_SIZE * 2;
+ fragP->fr_var = 0;
+ break;
case PLT_OFFSET:
fixP = fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_PLT);
break;
case BFD_RELOC_64_PCREL:
case BFD_RELOC_64:
+ case BFD_RELOC_MICROBLAZE_64_TEXTREL:
/* Add an imm instruction. First save the current instruction. */
for (i = 0; i < INST_WORD_SIZE; i++)
buf[i + INST_WORD_SIZE] = buf[i];
case BFD_RELOC_MICROBLAZE_64_GOT:
case BFD_RELOC_MICROBLAZE_64_PLT:
case BFD_RELOC_MICROBLAZE_64_GOTOFF:
+ case BFD_RELOC_MICROBLAZE_64_TEXTPCREL:
/* Add an imm instruction. First save the current instruction. */
for (i = 0; i < INST_WORD_SIZE; i++)
buf[i + INST_WORD_SIZE] = buf[i];
break;
case INST_NO_OFFSET:
+ case TEXT_OFFSET:
/* Used to be a reference to somewhere which was unknown. */
if (fragP->fr_symbol)
{
if (fragP->fr_opcode == NULL)
{
- /* Used as an absolute value. */
- fragP->fr_subtype = DEFINED_ABS_SEGMENT;
- /* Variable part does not change. */
- fragP->fr_var = INST_WORD_SIZE*2;
- }
+ /* Used as an absolute value. */
+ if (fragP->fr_subtype == INST_NO_OFFSET)
+ fragP->fr_subtype = DEFINED_ABS_SEGMENT;
+ /* Variable part does not change. */
+ fragP->fr_var = INST_WORD_SIZE*2;
+ }
else if (streq (fragP->fr_opcode, str_microblaze_ro_anchor))
{
/* It is accessed using the small data read only anchor. */
case GOT_OFFSET:
case PLT_OFFSET:
case GOTOFF_OFFSET:
+ case TEXT_PC_OFFSET:
case TLSGD_OFFSET:
case TLSLD_OFFSET:
case TLSTPREL_OFFSET:
case BFD_RELOC_MICROBLAZE_64_TLSDTPREL:
case BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL:
case BFD_RELOC_MICROBLAZE_64_TLSTPREL:
+ case BFD_RELOC_MICROBLAZE_64_TEXTPCREL:
+ case BFD_RELOC_MICROBLAZE_64_TEXTREL:
code = fixp->fx_r_type;
break;
+2018-04-09 Andrew Sadek <andrew.sadek.se@gmail.com>
+
+ Microblaze Target: PIC data text relative
+
+ * bfdlink.h (Add flag): Add new flag @ 'bfd_link_info' struct.
+ * elf/microblaze.h (Add 3 new relocations):
+ R_MICROBLAZE_TEXTPCREL_64, R_MICROBLAZE_TEXTREL_64
+ and R_MICROBLAZE_TEXTREL_32_LO for relax function.
+
2018-04-17 Alan Modra <amodra@gmail.com>
* elf/i370.h: Revert removal.
/* TRUE if ok to have multiple definition. */
unsigned int allow_multiple_definition: 1;
+ /* TRUE if ok to have prohibit multiple definition of absolute symbols. */
+ unsigned int prohibit_multiple_definition_absolute: 1;
+
/* TRUE if ok to have version with no definition. */
unsigned int allow_undefined_version: 1;
RELOC_NUMBER (R_MICROBLAZE_TLSDTPREL64, 27) /* TLS Offset Within TLS Block */
RELOC_NUMBER (R_MICROBLAZE_TLSGOTTPREL32, 28) /* TLS Offset From Thread Pointer */
RELOC_NUMBER (R_MICROBLAZE_TLSTPREL32, 29) /* TLS Offset From Thread Pointer */
-
+ RELOC_NUMBER (R_MICROBLAZE_TEXTPCREL_64, 30) /* PC-relative TEXT offset. */
+ RELOC_NUMBER (R_MICROBLAZE_TEXTREL_64, 31) /* TEXT Entry offset 64-bit. */
+ RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */
END_RELOC_NUMBERS (R_MICROBLAZE_max)
/* Global base address names. */
+2018-04-09 Andrew Sadek <andrew.sadek.se@gmail.com>
+
+ Microblaze Target: PIC data text relative
+
+ * ld/lexsup.c (Add 2 ld options):
+ (ld_options): add disable-multiple-abs-defs @ 'ld_options' array
+ (parse_args): parse new option and pass flag to 'link_info' struct.
+ * ld/ldlex.h (Add enum): add new enum @ 'option_values' enum.
+ * ld/ld.texinfo (Add new option): Add description for
+ 'disable-multiple-abs-defs'
+ * ld/main.c: Initialize flags with false @ 'main'. Handle
+ disable-multiple-abs-defs @ 'mutiple_definition'.
+
2018-04-16 Alan Modra <amodra@gmail.com>
* emultempl/sunos.em: Delete.
is only supported by the @samp{BFIN}, @samp{CR16} and @emph{M68K}
targets.
+@kindex --disable-multiple-abs-defs
+@item --disable-multiple-abs-defs
+Do not allow multiple definitions with symbols included
+in filename invoked by -R or --just-symbols
+
@kindex --fatal-warnings
@kindex --no-fatal-warnings
@item --fatal-warnings
OPTION_IGNORE_UNRESOLVED_SYMBOL,
OPTION_PUSH_STATE,
OPTION_POP_STATE,
+ OPTION_DISABLE_MULTIPLE_DEFS_ABS,
OPTION_PRINT_MEMORY_USAGE,
OPTION_REQUIRE_DEFINED_SYMBOL,
OPTION_ORPHAN_HANDLING,
link_info.keep_memory = TRUE;
link_info.combreloc = TRUE;
link_info.strip_discarded = TRUE;
+ link_info.prohibit_multiple_definition_absolute = FALSE;
link_info.emit_hash = DEFAULT_EMIT_SYSV_HASH;
link_info.emit_gnu_hash = DEFAULT_EMIT_GNU_HASH;
link_info.callbacks = &link_callbacks;
discarded, and this is not really a multiple definition at all.
FIXME: It would be cleaner to somehow ignore symbols defined in
sections which are being discarded. */
- if ((osec->output_section != NULL
- && !bfd_is_abs_section (osec)
- && bfd_is_abs_section (osec->output_section))
- || (nsec->output_section != NULL
- && !bfd_is_abs_section (nsec)
- && bfd_is_abs_section (nsec->output_section)))
+ if (!info->prohibit_multiple_definition_absolute
+ && ((osec->output_section != NULL
+ && ! bfd_is_abs_section (osec)
+ && bfd_is_abs_section (osec->output_section))
+ || (nsec->output_section != NULL
+ && !bfd_is_abs_section (nsec)
+ && bfd_is_abs_section (nsec->output_section))))
return;
name = h->root.string;
{ {"demangle", optional_argument, NULL, OPTION_DEMANGLE},
'\0', N_("[=STYLE]"), N_("Demangle symbol names [using STYLE]"),
TWO_DASHES },
+ { {"disable-multiple-abs-defs", no_argument, NULL,
+ OPTION_DISABLE_MULTIPLE_DEFS_ABS},
+ '\0', NULL, N_("Do not allow multiple definitions with symbols included\n"
+ " in filename invoked by -R or --just-symbols"),
+ TWO_DASHES},
{ {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
'\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
{ {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
case OPTION_NO_STRIP_DISCARDED:
link_info.strip_discarded = FALSE;
break;
+ case OPTION_DISABLE_MULTIPLE_DEFS_ABS:
+ link_info.prohibit_multiple_definition_absolute = TRUE;
+ break;
case OPTION_SHARED:
if (config.has_shared)
{