Module Name: src Committed By: bouyer Date: Tue Aug 29 09:10:36 UTC 2017
Modified Files: src/external/gpl3/binutils/dist/bfd [netbsd-8]: elfxx-mips.c elfxx-sparc.c src/external/gpl3/binutils/dist/gas/config [netbsd-8]: tc-mips.h src/external/gpl3/gcc/dist/gcc [netbsd-8]: configure configure.ac varasm.c src/external/gpl3/gcc/dist/gcc/config/arm [netbsd-8]: arm.h src/external/gpl3/gcc/dist/gcc/config/mips [netbsd-8]: netbsd.h src/lib/csu/arch/mips [netbsd-8]: crtend.S src/lib/csu/common [netbsd-8]: crtbegin.c src/share/mk [netbsd-8]: bsd.own.mk Log Message: Pull up following revision(s) (requested by joerg in ticket #240): external/gpl3/binutils/dist/gas/config/tc-mips.h: revision 1.7 external/gpl3/gcc/dist/gcc/configure: revision 1.16 external/gpl3/gcc/dist/gcc/varasm.c: revision 1.2 external/gpl3/gcc/dist/gcc/varasm.c: revision 1.3 external/gpl3/gcc/dist/gcc/config/mips/netbsd.h: revision 1.10 lib/csu/arch/mips/crtend.S: revision 1.4 share/mk/bsd.own.mk: revision 1.1011 lib/csu/common/crtbegin.c: revision 1.14 external/gpl3/binutils/dist/bfd/elfxx-mips.c: revision 1.11 external/gpl3/gcc/dist/gcc/configure.ac: revision 1.14 external/gpl3/binutils/dist/bfd/elfxx-sparc.c: revision 1.12 external/gpl3/gcc/dist/gcc/config/arm/arm.h: revision 1.14 Create references as absolute pointers internally for .cfi*. Do not warn for anonymous relocations in read-only .eh_frame, they will be turned into relative entries afterwards. A const declaration with explicit section attribute should create a read-only section, whether it is initialized or not. Use read-only .eh_frame. Detect advance_loc support with readelf, not objdump. The latter is broken in some situations before binutils 2.28. .eh_frame should be read-only on MIPS too. Build PIC libs on MIPS and PPC64. While the normal calling convention is position-independent, real PIC defaults to Global Dynamic as TLS model, while non-PIC and PIE code can use more restrictive models like Initial Exec. This is most visible with the thread_local destructor code now using TLS in libc as it would be clobbered by any other shared library with TLS due to static offset assignment by ld. Fix encoding of LSDA entries. .eh_frame references in non-PIC mode can use plain pointers. For PIC, any references to global objects must be indirect, but the .eh_frame entries themselve should be pcrel. One more missing check for DECL_INITIAL being non-NULL. TLS relocations for PIE and non-PIE main executable work the same, so apply the same relaxation rules and the same static binding rules. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.10.6.1 \ src/external/gpl3/binutils/dist/bfd/elfxx-mips.c cvs rdiff -u -r1.11 -r1.11.6.1 \ src/external/gpl3/binutils/dist/bfd/elfxx-sparc.c cvs rdiff -u -r1.6 -r1.6.6.1 \ src/external/gpl3/binutils/dist/gas/config/tc-mips.h cvs rdiff -u -r1.15 -r1.15.8.1 src/external/gpl3/gcc/dist/gcc/configure cvs rdiff -u -r1.13 -r1.13.8.1 src/external/gpl3/gcc/dist/gcc/configure.ac cvs rdiff -u -r1.1.1.6 -r1.1.1.6.8.1 src/external/gpl3/gcc/dist/gcc/varasm.c cvs rdiff -u -r1.13 -r1.13.8.1 \ src/external/gpl3/gcc/dist/gcc/config/arm/arm.h cvs rdiff -u -r1.9 -r1.9.4.1 \ src/external/gpl3/gcc/dist/gcc/config/mips/netbsd.h cvs rdiff -u -r1.3 -r1.3.22.1 src/lib/csu/arch/mips/crtend.S cvs rdiff -u -r1.13 -r1.13.8.1 src/lib/csu/common/crtbegin.c cvs rdiff -u -r1.1009.2.1 -r1.1009.2.2 src/share/mk/bsd.own.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/binutils/dist/bfd/elfxx-mips.c diff -u src/external/gpl3/binutils/dist/bfd/elfxx-mips.c:1.10 src/external/gpl3/binutils/dist/bfd/elfxx-mips.c:1.10.6.1 --- src/external/gpl3/binutils/dist/bfd/elfxx-mips.c:1.10 Wed Oct 26 18:42:52 2016 +++ src/external/gpl3/binutils/dist/bfd/elfxx-mips.c Tue Aug 29 09:10:36 2017 @@ -8596,12 +8596,18 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s /* In the N32 and 64-bit ABIs there may be multiple consecutive relocations for the same offset. If we have a R_MIPS_GPREL32 followed by a R_MIPS_64 then that - relocation is complete and needs no futher adjustment. */ + relocation is complete and needs no futher adjustment. + + Silently ignore absolute relocations in the .eh_frame + section, they will be dropped latter. + */ if ((rel == relocs || rel[-1].r_offset != rel->r_offset || r_type != R_MIPS_64 || ELF_R_TYPE(abfd, rel[-1].r_info) != R_MIPS_GPREL32) - && MIPS_ELF_READONLY_SECTION (sec)) + && MIPS_ELF_READONLY_SECTION (sec) + && !((r_type == R_MIPS_32 || r_type == R_MIPS_64) + && strcmp(sec->name, ".eh_frame") == 0)) { /* We tell the dynamic linker that there are relocations against the text segment. */ Index: src/external/gpl3/binutils/dist/bfd/elfxx-sparc.c diff -u src/external/gpl3/binutils/dist/bfd/elfxx-sparc.c:1.11 src/external/gpl3/binutils/dist/bfd/elfxx-sparc.c:1.11.6.1 --- src/external/gpl3/binutils/dist/bfd/elfxx-sparc.c:1.11 Wed Oct 26 18:42:52 2016 +++ src/external/gpl3/binutils/dist/bfd/elfxx-sparc.c Tue Aug 29 09:10:36 2017 @@ -1330,7 +1330,7 @@ sparc_elf_tls_transition (struct bfd_lin && ! _bfd_sparc_elf_tdata (abfd)->has_tlsgd) r_type = R_SPARC_REV32; - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) return r_type; switch (r_type) @@ -1501,13 +1501,13 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, case R_SPARC_TLS_LE_HIX22: case R_SPARC_TLS_LE_LOX10: - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) goto r_sparc_plt32; break; case R_SPARC_TLS_IE_HI22: case R_SPARC_TLS_IE_LO10: - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) info->flags |= DF_STATIC_TLS; /* Fall through */ @@ -2334,7 +2334,7 @@ allocate_dynrelocs (struct elf_link_hash /* If R_SPARC_TLS_IE_{HI22,LO10} symbol is now local to the binary, make it a R_SPARC_TLS_LE_{HI22,LO10} requiring no TLS entry. */ if (h->got.refcount > 0 - && !bfd_link_pic (info) + && !bfd_link_dll (info) && h->dynindx == -1 && _bfd_sparc_elf_hash_entry(h)->tls_type == GOT_TLS_IE) h->got.offset = (bfd_vma) -1; @@ -3582,7 +3582,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou else if (h != NULL) { tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type; - if (!bfd_link_pic (info) + if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type == GOT_TLS_IE) switch (SPARC_ELF_R_TYPE (rel->r_info)) @@ -3706,7 +3706,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou case R_SPARC_TLS_LDM_HI22: case R_SPARC_TLS_LDM_LO10: - if (! bfd_link_pic (info)) + if (! bfd_link_dll (info)) { bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); continue; @@ -3717,7 +3717,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou case R_SPARC_TLS_LDO_HIX22: case R_SPARC_TLS_LDO_LOX10: - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) { relocation -= dtpoff_base (info); break; @@ -3729,7 +3729,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou case R_SPARC_TLS_LE_HIX22: case R_SPARC_TLS_LE_LOX10: - if (bfd_link_pic (info)) + if (bfd_link_dll (info)) { Elf_Internal_Rela outrel; bfd_boolean skip; @@ -3761,7 +3761,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou break; case R_SPARC_TLS_LDM_CALL: - if (! bfd_link_pic (info)) + if (! bfd_link_dll (info)) { /* mov %g0, %o0 */ bfd_put_32 (output_bfd, 0x90100000, contents + rel->r_offset); @@ -3775,13 +3775,13 @@ _bfd_sparc_elf_relocate_section (bfd *ou tls_type = _bfd_sparc_elf_local_got_tls_type (input_bfd) [r_symndx]; else if (h != NULL) tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type; - if (! bfd_link_pic (info) + if (! bfd_link_dll (info) || (r_type == R_SPARC_TLS_GD_CALL && tls_type == GOT_TLS_IE)) { Elf_Internal_Rela *rel2; bfd_vma insn; - if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) + if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1)) { /* GD -> LE */ bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); @@ -3868,12 +3868,12 @@ _bfd_sparc_elf_relocate_section (bfd *ou continue; case R_SPARC_TLS_LDM_ADD: - if (! bfd_link_pic (info)) + if (! bfd_link_dll (info)) bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); continue; case R_SPARC_TLS_LDO_ADD: - if (! bfd_link_pic (info)) + if (! bfd_link_dll (info)) { /* Change rs1 into %g7. */ bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); @@ -3884,7 +3884,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou case R_SPARC_TLS_IE_LD: case R_SPARC_TLS_IE_LDX: - if (! bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) + if (! bfd_link_dll (info) && (h == NULL || h->dynindx == -1)) { bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); int rs2 = insn & 0x1f; Index: src/external/gpl3/binutils/dist/gas/config/tc-mips.h diff -u src/external/gpl3/binutils/dist/gas/config/tc-mips.h:1.6 src/external/gpl3/binutils/dist/gas/config/tc-mips.h:1.6.6.1 --- src/external/gpl3/binutils/dist/gas/config/tc-mips.h:1.6 Wed Oct 26 18:42:55 2016 +++ src/external/gpl3/binutils/dist/gas/config/tc-mips.h Tue Aug 29 09:10:35 2017 @@ -178,7 +178,7 @@ extern int mips_dwarf2_addr_size (void); #define DWARF2_ADDR_SIZE(bfd) mips_dwarf2_addr_size () #define DWARF2_FDE_RELOC_SIZE (compact_eh ? 4 : mips_dwarf2_addr_size ()) #define DWARF2_FDE_RELOC_ENCODING(enc) \ - (enc | (compact_eh ? DW_EH_PE_pcrel : 0)) + (compact_eh ? (enc)|DW_EH_PE_pcrel : DW_EH_PE_absptr) #define TARGET_USE_CFIPOP 1 Index: src/external/gpl3/gcc/dist/gcc/configure diff -u src/external/gpl3/gcc/dist/gcc/configure:1.15 src/external/gpl3/gcc/dist/gcc/configure:1.15.8.1 --- src/external/gpl3/gcc/dist/gcc/configure:1.15 Thu Jun 9 23:28:22 2016 +++ src/external/gpl3/gcc/dist/gcc/configure Tue Aug 29 09:10:35 2017 @@ -22891,7 +22891,7 @@ else test $ac_status = 0; }; } then -if $gcc_cv_objdump -Wf conftest.o 2>/dev/null \ +if $gcc_cv_readelf --debug-dump=frames conftest.o 2>/dev/null \ | grep 'DW_CFA_advance_loc[24]:[ ][ ]*75040[ ]' >/dev/null; then gcc_cv_as_cfi_advance_working=yes fi Index: src/external/gpl3/gcc/dist/gcc/configure.ac diff -u src/external/gpl3/gcc/dist/gcc/configure.ac:1.13 src/external/gpl3/gcc/dist/gcc/configure.ac:1.13.8.1 --- src/external/gpl3/gcc/dist/gcc/configure.ac:1.13 Thu Jun 9 23:28:22 2016 +++ src/external/gpl3/gcc/dist/gcc/configure.ac Tue Aug 29 09:10:36 2017 @@ -2693,7 +2693,7 @@ gcc_GAS_CHECK_FEATURE([working cfi advan .cfi_adjust_cfa_offset 128 .cfi_endproc], [[ -if $gcc_cv_objdump -Wf conftest.o 2>/dev/null \ +if $gcc_cv_readelf --debug-dump=frames conftest.o 2>/dev/null \ | grep 'DW_CFA_advance_loc[24]:[ ][ ]*75040[ ]' >/dev/null; then gcc_cv_as_cfi_advance_working=yes fi Index: src/external/gpl3/gcc/dist/gcc/varasm.c diff -u src/external/gpl3/gcc/dist/gcc/varasm.c:1.1.1.6 src/external/gpl3/gcc/dist/gcc/varasm.c:1.1.1.6.8.1 --- src/external/gpl3/gcc/dist/gcc/varasm.c:1.1.1.6 Tue Jun 7 05:58:06 2016 +++ src/external/gpl3/gcc/dist/gcc/varasm.c Tue Aug 29 09:10:35 2017 @@ -978,11 +978,17 @@ decode_reg_name (const char *name) } -/* Return true if DECL's initializer is suitable for a BSS section. */ +/* + * Return true if DECL's initializer is suitable for a BSS section. + * If there is an explicit section name attribute, assume that it is not + * for a BSS section, independent of the name. + */ bool bss_initializer_p (const_tree decl) { + if (DECL_SECTION_NAME (decl) != NULL) + return false; return (DECL_INITIAL (decl) == NULL /* In LTO we have no errors in program; error_mark_node is used to mark offlined constructors. */ @@ -6402,7 +6408,7 @@ categorize_decl_for_section (const_tree ret = SECCAT_BSS; else if (! TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl) - || ! TREE_CONSTANT (DECL_INITIAL (decl))) + || (DECL_INITIAL(decl) != NULL && ! TREE_CONSTANT (DECL_INITIAL (decl)))) { /* Here the reloc_rw_mask is not testing whether the section should be read-only or not, but whether the dynamic link will have to @@ -6422,7 +6428,8 @@ categorize_decl_for_section (const_tree location. -fmerge-all-constants allows even that (at the expense of not conforming). */ ret = SECCAT_RODATA; - else if (TREE_CODE (DECL_INITIAL (decl)) == STRING_CST) + else if (DECL_INITIAL (decl) != NULL + && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST) ret = SECCAT_RODATA_MERGE_STR_INIT; else ret = SECCAT_RODATA_MERGE_CONST; @@ -6446,6 +6453,7 @@ categorize_decl_for_section (const_tree no concept of a read-only thread-local-data section. */ if (ret == SECCAT_BSS || (flag_zero_initialized_in_bss + && DECL_INITIAL(decl) != NULL && initializer_zerop (DECL_INITIAL (decl)))) ret = SECCAT_TBSS; else Index: src/external/gpl3/gcc/dist/gcc/config/arm/arm.h diff -u src/external/gpl3/gcc/dist/gcc/config/arm/arm.h:1.13 src/external/gpl3/gcc/dist/gcc/config/arm/arm.h:1.13.8.1 --- src/external/gpl3/gcc/dist/gcc/config/arm/arm.h:1.13 Tue Jun 7 06:14:17 2016 +++ src/external/gpl3/gcc/dist/gcc/config/arm/arm.h Tue Aug 29 09:10:36 2017 @@ -964,10 +964,8 @@ extern int arm_arch_crc; /* DWARF unwinding uses the normal indirect/pcrel vs absptr format for 32bit platforms. */ #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ - ((flag_pic \ - && ((GLOBAL) || (CODE))) \ - ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \ - : DW_EH_PE_absptr) + (flag_pic ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \ + : DW_EH_PE_absptr) #else /* ttype entries (the only interesting data references used) use TARGET2 relocations. */ Index: src/external/gpl3/gcc/dist/gcc/config/mips/netbsd.h diff -u src/external/gpl3/gcc/dist/gcc/config/mips/netbsd.h:1.9 src/external/gpl3/gcc/dist/gcc/config/mips/netbsd.h:1.9.4.1 --- src/external/gpl3/gcc/dist/gcc/config/mips/netbsd.h:1.9 Sat Feb 25 21:16:50 2017 +++ src/external/gpl3/gcc/dist/gcc/config/mips/netbsd.h Tue Aug 29 09:10:36 2017 @@ -228,4 +228,4 @@ along with GCC; see the file COPYING3. #define WINT_TYPE "int" #undef TARGET_WRITABLE_EH_FRAME -#define TARGET_WRITABLE_EH_FRAME (flag_pic && TARGET_SHARED) +#define TARGET_WRITABLE_EH_FRAME 0 Index: src/lib/csu/arch/mips/crtend.S diff -u src/lib/csu/arch/mips/crtend.S:1.3 src/lib/csu/arch/mips/crtend.S:1.3.22.1 --- src/lib/csu/arch/mips/crtend.S:1.3 Thu Sep 5 00:28:11 2013 +++ src/lib/csu/arch/mips/crtend.S Tue Aug 29 09:10:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: crtend.S,v 1.3 2013/09/05 00:28:11 matt Exp $ */ +/* $NetBSD: crtend.S,v 1.3.22.1 2017/08/29 09:10:36 bouyer Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -30,7 +30,7 @@ #include <mips/asm.h> -RCSID("$NetBSD: crtend.S,v 1.3 2013/09/05 00:28:11 matt Exp $") +RCSID("$NetBSD: crtend.S,v 1.3.22.1 2017/08/29 09:10:36 bouyer Exp $") .section .ctors, "aw", @progbits .p2align PTR_SCALESHIFT @@ -46,7 +46,7 @@ __CTOR_LIST_END__: __DTOR_LIST_END__: .word 0 - .section .eh_frame, "aw", @progbits + .section .eh_frame, "a", @progbits .p2align PTR_SCALESHIFT .space _MIPS_SZPTR / 8 Index: src/lib/csu/common/crtbegin.c diff -u src/lib/csu/common/crtbegin.c:1.13 src/lib/csu/common/crtbegin.c:1.13.8.1 --- src/lib/csu/common/crtbegin.c:1.13 Wed Jun 29 11:16:47 2016 +++ src/lib/csu/common/crtbegin.c Tue Aug 29 09:10:36 2017 @@ -27,7 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: crtbegin.c,v 1.13 2016/06/29 11:16:47 joerg Exp $"); +__RCSID("$NetBSD: crtbegin.c,v 1.13.8.1 2017/08/29 09:10:36 bouyer Exp $"); #include "crtbegin.h" @@ -57,11 +57,7 @@ __dso_hidden void *__dso_handle; #endif #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) -__dso_hidden -#if !defined(__mips__) - const -#endif - long __EH_FRAME_LIST__[0] __section(".eh_frame"); +__dso_hidden const long __EH_FRAME_LIST__[0] __section(".eh_frame"); __weakref_visible void register_frame_info(const void *, const void *) __weak_reference(__register_frame_info); Index: src/share/mk/bsd.own.mk diff -u src/share/mk/bsd.own.mk:1.1009.2.1 src/share/mk/bsd.own.mk:1.1009.2.2 --- src/share/mk/bsd.own.mk:1.1009.2.1 Tue Jul 18 17:32:50 2017 +++ src/share/mk/bsd.own.mk Tue Aug 29 09:10:36 2017 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.own.mk,v 1.1009.2.1 2017/07/18 17:32:50 snj Exp $ +# $NetBSD: bsd.own.mk,v 1.1009.2.2 2017/08/29 09:10:36 bouyer Exp $ # This needs to be before bsd.init.mk .if defined(BSD_MK_COMPAT_FILE) @@ -788,22 +788,9 @@ MKLINT.ia64= no MKGDB.ia64= no # -# On the MIPS, all libs are compiled with ABIcalls (and are thus PIC), -# not just shared libraries, so don't build the _pic version. -# -.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \ - ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb" -MKPICLIB:= no -.endif - -.if !defined(COMMON_MACHINE_ARCH) -# Native PowerPC64 ABI is PIC. -MKPICLIB.powerpc64:= no -.endif - -# # On VAX using ELF, all objects are PIC, not just shared libraries, -# so don't build the _pic version. +# so don't build the _pic version. VAX has no native TLS support either, +# so differences between TLS models are not relevant. # MKPICLIB.vax= no