aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2018-08-29[MIPS/LD/testsuite] Skip o32 flags check on mips*-*-irix*Chenghua Xu2-1/+11
ld/ChangeLog: * testsuite/ld-mips-elf/mips-elf-flags.exp (good_combination): Skip o32 flags checking if target is mips*-*-irix*.
2018-08-27x86: Don't mask out the GNU_PROPERTY_X86_UINT32_VALID bitH.J. Lu8-0/+130
Since only the GNU_PROPERTY_X86_UINT32_VALID bit may be set in data-only relocatable objects which don't contain any instructions, linker shouldn't mask out the GNU_PROPERTY_X86_UINT32_VALID bit when merging GNU_PROPERTY_X86_XXX bits. Otherwise, linker output doesn't contain GNU_PROPERTY_X86_XXX property with any data-only relocatable inputs. This patch keeps the GNU_PROPERTY_X86_UINT32_VALID bit and updates readelf to print "<None>" if GNU_PROPERTY_X86_XXX property only has the GNU_PROPERTY_X86_UINT32_VALID bit. bfd/ * elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Don't mask out the GNU_PROPERTY_X86_UINT32_VALID bit. binutils/ * readelf.c (decode_x86_isa): Print <None> if bitmask only contains the GNU_PROPERTY_X86_UINT32_VALID bit. (decode_x86_feature_1): Likewise. (decode_x86_feature_2): Likewise. (print_gnu_property_note): Don't mask out the GNU_PROPERTY_X86_UINT32_VALID bit. * testsuite/binutils-all/i386/pr21231b.d: Updated. * testsuite/binutils-all/x86-64/pr21231b.d: Likewise. gas/ * testsuite/gas/i386/i386.exp: Run property-1 and x86-64-property-1. * testsuite/gas/i386/property-1.d: New file. * testsuite/gas/i386/property-1.s: Likewise. * testsuite/gas/i386/x86-64-property-1.d: Likewise. ld/ * testsuite/ld-i386/i386.exp: Run property-x86-5. * testsuite/ld-i386/property-x86-5.d: New file. * testsuite/ld-x86-64/property-x86-5-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-5.d: Likewise. * testsuite/ld-x86-64/property-x86-5a.s: Likewise. * testsuite/ld-x86-64/property-x86-5b.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run property-x86-5 and property-x86-5-x32.
2018-08-26Delay evaluation of alignment expressions in output sectionsAlan Modra10-40/+88
git commit 702d16713 broke expressions using CONSTANT(COMMONPAGESIZE) in ALIGN or SUBALIGN of output section statements, because these optional fields were evaluated at script parse time and the patch in question delayed setting of config.commonpagesize. The right thing to do is keep the tree representation of those fields for later evaluation. PR 23571 * ldlang.h (section_alignment): Make it an expression tree. (subsection_alignment): Likewise. * ldlang.c (topower): Delete. (output_section_statement_newfunc): Adjust initialization. (init_os): Evaluate section_alignment. (lang_size_sections_1): Likewise. (size_input_section): Evaluate subsection_alignment. (lang_enter_output_section_statement): Don't evaluate here. (lang_new_phdr): Use exp_get_vma rather than exp_get_value_int. * ldexp.h (exp_get_value_int): Delete. (exp_get_power): Declare. * ldexp.c (exp_get_value_int): Delete. (exp_get_power): New function. * emultempl/pe.em (place_orphan): Build expression for section alignment. * emultempl/pep.em (place_orphan): Likewise. * testsuite/ld-scripts/pr23571.d, * testsuite/ld-scripts/pr23571.t: New test. * testsuite/ld-scripts/align.exp: Run it.
2018-08-24[PATCH] [MIPS] LD/testsuite: Skip 32bit test if ld not support.Chenghua Xu2-0/+47
ld/ChangeLog: * testsuite/ld-mips-elf/mips-elf-flags.exp (check_ld_support_32bit, check_is_32bit_args): New procedures. (good_combination, bad_combination): Skip 32bit test if ld not support 32bit emulations.
2018-08-24x86: Update GNU_PROPERTY_X86_XXX macrosH.J. Lu55-48/+361
This patch updates GNU_PROPERTY_X86_XXX macros: 1. GNU_PROPERTY_X86_UINT32_AND_XXX: A 4-byte unsigned integer property. A bit is set if it is set in all relocatable inputs: #define GNU_PROPERTY_X86_UINT32_AND_LO 0xc0000002 #define GNU_PROPERTY_X86_UINT32_AND_HI 0xc0007fff 2. GNU_PROPERTY_X86_UINT32_OR_XXX: A 4-byte unsigned integer property. A bit is set if it is set in any relocatable inputs: #define GNU_PROPERTY_X86_UINT32_OR_LO 0xc0008000 #define GNU_PROPERTY_X86_UINT32_OR_HI 0xc000ffff 3. GNU_PROPERTY_X86_UINT32_OR_AND_XXX: A 4-byte unsigned integer property. A bit is set if it is set in any relocatable inputs and the property is present in all relocatable inputs: #define GNU_PROPERTY_X86_UINT32_OR_AND_LO 0xc0010000 #define GNU_PROPERTY_X86_UINT32_OR_AND_HI 0xc0017fff 4. GNU_PROPERTY_X86_FEATURE_2_NEEDED, GNU_PROPERTY_X86_FEATURE_2_USED and GNU_PROPERTY_X86_FEATURE_2_XXX bits. GNU_PROPERTY_X86_FEATURE_1_AND is unchanged. GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED are updated to better support targeted processors since GNU_PROPERTY_X86_ISA_1_?86 aren't isn't very useful. A new set of GNU_PROPERTY_X86_ISA_1_XXX bits are defined. The previous GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed to GNU_PROPERTY_X86_COMPAT_ISA_1_XXX. bfd/ * elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Handle X86_COMPAT_ISA_1_USED, X86_COMPAT_ISA_1_NEEDED, X86_UINT32_AND_LO, X86_UINT32_AND_HI, X86_UINT32_OR_LO, X86_UINT32_OR_HI, X86_UINT32_OR_AND_LO and X86_UINT32_OR_AND_HI instead of X86_ISA_1_USED, X86_ISA_1_NEEDED and X86_FEATURE_1_AND. (_bfd_x86_elf_merge_gnu_properties): Likewise. (_bfd_x86_elf_link_setup_gnu_properties): Add X86_FEATURE_2_NEEDED instead of X86_ISA_1_NEEDED. (_bfd_x86_elf_link_fixup_gnu_properties): Handle X86_COMPAT_ISA_1_USED, X86_COMPAT_ISA_1_NEEDED, X86_UINT32_AND_LO, X86_UINT32_AND_HI, X86_UINT32_OR_LO, X86_UINT32_OR_HI, X86_UINT32_OR_AND_LO and X86_UINT32_OR_AND_HI instead of X86_ISA_1_USED, X86_ISA_1_NEEDED and X86_FEATURE_1_AND. binutils/ * readelf.c (decode_x86_compat_isa): New function. (decode_x86_feature_2): Likewise. (decode_x86_isa): Updated for new X86_ISA_1_XXX bits. (decode_x86_feature): Renamed to ... (decode_x86_feature_1): This. Remove the type argument. (print_gnu_property_note): Handle X86_COMPAT_ISA_1_USED, X86_COMPAT_ISA_1_NEEDED, X86_UINT32_AND_LO, X86_UINT32_AND_HI, X86_UINT32_OR_LO, X86_UINT32_OR_HI, X86_UINT32_OR_AND_LO and X86_UINT32_OR_AND_HI instead of X86_ISA_1_USED, X86_ISA_1_NEEDED and X86_FEATURE_1_AND. * testsuite/binutils-all/i386/pr21231b.s: Updated to the current GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED values. * testsuite/binutils-all/x86-64/pr21231b.s: Likewise. * testsuite/binutils-all/x86-64/pr23494a.s: Likewise. * testsuite/binutils-all/x86-64/pr23494b.s: Likewise. * testsuite/binutils-all/x86-64/pr23494c.s: Likewise. * testsuite/binutils-all/i386/pr21231b.d: Updated. * testsuite/binutils-all/x86-64/pr21231b.d: Likewise. * testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494a.d: Likewise. * testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494c.d: Likewise. * testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494d.d: Likewise. * testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494e.d: Likewise. include/ * elf/common.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ... (GNU_PROPERTY_X86_COMPAT_ISA_1_USED): This. (GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ... (GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED): This. (GNU_PROPERTY_X86_ISA_1_XXX): Renamed to ... (GNU_PROPERTY_X86_COMPAT_ISA_1_XXX): This. (GNU_PROPERTY_X86_UINT32_AND_LO): New. (GNU_PROPERTY_X86_UINT32_AND_HI): Likewise. (GNU_PROPERTY_X86_UINT32_OR_LO): Likewise. (GNU_PROPERTY_X86_UINT32_OR_HI): Likewise. (GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise. (GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise. (GNU_PROPERTY_X86_ISA_1_CMOV): Likewise. (GNU_PROPERTY_X86_ISA_1_SSE): Likewise. (GNU_PROPERTY_X86_ISA_1_SSE2): Likewise. (GNU_PROPERTY_X86_ISA_1_SSE3): Likewise. (GNU_PROPERTY_X86_ISA_1_SSSE3): Likewise. (GNU_PROPERTY_X86_ISA_1_SSE4_1): Likewise. (GNU_PROPERTY_X86_ISA_1_SSE4_2): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX2): Likewise. (GNU_PROPERTY_X86_ISA_1_FMA): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512F): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512CD): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512ER): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512PF): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512VL): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512DQ): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512BW): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512_BITALG): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512_IFMA): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512_VBMI): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2): Likewise. (GNU_PROPERTY_X86_ISA_1_AVX512_VNNI): Likewise. (GNU_PROPERTY_X86_FEATURE_2_X86): Likewise. (GNU_PROPERTY_X86_FEATURE_2_X87): Likewise. (GNU_PROPERTY_X86_FEATURE_2_MMX): Likewise. (GNU_PROPERTY_X86_FEATURE_2_XMM): Likewise. (GNU_PROPERTY_X86_FEATURE_2_YMM): Likewise. (GNU_PROPERTY_X86_FEATURE_2_ZMM): Likewise. (GNU_PROPERTY_X86_FEATURE_2_FXSR): Likewise. (GNU_PROPERTY_X86_FEATURE_2_XSAVE): Likewise. (GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT): Likewise. (GNU_PROPERTY_X86_FEATURE_2_XSAVEC): Likewise. (GNU_PROPERTY_X86_FEATURE_1_AND): Updated to (GNU_PROPERTY_X86_UINT32_AND_LO + 0). (GNU_PROPERTY_X86_ISA_1_NEEDED): Defined to (GNU_PROPERTY_X86_UINT32_OR_LO + 0). (GNU_PROPERTY_X86_FEATURE_2_NEEDED): New. Defined to (GNU_PROPERTY_X86_UINT32_OR_LO + 1). (GNU_PROPERTY_X86_ISA_1_USED): Defined to (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0). (GNU_PROPERTY_X86_FEATURE_2_USED): New. Defined to (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1). ld/ * testsuite/ld-i386/i386.exp: Run pr23372c, pr23372d, pr23486c and pr23486d. * testsuite/ld-i386/pr23372a.s: Update comments. * testsuite/ld-i386/pr23372b.s: Likewise. * testsuite/ld-i386/pr23372c.s: Likewise. * testsuite/ld-x86-64/pr23372a.s: Likewise. * testsuite/ld-x86-64/pr23372b.s: Likewise. * testsuite/ld-x86-64/pr23372c.s: Likewise. * testsuite/ld-x86-64/pr23486a.s: Likewise. * testsuite/ld-x86-64/pr23486b.s: Likewise. * testsuite/ld-i386/pr23372c.d: New file. * testsuite/ld-i386/pr23372d.d: Likewise. * testsuite/ld-i386/pr23486c.d: Likewise. * testsuite/ld-i386/pr23486d.d: Likewise. * testsuite/ld-x86-64/pr23372c-x32.d: Likewise. * testsuite/ld-x86-64/pr23372c.d: Likewise. * testsuite/ld-x86-64/pr23372d-x32.d: Likewise. * testsuite/ld-x86-64/pr23372d.d: Likewise. * testsuite/ld-x86-64/pr23372d.s: Likewise. * testsuite/ld-x86-64/pr23372e.s: Likewise. * testsuite/ld-x86-64/pr23372f.s: Likewise. * testsuite/ld-x86-64/pr23486c-x32.d: Likewise. * testsuite/ld-x86-64/pr23486c.d: Likewise. * testsuite/ld-x86-64/pr23486c.s: Likewise. * testsuite/ld-x86-64/pr23486d-x32.d: Likewise. * testsuite/ld-x86-64/pr23486d.d: Likewise. * testsuite/ld-x86-64/pr23486d.s: Likewise. * testsuite/ld-i386/property-3.r: Updated. * testsuite/ld-i386/property-4.r: Likewise. * testsuite/ld-i386/property-5.r: Likewise. * testsuite/ld-i386/property-x86-3.d: Likewise. * testsuite/ld-i386/property-x86-ibt3a.d: Likewise. * testsuite/ld-i386/property-x86-shstk3a.d: Likewise. * testsuite/ld-i386/property-x86-shstk3b.d: Likewise. * testsuite/ld-x86-64/property-3.r: Likewise. * testsuite/ld-x86-64/property-4.r: Likewise. * testsuite/ld-x86-64/property-5.r: Likewise. * testsuite/ld-x86-64/property-x86-3-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-3.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise. * testsuite/ld-i386/property-x86-1.S: Updated to the current GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED values. * testsuite/ld-i386/property-x86-2.S: Likewise. * testsuite/ld-i386/property-x86-3.s: Likewise. * testsuite/ld-x86-64/property-x86-1.S: Likewise. * testsuite/ld-x86-64/property-x86-2.S: Likewise. * testsuite/ld-x86-64/property-x86-3.s: Likewise. * ld/testsuite/ld-x86-64/x86-64.exp: Run pr23372c, pr23372c-x32, pr23372d, pr23372d-x32, pr23486c, pr23486c-x32, pr23486d and pr23486d-x32.
2018-08-24ehdr_start twiddlesAlan Modra2-12/+21
We force __ehdr_start to defined in before_allocation, then restore the type and a union after dynamic symbols have been allocated. The union contains a number of structs, all starting with a "next" pointer, and various fields depending on the symbol type. The old code restored the entire union, but it isn't necessary to restore the "next" pointer, and in fact it could be wrong if __ehdr_start happened to be last on the list and some symbols were added before restoring. * emultempl/elf32.em (before_allocation): Don't restore __ehdr_start u.*.next pointer.
2018-08-24PR23566, false uninitialized warningAlan Modra2-10/+8
PR 23566 * emultempl/elf32.em (before_allocation): Warning fix.
2018-08-23Prune BFD warnings for unknown GNU propertiesH.J. Lu7-28/+31
When glibc is enabled with the new GNU_PROPERTY_X86_XXX bits: https://groups.google.com/forum/#!topic/x86-64-abi/-D05GQ3kWrA BFD will issue an unknown GNU property warning like warning: tmpdir/ld1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001 and ignore such GNU properties. This patch adds prune_warnings_extra to prune such warnings on release branches and updates prune_warnings to call prune_warnings_extra. binutils/ PR ld/23536 * Makefile.am (development.exp): New target. (EXTRA_DEJAGNU_SITE_CONFIG): New. (DISTCLEANFILES): Add development.exp. * Makefile.in: Regenerated. * testsuite/binutils-all/objcopy.exp (strip_test): Call prune_warnings to prune BFD output. (strip_test_with_saving_a_symbol): Likewise. (objcopy_test_without_global_symbol): Likewise. * testsuite/lib/binutils-common.exp (prune_warnings_extra): New proc. (prune_warnings): Likewise. gas/ PR ld/23536 * Makefile.am (development.exp): New target. (EXTRA_DEJAGNU_SITE_CONFIG): New. (DISTCLEANFILES): Add development.exp. * Makefile.in: Regenerated. ld/ PR ld/23536 * Makefile.am (development.exp): New target. (EXTRA_DEJAGNU_SITE_CONFIG): New. (DISTCLEANFILES): Add development.exp. * Makefile.in: Regenerated. * testsuite/ld-bootstrap/bootstrap.exp: Call prune_warnings to prune BFD output. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/lib/ld-lib.exp (prune_warnings): Removed. * testsuite/ld-elf/shared.exp: Allow "\n" in linker warnings.
2018-08-21Update the documentation of the linker's --hash-style option.Nick Clifton2-1/+8
PR 23426 * ld.texi (--hash-style): Note that the default is configurable and that for most Linux based systems it will be "both".
2018-08-18Remove duplicate ld testsuite functionAlan Modra2-26/+4
It's in binutils/testsuite/lib/binutils-common.exp * testsuite/ld-elf/elf.exp (is_elf64): Delete.
2018-08-17x86: Remove empty X86_FEATURE_1_AND propertyH.J. Lu7-77/+69
There is no need to generate .note.gnu.property section with empty X86_FEATURE_1_AND property. This patch adds fixup_gnu_properties to ELF linker backend so that x86 backend can remove it. bfd/ PR ld/23515 * elf-bfd.h (elf_backend_data): Add fixup_gnu_properties. * elf-properties.c (_bfd_elf_link_setup_gnu_properties): Call backend fixup_gnu_properties if it isn't NULL. Discard .note.gnu.property section if all properties have been removed. * elfxx-target.h (elf_backend_fixup_gnu_properties): New. (elfNN_bed): Initialize fixup_gnu_properties. * elfxx-x86.c (_bfd_x86_elf_link_fixup_gnu_properties): New function. * elfxx-x86.h (_bfd_x86_elf_link_fixup_gnu_properties): New prototype. (elf_backend_fixup_gnu_properties): New. ld/ PR ld/23515 * testsuite/ld-i386/ibt-plt-2a.d: Updated. * testsuite/ld-i386/ibt-plt-2b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b.d: Likewise.
2018-08-12ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.sH.J. Lu2-1/+5
Swap pr23486a.s and pr23486a.s so that pr23486b.d differs from pr23486a.d. * testsuite/ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s.
2018-08-11x86: Properly add X86_ISA_1_NEEDED propertyH.J. Lu4-1/+37
Existing properties may be removed during property merging. We avoid adding X86_ISA_1_NEEDED property only if existing properties won't be removed. bfd/ PR ld/23428 * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't add X86_ISA_1_NEEDED property only if existing properties won't be removed. ld/ PR ld/23428 * testsuite/ld-elf/dummy.s: New file. * testsuite/ld-elf/linux-x86.S: Add X86_FEATURE_1_AND property. * testsuite/ld-elf/linux-x86.exp: Add dummy.s to pr23428.
2018-08-08x86: Properly merge GNU_PROPERTY_X86_ISA_1_USEDH.J. Lu29-42/+182
Without the GNU_PROPERTY_X86_ISA_1_USED property, all ISAs may be used. If a bit in the GNU_PROPERTY_X86_ISA_1_USED property is unset, the corresponding x86 instruction set isn’t used. When merging properties from 2 input files and one input file doesn't have the GNU_PROPERTY_X86_ISA_1_USED property, the output file shouldn't have it neither. This patch removes the GNU_PROPERTY_X86_ISA_1_USED property if an input file doesn't have it. This patch replaces the GNU_PROPERTY_X86_ISA_1_USED property with the GNU_PROPERTY_X86_ISA_1_NEEDED property which is the minimum ISA requirement. bfd/ PR ld/23486 * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove GNU_PROPERTY_X86_ISA_1_USED if an input file doesn't have it. (_bfd_x86_elf_link_setup_gnu_properties): Adding the GNU_PROPERTY_X86_ISA_1_NEEDED, instead of GNU_PROPERTY_X86_ISA_1_USED, property. ld/ PR ld/23486 * testsuite/ld-i386/i386.exp: Run PR ld/23486 tests. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr23486a.d: New file. * testsuite/ld-i386/pr23486b.d: Likewise. * testsuite/ld-x86-64/pr23486a-x32.d: Likewise. * testsuite/ld-x86-64/pr23486a.d: Likewise. * testsuite/ld-x86-64/pr23486a.s: Likewise. * testsuite/ld-x86-64/pr23486b-x32.d: Likewise. * testsuite/ld-x86-64/pr23486b.d: Likewise. * testsuite/ld-x86-64/pr23486b.s: Likewise. * testsuite/ld-i386/property-3.r: Remove "x86 ISA used". * testsuite/ld-i386/property-4.r: Likewise. * testsuite/ld-i386/property-5.r: Likewise. * testsuite/ld-i386/property-x86-ibt3a.d: Likewise. * testsuite/ld-i386/property-x86-ibt3b.d: Likewise. * testsuite/ld-i386/property-x86-shstk3a.d: Likewise. * testsuite/ld-i386/property-x86-shstk3b.d: Likewise. * testsuite/ld-x86-64/property-3.r: Likewise. * testsuite/ld-x86-64/property-4.r: Likewise. * testsuite/ld-x86-64/property-5.r: Likewise. * testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
2018-08-07PowerPC64 EH info for _notoc linkage stubsAlan Modra5-9/+53
This patch generates EH info for the new _notoc linkage stubs, to support unwinding from asynchronous signal handlers. Unwinding through the __tls_get_addr_opt stub was already supported, but that was just a single stub. With multiple stubs the EH opcodes need to be emitted and sized when iterating over stubs, so this is done when emitting and sizing the stub code. Emitting the CIEs and FDEs is done when sizing the stubs, as we did before in order to have the linker generated FDEs indexed in .eh_frame_hdr. I moved the final tweaks to FDEs from ppc64_elf_finish_dynamic_sections to ppc64_elf_build_stubs simply because it's tidier to be done with them at that point. bfd/ * elf64-ppc.c (struct map_stub): Delete tls_get_addr_opt_bctrl. Add lr_restore, eh_size and eh_base. (eh_advance, eh_advance_size): New functions. (build_tls_get_addr_stub): Emit EH info for stub. (ppc_build_one_stub): Likewise for _notoc stubs. (ppc_size_one_stub): Size EH info for stub. (group_sections): Init new map_stub fields. (stub_eh_frame_size): Delete. (ppc64_elf_size_stubs): Size EH info for stubs. Set up dummy EH program for stubs. (ppc64_elf_build_stubs): Reinit new map_stub fields. Set FDE offset to stub section here.. (ppc64_elf_finish_dynamic_sections): ..rather than here. ld/ * testsuite/ld-powerpc/notoc.s: Generate some cfi. * testsuite/ld-powerpc/notoc.d: Adjust. * testsuite/ld-powerpc/notoc.wf: New file. * testsuite/ld-powerpc/powerpc.exp: Run "ext" and "notoc" tests as run_ld_link_tests rather than run_dump_test.
2018-08-07Explain what happens for PE targeted linkers in the case where the user ↵Martin Storsjo3-8/+18
actually tries to provide __CTOR_LIST__ and/or __DTOR_LIST__ symbols. * scripttempl/pe.sc: Improve the comment about overriding __CTOR_LIST__ and __DTOR_LIST__ symbols. * scripttemp/pep.sc: Likewise.
2018-08-07Updated Bulgarian translation for the ld/ directoryNick Clifton2-54/+58
2018-08-06[ARC] Update merging attributes.claziss5-0/+56
Some attributes were ignored during merging. Fix that, and add some errors. bfd/ 2017-09-19 Claudiu Zissulescu <claziss@synopsys.com> * elf32-arc.c (arc_elf_merge_attributes): Fix merge attributes. ld/ 2017-09-19 Claudiu Zissulescu <claziss@synopsys.com> * testsuite/ld-arc/attr-merge-6.d: New file. * testsuite/ld-arc/attr-merge-6a.s: Likewise. * testsuite/ld-arc/attr-merge-6b.s: Likewise. * testsuite/ld-arc/attr-merge-6bis.d: Likewise.
2018-08-06[ARC] Add Tag_ARC_ATR_version.claziss6-0/+13
Add a new tag (Tag_ARC_ATR_version) used to indicate if current attributes are interpreted in GNU way. This attribute is used by Synopsys custom compiler to correctly identify and interpret the object attributes section as generated by GNU tools. gas/ 2017-08-02 Claudiu Zissulescu <claziss@synopsys.com> * config/tc-arc.c (arc_set_public_attributes): Add Tag_ARC_ATR_version. (arc_convert_symbolic_attribute): Likewise. * testsuite/gas/arc/attr-arc600.d: Update test. * testsuite/gas/arc/attr-arc600_mul32x16.d: Likewise. * testsuite/gas/arc/attr-arc600_norm.d: Likewise. * testsuite/gas/arc/attr-arc601.d: Likewise. * testsuite/gas/arc/attr-arc601_mul32x16.d: Likewise. * testsuite/gas/arc/attr-arc601_mul64.d: Likewise. * testsuite/gas/arc/attr-arc601_norm.d: Likewise. * testsuite/gas/arc/attr-arc700.d: Likewise. * testsuite/gas/arc/attr-arcem.d: Likewise. * testsuite/gas/arc/attr-archs.d: Likewise. * testsuite/gas/arc/attr-autodetect-1.d: Likewise. * testsuite/gas/arc/attr-cpu-a601.d: Likewise. * testsuite/gas/arc/attr-cpu-a700.d: Likewise. * testsuite/gas/arc/attr-cpu-em.d: Likewise. * testsuite/gas/arc/attr-cpu-hs.d: Likewise. * testsuite/gas/arc/attr-em.d: Likewise. * testsuite/gas/arc/attr-em4.d: Likewise. * testsuite/gas/arc/attr-em4_dmips.d: Likewise. * testsuite/gas/arc/attr-em4_fpuda.d: Likewise. * testsuite/gas/arc/attr-em4_fpus.d: Likewise. * testsuite/gas/arc/attr-hs.d: Likewise. * testsuite/gas/arc/attr-hs34.d: Likewise. * testsuite/gas/arc/attr-hs38.d: Likewise. * testsuite/gas/arc/attr-hs38_linux.d: Likewise. * testsuite/gas/arc/attr-mul64.d: Likewise. * testsuite/gas/arc/attr-name.d: Likewise. * testsuite/gas/arc/attr-nps400.d: Likewise. * testsuite/gas/arc/attr-override-mcpu.d: Likewise. * testsuite/gas/arc/attr-quarkse_em.d: Likewise. bfd/ 2017-08-02 Claudiu Zissulescu <claziss@synopsys.com> * elf32-arc.c (arc_elf_merge_attributes): Handle Tag_ARC_ATR_version. binutils/ 2017-08-02 Claudiu Zissulescu <claziss@synopsys.com> * readelf.c (display_arc_attribute): Print Tag_ARC_ATR_version. include/ 2017-08-02 Claudiu Zissulescu <claziss@synopsys.com> * elf/arc.h (Tag_ARC_ATR_version): New tag. ld/ 2017-08-02 Claudiu Zissulescu <claziss@synopsys.com> * testsuite/ld-arc/attr-merge-0.d: Update test. * testsuite/ld-arc/attr-merge-1.d: Likewise. * testsuite/ld-arc/attr-merge-2.d: Likewise. * testsuite/ld-arc/attr-merge-3.d: Likewise. * testsuite/ld-arc/attr-merge-5.d: Likewise.
2018-08-05R_PPC64_REL24_NOTOC supportAlan Modra7-0/+201
R_PPC64_REL24_NOTOC is used on calls like "bl foo@notoc" to tell the linker that linkage stubs for PLT calls or long branches can't use r2 for pic addressing. Instead, new stubs that generate pc-relative addresses are used. One complication is that pc-relative offsets to the PLT may need to be 64-bit in large programs, in contrast to the toc-relative addressing used by older PLT linkage stubs where a 32-bit offset is sufficient until the PLT itself exceeds 2G in size. .eh_frame info to cover the _notoc stubs is yet to be implemented. bfd/ * elf64-ppc.c (ADDI_R12_R11, ADDI_R12_R12, LIS_R12), (ADDIS_R12_R11, ORIS_R12_R12_0, ORI_R12_R12_0), (SLDI_R12_R12_32, LDX_R12_R11_R12, ADD_R12_R11_R12): Define. (ppc64_elf_howto_raw): Add R_PPC64_REL24_NOTOC entry. (ppc64_elf_reloc_type_lookup): Support R_PPC64_REL24_NOTOC. (ppc_stub_type): Add ppc_stub_long_branch_notoc, ppc_stub_long_branch_both, ppc_stub_plt_branch_notoc, ppc_stub_plt_branch_both, ppc_stub_plt_call_notoc, and ppc_stub_plt_call_both. (is_branch_reloc): Add R_PPC64_REL24_NOTOC. (build_offset, size_offset): New functions. (plt_stub_size): Support plt_call_notoc and plt_call_both. (ppc_build_one_stub, ppc_size_one_stub): Support new stubs. (toc_adjusting_stub_needed): Handle R_PPC64_REL24_NOTOC. (ppc64_elf_size_stubs): Likewise, and new stubs. (ppc64_elf_build_stubs, ppc64_elf_relocate_section): Likewise. * reloc.c: Add BFD_RELOC_PPC64_REL24_NOTOC. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. gas/ * config/tc-ppc.c (ppc_elf_suffix): Support @notoc. (ppc_force_relocation, ppc_fix_adjustable): Handle REL24_NOTOC. ld/ * testsuite/ld-powerpc/ext.d, * testsuite/ld-powerpc/ext.s, * testsuite/ld-powerpc/ext.lnk, * testsuite/ld-powerpc/notoc.d, * testsuite/ld-powerpc/notoc.s: New tests. * testsuite/ld-powerpc/powerpc.exp: Run them.
2018-08-05Lose _r2off in powerpc64 stub namesAlan Modra3-6/+11
Not a lot is conveyed by putting _r2off in a stub symbol that can't be seen by inspecting the stub code or the toc restoring instruction immediately after a call via such a stub. Also, we don't distinguish plt_call stub symbols from plt_call_r2save stub symbols, so this patch makes long branch and plt branch stub symbols consistent with that decision. bfd/ * elf64-ppc.c (ppc_build_one_stub): Lose "_r2off" in stub symbols. ld/ * testsuite/ld-powerpc/elfv2exe.d: Adjust for stub symbol change. * testsuite/ld-powerpc/tocopt6.d: Likewise.
2018-08-03x32: Align the .note.gnu.property section to 4 bytesH.J. Lu2-0/+9
The .note.gnu.property section should be aligned to 4 bytes for x32. * testsuite/ld-x86-64/property-x86-3.s: Use ".p2align 2" to align .note.gnu.property section if __64_bit__ is undefined.
2018-08-03Update PRU assembler to corect hardware register numbering for DWARF.Dimitar Dimitrov1-1/+1
A small rework of the PRU GCC port exposed that CIE data alignment is erroneously set to 4 for PRU in GAS. In fact PRU stack must be aligned to 1. Set the macro to -1, to allow output from GCC to be assembled without errors. Also, while at it, set DWARF2 HW register numbering to follow latest * config/tc-pru.c (pru_regname_to_dw2regnum): Return the starting HW byte-register number. (pru_frame_initial_instructions): Use byte-numbering for FP index. * config/tc-pru.h (DWARF2_DEFAULT_RETURN_COLUMN): Use number from latest GCC. (DWARF2_CIE_DATA_ALIGNMENT): Set to -1.
2018-08-02Disable the PR12982 test for HPPA targets.Nick Clifton3-6/+20
PR 23463 * testsuite/ld-plugin/pr12982.d: Revert previous delta. * testsuite/ld-plugin/lto.exp: Skip the pr12982 test for HPPA targets.
2018-08-02ifunc.exp: Always build static_nonifunc_progH.J. Lu2-4/+8
Since static_nonifunc_prog isn't linked against libc.a, we can always build it. * testsuite/ld-ifunc/ifunc.exp: Always build static_nonifunc_prog.
2018-08-02Add a testcase for PR binutils/23460H.J. Lu8-0/+61
Add a testcase to limit open files to 16 for AR with plugin. Before commit 103da91bc083f94769e3758175a96d06cef1f8fe Author: Nick Clifton <nickc@redhat.com> Date: Wed Aug 1 14:34:41 2018 +0100 Close resource leaks in the BFD library's plugin handler. it failed with: ../binutils/ar: tmpdir/pr23460f.o: plugin needed to handle lto object PR binutils/23460 * testsuite/ld-plugin/lto.exp: Run the PR binutils/23460 test. * testsuite/ld-plugin/pr23460a.c: New file. * testsuite/ld-plugin/pr23460b.c: Likewise. * testsuite/ld-plugin/pr23460c.c: Likewise. * testsuite/ld-plugin/pr23460d.c: Likewise. * testsuite/ld-plugin/pr23460e.c: Likewise. * testsuite/ld-plugin/pr23460f.c: Likewise.
2018-08-01Fix spurious check-ld failures on aarch64-elfRoland McGrath7-14/+24
ld/ * testsuite/ld-aarch64/ifunc-1-local.d: Adjust regexps to match the offsets emitted by aarch64-elf configurations. * testsuite/ld-aarch64/ifunc-1.d: Likewise. * testsuite/ld-aarch64/ifunc-2-local.d: Likewise. * testsuite/ld-aarch64/ifunc-2.d: Likewise. * testsuite/ld-aarch64/ifunc-21.d: Likewise. * testsuite/ld-aarch64/ifunc-3a.d: Likewise.
2018-08-01Skip the test for PR12982 on HPPA targets as they always need an executable ↵Nick Clifton2-0/+9
stack. PR 23463 * testsuite/ld-plugin/pr12982.d: Skip thios test for the HPPA target.
2018-08-01Re: PowerPC64 __tls_get_addr_opt stub .eh_frame fixAlan Modra2-1/+6
The modified test failed on some powerpc targets due to differences in default hash style. If the default hash style is both, then more sections are created, bumping section ids. Section id is used in stub symbols and although the test is careful to not depend on id in labels, the stub hash traversal order changes when stub names change. That lead to the stubs being emitted in a different order and thus not matching expected output. * testsuite/ld-powerpc/powerpc.exp: Run tlsopt5 with hash-style specified.
2018-08-01PowerPC64 __tls_get_addr_opt stub .eh_frame fixAlan Modra5-6/+29
This patch sets stub_offset in ppc_size_one_stub rather than in ppc_build_one_stub. That allows the plt stub alignment to be done in just ppc_size_one_stub rather than both functions. The patch also corrects the place where the alignment was done, fixing a possible error in .eh_frame data, and tidies some offset calculations. bfd/ * elf64-ppc.c (plt_stub_pad): Delay plt_stub_size call until needed. (ppc_build_one_stub): Don't set stub_offset, instead assert that it is sane. Don't adjust stub_offset for alignment. Adjust size calculation. Use "targ" temp when calculating offsets. (ppc_size_one_stub): Set stub_offset here. Use "targ" temp when calculating offsets. Adjust for alignment before setting tls_get_addr_opt_bctrl. ld/ * testsuite/ld-powerpc/powerpc.exp: Run tlsopt5 with plt alignment. * testsuite/ld-powerpc/tlsopt5.s: Add extra call. * testsuite/ld-powerpc/tlsopt5.wf: Adjust expected output. * testsuite/ld-powerpc/tlsopt5.d: Likewise.
2018-08-01csky regenAlan Modra2-0/+6
bfd/ * po/SRC-POTFILES.in: Regenerate. gas/ * po/POTFILES.in: Regenerate. ld/ * po/BLD-POTFILES.in: Regenerate. opcodes/ * po/POTFILES.in: Regenerate.
2018-07-30Fix thinko in the placement of the .gnu.build.attributes section.Nick Clifton2-1/+7
* scripttempl/elf.sc: Move the .gnu.build.attributes section to after the .comment section.
2018-07-30Add support for the C_SKY series of processors.Andrew Jenner44-4/+1132
This patch series is a new binutils port for C-SKY processors, including support for both the V1 and V2 processor variants. V1 is derived from the MCore architecture while V2 is substantially different, with mixed 16- and 32-bit instructions, a larger register set, a different (but overlapping) ABI, etc. There is support for bare-metal ELF targets and Linux with both glibc and uClibc. This code is being contributed jointly by C-SKY Microsystems and Mentor Graphics. C-SKY is responsible for the technical content and has proposed Lifang Xia and Yunhai Shang as port maintainers. (Note that C-SKY does have a corporate copyright assignment on file with the FSF.) Mentor Graphics' role has been cleaning up the code, adding documentation and additional test cases, etc, to address issues we anticipated reviewers would complain about. bfd * Makefile.am (ALL_MACHINES, ALL_MACHINES_CFILES): Add C-SKY. (BFD32_BACKENDS, BFD_BACKENDS_CFILES): Likewise. * Makefile.in: Regenerated. * archures.c (enum bfd_architecture): Add bfd_arch_csky and related bfd_mach defines. (bfd_csky_arch): Declare. (bfd_archures_list): Add C-SKY. * bfd-in.h (elf32_csky_build_stubs): Declare. (elf32_csky_size_stubs): Declare. (elf32_csky_next_input_section: Declare. (elf32_csky_setup_section_lists): Declare. * bfd-in2.h: Regenerated. * config.bfd: Add C-SKY. * configure.ac: Likewise. * configure: Regenerated. * cpu-csky.c: New file. * elf-bfd.h (enum elf_target_id): Add C-SKY. * elf32-csky.c: New file. * libbfd.h: Regenerated. * reloc.c: Add C-SKY relocations. * targets.c (csky_elf32_be_vec, csky_elf32_le_vec): Declare. (_bfd_target_vector): Add C-SKY target vector entries. binutils* readelf.c: Include elf/csky.h. (guess_is_rela): Handle EM_CSKY. (dump_relocations): Likewise. (get_machine_name): Likewise. (is_32bit_abs_reloc): Likewise. include * dis-asm.h (csky_symbol_is_valid): Declare. * opcode/csky.h: New file. opcodes * Makefile.am (TARGET_LIBOPCODES_CFILES): Add csky-dis.c. * Makefile.in: Regenerated. * configure.ac: Add C-SKY. * configure: Regenerated. * csky-dis.c: New file. * csky-opc.h: New file. * disassemble.c (ARCH_csky): Define. (disassembler, disassemble_init_for_target): Add case for ARCH_csky. * disassemble.h (print_insn_csky, csky_get_disassembler): Declare. gas * Makefile.am (TARGET_CPU_CFILES): Add entry for C-SKY. (TARGET_CPU_HFILES, TARGET_ENV_HFILES): Likewise. * Makefile.in: Regenerated. * config/tc-csky.c: New file. * config/tc-csky.h: New file. * config/te-csky_abiv1.h: New file. * config/te-csky_abiv1_linux.h: New file. * config/te-csky_abiv2.h: New file. * config/te-csky_abiv2_linux.h: New file. * configure.tgt: Add C-SKY. * doc/Makefile.am (CPU_DOCS): Add entry for C-SKY. * doc/Makefile.in: Regenerated. * doc/all.texi: Set CSKY feature. * doc/as.texi (Overview): Add C-SKY options. (Machine Dependencies): Likewise. * doc/c-csky.texi: New file. * testsuite/gas/csky/*: New test cases. ld * Makefile.am (ALL_EMULATION_SOURCES): Add C-SKY emulations. (ecskyelf.c, ecskyelf_linux.c): New rules. * Makefile.in: Regenerated. * configure.tgt: Add C-SKY. * emulparams/cskyelf.sh: New file. * emulparams/cskyelf_linux.sh: New file. * emultempl/cskyelf.em: New file. * gen-doc.texi: Add C-SKY. * ld.texi: Likewise. (Options specific to C-SKY targets): New section. * testsuite/ld-csky/*: New tests.
2018-07-30Combine ,gnu.build.attributes.* sections into one .gnu.build.attributes ↵Nick Clifton2-0/+6
section during linking. gold * layout.cc (section_name_mapping): Add an entry for .gnu.build.attributes. ld * scripttempl/elf.sc: Place .gnu.build.attributes sections with other read-only sections.
2018-07-27S12Z: Emit uninitialized data in the .bss segmentJohn Darrington2-0/+6
* scripttempl/elfm9s12z.sc: Put input sections called .common into the .bss segment.
2018-07-27S12Z: Emit initialized data segment image.John Darrington2-3/+7
* scripttempl/elfm9s12z.sc: Emit the data_section at the end of text.
2018-07-26Re: Enhance powerpc ld -r --relaxAlan Modra2-3/+7
git commit 491993044ba6 broke the powerpc vxworks testsuite. * testsuite/ld-powerpc/vxworks-relax-2.rd: Update for 2018-07-25 ppc_elf_relax_section changes.
2018-07-26Implement PowerPC64 .localentry for value 1Alan Modra4-17/+58
This adds support for ".localentry 1", a new st_other STO_PPC64_LOCAL_MASK encoding that signifies a function with a single entry point like ".localentry 0", but unlike a ".localentry 0" function does not preserve r2. include/ * elf/ppc64.h: Specify byte offset to local entry for values of two to six in STO_PPC64_LOCAL_MASK. Clarify r2 return value for such functions when entering via global entry point. Specify meaning of a value of one in STO_PPC64_LOCAL_MASK. bfd/ * elf64-ppc.c (ppc64_elf_size_stubs): Use a ppc_stub_long_branch_r2off for calls to symbols with STO_PPC64_LOCAL_MASK bits set to 1. gas/ * config/tc-ppc.c (ppc_elf_localentry): Allow .localentry values of 1 and 7 to directly set value into STO_PPC64_LOCAL_MASK bits. ld/testsuite/ * ld-powerpc/elfv2.s: Add .localentry f5,1 testcase. * ld-powerpc/elfv2exe.d: Update. * ld-powerpc/elfv2so.d: Update.
2018-07-25Enhance powerpc ld -r --relaxAlan Modra5-18/+47
One of the ill effects of ld -r is to mash together sections. That can result in reduced icache performance at runtime due to unexpected movement of code. Another problem is that sections can become too large to link on targets that have limited relative addressing. ld -r --relax attempts to overcome the large section problem for branches by inserting trampolines, but the powerpc support added lots of unnecessary trampolines. This patch trims them somewhat. bfd/ * elf32-ppc.c (ppc_elf_relax_section): Ignore common or undef locals. Avoid trashing toff with added when used as a symbol index. Ignore R_PPC_PLTREL24 addends in unused example code. Avoid creating unnecessary fixups when relocatable. ld/ * testsuite/ld-powerpc/big.s: New file. * testsuite/ld-powerpc/relaxrl.d: New test. * testsuite/ld-powerpc/powerpc.exp: Run new test. * testsuite/ld-powerpc/relaxr.d: Adjust.
2018-07-24Updated French translation for ld/ and Swedish translation for binutils/Nick Clifton2-1219/+6208
bin * po/sv.po: Updated Swedish translation. ld * po/fr.po: Updated French translation.
2018-07-23xtensa: ld: convert tests to run_dump_testMax Filippov8-257/+38
Three tests with individual .exp files can be implemented in less verbose way with run_dump_test infrastructure. Convert them. ld/ 2018-07-23 Max Filippov <jcmvbkbc@gmail.com> * testsuite/ld-xtensa/coalesce.d: New file. * testsuite/ld-xtensa/coalesce.exp: Remove file. * testsuite/ld-xtensa/diff_overflow.d: New file. * testsuite/ld-xtensa/diff_overflow.exp: Remove file. * testsuite/ld-xtensa/lcall.d: New file. * testsuite/ld-xtensa/lcall.exp: Remove file. * testsuite/ld-xtensa/xtensa.exp (coalesce, diff_overflow) (lcall): New tests.
2018-07-23xtensa: ld: add tests for static linkage relaxationMax Filippov15-0/+249
ld/ 2018-07-23 Max Filippov <jcmvbkbc@gmail.com> * testsuite/ld-xtensa/relax-static-defs.s: New file. * testsuite/ld-xtensa/relax-static-local-pie.d: New file. * testsuite/ld-xtensa/relax-static-local-shared.d: New file. * testsuite/ld-xtensa/relax-static-local.s: New file. * testsuite/ld-xtensa/relax-static-pie.d: New file. * testsuite/ld-xtensa/relax-static-shared.d: New file. * testsuite/ld-xtensa/relax-static.s: New file. * testsuite/ld-xtensa/relax-undef-weak-local-pie.d: New file. * testsuite/ld-xtensa/relax-undef-weak-local-shared.d: New file. * testsuite/ld-xtensa/relax-undef-weak-local.s: New file. * testsuite/ld-xtensa/relax-undef-weak-pie.d: New file. * testsuite/ld-xtensa/relax-undef-weak-shared.d: New file. * testsuite/ld-xtensa/relax-undef-weak.s: New file. * testsuite/ld-xtensa/xtensa.exp: New file.
2018-07-23xtensa: ld: rename xtensa.exp to xtensa-linux.expMax Filippov2-0/+4
xtensa.exp in fact only checks xtensa*-*-linux* configurations, rename it to xtensa-linux.exp to allow xtensa.exp to check xtensa*-*-*. ld/ 2018-07-23 Max Filippov <jcmvbkbc@gmail.com> * testsuite/ld-xtensa/xtensa.exp: Rename to xtensa-linux.exp.
2018-07-23PowerPC64 fails reloc-discard testAlan Modra3-0/+18
PowerPC64 fails here due to emitting a warning about discarded dynamic relocations. That's a good thing, since accidentally discarding dynamic relocations will likely result in a non-working binary. * testsuite/ld-elf/reloc-discard-warn.d: New. * testsuite/ld-elf/reloc-discard.d: Skip test on PowerPC64.
2018-07-20ld: Discard .rel.* and .rela.* sectionsH.J. Lu2-1/+6
On many targets, like x86, .rel.dyn/.rela.dyn section is combined from different .rel/.rela sections by -z combreloc. To discard dynamic relocation section, we need to discard .rel.* and .rela.* sections instead of .rel.dyn and .rela.dyn sections. Note: This test fails for targets which issue a warning when dynamic section is discarded. * testsuite/ld-elf/reloc-discard.ld: Discard .rel.* and .rela.* sections instead of .rel.dyn and .rela.dyn sections.
2018-07-20x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if neededH.J. Lu18-10/+195
When -z separate-code, which is enabled by default for Linux/x86, is used to create executable, ld won't place any data in the code-only PT_LOAD segment. If there are no data sections placed before the code-only PT_LOAD segment, the program headers won't be mapped into any PT_LOAD segment. When the executable tries to access it (based on the program header address passed in AT_PHDR), it will lead to segfault. This patch inserts a GNU_PROPERTY_X86_ISA_1_USED note if there may be no data sections before the text section so that the first PT_LOAD segment won't be code-only and will contain the program header. Testcases are adjusted to either pass "-z noseparate-code" to ld or discard the .note.gnu.property section. A Linux/x86 run-time test is added. bfd/ PR ld/23428 * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): If the separate code program header is needed, make sure that the first read-only PT_LOAD segment has no code by adding a GNU_PROPERTY_X86_ISA_1_USED note. ld/ PR ld/23428 * testsuite/ld-elf/linux-x86.S: New file. * testsuite/ld-elf/linux-x86.exp: Likewise. * testsuite/ld-elf/pr23428.c: Likewise. * testsuite/ld-elf/sec64k.exp: Pass "-z noseparate-code" to ld for Linux/x86 targets. * testsuite/ld-i386/abs-iamcu.d: Likewise. * testsuite/ld-i386/abs.d: Likewise. * testsuite/ld-i386/pr12718.d: Likewise. * testsuite/ld-i386/pr12921.d: Likewise. * testsuite/ld-x86-64/abs-k1om.d: Likewise. * testsuite/ld-x86-64/abs-l1om.d: Likewise. * testsuite/ld-x86-64/abs.d: Likewise. * testsuite/ld-x86-64/pr12718.d: Likewise. * testsuite/ld-x86-64/pr12921.d: Likewise. * testsuite/ld-linkonce/zeroeh.ld: Discard .note.gnu.property section. * testsuite/ld-scripts/print-memory-usage.t: Likewise. * testsuite/ld-scripts/size-2.t: Likewise. * testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use ld to create executable if language is "asm".
2018-07-20[PATCH, LD, AArch64] Fix ifunc testismsAndre Simoes Dias Vieira2-2/+3
This patch fixes some ifunc testisms after H.J. Lu's patch to enable the use of IFUNC pointers in position dependent code for binutils. See PR LD/23169 in binutils bugzilla. The aarch64 ifunc error message test was changed to no longer expect this error message as this is now an accepted combination. This patch also disables the executable tests added by H.J. Lu for aarch64, just as Alan Modra did with his patch, as these tests only seem to work on some architectures. ld/ChangeLog: 2018-07-19 Andre Vieira <andre.simoesdiasvieira@arm.com> * testsuite/ld-aarch64/ifunc-9.d: Remove no longer expected error. * testsuite/ld-ifunc/ifunc.exp: Disable tests for aarch64.
2018-07-20MIPS/LD: Fix crashing with a discarded dynamic relocation sectionMaciej W. Rozycki4-0/+24
Fix a crash that occurs in `_bfd_mips_elf_finish_dynamic_sections' if a dynamic relocation section has been created, but marked to be discarded by an assignment to the /DISCARD/ output section in a linker script. In that case the output section is the absolute section, which has no ELF section data attached, so trying to set its `sh_size' parameter causes a null pointer dereference. This is only done as the value for the DT_RELSZ dynamic entry is being set, so fix the problem by not creating DT_REL, DT_RELSZ or DT_RELENT dynamic entries in the first place if the dynamic relocation section will not be output, as with no dynamic relocation data present these would not serve their purpose anyway. Add a generic ELF test case to verify that no dynamic relocation data is reported in the dynamic segment. bfd/ * elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Do not create DT_REL, DT_RELSZ or DT_RELENT dynamic entries if the dynamic relocation section will be discarded from output. (_bfd_mips_elf_finish_dynamic_sections) <DT_RELSZ>: Assert that the dynamic relocation section will be retained in output. ld/ * testsuite/ld-elf/reloc-discard.d: New test. * testsuite/ld-elf/reloc-discard.ld: New test linker script. * testsuite/ld-elf/reloc-discard.s: New test source.
2018-07-18S/390: Improve partial relro support for 64 bitAndreas Krebbel4-3/+23
Currently on S/390 the .got.plt always comes first which prevents the GNU_RELRO segment from being extended across the non-plt GOT entries. Just swapping both unfortunately is not that simple since our ABI requires the _GLOBAL_OFFSET_TABLE_ symbol to point to the very beginning of the entire GOT. Of the 3 magic GOT entries the first is accessed via got pointer while second and third are being accessed via DT_PLTGOT. In order to keep them together we make DT_PLTGOT to point to the .got instead of .got.plt. However, this violates an assumption in the dynamic linker prelink undo code about the GOTPLT entries starting at DT_PLTGOT + 3. We got rid of this requirement with a Glibc patch already in version 2.24: https://sourceware.org/ml/libc-alpha/2016-06/msg01302.html So the S/390 relro GOT layout will look like this with this patch: +----------------------------------+ |got[0]: DYNAMIC | <--- _GLOBAL_OFFSET_TABLE_ == DT_PLTGOT .got |got[1]: link_map parm | |got[2]: &_dl_runtime_resolve | +----------------------------------+ | | non-plt GOT entries | | | | +----------------------------------+ | | <--- .gotplt, PLT GOT entries | | | | | | +----------------------------------+ The patch detects the current layout in size_dynamic_section in order to deal also with linker scripts not generated by this ld version. With partial relro enabled we pick a linker script where .got and .got.plt are swapped which then triggers the rest of the logic. ld/ChangeLog: 2018-07-18 Andreas Krebbel <krebbel@linux.ibm.com> * emulparams/elf64_s390.sh: Define GENERATE_RELRO_SCRIPT and SEPARATE_GOTPLT. * testsuite/ld-s390/gotreloc_64-relro-1.dd: New test. * testsuite/ld-s390/gotreloc_64-norelro-1.dd: Renamed from ... * testsuite/ld-s390/gotreloc_64-1.dd: ... this. * testsuite/ld-s390/s390.exp: Split the GOT testcase into two. bfd/ChangeLog: 2018-07-18 Andreas Krebbel <krebbel@linux.ibm.com> * elf-s390-common.c (s390_gotplt_after_got_p): New function. (s390_got_pointer): New function. (s390_got_offset): New function. (s390_gotplt_offset): New function. * elf64-s390.c (allocate_dynrelocs): Adjust comment. (elf_s390_size_dynamic_sections): Move space for magic GOT entries from .got.plt to .got if necessary and pick the right location for _GLOBAL_OFFSET_TABLE_. (elf_s390_relocate_section): Use the wrapper functions from elf-s390-common.c to deal with both possible layouts (either .got or .got.plt first). (elf_s390_finish_dynamic_sections): Likewise. (elf_s390_finish_dynamic_symbol): Make the location of the GOT magic entries conditional.
2018-07-18ld: Enable using separate linker script for -z relroAndreas Krebbel2-8/+291
With this patch dedicated linker scripts can be generated for partial relro triggered by defining GENERATE_RELRO_SCRIPT in the target specific scripts. This is necessary for e.g. S/390 where usually the .got.plt comes first and prevents the relro segment from being extended across the non-plt GOT entries. The patch started with the work from Marcin taken from the mwk user branches. However, the patch needed substantial changes due to the 'separate code' feature which got committed in the meantime. ld/ChangeLog: 2018-07-18 Andreas Krebbel <krebbel@linux.ibm.com> Marcin Kościelnicki <koriakin@0x04.net> * emultempl/elf32.em: Add code to pick dedicated linker scripts for partial relro. * genscripts.sh: Generate dedicated linker scripts for partial relro.