aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2013-01-23 12:41:32 +0000
committerNick Clifton <nickc@redhat.com>2013-01-23 12:41:32 +0000
commit1a18f0aeb1c2986d87a6b04cae8800dbf341513c (patch)
tree577f50a6f03467dcc20438455870109ba09f761b /bfd
parentfb5b7503096382a626d35469b17caa24c5bb35a9 (diff)
downloadgdb-1a18f0aeb1c2986d87a6b04cae8800dbf341513c.zip
gdb-1a18f0aeb1c2986d87a6b04cae8800dbf341513c.tar.gz
gdb-1a18f0aeb1c2986d87a6b04cae8800dbf341513c.tar.bz2
* elf32-metag.c: Error on HIADDR16/LOADDR16 in shared link.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elf32-metag.c43
2 files changed, 39 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 625f2ba..dd110b7 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-23 Markos Chandras <markos.chandras@imgtec.com>
+
+ * elf32-metag.c: Error on HIADDR16/LOADDR16 in shared link.
+
2013-01-23 Leif Ekblad <leif@rdos.net>
* config.bfd (x86_64-*-rdos*): Remove targ_selvecs.
diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
index 6ae3bc0..2a0819b 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -2131,14 +2131,25 @@ elf_metag_check_relocs (bfd *abfd,
{
int r_type;
struct elf_metag_link_hash_entry *hh;
+ Elf_Internal_Sym *isym;
unsigned long r_symndx;
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
if (r_symndx < symtab_hdr->sh_info)
- hh = NULL;
+ {
+ /* A local symbol. */
+ isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+ abfd, r_symndx);
+ if (isym == NULL)
+ return FALSE;
+
+ hh = NULL;
+ }
else
{
+ isym = NULL;
+
hh = (struct elf_metag_link_hash_entry *)
eh_syms[r_symndx - symtab_hdr->sh_info];
while (hh->eh.root.type == bfd_link_hash_indirect
@@ -2262,9 +2273,31 @@ elf_metag_check_relocs (bfd *abfd,
hh->eh.plt.refcount += 1;
break;
- case R_METAG_ADDR32:
case R_METAG_HIADDR16:
case R_METAG_LOADDR16:
+ /* Let's help debug shared library creation. These relocs
+ cannot be used in shared libs. Don't error out for
+ sections we don't care about, such as debug sections or
+ non-constant sections. */
+ if (info->shared
+ && (sec->flags & SEC_ALLOC) != 0
+ && (sec->flags & SEC_READONLY) != 0)
+ {
+ const char *name;
+
+ if (hh)
+ name = hh->eh.root.root.string;
+ else
+ name = bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL);
+ (*_bfd_error_handler)
+ (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
+ abfd, elf_metag_howto_table[r_type].name, name);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+
+ /* Fall through. */
+ case R_METAG_ADDR32:
case R_METAG_RELBRANCH:
case R_METAG_GETSETOFF:
if (hh != NULL && !info->shared)
@@ -2337,12 +2370,6 @@ elf_metag_check_relocs (bfd *abfd,
/* Track dynamic relocs needed for local syms too. */
asection *sr;
void *vpp;
- Elf_Internal_Sym *isym;
-
- isym = bfd_sym_from_r_symndx (&htab->sym_cache,
- abfd, r_symndx);
- if (isym == NULL)
- return FALSE;
sr = bfd_section_from_elf_index (abfd, isym->st_shndx);
if (sr == NULL)