aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2019-04-15[binutils, ARM, 6/16] New BF instruction for Armv8.1-M MainlineAndre Vieira4-0/+43
This patch is part of a series of patches to add support for Armv8.1-M Mainline instructions to binutils. This patch adds the BF instruction. ChangeLog entries are as follows: *** gas/ChangeLog *** 2019-04-15 Sudakshina Das <sudi.das@arm.com> Andre Vieira <andre.simoesdiasvieira@arm.com> * config/tc-arm.c (T16_32_TAB): New entries for bf. (do_t_branch_future): New. (insns): New instruction for bf. * testsuite/gas/arm/armv8_1-m-bf.d: New. * testsuite/gas/arm/armv8_1-m-bf.s: New. * testsuite/gas/arm/armv8_1-m-bf-bad.s: New. * testsuite/gas/arm/armv8_1-m-bf-bad.l: New. * testsuite/gas/arm/armv8_1-m-bf-bad.d: New. * testsuite/gas/arm/armv8_1-m-bf-rel.d: New. * testsuite/gas/arm/armv8_1-m-bf-rel.s: New. *** ld/ChangeLog *** 2019-04-15 Sudakshina Das <sudi.das@arm.com> * testsuite/ld-arm/bf.s: New. * testsuite/ld-arm/bf.d: New. * testsuite/ld-arm/arm-elf.exp: Add above test. *** opcodes/ChangeLog *** 2019-04-15 Sudakshina Das <sudi.das@arm.com> * arm-dis.c (thumb32_opcodes): New instructions for bf.
2019-04-15[binutils, ARM, 1/16] Add support for Armv8.1-M Mainline CLIAndre Vieira4-0/+22
The patch is straightforward, it does the following: - support the new Tag_CPU_arch build attribute value, ie.: + declare the new value + update all the asserts forcing logic to be reviewed for new architectures + create a corresponding bfd_mach_arm_8_1M_MAIN enumerator in bfd and add mapping from Tag_CPU_arch to it + teach readelf about new Tag_CPU_arch value - declare armv8.1-m.main as a supported architecture value - define Armv8.1-M Mainline in terms of feature bits available - tell objdump mapping from bfd_mach_arm_8_1M_MAIN enumerator to feature bits available - update architecture-specific logic in gas and bfd guarded by the asserts mentioned above. - tests for all the above ChangeLog entries are as follows: *** bfd/ChangeLog *** 2019-04-15 Thomas Preud'homme <thomas.preudhomme@arm.com> * archures.c (bfd_mach_arm_8_1M_MAIN): Define. * bfd-in2.h: Regenerate. * cpu-arm.c (arch_info_struct): Add entry for Armv8.1-M Mainline. * elf32-arm.c (using_thumb_only): Return true for Armv8.1-M Mainline and update assert. (using_thumb2): Likewise. (using_thumb2_bl): Update assert. (arch_has_arm_nop): Likewise. (bfd_arm_get_mach_from_attributes): Add case for Armv8.1-M Mainline. (tag_cpu_arch_combine): Add logic for Armv8.1-M Mainline merging. *** binutils/ChangeLog *** 2019-04-15 Thomas Preud'homme <thomas.preudhomme@arm.com> * readelf.c (arm_attr_tag_CPU_arch): Add entry for Armv8.1-M Mainline. *** gas/ChangeLog *** 2019-04-15 Thomas Preud'homme <thomas.preudhomme@arm.com> * config/tc-arm.c (cpu_arch_ver): Add entry for Armv8.1-M Mainline Tag_CPU_arch build attribute value. Reindent. (get_aeabi_cpu_arch_from_fset): Update assert. (aeabi_set_public_attributes): Update assert for Tag_DIV_use logic. * testsuite/gas/arm/attr-march-armv8_1-m.main.d: New test. *** include/ChangeLog *** 2019-04-15 Thomas Preud'homme <thomas.preudhomme@arm.com> * elf/arm.h (TAG_CPU_ARCH_V8_1M_MAIN): new macro. (MAX_TAG_CPU_ARCH): Set value to above macro. * opcode/arm.h (ARM_EXT2_V8_1M_MAIN): New macro. (ARM_AEXT_V8_1M_MAIN): Likewise. (ARM_AEXT2_V8_1M_MAIN): Likewise. (ARM_ARCH_V8_1M_MAIN): Likewise. *** ld/ChangeLog *** 2019-04-15 Thomas Preud'homme <thomas.preudhomme@arm.com> * testsuite/ld-arm/attr-merge-13.attr: New test. * testsuite/ld-arm/attr-merge-13a.s: New test. * testsuite/ld-arm/attr-merge-13b.s: New test. *** opcodes/ChangeLog *** 2019-04-15 Thomas Preud'homme <thomas.preudhomme@arm.com> * arm-dis.c (select_arm_features): Add logic for Armv8.1-M Mainline.
2019-04-13Automatic makefile dependencies for generated ld/e*.cAlan Modra155-2808/+1050
This patch modifies genscripts.sh to emit dependency info along with the generated emulation e*.c files. This is done by a new source_sh function that records its arg to a file (.deps/e*.Tc), using the function whenever a shell script is sourced. Entries in the file are made unique and written to .deps/e*.Pc. These files are then included by the Makefile. * Makefile.am (GENSCRIPTS): Pass LIB_PATH as a parameter. Add DEPDIR parameter. (ELF_DEPS, ELF_GEN_DEPS, ELF_X86_DEPS): Delete. (ALL_EMULATION_SOURCES, ALL_64_EMULATION_SOURCES): Depend on $GEN_DEPENDS. (e*.c): Delete all dependencies, instead include dependencies from $DEPDIR/*.Pc. * Makefile.in: Regenerate. * configure.ac (source_sh): Define and use function. * configure: Regenerate. * emulparams/aarch64cloudabib.sh, * emulparams/aarch64elf32b.sh, * emulparams/aarch64elfb.sh, * emulparams/aarch64fbsdb.sh, * emulparams/aarch64linux32b.sh, * emulparams/aarch64linuxb.sh, * emulparams/arcelf.sh, * emulparams/arcelf_prof.sh, * emulparams/arclinux.sh, * emulparams/arclinux_nps.sh, * emulparams/arclinux_prof.sh, * emulparams/arcv2elf.sh, * emulparams/arcv2elfx.sh, * emulparams/armelf_fbsd.sh, * emulparams/armelf_linux_eabi.sh, * emulparams/armelf_linux_fdpiceabi.sh, * emulparams/armelf_nacl.sh, * emulparams/armelf_nbsd.sh, * emulparams/armelf_vxworks.sh, * emulparams/armelfb.sh, * emulparams/armelfb_fbsd.sh, * emulparams/armelfb_fuchsia.sh, * emulparams/armelfb_linux.sh, * emulparams/armelfb_linux_eabi.sh, * emulparams/armelfb_linux_fdpiceabi.sh, * emulparams/armelfb_nacl.sh, * emulparams/armelfb_nbsd.sh, * emulparams/armsymbian.sh, * emulparams/cskyelf_linux.sh, * emulparams/elf32_sparc_sol2.sh, * emulparams/elf32_sparc_vxworks.sh, * emulparams/elf32_tic6x_be.sh, * emulparams/elf32_tic6x_elf_be.sh, * emulparams/elf32_tic6x_elf_le.sh, * emulparams/elf32_tic6x_linux_be.sh, * emulparams/elf32_tic6x_linux_le.sh, * emulparams/elf32_x86_64.sh, * emulparams/elf32_x86_64_nacl.sh, * emulparams/elf32b4300.sh, * emulparams/elf32bfinfd.sh, * emulparams/elf32bmipn32.sh, * emulparams/elf32bsmip.sh, * emulparams/elf32btsmip.sh, * emulparams/elf32btsmip_fbsd.sh, * emulparams/elf32btsmipn32.sh, * emulparams/elf32btsmipn32_fbsd.sh, * emulparams/elf32ebmip.sh, * emulparams/elf32ebmipvxworks.sh, * emulparams/elf32elmip.sh, * emulparams/elf32elmipvxworks.sh, * emulparams/elf32frvfd.sh, * emulparams/elf32l4300.sh, * emulparams/elf32lm32fd.sh, * emulparams/elf32lmip.sh, * emulparams/elf32lppc.sh, * emulparams/elf32lppclinux.sh, * emulparams/elf32lppcnto.sh, * emulparams/elf32lppcsim.sh, * emulparams/elf32lr5900.sh, * emulparams/elf32lr5900n32.sh, * emulparams/elf32lriscv.sh, * emulparams/elf32lriscv_ilp32.sh, * emulparams/elf32lriscv_ilp32f.sh, * emulparams/elf32lsmip.sh, * emulparams/elf32ltsmip.sh, * emulparams/elf32ltsmip_fbsd.sh, * emulparams/elf32ltsmipn32.sh, * emulparams/elf32ltsmipn32_fbsd.sh, * emulparams/elf32microblazeel.sh, * emulparams/elf32or1k_linux.sh, * emulparams/elf32ppc.sh, * emulparams/elf32ppc_fbsd.sh, * emulparams/elf32ppccommon.sh, * emulparams/elf32ppclinux.sh, * emulparams/elf32ppcnto.sh, * emulparams/elf32ppcsim.sh, * emulparams/elf32ppcvxworks.sh, * emulparams/elf32ppcwindiss.sh, * emulparams/elf32tilegx_be.sh, * emulparams/elf64_ia64_fbsd.sh, * emulparams/elf64_sparc_fbsd.sh, * emulparams/elf64_sparc_sol2.sh, * emulparams/elf64alpha_fbsd.sh, * emulparams/elf64alpha_nbsd.sh, * emulparams/elf64bmip-defs.sh, * emulparams/elf64bmip.sh, * emulparams/elf64btsmip.sh, * emulparams/elf64btsmip_fbsd.sh, * emulparams/elf64lppc.sh, * emulparams/elf64lriscv-defs.sh, * emulparams/elf64lriscv.sh, * emulparams/elf64lriscv_lp64.sh, * emulparams/elf64lriscv_lp64f.sh, * emulparams/elf64ltsmip.sh, * emulparams/elf64ltsmip_fbsd.sh, * emulparams/elf64ppc.sh, * emulparams/elf64ppc_fbsd.sh, * emulparams/elf64rdos.sh, * emulparams/elf64tilegx_be.sh, * emulparams/elf_i386.sh, * emulparams/elf_i386_be.sh, * emulparams/elf_i386_fbsd.sh, * emulparams/elf_i386_ldso.sh, * emulparams/elf_i386_nacl.sh, * emulparams/elf_i386_sol2.sh, * emulparams/elf_i386_vxworks.sh, * emulparams/elf_iamcu.sh, * emulparams/elf_k1om.sh, * emulparams/elf_k1om_fbsd.sh, * emulparams/elf_l1om.sh, * emulparams/elf_l1om_fbsd.sh, * emulparams/elf_x86_64.sh, * emulparams/elf_x86_64_cloudabi.sh, * emulparams/elf_x86_64_fbsd.sh, * emulparams/elf_x86_64_nacl.sh, * emulparams/elf_x86_64_sol2.sh, * emulparams/h8300helf.sh, * emulparams/h8300helf_linux.sh, * emulparams/h8300hnelf.sh, * emulparams/h8300self.sh, * emulparams/h8300self_linux.sh, * emulparams/h8300snelf.sh, * emulparams/h8300sxelf.sh, * emulparams/h8300sxelf_linux.sh, * emulparams/h8300sxnelf.sh, * emulparams/hppanbsd.sh, * emulparams/hppaobsd.sh, * emulparams/m32rlelf.sh, * emulparams/m32rlelf_linux.sh, * emulparams/m68kelfnbsd.sh, * emulparams/mn10300.sh, * emulparams/msp430X.sh, * emulparams/nds32belf.sh, * emulparams/nds32belf16m.sh, * emulparams/nds32belf_linux.sh, * emulparams/pjlelf.sh, * emulparams/ppclynx.sh, * emulparams/score7_elf.sh, * emulparams/shelf_fd.sh, * emulparams/shelf_linux.sh, * emulparams/shelf_nbsd.sh, * emulparams/shelf_uclinux.sh, * emulparams/shelf_vxworks.sh, * emulparams/shl.sh, * emulparams/shlelf.sh, * emulparams/shlelf_fd.sh, * emulparams/shlelf_nbsd.sh, * emulparams/shlelf_vxworks.sh: Use source_sh. * genscripts.sh: Adjust for changed parameters. Emit dependencies for e*.c to .deps/*.Pc. (source_sh): New function, use it throughout to source scripts. * genscrba.sh (source_em): Use source_sh.
2019-04-13ld TDIRS substitutionAlan Modra5-62/+28
It is no longer true that autoconf/automake cannot substitute vars with embedded new-lines. * configure.ac (TDIRS): Build up tdirs in this variable and AC_SUBST, also using AM_SUBST_NOTMAKE. * configure: Regenerate. * Makefile.am (DISTCLEANFILES): Remove tdirs. * Makefile.in: Regenerate.
2019-04-12Fix thinko in linker documentation.Nick Clifton2-1/+7
PR 24450 * ld.texi (Output Section Attributes): Add ALIGN_WITH_INPUT to example of section attributes.
2019-04-11ld: Add --no-print-map-discarded optionFaraz Shahbazker12-12/+76
Add a new option to disable the listing of discarded sections in map file output. The use case stems from a large application built with -ffunction-sections --gc-sections where the list of discarded sections blows up the map file output. The default behaviour remains to print discarded sections, but the new option allows us to disable it. ld/ * NEWS: Mention new option --no-print-map-discarded. * ld.h (ld_config_type) <print_map_discarded>: New field. * ldlang.c (lang_map): Conditionally output discarded sections in map files based on configuration option. * ldlex.h (option_values) <OPTION_PRINT_MAP_DISCARDED, OPTION_NO_PRINT_MAP_DISCARDED>: New. * ldmain.c (main): Enabled print_map_discarded by default. * lexsup.c (ld_options): Add new command-line options. (parse_args) <OPTION_NO_PRINT_MAP_DISCARDED, OPTION_PRINT_MAP_DISCARDED>: New cases. * ld.texi: Document new options. * testsuite/ld-gc/gc.exp: Add new test. * testsuite/ld-gc/skip-map-discarded.s: New file. * testsuite/ld-gc/skip-map-discarded.d: New file. * testsuite/ld-gc/skip-map-discarded.map: New file.
2019-04-11x86: Add -z cet-report=[none|warning|error]H.J. Lu36-0/+355
Add -z cet-report=[none|warning|error] to report the missing Intel Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK) properties in input .note.gnu.property section. -z cet-report=none, which is the default, will make the linker not report missing properties in input files. -z cet-report=warning will make the linker issue a warning for missing properties in input files. -z cet-report=error will make the linker issue an error for missing properties in input files. Note that -z ibt will turn off the missing IBT property report and -z shstk will turn off the missing SHSTK property report. Supported for Linux/i386 and Linux/x86_64. bfd/ * elf-linker-x86.h (elf_x86_cet_report): New. (elf_linker_x86_params): Add cet_report. * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Report missing IBT and SHSTK properties if needed. ld/ * ld.texi: Document -z cet-report=[none|warning|error]. * emulparams/cet.sh: Add -z cet-report=[none|warning|error]. * testsuite/ld-i386/i386.exp: Run -z cet-report=[warning|error] tests. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/property-x86-cet1.d: New file. * testsuite/ld-i386/property-x86-cet2a.d: Likewise. * testsuite/ld-i386/property-x86-cet2b.d: Likewise. * testsuite/ld-i386/property-x86-cet3a.d: Likewise. * testsuite/ld-i386/property-x86-cet3b.d: Likewise. * testsuite/ld-i386/property-x86-cet4a.d: Likewise. * testsuite/ld-i386/property-x86-cet4b.d: Likewise. * testsuite/ld-i386/property-x86-cet5a.d: Likewise. * testsuite/ld-i386/property-x86-cet5b.d: Likewise. * testsuite/ld-i386/property-x86-cet6.d: Likewise. * testsuite/ld-x86-64/property-x86-cet.s: Likewise. * testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet1.d: Likewise. * testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet2a.d: Likewise. * testsuite/ld-x86-64/property-x86-cet2b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet2b.d: Likewise. * testsuite/ld-x86-64/property-x86-cet3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet3a.d: Likewise. * testsuite/ld-x86-64/property-x86-cet3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet3b.d: Likewise. * testsuite/ld-x86-64/property-x86-cet4a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet4a.d: Likewise. * testsuite/ld-x86-64/property-x86-cet4b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet4b.d: Likewise. * testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet5a.d: Likewise. * testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet5b.d: Likewise. * testsuite/ld-x86-64/property-x86-cet6-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-cet6.d: Likewise.
2019-04-11ld: Add -static-pie testsH.J. Lu4-1/+110
Add -static-pie tests for DT_INIT_ARRAY, DT_FINI_ARRAY, DT_PREINIT_ARRAY and IFUNC. * testsuite/config/default.exp (STATIC_PIE_LDFLAGS): New. Set to "-static-pie" if target compiler supports it. * testsuite/ld-elf/elf.exp: Run -static-pie tests if $STATIC_PIE_LDFLAGS isn't empty. * testsuite/ld-ifunc/ifunc.exp: Likewise.
2019-04-11AArch64: When DF_BIND_NOW don't use TLSDESC GOT value.Tamar Christina3-0/+26
When using DF_BIND_NOW on AArch64 we don't reserve the GOT slot for a TLSDESC, but we still emitted DT_TLSDESC_GOT and DT_TLSDESC_PLT. This caused random memory corruption as the "special" value of (bfd_vma)-1 would be set for dt_tlsdesc_got. Since we don't have a value of dt_tlsdesc_got I also don't emit DT_TLSDESC_PLT now becuase it would point to an incomplete PLT. To be able to write the PLT entry DT_TLSDESC_GOT is needed and since we don't have one we can't write the PLT entry either. It is my understanding that GLIBC doesn't need these two entries when not lazy loading. Conversely AArch32 does not reserve neither the GOT not the PLT slot when doing DF_BIND_NOW. AArch32 does not need these checks because these values are initialized to 0 and so the if (...) checks don't pass, but on AArch64 these are initialized to (bfd_vma)-1 and thus we need some extra checks. bfd/ChangeLog: PR ld/24302 * elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Don't emit DT_TLSDESC_GOT and DT_TLSDESC_PLT when DF_BIND_NOW. (elfNN_aarch64_finish_dynamic_sections): Don't write PLT if DF_BIND_NOW. ld/ChangeLog: PR ld/24302 * testsuite/ld-aarch64/aarch64-elf.exp: Add new test. * testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: New test.
2019-04-10ld: Don't define __rel[a]_iplt_start/__rel[a]_iplt_end in PIEH.J. Lu2-8/+18
__rel[a]_iplt_start and __rel[a]_iplt_end are defined to handle IFUNC in static executables. For PIE, since IFUNC is handled as the part of the normal dynamic relocation processing, there is no need to define these symbols in PIE. * scripttempl/elf.sc (CREATE_PIC): New. Set for CREATE_SHLIB or CREATE_PIE. (__rel_iplt_start): Don't define for CREATE_PIC. (__rel_iplt_end): Likewise. (__rela_iplt_start): Likewise. (__rela_iplt_end): Likewise.
2019-04-10Re: XFAIL PR ld/20995 tests for lynxos and nto targetsAlan Modra2-2/+7
* testsuite/ld-elf/shared.exp: Don't xfail PR ld/20995 for powerpc-nto.
2019-04-10cskyelf.em branch stub handlingAlan Modra2-16/+23
This fixes the csky-elf ld-elf/pr21884 and ld-unique/pr21529 failures, by disabling branch stubs for binary (and other non-csky) output. The csky-linux target gets branch stubs off by default because presumably there are reasons why branch stubs were disabled, but rather than killing the support completely it can be enabled by --branch-stub. * emultempl/cskyelf.em (csk_elf_before_parse): New function, setting use_branch_stub false for linux. (csky_elf_create_output_section_statements): Do emit this function and all others in the file for linux, plus the branch option control. Disable branch stubs when non-ELF.
2019-04-10Fix some ld dependenciesAlan Modra8-58/+34
In looking at the csky-elf vs. csky-linux differences, the first thing I compared was csky_elf.sh and cskyelf_linux.sh. Those files are mostly the same but besides the real differences, annoyingly have some lines ordered differently. It's better in such cases to have one file source the other, making differences plain. This patch does that for csky and microblaze, removes an unused variable defined in a few places, and fixes ld makefile dependencies. * Makefile.am (eskyelf.c, eskyelf_linux.c): Depend on cskyelf.em. (ecskyelf_linux.c): Depend on cskyelf.sh. (eelf32microblazeel.c): Depend on elf32microblaze.sh. * Makefile.in: Regenerate. * emulparams/cskyelf.sh: Comment regarding cskelf_linux.sh. (PAGE_SIZE): Don't define. * emulparams/cskyelf_linux.sh: Source sckyelf.sh, leaving just the differing variable defs/undefs. * emulparams/elf32mcore.sh (PAGE_SIZE): Don't define. * emulparams/elf32microblaze.sh: Comment re. elf32microblazeel.sh. (OUTPUT_FORMAT): Use BIG_OUTPUT_FORMAT. (PAGE_SIZE): Don't define. * emulparams/elf32microblazeel.sh: Source elf32microblaze.sh, leaving just the differing OUTPUT_FORMAT.
2019-04-10Regen BLD-POTFILES.inAlan Modra2-1/+4
* po/BLD-POTFILES.in: Regenerate.
2019-04-08XFAIL PR ld/20995 tests for lynxos and nto targetsH.J. Lu2-2/+9
lynxos and nto targets don't support RELRO. * testsuite/ld-elf/shared.exp: XFAIL PR ld/20995 tests for lynxos and nto targets.
2019-04-08x86: Remove i386-*-kaos* and i386-*-chaos targetsH.J. Lu5-25/+8
Remove i386-*-kaos* and i386-*-chaos targets since they are no longer supported by config.sub: $ .../config.sub i386-kaos Invalid configuration `i386-kaos': system `kaos' not recognized $ .../config.sub i386-chaos Invalid configuration `i386-chaos': system `chaos' not recognized $ bfd/ * config.bfd: Remove i[3-7]86-*-kaos* and i[3-7]86-*-chaos targets. gas/ * configure.tgt: Remove i386-*-kaos* and i386-*-chaos targets. * testsuite/gas/i386/i386.exp: Remove *-*-caos* and "*-*-kaos* check. ld/ * Makefile.am (ALL_EMULATION_SOURCES): Remove eelf_i386_chaos.c. (eelf_i386_chaos.c): Removed. * Makefile.in: Regenerated. * configure.tgt: Remove i[3-7]86-*-kaos*. * emulparams/elf_i386_chaos.sh: Removed.
2019-04-08Use elf-x86.em for i386-moss and i386-beosH.J. Lu3-0/+7
* emulparams/elf_i386_be.sh (EXTRA_EM_FILE): New. * emulparams/i386moss.sh (EXTRA_EM_FILE): Likewise.
2019-04-08Fix i386-lynxos and other runtime linker failsAlan Modra4-0/+9
Segfaults due to htab->params being NULL. * emulparams/elf64rdos.sh (EXTRA_EM_FILE): Define. * emulparams/i386lynx.sh (EXTRA_EM_FILE): Define. * emulparams/i386nto.sh (EXTRA_EM_FILE): Define.
2019-04-06x86: Move x86-specific linker options to elf_linker_x86_paramsH.J. Lu21-18/+143
Remove x86-specific linker options from bfd_link_info and put them in elf_linker_x86_params. Add _bfd_elf_linker_x86_set_options to pass x86-specific linker options from ld to bfd. bfd/ * elf-linker-x86.h: New file. * elf32-i386.c (elf_i386_convert_load_reloc): Use htab->params to get x86-specific linker options. * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise. (elf_x86_64_check_relocs): Likewise. (elf_x86_64_relocate_section): Likewise. (elf_x86_64_link_setup_gnu_properties): Likewise. * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Likewise. (_bfd_x86_elf_link_setup_gnu_properties): Likewise. (_bfd_elf_linker_x86_set_options): New function. * elfxx-x86.h: Include "elf-linker-x86.h". (elf_x86_link_hash_table): Add params. include/ * bfdlink.h (bfd_link_info): Remove x86-specific linker options. ld/ * Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emultempl/elf-x86.em. (eelf_i386_sol2.c): Also depend on $(srcdir)/emultempl/solaris2-x86.em. (eelf_x86_64_sol2.c): Likewise. * Makefile.in: Regenerated. * emulparams/call_nop.sh: Set x86-specific linker options via params. * emulparams/cet.sh: Likewise. * emulparams/reloc_overflow.sh: Likewise. * emulparams/elf32_x86_64.sh (EXTRA_EM_FILE): New. Set to "elf-x86". * emulparams/elf_i386.sh: Likewise. * emulparams/elf_i386_be.sh: Likewise. * emulparams/elf_i386_chaos.sh: Likewise. * emulparams/elf_i386_ldso.sh: Likewise. * emulparams/elf_i386_vxworks.sh: Likewise. * emulparams/elf_iamcu.sh: Likewise. * emulparams/elf_k1om.sh: Likewise. * emulparams/elf_l1om.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * emulparams/elf_i386_sol2.sh (EXTRA_EM_FILE): Changed to "solaris2-x86". * emulparams/elf_x86_64_sol2.sh: Likewise. * emultempl/elf-x86.em: New file. * emultempl/solaris2-x86.em: Likewise. * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Don't set link_info.call_nop_byte.
2019-04-05PowerPC disassembler: Don't emit trailing spacesAlan Modra4-3/+9
When an instruction has operands, the PowerPC disassembler prints spaces after the opcode so as to line up operands. If the operands are all optional and all default value, then no operands are printed, leaving trailing spaces. This patch fixes that. opcodes/ * ppc-dis.c (print_insn_powerpc): Delay printing spaces after opcode until first operand is output. gas/ * testsuite/gas/ppc/476.d: Remove trailing spaces. * testsuite/gas/ppc/a2.d: Likewise. * testsuite/gas/ppc/booke.d: Likewise. * testsuite/gas/ppc/booke_xcoff.d: Likewise. * testsuite/gas/ppc/e500.d: Likewise. * testsuite/gas/ppc/e500mc.d: Likewise. * testsuite/gas/ppc/e6500.d: Likewise. * testsuite/gas/ppc/htm.d: Likewise. * testsuite/gas/ppc/power6.d: Likewise. * testsuite/gas/ppc/power8.d: Likewise. * testsuite/gas/ppc/power9.d: Likewise. * testsuite/gas/ppc/vle.d: Likewise. ld/ * testsuite/ld-powerpc/tlsexe32.d: Remove trailing spaces. * testsuite/ld-powerpc/tlsopt5.d: Likewise. * testsuite/ld-powerpc/tlsopt5_32.d: Likewise.
2019-04-03PR24411, Division is not accepted in MEMORY length expressionAlan Modra2-1/+11
Let's hope no one has section names starting with '/' in scripts. If they do, this change to fix parsing of '/' in expressiongs will break their project. PR 24411 ldlex.l (SYMBOLNAMECHAR1): Don't match '/'. (<EXPRESSION>"/DISCARD/"): New.
2019-04-03ldlex.l tidyAlan Modra2-20/+22
Underscore was specified twice in all these patterns, and backslash twice in some. Flex warned about the $SYSROOT rule, which is covered by earlier rules: "ldlex.l:386: warning, rule cannot be matched". * ldlex.l: Formatting. (CMDFILENAMECHAR, CMDFILENAMECHAR1): Delete. (FILENAMECHAR1, SYMBOLNAMECHAR1, FILENAMECHAR, WILDCHAR), (NOCFILENAMECHAR): Remove duplicate chars. Reorder. (SYMBOLCHARN): Likewise. Rename to SYMBOLNAMECHAR. (<INPUTLIST>"$SYSROOT"..): Delete rule.
2019-03-29bfd: xtensa: fix shrink_dynamic_reloc_sections for export-dynamicMax Filippov3-0/+22
shrink_dynamic_reloc_sections must remove PLT entry that was created for an undefined weak symbol in the presence of --export-dynamic option when relaxation coalesces literals pointing to that symbol. This fixes the following assertion: ld: BFD (GNU Binutils) 2.31.1 internal error, aborting at elf32-xtensa.c:3292 in elf_xtensa_finish_dynamic_sections 2019-03-29 Max Filippov <jcmvbkbc@gmail.com> bfd/ * elf32-xtensa.c (shrink_dynamic_reloc_sections): Add info->export_dynamic to the conditional. ld/ * testsuite/ld-xtensa/relax-undef-weak-pie-export-dynamic.d: New test definition. * testsuite/ld-xtensa/xtensa.exp (relax-undef-weak-pie-export-dynamic): Add new test.
2019-03-26Provide string description of definition, visibility and resolution in LTO ↵marxin3-6/+81
plug-in. ld/ChangeLog: 2019-02-26 Martin Liska <mliska@suse.cz> * plugin.c (get_symbols): Add lto_kind_str, lto_resolution_str, lto_visibility_str and use then to inform about plugin-symbols. * testsuite/ld-plugin/plugin-12.d: Adjust expected pattern.
2019-03-25Arm: Fix Arm disassembler mapping symbol search.Tamar Christina3-3/+9
Similar to the AArch64 patches the Arm disassembler has the same issues with out of order sections but also a few short comings. For one thing there are multiple code blocks to determine mapping symbols, and they all work slightly different, and neither fully correct. The first thing this patch does is centralise the mapping symbols search into one function mapping_symbol_for_insn. This function is then updated to perform a search in a similar way as AArch64. Their used to be a value has_mapping_symbols which was used to determine the default disassembly for objects that have no mapping symbols. The problem with the approach was that it was determining this value in the same loop that needed it, which is why this field could take on the states -1, 0, 1 where -1 means "don't know". However this means that until you actually find a mapping symbol or reach the end of the disassembly glob, you don't know if you did the right action or not, and if you didn't you can't correct it anymore. This is why the two jump-reloc-veneers-* testcases end up disassembling some insn as data when they shouldn't. Out of order here refers to an object file where sections are not listed in a monotonic increasing VMA order. The ELF ABI for Arm [1] specifies the following for mapping symbols: 1) A text section must always have a corresponding mapping symbol at it's start. 2) Data sections do not require any mapping symbols. 3) The range of a mapping symbol extends from the address it starts on up to the next mapping symbol (exclusive) or section end (inclusive). However there is no defined order between a symbol and it's corresponding mapping symbol in the symbol table. This means that while in general we look up for a corresponding mapping symbol, we have to make at least one check of the symbol below the address being disassembled. When disassembling different PCs within the same section, the search for mapping symbol can be cached somewhat. We know that the mapping symbol corresponding to the current PC is either the previous one used, or one at the same address as the current PC. However this optimization and mapping symbol search must stop as soon as we reach the end or start of the section. Furthermore if we're only disassembling a part of a section, the search is a allowed to search further than the current chunk, but is not allowed to search past it (The mapping symbol if there, must be at the same address, so in practice we usually stop at PC+4). lastly, since only data sections don't require a mapping symbol the default mapping type should be DATA and not INSN as previously defined, however if the binary has had all its symbols stripped than this isn't very useful. To fix this we determine the default based on the section flags. This will allow the disassembler to be more useful on stripped binaries. If there is no section than we assume you to be disassembling INSN. [1] https://developer.arm.com/docs/ihi0044/latest/elf-for-the-arm-architecture-abi-2018q4-documentation#aaelf32-table4-7 binutils/ChangeLog: * testsuite/binutils-all/arm/in-order-all.d: New test. * testsuite/binutils-all/arm/in-order.d: New test. * testsuite/binutils-all/arm/objdump.exp: Support .d tests. * testsuite/binutils-all/arm/out-of-order-all.d: New test. * testsuite/binutils-all/arm/out-of-order.T: New test. * testsuite/binutils-all/arm/out-of-order.d: New test. * testsuite/binutils-all/arm/out-of-order.s: New test. ld/ChangeLog: * testsuite/ld-arm/jump-reloc-veneers-cond-long.d: Update disassembly. * testsuite/ld-arm/jump-reloc-veneers-long.d: Update disassembly. opcodes/ChangeLog: * arm-dis.c (struct arm_private_data): Remove has_mapping_symbols. (mapping_symbol_for_insn): Implement new algorithm. (print_insn): Remove duplicate code.
2019-03-21[BFD, AArch64, x86] Improve warning for --force-btiSudakshina Das6-4/+48
The AArch64 linker option to turn on BTI (--force-bti) warns in case there are input objects which have a missing GNU NOTE section for BTI. This patch is trying to improve the warnings that come out. In order to do so, I propose adding a new argument to elf_merge_gnu_properties and the backend function merge_gnu_properties. This new argument makes sure that we now pass both the objects along with the properties to which they belong to. The x86 backend function has also been updated to match this change. *** bfd/ChangeLog *** 2019-03-21 Sudakshina Das <sudi.das@arm.com> * elf-bfd.h (struct elf_backend_data): Add argument to merge_gnu_properties. * elf-properties.c (elf_merge_gnu_properties): Add argument to itself and while calling bed->merge_gnu_properties. (elf_merge_gnu_property_list): Update the calls for elf_merge_gnu_properties. * elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling of --force-bti warning and add argument. * elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add warning. * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument. * elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in declaration. *** ld/ChangeLog *** 2019-03-21 Sudakshina Das <sudi.das@arm.com> * testsuite/ld-aarch64/aarch64-elf.exp: Add new test. * testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section. * testsuite/ld-aarch64/bti-plt-6.d: Update warning. * testsuite/ld-aarch64/bti-plt-7.d: Likewise. * testsuite/ld-aarch64/bti-warn.d: New test.
2019-03-21Adjust pr14156 test for m68hc1*Alan Modra9-8/+17
The test section alignment is unnecessarily high, overflowing the m68hc11 page used by .init code. * testsuite/ld-elf/fini2.s: Reduce alignment. * testsuite/ld-elf/fini3.s: Likewise. * testsuite/ld-elf/finin.s: Likewise. * testsuite/ld-elf/init2.s: Likewise. * testsuite/ld-elf/init3.s: Likewise. * testsuite/ld-elf/initn.s: Likewise. * testsuite/ld-elf/pr14156a.d: Don't xfail m68hc1*-* or xgate-*. * testsuite/ld-elf/pr14156b.d: Don't xfail xgate-*.
2019-03-21Add SORT_NONE to .init and .fini in scriptsAlan Modra38-86/+119
The special case for .init and .fini in update_wild_statements is ineffective for .init or .fini wildcards inside other output sections. The special case needs to be on the wildcard, not the output section. This patch is belt and braces, both fixing update_wild_statements and the scripts. * scripttempl/alpha.sc, * scripttempl/armbpabi.sc, * scripttempl/crisaout.sc, * scripttempl/elf32cr16.sc, * scripttempl/elf32crx.sc, * scripttempl/elf32xc16x.sc, * scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc, * scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc, * scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc, * scripttempl/elfd30v.sc, * scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc, * scripttempl/elfmicroblaze.sc, * scripttempl/elfxgate.sc, * scripttempl/elfxtensa.sc, * scripttempl/epiphany_4x4.sc, * scripttempl/ft32.sc, * scripttempl/i386beos.sc, * scripttempl/iq2000.sc, * scripttempl/mcorepe.sc, * scripttempl/mep.sc, * scripttempl/mips.sc, * scripttempl/moxie.sc, * scripttempl/pe.sc, * scripttempl/pep.sc, * scripttempl/ppcpe.sc, * scripttempl/tic4xcoff.sc, * scripttempl/tic80coff.sc, * scripttempl/v850.sc, * scripttempl/v850_rh850.sc, * scripttempl/visium.sc, * scripttempl/xstormy16.sc: Add KEEP and SORT_NONE to .init and .fini wildcards. * scripttempl/elf32xc16x.sc, * scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc: Add .fini wildcard. * scripttempl/elf_chaos.sc: Add .init output section. * scripttempl/elfd30v.sc: Remove duplicate .init. * scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc, * scripttempl/elfxgate.sc: Remove duplicate .init, and add .fini wildcard. * scripttempl/ppcpe.sc (INIT, FINI): Delete. * ldlang.c (update_wild_statements): Special case .init and .fini in the wildcard, not the output section.
2019-03-21lm32-linux ld testsuite failsAlan Modra2-0/+5
A number of the fails are due to ld supporting the creation of shared libraries but not allowing linking against them without using an option like -Bdynamic. FAIL: Symbol export class test (final shared object) FAIL: PROVIDE_HIDDEN test 4 FAIL: PROVIDE_HIDDEN test 6 FAIL: PROVIDE_HIDDEN test 10 FAIL: PROVIDE_HIDDEN test 12 FAIL: Build pr22471b.so FAIL: Build pr22649-2b.so FAIL: Build pr22649-2d.so FAIL: PR ld/20828 dynamic symbols with section GC (plain) FAIL: PR ld/20828 dynamic symbols with section GC (version script) FAIL: PR ld/20828 dynamic symbols with section GC (versioned) FAIL: PR ld/21233 dynamic symbols with section GC (--undefined) FAIL: PR ld/21233 dynamic symbols with section GC (--require-defined) FAIL: PR ld/21233 dynamic symbols with section GC (EXTERN) FAIL: Build pr22150 FAIL: PR ld/14170 FAIL: Link using broken linker script FAIL: pr17068 link --as-needed lib in group FAIL: ld-gc/pr20022 * emulparams/elf32lm32fd.sh (DYNAMIC_LINK): Undef.
2019-03-21Fix some dlx failsAlan Modra3-4/+9
Generic linker ELF targets using CREATE_OBJECT_SYMBOLS in their scripts run into a problem. The file symbols are created by _bfd_generic_link_output_symbols in each object file, in the section corresponding to the CREATE_OBJECT_SYMBOLS section, typically .text. If it so happens that the output .text section is stripped due to being empty, then elf.c:assign_section_numbers won't assign an ELF section number and swap_out_syms will report "unable to find equivalent output section" for the object symbols. Fix this by always keeping an output section with CREATE_OBJECT_SYMBOLS. * ldlang.c (lang_size_sections_1): Set SEC_KEEP on create_object_symbols_section. * testsuite/ld-elf/pr22319.d: Don't xfail dlx.
2019-03-18csky ld testsuite fixesAlan Modra5-6/+14
* testsuite/ld-elf/merge.d: Remove csky from xfails, add moxie. * testsuite/ld-elf/pr21884.d: Remove csky from xfails. * testsuite/ld-elf/shared.exp: Add csky to list not xfailing pr22374. * testsuite/ld-unique/pr21529.d: Remove csky from xfails
2019-03-15Update the documentation describing where the linker will attempt to locate ↵Nick Clifton2-1/+7
plugins. PR 24262 * ld.texi (-plugin): Correct the path used to locate linker plugins.
2019-03-13[BFD, LD, AArch64, 3/3] Add --pac-plt to enable PLTs protected with PAC.Sudakshina Das9-0/+156
This is part of the patch series to add support for BTI and PAC in AArch64 linker. 1) This patch adds new definitions of PAC enabled PLTs and both BTI and PAC enabled PLTs. 2) It also defines the new dynamic tag DT_AARCH64_PAC_PLT for the PAC enabled PLTs. 3) This patch adds a new ld command line option: --pac-plt. In the presence of this option, the linker uses the PAC enabled PLTs and marks with DT_AARCH64_PAC_PLT. 4) In case both BTI and PAC are enabled the linker should pick PLTs enabled with both and also use dynamic tags for both. All these are made according to the new AArch64 ELF ABI https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4 *** bfd/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> * elfnn-aarch64.c (PLT_PAC_ENTRY_SIZE, PLT_PAC_SMALL_ENTRY_SIZE): New. (PLT_BTI_PAC_ENTRY_SIZE, PLT_BTI_PAC_SMALL_ENTRY_SIZE): New. (setup_plt_values): Account for PAC or PAC and BTI enabled PLTs. (elfNN_aarch64_size_dynamic_sections): Add checks for PLT_BTI_PAC and PLT_PAC_PLT. (elfNN_aarch64_finish_dynamic_sections): Account for PLT_BTI_PAC. (get_plt_type): Add case for DT_AARCH64_PAC_PLT. (elfNN_aarch64_plt_sym_val): Add cases for PLT_BTI_PAC and PLT_PAC. *** binutils/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> * readelf.c (get_aarch64_dynamic_type): Add case for DT_AARCH64_PAC_PLT. (dynamic_section_aarch64_val): Likewise. *** include/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> * elf/aarch64.h (DT_AARCH64_PAC_PLT): New. *** ld/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> * NEWS: Document --pac-plt. * emultempl/aarch64elf.em (OPTION_PAC_PLT): New. (PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add pac-plt. (PARSE_AND_LIST_ARGS_CASES): Handle OPTION_PAC_PLT. * testsuite/ld-aarch64/aarch64-elf.exp: Add the following tests. * testsuite/ld-aarch64/bti-pac-plt-1.d: New test. * testsuite/ld-aarch64/bti-pac-plt-2.d: New test. * testsuite/ld-aarch64/pac-plt-1.d: New test. * testsuite/ld-aarch64/pac-plt-2.d: New test. * testsuite/ld-aarch64/bti-plt-1.s: Add .ifndef directive.
2019-03-13[BFD, LD, AArch64, 2/3] Add --force-bti to enable BTI and to select BTI ↵Sudakshina Das15-1/+291
enabled PLTs This is part of the patch series to add support for BTI and PAC in AArch64 linker. 1) This patch adds a new ld command line option: --force-bti. In the presence of this option, the linker enables BTI with the GNU_PROPERTY_AARCH64_FEATURE_1_BTI feature. This gives out warning in case of missing gnu notes for BTI in inputs. 2) It also defines a new set of BTI enabled PLTs. These are used either when all the inputs are marked with GNU_PROPERTY_AARCH64_FEATURE_1_BTI or when the new --force-bti option is used. This required adding new fields in elf_aarch64_link_hash_table so that we could make the PLT related information more generic. 3) It also defines a dynamic tag DT_AARCH64_BTI_PLT. The linker uses this whenever it picks BTI enabled PLTs. All these are made according to the new AArch64 ELF ABI https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4 *** bfd/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> Szabolcs Nagy <szabolcs.nagy@arm.com> * bfd-in.h (aarch64_plt_type, aarch64_enable_bti_type): New. (aarch64_bti_pac_info): New. (bfd_elf64_aarch64_set_options): Add aarch64_bti_pac_info argument. (bfd_elf32_aarch64_set_options): Likewise. * bfd-in2.h: Regenerate * elfnn-aarch64.c (PLT_BTI_ENTRY_SIZE): New. (PLT_BTI_SMALL_ENTRY_SIZE, PLT_BTI_TLSDESC_ENTRY_SIZE): New. (elfNN_aarch64_small_plt0_bti_entry): New. (elfNN_aarch64_small_plt_bti_entry): New. (elfNN_aarch64_tlsdesc_small_plt_bti_entry): New. (elf_aarch64_obj_tdata): Add no_bti_warn and plt_type fields. (elf_aarch64_link_hash_table): Add plt0_entry, plt_entry and tlsdesc_plt_entry_size fields. (elfNN_aarch64_link_hash_table_create): Initialise the new fields. (setup_plt_values): New helper function. (bfd_elfNN_aarch64_set_options): Use new bp_info to set plt sizes and bti enable type. (elfNN_aarch64_allocate_dynrelocs): Use new size members instead of fixed macros. (elfNN_aarch64_size_dynamic_sections): Likewise and add checks. (elfNN_aarch64_create_small_pltn_entry): Use new generic pointers to plt stubs instead of fixed ones and update filling them according to the need for bti. (elfNN_aarch64_init_small_plt0_entry): Likewise. (elfNN_aarch64_finish_dynamic_sections): Likewise. (get_plt_type, elfNN_aarch64_get_synthetic_symtab): New. (elfNN_aarch64_plt_sym_val): Update size accordingly. (elfNN_aarch64_link_setup_gnu_properties): Set up plts if BTI GNU NOTE is set. (bfd_elfNN_get_synthetic_symtab): Define. (elfNN_aarch64_merge_gnu_properties): Give out warning with --force-bti and mising BTI NOTE SECTION. *** binutils/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> Szabolcs Nagy <szabolcs.nagy@arm.com> * readelf.c (get_aarch64_dynamic_type): New. (get_dynamic_type): Use above for EM_AARCH64. (dynamic_section_aarch64_val): New. (process_dynamic_section): Use above for EM_AARCH64. *** include/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> Szabolcs Nagy <szabolcs.nagy@arm.com> * elf/aarch64.h (DT_AARCH64_BTI_PLT): New. *** ld/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> Szabolcs Nagy <szabolcs.nagy@arm.com> * NEWS: Document --force-bti. * emultempl/aarch64elf.em (plt_type, bti_type, OPTION_FORCE_BTI): New. (PARSE_AND_LIST_SHORTOPTS, PARSE_AND_LIST_OPTIONS): Add force-bti. (PARSE_AND_LIST_ARGS_CASES): Handle OPTION_FORCE_BTI. * testsuite/ld-aarch64/aarch64-elf.exp: Add all the tests below. * testsuite/ld-aarch64/bti-plt-1.d: New test. * testsuite/ld-aarch64/bti-plt-1.s: New test. * testsuite/ld-aarch64/bti-plt-2.s: New test. * testsuite/ld-aarch64/bti-plt-2.d: New test. * testsuite/ld-aarch64/bti-plt-3.d: New test. * testsuite/ld-aarch64/bti-plt-4.d: New test. * testsuite/ld-aarch64/bti-plt-5.d: New test. * testsuite/ld-aarch64/bti-plt-6.d: New test. * testsuite/ld-aarch64/bti-plt-7.d: New test. * testsuite/ld-aarch64/bti-plt-so.s: New test. * testsuite/ld-aarch64/bti-plt.ld: New test.
2019-03-13[BFD, LD, AArch64, 1/3] Add support for GNU PROPERTIES in AArch64 for BTI ↵Sudakshina Das8-0/+147
and PAC This is part of the patch series to add support for BTI and PAC in AArch64 linker. This patch implements the following: 1) This extends in the gnu property support in the linker for AArch64 by defining backend hooks for elf_backend_setup_gnu_properties, elf_backend_merge_gnu_properties and elf_backend_parse_gnu_properties. 2) It defines AArch64 specific GNU property GNU_PROPERTY_AARCH64_FEATURE_1_AND and 2 bit for BTI and PAC in it. 3) It also adds support in readelf.c to read and print these new GNU properties in AArch64. All these are made according to the new AArch64 ELF ABI https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4 *** bfd/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> * elf-properties.c (_bfd_elf_link_setup_gnu_properties): Exclude linker created inputs from merge. * elfnn-aarch64.c (struct elf_aarch64_obj_tdata): Add field for GNU_PROPERTY_AARCH64_FEATURE_1_AND properties. (elfNN_aarch64_link_setup_gnu_properties): New. (elfNN_aarch64_merge_gnu_properties): New. (elf_backend_setup_gnu_properties): Define for AArch64. (elf_backend_merge_gnu_properties): Likewise. * elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Define. (_bfd_aarch64_elf_parse_gnu_properties): Define. (_bfd_aarch64_elf_merge_gnu_properties): Define. * elfxx-aarch64.h (_bfd_aarch64_elf_link_setup_gnu_properties): Declare. (_bfd_aarch64_elf_parse_gnu_properties): Declare. (_bfd_aarch64_elf_merge_gnu_properties): Declare. (elf_backend_parse_gnu_properties): Define for AArch64. *** binutils/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> * readelf.c (decode_aarch64_feature_1_and): New. (print_gnu_property_note): Add case for AArch64 gnu notes. *** include/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> * elf/common.h (GNU_PROPERTY_AARCH64_FEATURE_1_AND): New. (GNU_PROPERTY_AARCH64_FEATURE_1_BTI): New. (GNU_PROPERTY_AARCH64_FEATURE_1_PAC): New. *** ld/ChangeLog *** 2019-03-13 Sudakshina Das <sudi.das@arm.com> * NEWS: Document GNU_PROPERTY_AARCH64_FEATURE_1_BTI and GNU_PROPERTY_AARCH64_FEATURE_1_PAC. * testsuite/ld-aarch64/aarch64-elf.exp: Add run commands for new tests. * testsuite/ld-aarch64/property-bti-pac1.d: New test. * testsuite/ld-aarch64/property-bti-pac1.s: New test. * testsuite/ld-aarch64/property-bti-pac2.d: New test. * testsuite/ld-aarch64/property-bti-pac2.s: New test. * testsuite/ld-aarch64/property-bti-pac3.d: New test.
2019-03-13x86: Properly set IBT and SHSTK properties for -z ibt/shstkH.J. Lu12-0/+151
There should be no AND properties if some input doesn't have them. We should set IBT and SHSTK properties for -z ibt and -z shstk if needed. bfd/ PR ld/24322 * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Properly merge GNU_PROPERTY_X86_FEATURE_1_[IBT|SHSTK]. ld/ PR ld/24322 * testsuite/ld-i386/i386.exp: Run PR ld/24322 tests. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr24322a.d: New file. * testsuite/ld-i386/pr24322b.d: Likewise. * testsuite/ld-x86-64/pr24322a-x32.d: Likewise. * testsuite/ld-x86-64/pr24322a.d: Likewise. * testsuite/ld-x86-64/pr24322b-x32.d: Likewise. * testsuite/ld-x86-64/pr24322b.d: Likewise. * testsuite/ld-x86-64/pr24322a.s: Likewise. * testsuite/ld-x86-64/pr24322b.s: Likewise. * testsuite/ld-x86-64/pr24322c.s: Likewise.
2019-03-06Allow the use of the ORIGIN and LENGTH attributes in expressions inside ↵Nick Bowler2-24/+26
MEMORY regions. PR 24289 * ldexp.c (fold_name): Allow lookups of the LENGTH and ORIGIN attributes during the first phase.
2019-03-01Revert "Add support to GNU ld to separate got related plt entries"Andreas Krebbel17-105/+120
bfd/ChangeLog: 2019-03-01 Andreas Krebbel <krebbel@linux.ibm.com> This reverts commit 5a12586d44fa8d5dfc74cbca4f2f36a273a16335. 2019-01-14 Maamoun Tarsha <maamountk@hotmail.com> PR 20113 * elf32-s390.c (allocate_dynrelocs): Update comment. ld/ChangeLog: 2019-03-01 Andreas Krebbel <krebbel@linux.ibm.com> This reverts commit 5a12586d44fa8d5dfc74cbca4f2f36a273a16335. 2019-01-14 Maamoun Tarsha <maamountk@hotmail.com> PR 20113 * emulparams/elf64_s390.sh (SEPARATE_GOTPLT): Define. * emulparams/elf_s390.sh (SEPARATE_GOTPLT): Define. * testsuite/ld-s390/gotreloc_31-1.dd: Update expected output. * testsuite/ld-s390/tlsbin.dd: Likewise. * testsuite/ld-s390/tlsbin.rd: Likewise. * testsuite/ld-s390/tlsbin.sd: Likewise. * testsuite/ld-s390/tlsbin_64.dd: Likewise. * testsuite/ld-s390/tlsbin_64.rd: Likewise. * testsuite/ld-s390/tlsbin_64.sd: Likewise. * testsuite/ld-s390/tlspic.dd: Likewise. * testsuite/ld-s390/tlspic.rd: Likewise. * testsuite/ld-s390/tlspic.sd: Likewise. * testsuite/ld-s390/tlspic_64.dd: Likewise. * testsuite/ld-s390/tlspic_64.rd: Likewise. * testsuite/ld-s390/tlspic_64.sd: Likewise. * testsuite/ld-s390/s390.exp: Skip s390 tests for tpf targets.
2019-02-27x86-64: Skip protected check on symbol defined by linkerH.J. Lu7-0/+48
Skip symbol defined by linker when checking copy reloc on protected symbol. bfd/ PR ld/24276 * elf64-x86-64.c (elf_x86_64_check_relocs): Skip symbol defined by linker when checking copy reloc on protected symbol. ld/ PR ld/24276 * testsuite/ld-i386/i386.exp: Run PR ld/24276 test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr24276.dso: New file. * testsuite/ld-i386/pr24276.warn: Likewise. * testsuite/ld-x86-64/pr24276.dso: Likewise. * testsuite/ld-x86-64/pr24276.warn: Likewise.
2019-02-21PowerPC __tls_get_addr arg parsingAlan Modra1-1/+2
The syntax we ended up with for -m32 -fPIC calls to __tls_get_addr is rather weird. bl __tls_get_addr+0x8000(gd0@tlsgd)@plt This came about by accident, probably due to requiring the arg reloc before the call reloc. Of course the @plt really belongs with __tls_get_addr since it affects the call rather than the call arg, and it isn't a great deal of trouble to ensure the relocs are emitted in the correct order. This patch supports a newer syntax, like so: bl __tls_get_addr+0x8000@plt(gd0@tlsgd) gas/ * config/tc-ppc.c (parse_tls_arg): New function, extracted.. (md_assembler): ..from here. Call it after parsing other suffix modifiers too. ld/ * testsuite/ld-powerpc/tls32.s: Test new @plt syntax.
2019-02-20bfd: xtensa: fix callx relaxationMax Filippov6-0/+44
Big section alignment requirements between source and destination of a long call can result in making call range bigger than what's reachable by the call opcode. Add biggest section alignment of sections between the call site and call destination to the call distance when making long call relaxation decision. 2019-02-20 Eric Tsai <erictsai@cadence.com> bfd/ * elf32-xtensa.c (is_resolvable_asm_expansion): Scan output sections between the call site and call destination and adjust call distance by the largest alignment. ld/ * testsuite/ld-xtensa/call_overflow.d: New test definition. * testsuite/ld-xtensa/call_overflow1.s: New test source. * testsuite/ld-xtensa/call_overflow2.s: New test source. * testsuite/ld-xtensa/call_overflow3.s: New test source. * testsuite/ld-xtensa/xtensa.exp: Add call_overflow test.
2019-02-14[ld, hurd] Remove 'ld-elf/elf.exp' XFAILsThomas Schwinge2-7/+4
... as a follow-up to commit d98164028637041c5de99af0d057bde3f168a8a8 "Run more ld tests when not native", which replaced by a proper solution the following mess before present in 'ld/configure.host': -*-*-gnu*) - # When creating static executables, we ought to use crt0.o instead of crt1.o, - # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>, - # but the testing infrastructure is not prepared for that. This is not - # relevant for most tests, and the few remaining ones have been XFAILed. - HOSTING_CRT0='[...]' - HOSTING_LIBS='[...]' ld/ * testsuite/ld-elf/elf.exp: Remove Hurd XFAILs.
2019-02-12Updated French translation for ld/ and gold/ subdirectoriesNick Clifton2-2105/+2144
2019-02-09[ARC] don't force _init/_fini as DT_INIT/DT_FINI.Claudiu Zissulescu2-28/+5
Recent gcc commit b4371b277f1e ("[ARC] Enable init_array support") inhibits DT_"INIT,FINI} in favor of DT_{INIT,FINI}ARRAY. Even prior to that, it seems ARC port is the only one with this special DT_INIT/FINI handling in linker emulation. Removing it doesn't seem to change any uClibc/glibc testsuite results, so this can RIP anyways. bfd/ 2019-02-01 Vineet Gupta <vgupta@synopsys.com> * elf32-arc.c: Delete init_str, fini_str ld/ 2019-02-01 Vineet Gupta <vgupta@synopsys.com> * emultempl/arclinux.em : Delete special INIT/FINI handling.
2019-02-07Fix typo in description of --start-group/--end-group options.Nick Clifton2-1/+7
PR 24175 * ld.texi (Options): Add missing word to the description of the --start-group option.
2019-02-06Fix some ldscripts/pr24008 failsAlan Modra2-0/+9
These targets were all failing due to extra symbols. pdp11-dec-aout +FAIL: ld-scripts/pr24008 powerpc-aix5.1 +FAIL: ld-scripts/pr24008 powerpc-aix5.2 +FAIL: ld-scripts/pr24008 rs6000-aix4.3.3 +FAIL: ld-scripts/pr24008 rs6000-aix5.1 +FAIL: ld-scripts/pr24008 rs6000-aix5.2 +FAIL: ld-scripts/pr24008 Some fails remain, those I saw were segfaults or assertion fails that indicate target bugs. PR ld/24008 * testsuite/ld-scripts/pr24008.d: Pass with extra target defined symbols.
2019-02-05x86-64: Restore PIC check for PCREL reloc against protected symbolH.J. Lu5-0/+26
commit bd7ab16b4537788ad53521c45469a1bdae84ad4a Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Feb 13 07:34:22 2018 -0800 x86-64: Generate branch with PLT32 relocation removed check R_X86_64_PC32 relocation against protected symbols in shared objects. Since elf_x86_64_check_relocs is called after we have seen all input files, we can check for PC-relative relocations in elf_x86_64_check_relocs. We should not allow PC-relative relocations against protected symbols since address of protected function and location of protected data may not be in the shared object. bfd/ PR ld/24151 * elf64-x86-64.c (elf_x86_64_need_pic): Check SYMBOL_DEFINED_NON_SHARED_P instead of def_regular. (elf_x86_64_relocate_section): Move PIC check for PC-relative relocations to ... (elf_x86_64_check_relocs): Here. (elf_x86_64_finish_dynamic_symbol): Use SYMBOL_DEFINED_NON_SHARED_P to check if a symbol is defined in a non-shared object. * elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): New. ld/ PR ld/24151 * testsuite/ld-x86-64/pr24151a-x32.d: New file. * testsuite/ld-x86-64/pr24151a.d: Likewise. * testsuite/ld-x86-64/pr24151a.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr24151a and pr24151a-x32.
2019-01-31Document ld -t behaviourAlan Modra3-1/+16
* NEWS: Mention -t change. * ld.texi (--trace/-t): Expand documentation a little.
2019-01-29Add a testcase for PR ld/24008H.J. Lu6-0/+35
PR ld/24008 * testsuite/ld-scripts/defined.exp: Run pr24008. * testsuite/ld-scripts/pr24008.d: New file. * testsuite/ld-scripts/pr24008.map: Likewise. * testsuite/ld-scripts/pr24008.s: Likewise. * testsuite/ld-scripts/pr24008.t: Likewise.
2019-01-29Skip ld/pr23169 on SPARC.Eric Botcazou2-1/+7
The test is already skipped on PowerPC and Aarch64 because it's invalid. * testsuite/ld-ifunc/ifunc.exp: Skip pr23169 on SPARC.