From 0c4ae2689461e40161e6b35eb8e5159b14c3bd3c Mon Sep 17 00:00:00 2001 From: Evgeniy Didin Date: Thu, 31 Oct 2019 16:47:02 +0300 Subject: [PATCH] package/binutils/arc-2019.09-eng002: fix glibc build with -fPIE In Binutils rev arc-2019.09-eng002 there is a commit 182352753240 ("[ARC] Check UNDEFWEAK_NO_DYNAMIC_RELOC") which caused glibc build error in case of BR2_PIC_PIE=y. This commit adds reverting this commit patch to package/binutils/arc-2019.09-eng002 These binutils changes will be a part of the next -eng00x or RCx ARC toolchain but now we are making this commit to get known issue fixed. Fixes: http://autobuild.buildroot.net/results/4bc/4bca850dbf966687bf85c2c23465be0da47b7997// Signed-off-by: Evgeniy Didin Cc: Claudiu Zissulescu Cc: Thomas Petazzoni Cc: arc-buildroot@synopsys.com Signed-off-by: Thomas Petazzoni --- ...ARC-Check-UNDEFWEAK_NO_DYNAMIC_RELOC.patch | 244 ++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 package/binutils/arc-2019.09-eng002/0002-Revert-ARC-Check-UNDEFWEAK_NO_DYNAMIC_RELOC.patch diff --git a/package/binutils/arc-2019.09-eng002/0002-Revert-ARC-Check-UNDEFWEAK_NO_DYNAMIC_RELOC.patch b/package/binutils/arc-2019.09-eng002/0002-Revert-ARC-Check-UNDEFWEAK_NO_DYNAMIC_RELOC.patch new file mode 100644 index 0000000000..74a1a8cd9b --- /dev/null +++ b/package/binutils/arc-2019.09-eng002/0002-Revert-ARC-Check-UNDEFWEAK_NO_DYNAMIC_RELOC.patch @@ -0,0 +1,244 @@ +From 0bd0ecc386b82ce4b61dc64fe6cdd6a851acc866 Mon Sep 17 00:00:00 2001 +From: Claudiu Zissulescu +Date: Thu, 31 Oct 2019 10:39:07 +0100 +Subject: [PATCH] Revert "[ARC] Check UNDEFWEAK_NO_DYNAMIC_RELOC" + +Gives errors when -fPIE used. + +Signed-off-by: Claudiu Zissulescu + +This reverts commit 1823527532407648f3061b130c55f2138496b2aa. +--- + bfd/elf32-arc.c | 120 +++++++++++++------------------ + ld/testsuite/ld-arc/weakhid.s | 13 ---- + ld/testsuite/ld-arc/weakhiddso.d | 29 -------- + 3 files changed, 50 insertions(+), 112 deletions(-) + delete mode 100644 ld/testsuite/ld-arc/weakhid.s + delete mode 100644 ld/testsuite/ld-arc/weakhiddso.d + +diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c +index b92b0b7501a..e9463bea04f 100644 +--- a/bfd/elf32-arc.c ++++ b/bfd/elf32-arc.c +@@ -1462,7 +1462,6 @@ elf_arc_relocate_section (bfd * output_bfd, + struct elf_link_hash_entry * h2; + const char * msg; + bfd_boolean unresolved_reloc = FALSE; +- bfd_boolean resolved_to_zero; + + struct arc_relocation_data reloc_data = + { +@@ -1604,8 +1603,6 @@ elf_arc_relocate_section (bfd * output_bfd, + continue; + } + +- resolved_to_zero = (h != NULL && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)); +- + if (r_symndx < symtab_hdr->sh_info) /* A local symbol. */ + { + reloc_data.sym_value = sym->st_value; +@@ -1714,8 +1711,7 @@ elf_arc_relocate_section (bfd * output_bfd, + reloc_data.sym_section = htab->splt; + reloc_data.should_relocate = TRUE; + } +- /* See pr22269. */ +- else if (!resolved_to_zero) ++ else + continue; + } + else +@@ -1787,26 +1783,24 @@ elf_arc_relocate_section (bfd * output_bfd, + + switch (r_type) + { +- case R_ARC_32: +- case R_ARC_32_ME: +- case R_ARC_PC32: +- case R_ARC_32_PCREL: +- if (bfd_link_pic (info) +- && !resolved_to_zero +- && (input_section->flags & SEC_ALLOC) != 0 +- && (!IS_ARC_PCREL_TYPE (r_type) +- || (h != NULL +- && h->dynindx != -1 +- && !h->def_regular +- && (!info->symbolic || !h->def_regular)))) +- { +- Elf_Internal_Rela outrel; +- bfd_byte *loc; +- bfd_boolean skip = FALSE; +- bfd_boolean relocate = FALSE; +- asection *sreloc = _bfd_elf_get_dynamic_reloc_section +- (input_bfd, input_section, +- /*RELA*/ TRUE); ++ case R_ARC_32: ++ case R_ARC_32_ME: ++ case R_ARC_PC32: ++ case R_ARC_32_PCREL: ++ if (bfd_link_pic (info) ++ && (!IS_ARC_PCREL_TYPE (r_type) ++ || (h != NULL ++ && h->dynindx != -1 ++ && !h->def_regular ++ && (!info->symbolic || !h->def_regular)))) ++ { ++ Elf_Internal_Rela outrel; ++ bfd_byte *loc; ++ bfd_boolean skip = FALSE; ++ bfd_boolean relocate = FALSE; ++ asection *sreloc = _bfd_elf_get_dynamic_reloc_section ++ (input_bfd, input_section, ++ /*RELA*/ TRUE); + + BFD_ASSERT (sreloc != NULL); + +@@ -2009,8 +2003,6 @@ elf_arc_check_relocs (bfd * abfd, + + switch (r_type) + { +- case R_ARC_8: +- case R_ARC_16: + case R_ARC_32: + case R_ARC_32_ME: + /* During shared library creation, these relocs should not +@@ -2041,51 +2033,39 @@ elf_arc_check_relocs (bfd * abfd, + return FALSE; + } + +- /* In some cases we are not setting the 'non_got_ref' flag, +- even though the relocations don't require a GOT access. +- We should extend the testing in this area to ensure that +- no significant cases are being missed. */ +- if (h) +- h->non_got_ref = 1; +- +- /* We don't need to handle relocs into sections not going +- into the "real" output. */ +- if ((sec->flags & SEC_ALLOC) == 0) +- break; ++ /* In some cases we are not setting the 'non_got_ref' ++ flag, even though the relocations don't require a GOT ++ access. We should extend the testing in this area to ++ ensure that no significant cases are being missed. */ ++ if (h) ++ h->non_got_ref = 1; ++ /* FALLTHROUGH */ ++ case R_ARC_PC32: ++ case R_ARC_32_PCREL: ++ if ((bfd_link_pic (info)) ++ && ((r_type != R_ARC_PC32 && r_type != R_ARC_32_PCREL) ++ || (h != NULL ++ && (!info->symbolic || !h->def_regular)))) ++ { ++ if (sreloc == NULL) ++ { ++ if (info->dynamic ++ && ! htab->dynamic_sections_created ++ && ! _bfd_elf_link_create_dynamic_sections (abfd, info)) ++ return FALSE; ++ sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj, ++ 2, abfd, ++ /*rela*/ ++ TRUE); ++ ++ if (sreloc == NULL) ++ return FALSE; ++ } ++ sreloc->size += sizeof (Elf32_External_Rela); + +- /* No need to do anything if we're not creating a shared +- object. */ +- if (!bfd_link_pic (info) +- || (h != NULL +- && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))) ++ } ++ default: + break; +- +- /* FALLTHROUGH */ +- case R_ARC_PC32: +- case R_ARC_32_PCREL: +- if ((bfd_link_pic (info)) +- && ((r_type != R_ARC_PC32 && r_type != R_ARC_32_PCREL) +- || (h != NULL +- && (!info->symbolic || !h->def_regular)))) +- { +- if (sreloc == NULL) +- { +- if (info->dynamic +- && ! htab->dynamic_sections_created +- && ! _bfd_elf_link_create_dynamic_sections (abfd, info)) +- return FALSE; +- sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj, +- 2, abfd, +- /*rela*/ +- TRUE); +- +- if (sreloc == NULL) +- return FALSE; +- } +- sreloc->size += sizeof (Elf32_External_Rela); +- } +- default: +- break; + } + + if (is_reloc_for_PLT (howto)) +diff --git a/ld/testsuite/ld-arc/weakhid.s b/ld/testsuite/ld-arc/weakhid.s +deleted file mode 100644 +index a8c87da1a2d..00000000000 +--- a/ld/testsuite/ld-arc/weakhid.s ++++ /dev/null +@@ -1,13 +0,0 @@ +- .weak xweakobj +- .weak xweakhidobj +- .hidden xweakhidobj +- +- .data +- .global x +- .type x,@object +-x: +- .word xweakhidobj +- .word xweakobj +- .word xregobj +-.Lfe1: +- .size x,.Lfe1-x +diff --git a/ld/testsuite/ld-arc/weakhiddso.d b/ld/testsuite/ld-arc/weakhiddso.d +deleted file mode 100644 +index f52f27fc048..00000000000 +--- a/ld/testsuite/ld-arc/weakhiddso.d ++++ /dev/null +@@ -1,29 +0,0 @@ +-#source: weakhid.s +-#ld: --shared -m arclinux -z nocombreloc --hash-style=sysv +-#objdump: -s -R -T +- +-# Check that .weak and .weak .hidden object references are handled +-# correctly when generating a DSO. Copied from CRIS port. +- +-.*: +file format .*arc.* +- +-DYNAMIC SYMBOL TABLE: +-0+2208 l d \.data 0+ \.data +-0+2208 g DO \.data 0+c x +-0+ D \*UND\* 0+ xregobj +-0+2214 g D \.data 0+ __bss_start +-0+ w D \*UND\* 0+ xweakobj +-0+2214 g D \.data 0+ _edata +-0+2214 g D \.data 0+ _end +- +- +-DYNAMIC RELOCATION RECORDS +-OFFSET TYPE VALUE +-0+2210 R_ARC_32 +xregobj +-0+ R_ARC_NONE +\*ABS\* +- +-Contents of section \.hash: +-#... +-Contents of section \.data: +- 2208 00000000 00000000 00000000 .* +-#... +\ No newline at end of file +-- +2.17.2 + -- 2.30.2