Discussion:
[PATCH 0/6][ARC 1][COMMITTED] Backports from mainline.
Claudiu Zissulescu
2018-11-15 15:44:24 UTC
Permalink
Set of patches backported from mainline to binutils-2_31-branch.

//Claudiu

Claudiu Zissulescu (1):
[ARC] Fix local got entry list.

Cupertino Miranda (5):
[ARC] Make sure global symbol is not an indirect or warning.
[ARC] PLT information was still being generated when symbol was
forced_local.
[ARC] Fixes TLS failures related to tls-align.
[ARC] Fixed issue with DTSOFF relocs.
[ARC] More fixes for TLS.

bfd/ChangeLog | 56 +++++++++++++++-
bfd/arc-got.h | 80 +++++++++++++----------
bfd/elf32-arc.c | 134 ++++++++++++++++++++++++++++----------
include/ChangeLog | 6 ++
include/elf/arc-reloc.def | 4 +-
5 files changed, 209 insertions(+), 71 deletions(-)
--
2.19.1
Claudiu Zissulescu
2018-11-15 15:44:25 UTC
Permalink
From: Cupertino Miranda <***@synopsys.com>

Problem identified in the context of glibc with latest upstream binutils.
Dynamic symbol space was being reserved but, no actual information for the
symbol was being set. Data for the symbol was kept initialized with -1.
No easy test case was possible to be created.

bfd/
2018-03-01 Cupertino Miranda <***@synopsys.com>

* elf32-arc.c (elf_arc_check_relocs): Changed.
---
bfd/ChangeLog | 9 ++++++++-
bfd/elf32-arc.c | 7 ++++++-
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 318bf9412c..c01914fe27 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,7 +1,14 @@
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
- 2018-03-01 Cupertino Miranda <***@synopsys.com>
+ 2018-03-02 Cupertino Miranda <***@synopsys.com>
+ * elf32-arc.c (elf_arc_check_relocs): Changed.
+
+
+2018-11-15 Claudiu Zissulescu <***@synopsys.com>
+
+ Backport from mainline
+ 2018-03-02 Cupertino Miranda <***@synopsys.com>
* elf32-arc.c (elf_arc_finish_dynamic_symbol) Return FALSE in case
arc_htab is NULL.

diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 1d0b6b8abe..8c1434a8cd 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1960,7 +1960,12 @@ elf_arc_check_relocs (bfd * abfd,
if (r_symndx < symtab_hdr->sh_info) /* Is a local symbol. */
h = NULL;
else /* Global one. */
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ }


switch (r_type)
--
2.19.1
Claudiu Zissulescu
2018-11-15 15:44:26 UTC
Permalink
From: Cupertino Miranda <***@synopsys.com>

A change upstream reveiled this issue, triggering an assert when linking glibc.

bfd/
2018-03-01 Cupertino Miranda <***@synopsys.com>

* elf32-arc.c (elf_arc_check_relocs): Changed.
---
bfd/ChangeLog | 7 +++++++
bfd/elf32-arc.c | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c01914fe27..14e4107326 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -5,6 +5,13 @@
* elf32-arc.c (elf_arc_check_relocs): Changed.


+2018-11-15 Claudiu Zissulescu <***@synopsys.com>
+
+ Backport from mainline
+ 2018-03-02 Cupertino Miranda <***@synopsys.com>
+ * elf32-arc.c (elf_arc_check_relocs): Changed.
+
+
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 8c1434a8cd..052765ebdb 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -2041,7 +2041,8 @@ elf_arc_check_relocs (bfd * abfd,
if (h == NULL)
continue;
else
- h->needs_plt = 1;
+ if (h->forced_local == 0)
+ h->needs_plt = 1;
}

/* Add info to the symbol got_entry_list. */
--
2.19.1
Claudiu Zissulescu
2018-11-15 15:44:27 UTC
Permalink
From: Cupertino Miranda <***@synopsys.com>

This patch fixes glibc testcase in nptl/tls-align.

bfd/
2018-08-01 Cupertino Miranda <***@synopsys.com>

* arc-got.h (relocate_fix_got_relocs_for_got_info): Changed, fixed
TCB_SIZE offsize to include section alignment.
* elf32-arc.c (arc_special_overflow_checks): Likewise.

include/
2018-08-01 Cupertino Miranda <***@synopsys.com>

* arc-reloc.def (ARC_TLS_LE_32): Updated reloc formula.
---
bfd/ChangeLog | 9 +++++++++
bfd/arc-got.h | 8 +++++++-
bfd/elf32-arc.c | 3 ++-
include/ChangeLog | 6 ++++++
include/elf/arc-reloc.def | 2 +-
5 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 14e4107326..b26e53135c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2018-11-15 Claudiu Zissulescu <***@synopsys.com>
+
+ Backport from mainline
+ 2018-08-01 Cupertino Miranda <***@synopsys.com>
+ * arc-got.h (relocate_fix_got_relocs_for_got_info): Changed, fixed
+ TCB_SIZE offsize to include section alignment.
+ * elf32-arc.c (arc_special_overflow_checks): Likewise.
+
+
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
diff --git a/bfd/arc-got.h b/bfd/arc-got.h
index 81ce88fe21..e32d9b30e3 100644
--- a/bfd/arc-got.h
+++ b/bfd/arc-got.h
@@ -24,6 +24,9 @@

#define TCB_SIZE (8)

+#define align_power(addr, align) \
+ (((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align))))
+
enum tls_type_e
{
GOT_UNKNOWN = 0,
@@ -359,7 +362,10 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p,

bfd_put_32 (output_bfd,
sym_value - sec_vma
- + (elf_hash_table (info)->dynamic_sections_created ? 0 : TCB_SIZE),
+ + (elf_hash_table (info)->dynamic_sections_created
+ ? 0
+ : (align_power (TCB_SIZE,
+ tls_sec->alignment_power))),
htab->sgot->contents + entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0));
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 052765ebdb..d11b773adc 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1202,7 +1202,8 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data,
#define _SDA_BASE_ (bfd_signed_vma) (reloc_data.sdata_begin_symbol_vma)
#define TLS_REL (bfd_signed_vma) \
((elf_hash_table (info))->tls_sec->output_section->vma)
-#define TLS_TBSS (8)
+#define TLS_TBSS (align_power(TCB_SIZE, \
+ reloc_data.sym_section->alignment_power))

#define none (0)

diff --git a/include/ChangeLog b/include/ChangeLog
index 7decb4fd7b..e0b82bc338 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-15 Claudiu Zissulescu <***@synopsys.com>
+
+ Backport from mainline
+ 2018-08-01 Cupertino Miranda <***@synopsys.com>
+ * arc-reloc.def (ARC_TLS_LE_32): Updated reloc formula.
+
2018-07-18 Nick Clifton <***@redhat.com>

2.31.1 Release point.
diff --git a/include/elf/arc-reloc.def b/include/elf/arc-reloc.def
index a6db724da9..e1c69c9d70 100644
--- a/include/elf/arc-reloc.def
+++ b/include/elf/arc-reloc.def
@@ -489,7 +489,7 @@ ARC_RELOC_HOWTO(ARC_TLS_LE_32, 75, \
32, \
replace_word32, \
dont, \
- ( ME ( ( ( ( S + A ) + TCB_SIZE ) - TLS_REL ) ) ))
+ ( ME ( ( ( ( S + A ) + TLS_TBSS ) - TLS_REL ) ) ))

ARC_RELOC_HOWTO(ARC_S25W_PCREL_PLT, 76, \
2, \
--
2.19.1
Claudiu Zissulescu
2018-11-15 15:44:28 UTC
Permalink
From: Cupertino Miranda <***@synopsys.com>

Inserted offset in final section in the GOT entry of type DTSOFF soon to be
relocated by the dynamic loader.

bfd/
2018-09-06 Cupertino Miranda <***@synopsys.com>

* arc-got.h (relocate_fix_got_relocs_for_got_info): Changed. Take TLS
section alignment in consideration for this relocation.
* elf32-arc.c (FINAL_SECTSTART): Added this formula macro.
(ARC_TLS_DTPOFF) Updated reloc to use new created macro instead.
---
bfd/ChangeLog | 12 +++++++++---
bfd/arc-got.h | 10 +++++++---
bfd/elf32-arc.c | 2 ++
include/elf/arc-reloc.def | 2 +-
4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b26e53135c..896adc86c6 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2018-11-15 Claudiu Zissulescu <***@synopsys.com>
+
+ Backport from mainline
+ 2018-09-06 Cupertino Miranda <***@synopsys.com>
+ * arc-got.h (relocate_fix_got_relocs_for_got_info): Changed. Take
+ TLS section alignment in consideration for this relocation.
+ * elf32-arc.c (FINAL_SECTSTART): Added this formula macro.
+ (ARC_TLS_DTPOFF) Updated reloc to use new created macro instead.
+
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
@@ -6,21 +15,18 @@
TCB_SIZE offsize to include section alignment.
* elf32-arc.c (arc_special_overflow_checks): Likewise.

-
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
2018-03-02 Cupertino Miranda <***@synopsys.com>
* elf32-arc.c (elf_arc_check_relocs): Changed.

-
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
2018-03-02 Cupertino Miranda <***@synopsys.com>
* elf32-arc.c (elf_arc_check_relocs): Changed.

-
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
diff --git a/bfd/arc-got.h b/bfd/arc-got.h
index e32d9b30e3..07722fdffd 100644
--- a/bfd/arc-got.h
+++ b/bfd/arc-got.h
@@ -335,7 +335,11 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p,
bfd_vma sec_vma = tls_sec->output_section->vma;

bfd_put_32 (output_bfd,
- sym_value - sec_vma,
+ sym_value - sec_vma
+ + (elf_hash_table (info)->dynamic_sections_created
+ ? 0
+ : (align_power (TCB_SIZE,
+ tls_sec->alignment_power))),
htab->sgot->contents + entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0));
@@ -346,7 +350,7 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p,
"GOT_TLS_IE"),
(long) (sym_value - sec_vma),
(long) (htab->sgot->output_section->vma
- + htab->sgot->output_offset->vma
+ + htab->sgot->output_offset
+ entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0)),
@@ -376,7 +380,7 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p,
"GOT_TLS_IE"),
(long) (sym_value - sec_vma),
(long) (htab->sgot->output_section->vma
- + htab->sgot->output_offset->vma
+ + htab->sgot->output_offset
+ entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0)),
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index d11b773adc..5ef62aa218 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1198,6 +1198,8 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data,
+ (reloc_data.reloc_offset))))
#define SECTSTART (bfd_signed_vma) (reloc_data.sym_section->output_section->vma \
+ reloc_data.sym_section->output_offset)
+#define FINAL_SECTSTART \
+ (bfd_signed_vma) (reloc_data.sym_section->output_section->vma)
#define JLI (bfd_signed_vma) (reloc_data.sym_section->output_section->vma)
#define _SDA_BASE_ (bfd_signed_vma) (reloc_data.sdata_begin_symbol_vma)
#define TLS_REL (bfd_signed_vma) \
diff --git a/include/elf/arc-reloc.def b/include/elf/arc-reloc.def
index e1c69c9d70..61edd6e67a 100644
--- a/include/elf/arc-reloc.def
+++ b/include/elf/arc-reloc.def
@@ -468,7 +468,7 @@ ARC_RELOC_HOWTO(ARC_TLS_DTPOFF, 67, \
32, \
replace_word32, \
dont, \
- ( ME ( S - SECTSTART ) + A ))
+ ( ME ( S - FINAL_SECTSTART ) + A ))

ARC_RELOC_HOWTO(ARC_TLS_DTPOFF_S9, 73, \
2, \
--
2.19.1
Claudiu Zissulescu
2018-11-15 15:44:29 UTC
Permalink
Fix a memory leak appearing when the local got entry list was constructed.

bfd/
xxxx-xx-xx Claudiu Zissulescu <***@synopsys.com>

* arc-got.h (arc_get_local_got_ents): Revamp it; use
elf_local_got_ents to store the local got list.
(get_got_entry_list_for_symbo): Restructure it.
* elf32-arc.c (elf_arc_relocate_section): Correct the call to
get_got_entry_list_for_symbol.
---
bfd/ChangeLog | 10 ++++++++++
bfd/arc-got.h | 33 +++++++++++++++------------------
bfd/elf32-arc.c | 2 +-
3 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 896adc86c6..09091f65ae 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2018-11-15 Claudiu Zissulescu <***@synopsys.com>
+
+ Backport from mainline
+ 2018-11-09 Claudiu Zissulescu <***@synopsys.com>
+ * arc-got.h (arc_get_local_got_ents): Revamp it; use
+ elf_local_got_ents to store the local got list.
+ (get_got_entry_list_for_symbo): Restructure it.
+ * elf32-arc.c (elf_arc_relocate_section): Correct the call to
+ get_got_entry_list_for_symbol.
+
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
diff --git a/bfd/arc-got.h b/bfd/arc-got.h
index 07722fdffd..69e9aa3275 100644
--- a/bfd/arc-got.h
+++ b/bfd/arc-got.h
@@ -54,27 +54,26 @@ struct got_entry
enum tls_got_entries existing_entries;
};

+/* Return the local got list, if not defined, create an empty one. */
+
static struct got_entry **
arc_get_local_got_ents (bfd * abfd)
{
- static struct got_entry **local_got_ents = NULL;
-
- if (local_got_ents == NULL)
+ if (elf_local_got_ents (abfd) == NULL)
{
- size_t size;
- Elf_Internal_Shdr *symtab_hdr = &((elf_tdata (abfd))->symtab_hdr);
-
- size = symtab_hdr->sh_info * sizeof (bfd_vma);
- local_got_ents = (struct got_entry **)
- bfd_alloc (abfd, sizeof (struct got_entry *) * size);
- if (local_got_ents == NULL)
- return FALSE;
-
- memset (local_got_ents, 0, sizeof (struct got_entry *) * size);
- elf_local_got_ents (abfd) = local_got_ents;
+ bfd_size_type amt = (elf_tdata (abfd)->symtab_hdr.sh_info
+ * sizeof (*elf_local_got_ents (abfd)));
+ elf_local_got_ents (abfd) = bfd_zmalloc (amt);
+ if (elf_local_got_ents (abfd) == NULL)
+ {
+ _bfd_error_handler (_("%pB: cannot allocate memory for local "
+ "GOT entries"), abfd);
+ bfd_set_error (bfd_error_bad_value);
+ return NULL;
+ }
}

- return local_got_ents;
+ return elf_local_got_ents (abfd);
}

static struct got_entry *
@@ -167,9 +166,7 @@ get_got_entry_list_for_symbol (bfd *abfd,
}
else
{
- struct got_entry **local_got_ents
- = arc_get_local_got_ents (abfd);
- return &local_got_ents[r_symndx];
+ return arc_get_local_got_ents (abfd) + r_symndx;
}
}

diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 5ef62aa218..bde142f37f 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1724,7 +1724,7 @@ elf_arc_relocate_section (bfd * output_bfd,
reloc_data.should_relocate = TRUE;

struct got_entry **list
- = get_got_entry_list_for_symbol (output_bfd, r_symndx, h);
+ = get_got_entry_list_for_symbol (input_bfd, r_symndx, h);

reloc_data.got_offset_value
= relocate_fix_got_relocs_for_got_info (list,
--
2.19.1
Claudiu Zissulescu
2018-11-15 15:44:30 UTC
Permalink
From: Cupertino Miranda <***@synopsys.com>

Added warning for static TLS reloc.

Fixed issue related to TLS and partial static linking of libraries:
This issue was detected when throwing exceptions in C++ while linking with
-static-libstdc++.
TLS relocation from the libstdc++ wasn't being patched as local now that it was
static linked with the executable.

Fix for TLS with static and pie. Problem introduced by earlier patch:
Fixes the following glibc tests:
- elf/tst-tls1-static

bfd/
xxxx-xx-xx Cupertino Miranda <***@synopsys.com>

* arc-got.h (arc_got_entry_type_for_reloc): Changed to
correct static TLS relocs.
* elf32-arc.c (elf_arc_check_relocs): Introduced warning to
TLS relocs which require -fPIC.
(arc_create_forced_local_got_entries_for_tls): Created.
Traverses list of GOT entries to be resolved statically
when needed.
(elf_arc_finish_dynamic_sections): Changed. Calls
arc_create_forced_local_got_entries_for_tls for each known
possibly GOT symbol.
---
bfd/ChangeLog | 15 +++++++
bfd/arc-got.h | 33 ++++++++------
bfd/elf32-arc.c | 117 +++++++++++++++++++++++++++++++++++-------------
3 files changed, 121 insertions(+), 44 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 09091f65ae..53bb9ebca1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,18 @@
+2018-11-15 Claudiu Zissulescu <***@synopsys.com>
+
+ Backport from mainline
+ 2018-11-09 Cupertino Miranda <***@synopsys.com>
+ * arc-got.h (arc_got_entry_type_for_reloc): Changed to
+ correct static TLS relocs.
+ * elf32-arc.c (elf_arc_check_relocs): Introduced warning to
+ TLS relocs which require -fPIC.
+ (arc_create_forced_local_got_entries_for_tls): Created.
+ Traverses list of GOT entries to be resolved statically
+ when needed.
+ (elf_arc_finish_dynamic_sections): Changed. Calls
+ arc_create_forced_local_got_entries_for_tls for each known
+ possibly GOT symbol.
+
2018-11-15 Claudiu Zissulescu <***@synopsys.com>

Backport from mainline
diff --git a/bfd/arc-got.h b/bfd/arc-got.h
index 69e9aa3275..253578b90c 100644
--- a/bfd/arc-got.h
+++ b/bfd/arc-got.h
@@ -208,7 +208,7 @@ arc_got_entry_type_for_reloc (reloc_howto_type *howto)
__LINE__, name_for_global_symbol (H)); \
} \
if (H) \
- if (h->dynindx == -1 && !h->forced_local) \
+ if (H->dynindx == -1 && !H->forced_local) \
if (! bfd_elf_link_record_dynamic_symbol (info, H)) \
return FALSE; \
htab->s##SECNAME->size += 4; \
@@ -284,6 +284,7 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p,
BFD_ASSERT (entry);

if (h == NULL
+ || h->forced_local == TRUE
|| (! elf_hash_table (info)->dynamic_sections_created
|| (bfd_link_pic (info)
&& SYMBOL_REFERENCES_LOCAL (info, h))))
@@ -331,27 +332,31 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p,
BFD_ASSERT (tls_sec && tls_sec->output_section);
bfd_vma sec_vma = tls_sec->output_section->vma;

- bfd_put_32 (output_bfd,
+ if (h == NULL || h->forced_local
+ || !elf_hash_table (info)->dynamic_sections_created)
+ {
+ bfd_put_32 (output_bfd,
sym_value - sec_vma
+ (elf_hash_table (info)->dynamic_sections_created
? 0
- : (align_power (TCB_SIZE,
+ : (align_power (0,
tls_sec->alignment_power))),
htab->sgot->contents + entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0));

- ARC_DEBUG ("arc_info: FIXED -> %s value = %#lx "
- "@ %lx, for symbol %s\n",
- (entry->type == GOT_TLS_GD ? "GOT_TLS_GD" :
- "GOT_TLS_IE"),
- (long) (sym_value - sec_vma),
- (long) (htab->sgot->output_section->vma
- + htab->sgot->output_offset
- + entry->offset
- + (entry->existing_entries == TLS_GOT_MOD_AND_OFF
- ? 4 : 0)),
- symbol_name);
+ ARC_DEBUG ("arc_info: FIXED -> %s value = %#lx "
+ "@ %lx, for symbol %s\n",
+ (entry->type == GOT_TLS_GD ? "GOT_TLS_GD" :
+ "GOT_TLS_IE"),
+ (long) (sym_value - sec_vma),
+ (long) (htab->sgot->output_section->vma
+ + htab->sgot->output_offset
+ + entry->offset
+ + (entry->existing_entries == TLS_GOT_MOD_AND_OFF
+ ? 4 : 0)),
+ symbol_name);
+ }
}
break;

diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index bde142f37f..495fa342d3 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1973,36 +1973,35 @@ elf_arc_check_relocs (bfd * abfd,

switch (r_type)
{
- case R_ARC_32:
- case R_ARC_32_ME:
- /* During shared library creation, these relocs should not
- appear in a shared library (as memory will be read only
- and the dynamic linker can not resolve these. However
- the error should not occur for e.g. debugging or
- non-readonly sections. */
- if (h != NULL
- && (bfd_link_dll (info) && !bfd_link_pie (info))
- && (sec->flags & SEC_ALLOC) != 0
- && (sec->flags & SEC_READONLY) != 0
- && ((sec->flags & SEC_CODE) != 0
- || (sec->flags & SEC_DEBUGGING) != 0))
- {
- const char *name;
- if (h)
- name = h->root.root.string;
- else
- /* bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL); */
- name = "UNKNOWN";
- _bfd_error_handler
- /* xgettext:c-format */
- (_("%pB: relocation %s against `%s' can not be used"
- " when making a shared object; recompile with -fPIC"),
- abfd,
- arc_elf_howto (r_type)->name,
- name);
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
+ case R_ARC_32:
+ case R_ARC_32_ME:
+ /* During shared library creation, these relocs should not
+ appear in a shared library (as memory will be read only
+ and the dynamic linker can not resolve these. However
+ the error should not occur for e.g. debugging or
+ non-readonly sections. */
+ if (h != NULL
+ && (bfd_link_dll (info) && !bfd_link_pie (info))
+ && (sec->flags & SEC_ALLOC) != 0
+ && (sec->flags & SEC_READONLY) != 0
+ && ((sec->flags & SEC_CODE) != 0
+ || (sec->flags & SEC_DEBUGGING) != 0))
+ {
+ const char *name;
+ if (h)
+ name = h->root.root.string;
+ else
+ name = "UNKNOWN";
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: relocation %s against `%s' can not be used"
+ " when making a shared object; recompile with -fPIC"),
+ abfd,
+ arc_elf_howto (r_type)->name,
+ name);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }

/* In some cases we are not setting the 'non_got_ref'
flag, even though the relocations don't require a GOT
@@ -2052,6 +2051,25 @@ elf_arc_check_relocs (bfd * abfd,
if (is_reloc_for_GOT (howto)
|| is_reloc_for_TLS (howto))
{
+ if (bfd_link_dll (info) && !bfd_link_pie (info)
+ && (r_type == R_ARC_TLS_LE_32 || r_type == R_ARC_TLS_LE_S9))
+ {
+ const char *name;
+ if (h)
+ name = h->root.root.string;
+ else
+ /* bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL); */
+ name = "UNKNOWN";
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: relocation %s against `%s' can not be used"
+ " when making a shared object; recompile with -fPIC"),
+ abfd,
+ arc_elf_howto (r_type)->name,
+ name);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
if (! _bfd_elf_create_got_section (dynobj, info))
return FALSE;

@@ -2474,6 +2492,39 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd,
s = bfd_get_linker_section (dynobj, SECTION); \
break;

+
+struct obfd_info_group {
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+};
+
+static bfd_boolean
+arc_create_forced_local_got_entries_for_tls (struct bfd_hash_entry *bh,
+ void *data)
+{
+ struct elf_arc_link_hash_entry * h =
+ (struct elf_arc_link_hash_entry *) bh;
+ struct obfd_info_group *tmp = (struct obfd_info_group *) data;
+
+ if (h->got_ents != NULL)
+ {
+ BFD_ASSERT (h);
+
+ struct got_entry *list = h->got_ents;
+
+ while (list != NULL)
+ {
+ create_got_dynrelocs_for_single_entry (list, tmp->output_bfd,
+ tmp->info,
+ (struct elf_link_hash_entry *) h);
+ list = list->next;
+ }
+ }
+
+ return TRUE;
+}
+
+
/* Function : elf_arc_finish_dynamic_sections
Brief : Finish up the dynamic sections handling.
Args : output_bfd :
@@ -2607,6 +2658,12 @@ elf_arc_finish_dynamic_sections (bfd * output_bfd,
}
}

+ struct obfd_info_group group;
+ group.output_bfd = output_bfd;
+ group.info = info;
+ bfd_hash_traverse (&info->hash->table,
+ arc_create_forced_local_got_entries_for_tls, &group);
+
return TRUE;
}
--
2.19.1
Loading...