Commit Graph

226 Commits

Author SHA1 Message Date
H.J. Lu b32632c499 ld: Add --enable-textrel-check=[no|yes|warning|error]
Add a configure option, --enable-textrel-check=[no|yes|warning|error],
to decide what ELF linker should do by default with DT_TEXTREL in an
executable or shared library.

	PR ld/20824
	* NEWS: Mention --enable-textrel-check=[no|yes|warning|error].
	* configure.ac: Add --enable-textrel-check=[no|yes|warning|error].
	(DEFAULT_LD_TEXTREL_CHECK): New AC_DEFINE_UNQUOTED.
	(DEFAULT_LD_TEXTREL_CHECK_WARNING): Likewise.
	* ldmain.c (main): Initialize link_info.textrel_check to
	DEFAULT_LD_TEXTREL_CHECK.
	* lexsup.c (ld_options): Check DEFAULT_LD_TEXTREL_CHECK_WARNING.
	* config.in: Regenerated.
	* configure: Likewise.
2020-05-28 04:21:16 -07:00
Nick Clifton 72a3b182e1 Linker: Remove support for -Map= with an empty argument.
* lexsup.c (parse_args): Generate an error if a name is not
	provided to the -Map option.
	(ld_options): Mention that the -Map option supports a directory
	name as an argument.
	* NEWS: Remove mention of support for an empty string as an
	argument to -Map.
	* ld.texi: Likewise.
2020-05-28 10:51:29 +01:00
Nick Clifton 198204a7f0 [PATCH] allow empty string as argument to -Map
* lexsup.c (parse_args): If the map filename is defined but empty
	create a name based upon the output file name.  If the name is
	defined but refers to a directory create a file inside the
	directory based on the output file name.
	* ld.texi: Document the new feature.
	* testsuite/ld-script/map-address.exp: Add test of new feature.
	* NEWS: Mention the new feature.
2020-05-27 17:49:17 +01:00
H.J. Lu a6dbf402de ld: Add --warn-textrel and obsolete --warn-shared-textrel
--warn-shared-textrel and -z text apply to both shared object and PIE.
Add --warn-textrel and obsolete --warn-shared-textrel.  Consolidate
--warn-textrel and -z text/notext/textoff implementation.

bfd/

	PR ld/22909
	* elflink.c (bfd_elf_final_link): Use bfd_link_textrel_check.
	Check bfd_link_dll when issue a DT_TEXTREL warning.
	* elfxx-x86.c (maybe_set_textrel): Likewise.
	(_bfd_x86_elf_size_dynamic_sections): Likewise.

include/

	PR ld/22909
	* bfdlink.h (textrel_check_method): New enum.
	(bfd_link_textrel_check): New.
	(bfd_link_info): Replace warn_shared_textrel and error_textrel
	with textrel_check.

ld/

	PR ld/22909
	* NEWS: Mention --warn-textrel.
	* ld.texi: Update -z text/notext/textoff.  Add --warn-textrel.
	Remove --warn-shared-textrel.
	* ldlex.h (option_values): Rename OPTION_WARN_SHARED_TEXTREL to
	OPTION_WARN_TEXTREL.
	* lexsup.c (ld_options): Add --warn-textrel.  Obsolete
	--warn-shared-textrel.
	(parse_args): Updated.
	(elf_shlib_list_options): Check link_info.textrel_check.
	* emultempl/elf.em: Updated.
	* testsuite/ld-elf/pr19539.d: Replace -z notext with
	--warn-textrel.  Expect a warning.
	* testsuite/ld-i386/warn1.d: Update expected warning.
2020-05-27 04:54:10 -07:00
Fangrui Song 161719466a For relative paths in INPUT() and GROUP(), search the directory of the current linker script before searching other paths.
PR ld/25806
	* ldlang.h (struct lang_input_statement_struct): Add extra_search_path.
	* ldlang.c (current_input_file): New.
	(ldirname): New.
	(new_afile): Add from_filename parameter. Set extra_search_path.
	(lang_add_input_file): Pass current_input_file to new_afile.
	(load_symbols): Set current_input_file.
2020-04-22 16:20:02 +01:00
Stephen Casner fa1477dc34 Fixes for the magic number used in PDP11 AOUT binaries.
PR ld/25677
include	* aout/aout64.h (N_DATADDR): Add IMAGIC case.

bfd	* pdp11.c: Add implementation of --imagic option.
	(adjust_o_magic): Fix objcopy --extract-symbol test.
	* libaout.h (enum aout_magic): Add i_magic.

ld	* emulparams/pdp11.sh (SCRIPT_NAME): Change to pdp11.
	(EXTRA_EM_FILE): New, add emulation file pdp11.
	* scripttempl/pdp11.sc: New, derived from aout.sc without
	irrelevant input sections.
	* emultempl/pdp11.em (_add_options, _handle_option)
	(_list_options): New. Add options -z, --imagic for pdp11-aout.
	(_before_parse): Make --omagic be default instead of --nmagic.
	(_get_script): Modify special-case linker script for --imagic.
	* lexsup.c (parse_args): Explictly set config.text_read_only for -n.
	* ld.texi (Options): Add documentation of PDP11-specific options.
	(Options): Fix unrelated typo to --no-compact-branches.
	* gen-doc.texi: @set PDP11.
	* testsuite/ld-pdp11/pdp11.exp: New, start pdp11 testing.
	* testsuite/ld-pdp11/sections.s: New, source for options tests.
	* testsuite/ld-pdp11/imagic.d: New, test --imagic format.
	* testsuite/ld-pdp11/imagicz.d: New, test -z (imagic) format.
	* testsuite/ld-pdp11/nmagic.d: New, test --nmagic format.
	* testsuite/ld-pdp11/omagic.d: New, test --omagic format.
2020-04-14 14:41:27 +01:00
Christophe Lyon abf874aafe Add support for non-contiguous memory regions
2020-01-06  Christophe Lyon  <christophe.lyon@linaro.org>

	bfd/
	* bfd-in2.h: Regenerate.
	* section.c (asection): Add already_assigned field.
	(BFD_FAKE_SECTION): Add default initializer for it.
	* ecoff.c (bfd_debug_section): Initialize already_assigned field.
	* elf32-arm.c (arm_build_one_stub): Add support for
	non_contiguous_regions.
	* elf32-csky.c (csky_build_one_stub): Likewise.
	* elf32-hppa.c (hppa_build_one_stub): Likewise.
	* elf32-m68hc11.c (m68hc11_elf_build_one_stub): Likewise.
	* elf32-m68hc12.c (m68hc12_elf_build_one_stub): Likewise.
	* elf32-metag.c (metag_build_one_stub): Likewise.
	* elf32-nios2.c (nios2_build_one_stub): Likewise.
	* elf64-ppc.c (ppc_build_one_stub): Likewise.
	(ppc_size_one_stub): Likewise.
	* elfnn-aarch64.c (aarch64_build_one_stub): Likewise.
	* elflink.c (elf_link_input_bfd): Likewise.

	include/
	* bfdlink.h (bfd_link_info): Add non_contiguous_regions and
	non_contiguous_regions_warnings fields.

	ld/
	* ldlang.c (lang_add_section): Add support for
	non_contiguous_regions.
	(size_input_section): Likewise.
	(lang_size_sections_1): Likewise.
	(process_insert_statements): Likewise.
	* ldlex.h (option_values): Add OPTION_NON_CONTIGUOUS_REGIONS and
	OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS.
	* lexsup.c (ld_options): Add entries for
	--enable-non-contiguous-regions and
	--enable-non-contiguous-regions-warnings.
	(parse_args): Handle it.
	* NEWS: Add --enable-non-contiguous-regions and
	--enable-non-contiguous-regions-warnings.
	* ld.texi: Add --enable-non-contiguous-regions and
	--enable-non-contiguous-regions-warnings documentation.
	* emultempl/armelf.em (elf32_arm_add_stub_section): Add
	SEC_LINKER_CREATED flag.
	* emultempl/xtensaelf.em (ld_build_required_section_dependence):
	Emit an error when --enable-non-contiguous-regions is used.
	* testsuite/ld-elf/non-contiguous.d: New.
	* testsuite/ld-elf/non-contiguous.ld: New.
	* testsuite/ld-elf/non-contiguous.s: New.
	* testsuite/ld-arm/arm-elf.exp: Run the new tests.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm.s: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm.d: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm.ld: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm2.d: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm3.ld: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm3.d: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm3.ld: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm4.d: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm4.ld: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm5.d: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm5.ld: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm6.d: New.
	* testsuite/ld-arm/arm-elf/non-contiguous-arm6.ld: New.
	* testsuite/ld-powerpc/powerpc.exp: Run new tests.
	* testsuite/ld-powerpc/non-contiguous-powerpc.d: New.
	* testsuite/ld-powerpc/non-contiguous-powerpc.ld: New.
	* testsuite/ld-powerpc/non-contiguous-powerpc.sd: New.
	* testsuite/ld-powerpc/non-contiguous-powerpc64.d: New.
2020-03-13 14:44:45 +00:00
Alan Modra 7b3c27152b PR25585, PHDR segment not covered by LOAD segment
I closed this bug as invalid, but I think it is worth mentioning in NEWS
that older linkers didn't check PT_PHDR very well.  The patch also allows
people to force an output file with --noinhibit-exec after the error.

bfd/
	PR 25585
	* elf.c (assign_file_positions_for_load_sections): Continue linking
	on "PHDR segment not covered by LOAD segment" errors.
ld/
	PR 25585
	* NEWS: Mention better "PHDR segment not covered by LOAD segment"
	checking.
2020-02-22 12:53:52 +10:30
Nick Clifton ae77468624 Add markers for 2.34 branch to the NEWS files and ChangeLogs. 2020-01-18 13:50:25 +00:00
Sergey Belyashov 6655dba246 Add support for the GBZ80, Z180, and eZ80 variants of the Z80 architecure. Add an ELF based target for these as well.
PR 25224
bfd	* Makefile.am: Add z80-elf target support.
	* configure.ac: Likewise.
	* targets.c: Likewise.
	* config.bfd: Add z80-elf target support and new arches: ez80 and z180.
	* elf32-z80.c: New file.
	* archures.c: Add new z80 architectures: eZ80 and Z180.
	* coffcode.h: Likewise.
	* cpu-z80.c: Likewise.
	* bfd-in2.h: Likewise plus additional Z80 relocations.
	* coff-z80.c: Add new relocations for Z80 target and local label check.

gas	* config/tc-z80.c: Add new architectures: Z180 and eZ80. Add support
	for assembler code generated by SDCC. Add new relocation types. Add
	z80-elf target support.
	* config/tc-z80.h: Add z80-elf target support. Enable dollar local
	labels. Local labels starts from ".L".
	* testsuite/gas/all/fwdexp.d: Fix failure due to symbol conflict.
	* testsuite/gas/all/fwdexp.s: Likewise.
	* testsuite/gas/z80/suffix.d: Fix failure on ELF target.
	* testsuite/gas/z80/z80.exp: Add new tests
	* testsuite/gas/z80/dollar.d: New file.
	* testsuite/gas/z80/dollar.s: New file.
	* testsuite/gas/z80/ez80_adl_all.d: New file.
	* testsuite/gas/z80/ez80_adl_all.s: New file.
	* testsuite/gas/z80/ez80_adl_suf.d: New file.
	* testsuite/gas/z80/ez80_isuf.s: New file.
	* testsuite/gas/z80/ez80_z80_all.d: New file.
	* testsuite/gas/z80/ez80_z80_all.s: New file.
	* testsuite/gas/z80/ez80_z80_suf.d: New file.
	* testsuite/gas/z80/r800_extra.d: New file.
	* testsuite/gas/z80/r800_extra.s: New file.
	* testsuite/gas/z80/r800_ii8.d: New file.
	* testsuite/gas/z80/r800_z80_doc.d: New file.
	* testsuite/gas/z80/z180.d: New file.
	* testsuite/gas/z80/z180.s: New file.
	* testsuite/gas/z80/z180_z80_doc.d: New file.
	* testsuite/gas/z80/z80_doc.d: New file.
	* testsuite/gas/z80/z80_doc.s: New file.
	* testsuite/gas/z80/z80_ii8.d: New file.
	* testsuite/gas/z80/z80_ii8.s: New file.
	* testsuite/gas/z80/z80_in_f_c.d: New file.
	* testsuite/gas/z80/z80_in_f_c.s: New file.
	* testsuite/gas/z80/z80_op_ii_ld.d: New file.
	* testsuite/gas/z80/z80_op_ii_ld.s: New file.
	* testsuite/gas/z80/z80_out_c_0.d: New file.
	* testsuite/gas/z80/z80_out_c_0.s: New file.
	* testsuite/gas/z80/z80_reloc.d: New file.
	* testsuite/gas/z80/z80_reloc.s: New file.
	* testsuite/gas/z80/z80_sli.d: New file.
	* testsuite/gas/z80/z80_sli.s: New file.

ld	* Makefile.am: Add new target z80-elf
	* configure.tgt: Likewise.
	* emultempl/z80.em: Add support for eZ80 and Z180 architectures.
	* emulparams/elf32z80.sh: New file.
	* emultempl/z80elf.em: Likewise.
	* testsuite/ld-z80/arch_ez80_adl.d: Likewise.
	* testsuite/ld-z80/arch_ez80_z80.d: Likewise.
	* testsuite/ld-z80/arch_r800.d: Likewise.
	* testsuite/ld-z80/arch_z180.d: Likewise.
	* testsuite/ld-z80/arch_z80.d: Likewise.
	* testsuite/ld-z80/comb_arch_ez80_z80.d: Likewise.
	* testsuite/ld-z80/comb_arch_z180.d: Likewise.
	* testsuite/ld-z80/labels.s: Likewise.
	* testsuite/ld-z80/relocs.s: Likewise.
	* testsuite/ld-z80/relocs_b_ez80.d: Likewise.
	* testsuite/ld-z80/relocs_b_z80.d: Likewise.
	* testsuite/ld-z80/relocs_f_z80.d: Likewise.
	* testsuite/ld-z80/z80.exp: Likewise.

opcodes	* z80-dis.c: Add support for eZ80 and Z80 instructions.
2020-01-02 14:14:59 +00:00
Alan Modra b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Alan Modra 595d3787e9 Remove CR16C support
I think it is past time to remove CR16C support.  CR16C was added in
2004, and only for ld.  gas and binutils support is lacking, and there
have been no commits to bfd/elf32-cr16c.c other than warning fixes or
global maintainers making changes to all targets.  I see no maintainer
listed for CR16C, and no commits from anyone at NSC supporting the
target.  Furthermore, at the time the CR16 support was added in 2007,
config.sub was changed upstream to no longer recognise cr16c as a
valid cpu.  That means the CR16C ld support is only available as a
secondary target by configuring with, for example,
--enable-targets=all or --enable-targets=cr16c-unknown-elf.  No
testing of the CR16C target is possible.

include/
	* elf/cr16c.h: Delete.
bfd/
	* cpu-cr16c.c: Delete.
	* elf32-cr16c.c: Delete.
	* Makefile.am,
	* archures.c,
	* config.bfd,
	* configure.ac,
	* reloc.c,
	* targets.c: Remove cr16c support.
	* Makefile.in,
	* bfd-in2.h,
	* configure,
	* libbfd.h,
	* po/SRC-POTFILES.in: Regenerate.
ld/
	* emulparams/elf32cr16c.sh: Delete.
	* scripttempl/elf32cr16c.sc: Delete.
	* Makefile.am,
	* configure.tgt: Remove cr16c support.
	* NEWS: Mention removal of cr16c.
	* Makefile.in,
	* po/BLD-POTFILES.in: Regenerate.
2019-11-07 20:09:20 +10:30
Nick Clifton 4786fbf372 Update the README-how-to-make-a-release file with a note to reset the development flag back to true after making a point release. Aldo fix a typo in the ld/NEWS file.
binutils* README-how-to-make-a-release: Add a note to reset the
	development flag back to true after making a point release.

ld	* NEWS: Delete superflous "Changes in 2.33" comment.
2019-10-13 13:33:27 +01:00
Phil Blundell 60391a255b Add markers for 2.33 branch to NEWS and ChangeLog files. 2019-09-09 10:27:40 +01:00
Sudakshina Das 8bf6d176b0 [LD, AArch64] Move ELF options behind -z
This patch moves the current AArch64 ld options of --force-bti
and --pac-plt to -z force-bti and -z pac-plt since these are
ELF specific options.

*** bfd/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* bfd-in.h: Change comment.
	* bfd-in2.h: Regenerate.
	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update warning.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties):
	Likwise.

*** ld/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* NEWS: Update options names.
	* emultempl/aarch64elf.em (OPTION_FORCE_BTI, OPTION_PAC_PLT): Remove.
	(PARSE_AND_LIST_LONGOPTS): Remove force-bti and pac-plt.
	(PARSE_AND_LIST_OPTIONS): Update to -z.
	(PARSE_AND_LIST_ARGS_CASE_Z_AARCH64): New.
	(PARSE_AND_LIST_ARGS_CASE_Z): Add PARSE_AND_LIST_ARGS_CASE_Z_AARCH64.
	(PARSE_AND_LIST_ARGS_CASES): Move cases for these options.
	* testsuite/ld-aarch64/bti-pac-plt-1.d: Update option.
	* testsuite/ld-aarch64/bti-pac-plt-2.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-1.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-2.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-3.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: Likewise.
	* testsuite/ld-aarch64/pac-plt-1.d: Likewise.
	* testsuite/ld-aarch64/pac-plt-2.d: Likewise.
2019-06-06 12:21:14 +01:00
Tamar Christina 739b5c9c77 AArch64: Implement choice between Cortex-A53 erratum workarounds. (PR ld/24373)
The Cortex-A53 erratum currently has two ways it can resolve the erratum when
using the flag --fix-cortex-a53-843419:

1) If the address is within the range of an ADR instruction it rewrites the ADRP
   into an ADR, and those doesn't need the use of a veneer.

2) If the address is not within range, it adds a branch to a veneer which will
   execute the final bit of the erratum workaround and branch back to the call
   site.

When we do this we always generate the veneers and we always align the size of
the text section to 4KB.  This is because we only know which workaround we can
use after all linking has finished and all addresses are known.  This means even
though the veneers are not used, we still generate the section and we still
change the size of the input section.

This is problematic for small memory devices as this would require the user to
take about a ~4KB hit in memory even though it's not even used.

Since there's no real way to restart the linking process from the final write
phase this patch solves the issue by allowing the user more control over which
erratum workaround gets used.

Concretely this changes the option --fix-cortex-a53-843419 to take optional
arguments --fix-cortex-a53-843419[=full|adr|adrp]

- full (default): Use both ADRP and ADR workaround. This is equivalent to not
		  specifying any options and is the default behavior before this
		  patch.

- adr: Only use the ADR workaround, this will not cause any increase in binary
       size but linking will fail if the referenced address is out of range of
       an ADR instruction.

- adrp: Use only the ADRP workaround, this will never rewrite your ADRP.

In the cases where the user knows how big their binaries are the `adr` option
would prevent the unneeded overhead.

bfd/ChangeLog:

	PR ld/24373
	* bfd-in.h (enum erratum_84319_opts): New
	(bfd_elf64_aarch64_set_options, bfd_elf32_aarch64_set_options): Change
	int to enum erratum_84319_opts.
	* bfd-in2.h: Regenerate.
	* elfnn-aarch64.c (struct elf_aarch64_link_hash_table): Change
	fix_erratum_843419 to use new enum, remove fix_erratum_843419_adr.
	(_bfd_aarch64_add_stub_entry_after): Conditionally create erratum stub.
	(aarch64_size_one_stub): Conditionally size erratum 843419 stubs.
	(_bfd_aarch64_resize_stubs): Amend comment.
	(elfNN_aarch64_size_stubs): Don't generate stubs when no workaround
	requested.
	(bfd_elfNN_aarch64_set_options): Use new fix_erratum_843419 enum.
	(_bfd_aarch64_erratum_843419_branch_to_stub): Implement selection of
	erratum workaround.
	(clear_erratum_843419_entry): Update erratum conditional.

ld/ChangeLog:

	PR ld/24373
	* emultempl/aarch64elf.em (PARSE_AND_LIST_LONGOPTS): Add optional args
	to flags.
	* NEWS: Add changes to flag.
	(PARSE_AND_LIST_OPTIONS): Update help descriptions.
	(PARSE_AND_LIST_ARGS_CASES): Add new options to parser.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add new run_dump_tests.
	* testsuite/ld-aarch64/erratum843419-adr.d: New test.
	* testsuite/ld-aarch64/erratum843419-adrp.d: New test.
	* testsuite/ld-aarch64/erratum843419-far-adr.d: New test.
	* testsuite/ld-aarch64/erratum843419-far-full.d: New test.
	* testsuite/ld-aarch64/erratum843419-far.s: New test.
	* testsuite/ld-aarch64/erratum843419-full.d: New test.
	* testsuite/ld-aarch64/erratum843419-near.s: New test.
	* testsuite/ld-aarch64/erratum843419-no-args.d: New test.
2019-05-21 13:05:22 +01:00
Faraz Shahbazker 035801cebe ld: Add --no-print-map-discarded option
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-11 10:16:31 -07:00
Sudakshina Das 1dbade7441 [BFD, LD, AArch64, 3/3] Add --pac-plt to enable PLTs protected with PAC.
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 11:47:33 +00:00
Sudakshina Das 37c18eedff [BFD, LD, AArch64, 2/3] Add --force-bti to enable BTI and to select BTI 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 11:47:07 +00:00
Sudakshina Das cd702818c6 [BFD, LD, AArch64, 1/3] Add support for GNU PROPERTIES in AArch64 for BTI 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-13 11:47:00 +00:00
Alan Modra 4f4690cd42 Document ld -t behaviour
* NEWS: Mention -t change.
	* ld.texi (--trace/-t): Expand documentation a little.
2019-01-31 11:37:44 +10:30
Nick Clifton f48dfe417e Change version to 2.32.51 and regenerate configure and pot files. 2019-01-19 16:51:42 +00:00
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
H.J. Lu d2ef37ebd9 elf: Report property change when merging properties
With merging properties, report property change in linker map file, like

Merging program properties

Removed property 0xc0010000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x0) and /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o (0x0)
Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x3) and x.o (not found)
Removed property 0xc0000000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0)
Removed property 0xc0000001 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0)

bfd/

	* elf-properties.c (elf_find_and_remove_property): Add a
	bfd_boolean argument to indicate if the property should be
	removed.
	(elf_merge_gnu_property_list): Updated.  Report
	property change in linker map file.
	(elf_get_gnu_property_section_size): Skip property_remove
	properties.
	(elf_write_gnu_properties): Likewise.
	(_bfd_elf_link_setup_gnu_properties): Report property merge
	in linker map file.  Pass abfd to elf_merge_gnu_property_list.

include/

	* bfdlink.h (bfd_link_info): Add has_map_file.

ld/

	* NEWS: Updated for property change report.
	* ld.texi: Document property change report.
	* ldmain.c (main): Set link_info.has_map_file to TRUE when
	linker map file is used.
	* testsuite/ld-scripts/rgn-over1.d: Updated.
	* testsuite/ld-scripts/rgn-over2.d: Likewise.
	* testsuite/ld-scripts/rgn-over3.d: Likewise.
	* testsuite/ld-scripts/rgn-over4.d: Likewise.
	* testsuite/ld-scripts/rgn-over5.d: Likewise.
	* testsuite/ld-scripts/rgn-over6.d: Likewise.
	* testsuite/ld-scripts/rgn-over7.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Check linker map
	file.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.map: New file.
2018-12-07 08:30:43 -08:00
Andrew Jenner b8891f8d62 Add support for the C_SKY series of processors.
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-30 12:24:14 +01:00
Thomas Preud'homme a05a5b64cf Fix use of "command line X" in binutils doc
Binutils documentation uses a mix of spelling for the compound word
"command-line X". According to [1]:

"Sometimes compound words are written separately (nail polish),
sometimes with a hyphen (short-sighted) and sometimes as one word
(eyelashes). Often new compounds are written as two separate words and,
as they become more familiar, they are either connected with a hyphen
(-) or made into one word."

I think command-line X is common enough in our industry that the two
workds command and line should be connected. Since command-line is more
common than commandline, I propose to update binutils documentation to
consistently use "command-line" when this is used as an adjective to a
noun (eg. command-line argument, command-line switch, command-line
option and command-line flag). I've left occurences of "the command
line" as is. I've also left gdb, sim and readline alone and have only
touched public documentation (texi and NEWS files).

[1]
http://dictionary.cambridge.org/grammar/british-grammar/word-formation/compounds

2018-07-02  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* doc/bfdint.texi: Use command-line consistently when used in a
	compount word.
	* doc/bfdsumm.texi: Likewise.

binutils/
	* NEWS: Use command-line consistently when used in a compount word.
	* doc/binutils.texi: Likewise and fix trailing whitespace on same
	line.

gas/
	* NEWS: Use command-line consistently when used in a compount word.
	* doc/as.texi: Likewise.
	* doc/c-aarch64.texi: Likewise.
	* doc/c-alpha.texi: Likewise.
	* doc/c-arc.texi: Likewise.
	* doc/c-arm.texi: Likewise.
	* doc/c-avr.texi: Likewise.
	* doc/c-bfin.texi: Likewise.
	* doc/c-cris.texi: Likewise.
	* doc/c-epiphany.texi: Likewise.
	* doc/c-i386.texi: Likewise.
	* doc/c-ia64.texi: Likewise.
	* doc/c-lm32.texi: Likewise.
	* doc/c-m32r.texi: Likewise.
	* doc/c-m68k.texi: Likewise.
	* doc/c-mips.texi: Likewise.
	* doc/c-mmix.texi: Likewise.
	* doc/c-msp430.texi: Likewise.
	* doc/c-mt.texi: Likewise.
	* doc/c-nios2.texi: Likewise.
	* doc/c-ppc.texi: Likewise.
	* doc/c-pru.texi: Likewise.
	* doc/c-rl78.texi: Likewise.
	* doc/c-rx.texi: Likewise.
	* doc/c-tic6x.texi: Likewise.
	* doc/c-v850.texi: Likewise.
	* doc/c-vax.texi: Likewise.
	* doc/c-visium.texi: Likewise.
	* doc/c-xstormy16.texi: Likewise.
	* doc/c-xtensa.texi: Likewise.
	* doc/c-z80.texi: Likewise.
	* doc/c-z8k.texi: Likewise.
	* doc/internals.texi: Likewise.

gprof/
	* gprof.texi: Use command-line consistently when used in a compount
	word.

ld/
	* NEWS: Use command-line consistently when used in a compount word.
	* ld.texinfo: Likewise.
	* ldint.texinfo: Likewise.
2018-07-02 11:18:24 +01:00
Nick Clifton 719d828850 Add 2.30 branch notes to ChangeLogs and NEWS files. 2018-06-24 18:36:15 +01:00
Eric Botcazou 142b7a144b Add blurb about linker changes for Cygwin and Mingw targets. 2018-04-04 12:18:09 +02:00
H.J. Lu f6aec96dce ld: Add --enable-separate-code
This patch adds --enable-separate-code to ld configure to turn on
-z separate-code by default and enables it by default for Linux/x86.
This avoids mixing code pages with data to improve cache performance
as well as security.

To reduce x86-64 executable and shared object sizes, the maximum page
size is reduced from 2MB to 4KB when -z separate-code is turned on by
default.  Note: -z max-page-size= can be used to set the maximum page
size.

We compared SPEC CPU 2017 performance before and after this change on
Skylake server.  There are no any significant performance changes.
Everything is mostly below +/-1%.

bfd/

	* config.in: Regenerated.
	* configure: Likewise.
	* configure.ac: Add --enable-separate-code.
	(DEFAULT_LD_Z_SEPARATE_CODE): New AC_DEFINE_UNQUOTED.  Default
	to 1 for Linux/x86 targets,
	* elf64-x86-64.c (ELF_MAXPAGESIZE): Set to 0x1000 if
	DEFAULT_LD_Z_SEPARATE_CODE is 1.

ld/

	* NEWS: Mention --enable-separate-code.
	* configure.ac: Add --enable-separate-code.
	(DEFAULT_LD_Z_SEPARATE_CODE): New AC_DEFINE_UNQUOTED.
	* configure.tgt: Default ac_default_ld_z_separate_code to 1 for
	Linux/x86 targets.
	* config.in: Regenerated.
	* configure: Likewise.
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set
	link_info.separate_code DEFAULT_LD_Z_SEPARATE_CODE.
2018-02-27 11:34:29 -08:00
Nick Clifton 9176ac5bfc Add 2.30 markers to NEWS files.
binutils/
	* NEWS: Add marker for 2.30.

gas/
	* NEWS: Add marker for 2.30.

ld/
	* NEWS: Add marker for 2.30.
2018-01-13 13:20:55 +00:00
Nick Clifton 97a232d733 Add -z undefs option to the ELF linker.
Currently we have no obvious way to revert the action of the "-z defs"
  command line option.  The "--unresolved-symbols=ignore-in-object-files"
  does pretty much what is needed, but it is non-obvious and it also
  touches the setting for reporting unresolved symbol references from
  shared libraries.  So I am proposing adding a "-z undefs" option to be
  the inverse of "-z defs".  (I thought that "-z nodefs" might be
  confusing since it implies banning all definitions, rather than
  allowing them).

  In addition the description of the "-z defs" option in the linker
  documentation is misleading in one place, where it says:

    'defs'
       Disallows undefined symbols in object files.  Undefined
       symbols in shared libraries are still allowed.

  whereas later on it gets it right:

    '-z defs'
       Report unresolved symbol references from regular object files.
       This is done even if the linker is creating a non-symbolic shared
       library.  The switch '--[no-]allow-shlib-undefined' controls the
       behaviour for reporting unresolved references found in shared
       libraries being linked in.

	* emultempl/elf32.em (_handle_option): Add support for "-z undefs"
	as the opposite of "-z defs".
	* ld.texinfo: Document the new option.  Update the description of
	the -z defs option to make it clear that it does generate an error
	if an undefined symbol reference is found in an object file whilst
	creating a shared library.
	* NEWS: Document this new feature.
2018-01-12 08:15:55 +00:00
H.J. Lu 47acac12c8 ld: Add "-z separate-code" option to ELF linker
The new "-z separate-code" option will generate separate code LOAD
segment which must be in wholly disjoint pages from any other data.

include/

	PR ld/22393
	* bfdlink.h (bfd_link_info): Add separate_code.

ld/

	PR ld/22393
	* NEWS: Mention "-z separate-code".
	* emultempl/elf32.em (gld${EMULATION_NAME}_get_script): Get
	builtin linker scripts and return linker scripts from disk for
	"-z separate-code".
	(gld${EMULATION_NAME}_handle_option): Handle "-z separate-code"
	and "-z noseparate-code".
	* genscripts.sh: Generate linker scripts for "-z separate-code".
	(LD_FLAG): Set to *textonly for "-z separate-code".
	* ld.texinfo: Document "-z separate-code".
	* lexsup.c (elf_shlib_list_options): Add linker help messsages
	for "-z separate-code" and "-z noseparate-code".
	* scripttempl/elf.sc (SEPARATE_TEXT): New
	(TEXT_SEGMENT_ALIGN): Likewise.
	Use ${TEXT_SEGMENT_ALIGN} to align and pad text segment to
	${MAXPAGESIZE}.
2018-01-11 19:01:52 -08:00
Alan Modra 219d1afa89 Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
Alan Modra 6c19b93bcd ld whitespace fixes
* pe-dll.c: Formatting, whitespace fixes.
	* NEWS: Whitespace fixes.
	* configure.ac: Likewise.
	* configure.tgt: Likewise.
	* deffilep.y: Likewise.
	* genscripts.sh: Likewise.
	* ld.texinfo: Likewise.
	* ldgram.y: Likewise.
	* ldlang.c: Likewise.
	* ldlex.l: Likewise.
	* lexsup.c: Likewise.
	* plugin.c: Likewise.
	* emulparams/arc-endianness.sh: Likewise.
	* emulparams/elf32_x86_64.sh: Likewise.
	* emulparams/elf64mmix.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/h8300elf.sh: Likewise.
	* emulparams/h8300elf_linux.sh: Likewise.
	* emulparams/vxworks.sh: Likewise.
	* emultempl/aarch64elf.em: Likewise.
	* emultempl/aix.em: Likewise.
	* emultempl/armelf.em: Likewise.
	* emultempl/avrelf.em: Likewise.
	* emultempl/beos.em: Likewise.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/m68kcoff.em: Likewise.
	* emultempl/m68kelf.em: Likewise.
	* emultempl/metagelf.em: Likewise.
	* emultempl/msp430.em: Likewise.
	* emultempl/nds32elf.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/sh64elf.em: Likewise.
	* emultempl/spu_ovl.S: Likewise.
	* emultempl/spuelf.em: Likewise.
	* emultempl/tic6xdsbt.em: Likewise.
	* emultempl/ticoff.em: Likewise.
	* emultempl/vms.em: Likewise.
	* po/Make-in: Likewise.
	* scripttempl/DWARF.sc: Likewise.
	* scripttempl/aix.sc: Likewise.
	* scripttempl/alpha.sc: Likewise.
	* scripttempl/alphavms.sc: Likewise.
	* scripttempl/aout.sc: Likewise.
	* scripttempl/arclinux.sc: Likewise.
	* scripttempl/armaout.sc: Likewise.
	* scripttempl/armbpabi.sc: Likewise.
	* scripttempl/armcoff.sc: Likewise.
	* scripttempl/avr.sc: Likewise.
	* scripttempl/crisaout.sc: Likewise.
	* scripttempl/delta68.sc: Likewise.
	* scripttempl/dlx.sc: Likewise.
	* scripttempl/elf.sc: Likewise.
	* scripttempl/elf32cr16.sc: Likewise.
	* scripttempl/elf32cr16c.sc: Likewise.
	* scripttempl/elf32crx.sc: Likewise.
	* scripttempl/elf32msp430.sc: Likewise.
	* scripttempl/elf32msp430_3.sc: Likewise.
	* scripttempl/elf32sh-symbian.sc: Likewise.
	* scripttempl/elf32xc16x.sc: Likewise.
	* scripttempl/elf32xc16xl.sc: Likewise.
	* scripttempl/elf32xc16xs.sc: Likewise.
	* scripttempl/elf64hppa.sc: Likewise.
	* scripttempl/elf_chaos.sc: Likewise.
	* scripttempl/elfarc.sc: Likewise.
	* scripttempl/elfarcv2.sc: Likewise.
	* scripttempl/elfd10v.sc: Likewise.
	* scripttempl/elfd30v.sc: Likewise.
	* scripttempl/elfi370.sc: Likewise.
	* scripttempl/elfm68hc11.sc: Likewise.
	* scripttempl/elfm68hc12.sc: Likewise.
	* scripttempl/elfmicroblaze.sc: Likewise.
	* scripttempl/elfxgate.sc: Likewise.
	* scripttempl/elfxtensa.sc: Likewise.
	* scripttempl/epiphany_4x4.sc: Likewise.
	* scripttempl/epocpe.sc: Likewise.
	* scripttempl/h8300.sc: Likewise.
	* scripttempl/h8300h.sc: Likewise.
	* scripttempl/h8300hn.sc: Likewise.
	* scripttempl/h8300s.sc: Likewise.
	* scripttempl/h8300sn.sc: Likewise.
	* scripttempl/h8300sx.sc: Likewise.
	* scripttempl/h8300sxn.sc: Likewise.
	* scripttempl/h8500.sc: Likewise.
	* scripttempl/h8500b.sc: Likewise.
	* scripttempl/h8500c.sc: Likewise.
	* scripttempl/h8500m.sc: Likewise.
	* scripttempl/h8500s.sc: Likewise.
	* scripttempl/hppaelf.sc: Likewise.
	* scripttempl/i386beos.sc: Likewise.
	* scripttempl/i386coff.sc: Likewise.
	* scripttempl/i386go32.sc: Likewise.
	* scripttempl/i386msdos.sc: Likewise.
	* scripttempl/i860coff.sc: Likewise.
	* scripttempl/i960.sc: Likewise.
	* scripttempl/ia64vms.sc: Likewise.
	* scripttempl/ip2k.sc: Likewise.
	* scripttempl/iq2000.sc: Likewise.
	* scripttempl/m68kaux.sc: Likewise.
	* scripttempl/m68kcoff.sc: Likewise.
	* scripttempl/m88kbcs.sc: Likewise.
	* scripttempl/mcorepe.sc: Likewise.
	* scripttempl/mep.sc: Likewise.
	* scripttempl/mips.sc: Likewise.
	* scripttempl/mipsbsd.sc: Likewise.
	* scripttempl/mmo.sc: Likewise.
	* scripttempl/moxie.sc: Likewise.
	* scripttempl/nds32elf.sc: Likewise.
	* scripttempl/nw.sc: Likewise.
	* scripttempl/pe.sc: Likewise.
	* scripttempl/pep.sc: Likewise.
	* scripttempl/pj.sc: Likewise.
	* scripttempl/ppcpe.sc: Likewise.
	* scripttempl/psos.sc: Likewise.
	* scripttempl/riscix.sc: Likewise.
	* scripttempl/sh.sc: Likewise.
	* scripttempl/sparccoff.sc: Likewise.
	* scripttempl/st2000.sc: Likewise.
	* scripttempl/tic30aout.sc: Likewise.
	* scripttempl/tic30coff.sc: Likewise.
	* scripttempl/tic4xcoff.sc: Likewise.
	* scripttempl/tic54xcoff.sc: Likewise.
	* scripttempl/tic80coff.sc: Likewise.
	* scripttempl/v850.sc: Likewise.
	* scripttempl/v850_rh850.sc: Likewise.
	* scripttempl/vanilla.sc: Likewise.
	* scripttempl/visium.sc: Likewise.
	* scripttempl/w65.sc: Likewise.
	* scripttempl/xstormy16.sc: Likewise.
	* scripttempl/z80.sc: Likewise.
	* scripttempl/z8000.sc: Likewise.
	* configure: Regenerate.
2017-10-12 23:30:43 +10:30
Alan Modra 9194f82dc3 PR21294, Binary size regression on PPC embedded
PR 21294
	* NEWS: Note that defaulting to -z relro results in increased
	memory and disk size.
2017-10-03 15:11:25 +10:30
Nick Clifton 93ab9c0de7 Add -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag bit in the dynamic tags.
* emultempl/elf32.em (handle_option): Accept the -z globalaudit
	command line option.
	* lexsup.c (elf_static_list_options): Add -z globalaudit.
	* ld.texinfo: Document the support for the new command line
	option.
	* NEWS: Mention the new feature.
	* testsuite/ld-elf/audit.exp: Add a test of the -z globalaudit
	command line option.
	* testsuite/ld-elf/globalaudit.rd: New file: Expected output from
	readelf.
2017-08-11 16:36:28 +01:00
Andrew Burgess 2b94abd48a Make some improvements to how SORT_* specifiers and EXCLUDE_FILE specifiers are handled in the linker script grammar.
* ldgram.y (ldgram_had_keep): Make static.
	(ldgram_vers_current_lang): Likewise.
	(filename_spec): New rule.
	(input_section_spec_no_keep): Use filename_spec.
	(wildcard_maybe_exclude): New rule.
	(wildcard_spec): Rename to...
	(section_name_spec): ...this.
	(section_NAME_list): Rename to...
	(section_name_list): ...this.
	(section_name_spec): Simplifiy and use wildcard_maybe_exclude.
	* ldlang.c (placed_commons): Delete.
	(lang_add_wild): No longer set placed_commons.
	(print_wild_statement): Use full names for SORT specifiers.
	* testsuite/ld-scripts/align.exp: Run new tests.
	* testsuite/ld-scripts/align3.d: New file.
	* testsuite/ld-scripts/align3.t: New file.
	* testsuite/ld-scripts/align4.d: New file.
	* testsuite/ld-scripts/align4.t: New file.
	* testsuite/ld-scripts/align5.d: New file.
	* testsuite/ld-scripts/align5.t: New file.
	* testsuite/ld-scripts/exclude-file-5.d: New file.
	* testsuite/ld-scripts/exclude-file-5.map: New file.
	* testsuite/ld-scripts/exclude-file-5.t: New file.
	* testsuite/ld-scripts/exclude-file-6.d: New file.
	* testsuite/ld-scripts/exclude-file-6.map: New file.
	* testsuite/ld-scripts/exclude-file-6.t: New file.
	* NEWS: Mention the changes.
2017-07-28 13:01:10 +01:00
Tristan Gingold 55a09eb6df Add markers.
binutils/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.29.

gas/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.29.

ld/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.29.
2017-07-04 11:07:03 +02:00
H.J. Lu 48580982ef x86: Support Intel Shadow Stack with SHSTK property
To support Intel Shadow Stack (SHSTK) in Intel Control-flow Enforcement
Technology (CET) instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

 #define GNU_PROPERTY_X86_FEATURE_1_SHSTK (1U << 1)

is added to GNU program properties to indicate that all executable sections
are compatible with SHSTK where return address popped from shadow stack
always matches return address popped from normal stack.

GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on output only if it is set on all
relocatable inputs.

bfd/

	* elf32-i386.c (elf_i386_merge_gnu_properties): If info->shstk
	is set, turn on GNU_PROPERTY_X86_FEATURE_1_SHSTK.
	(elf_i386_link_setup_gnu_properties): If info->shstk is set,
	turn on GNU_PROPERTY_X86_FEATURE_1_IBT.
	* elf64-x86-64.c (elf_x86_64_merge_gnu_properties): If
	info->shstk is set, turn on GNU_PROPERTY_X86_FEATURE_1_SHSTK.
	(elf_x86_64_link_setup_gnu_properties): If info->shstk is set,
	turn on GNU_PROPERTY_X86_FEATURE_1_IBT.

binutils/

	* readelf.c (decode_x86_feature): Decode
	GNU_PROPERTY_X86_FEATURE_1_SHSTK.
	* testsuite/binutils-all/i386/shstk.d: New file.
	* testsuite/binutils-all/i386/shstk.s: Likewise.
	* testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk.s: Likewise.

include/

	* bfdlink.h (bfd_link_info): Add shstk.
	* elf/common.h (GNU_PROPERTY_X86_FEATURE_1_SHSTK): New.

ld/

	* NEWS: Mention -z shstk and GNU_PROPERTY_X86_FEATURE_1_SHSTK.
	* emulparams/cet.sh (PARSE_AND_LIST_OPTIONS_CET): Add "-z shstk".
	(PARSE_AND_LIST_ARGS_CASE_Z_CET): Support "-z shstk".
	* ld.texinfo: Document -z shstk.
	* testsuite/ld-i386/i386.exp: Run SHSTK tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/property-x86-shstk.s: New file.
	* testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk2.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk4.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk.s: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2.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-x86-64/property-x86-shstk4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.
2017-06-22 05:50:31 -07:00
H.J. Lu ee2fdd6f36 x86: Support Intel IBT with IBT property and IBT-enable PLT
To support IBT in Intel Control-flow Enforcement Technology (CET)
instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

 #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002

 #define GNU_PROPERTY_X86_FEATURE_1_IBT (1U << 0)

are added to GNU program properties to indicate that all executable
sections are compatible with IBT when ENDBR instruction starts each
valid target where an indirect branch instruction can land.

GNU_PROPERTY_X86_FEATURE_1_IBT is set on output only if it is set on
all relocatable inputs.

The followings changes are made to the Procedure Linkage Table (PLT):

1. For 64-bit x86-64,  PLT is changed to

PLT0:  push       GOT[1]
       bnd jmp    *GOT[2]
       nop
...
PLTn:  endbr64
       push       namen_reloc_index
       bnd jmp    PLT0

together with the second PLT section:

PLTn:  endbr64
       bnd jmp   *GOT[namen_index]
       nop

BND prefix is also added so that IBT-enabled PLT is compatible with MPX.

2. For 32-bit x86-64 (x32) and i386,  PLT is changed to

PLT0:  push       GOT[1]
       jmp        *GOT[2]
       nop
...
PLTn:  endbr64                                 # endbr32 for i386.
       push       namen_reloc_index
       jmp        PLT0

together with the second PLT section:

PLTn:  endbr64                                 # endbr32 for i386.
       jmp       *GOT[namen_index]
       nop

BND prefix isn't used since MPX isn't supported on x32 and BND registers
aren't used in parameter passing on i386.

GOT is an array of addresses.  Initially, GOT[namen_index] is filled
with the address of the ENDBR instruction of the corresponding entry
in the first PLT section.  The function, namen, is called via the
ENDBR instruction in the second PLT entry.  GOT[namen_index] is updated
to the actual address of the function, namen, at run-time.

2 linker command line options are added:

1. -z ibtplt: Generate IBT-enabled PLT.
2. -z ibt: Generate GNU_PROPERTY_X86_FEATURE_1_IBT in GNU program
properties as well as IBT-enabled PLT.

bfd/

	* elf32-i386.c (elf_i386_lazy_ibt_plt0_entry): New.
	(elf_i386_lazy_ibt_plt_entry): Likewise.
	(elf_i386_pic_lazy_ibt_plt0_entry): Likewise.
	(elf_i386_non_lazy_ibt_plt_entry): Likewise.
	(elf_i386_pic_non_lazy_ibt_plt_entry): Likewise.
	(elf_i386_eh_frame_lazy_ibt_plt): Likewise.
	(elf_i386_lazy_plt_layout): Likewise.
	(elf_i386_non_lazy_plt_layout): Likewise.
	(elf_i386_link_hash_entry): Add plt_second.
	(elf_i386_link_hash_table): Add plt_second and
	plt_second_eh_frame.
	(elf_i386_allocate_dynrelocs): Use the second PLT if needed.
	(elf_i386_size_dynamic_sections): Use .plt.got unwind info for
	the second PLT.  Check the second PLT.
	(elf_i386_relocate_section): Use the second PLT to resolve
	PLT reference if needed.
	(elf_i386_finish_dynamic_symbol): Fill and use the second PLT if
	needed.
	(elf_i386_finish_dynamic_sections): Set sh_entsize on the
	second PLT.  Generate unwind info for the second PLT.
	(elf_i386_plt_type): Add plt_second.
	(elf_i386_get_synthetic_symtab): Support the second PLT.
	(elf_i386_parse_gnu_properties): Support
	GNU_PROPERTY_X86_FEATURE_1_AND.
	(elf_i386_merge_gnu_properties): Support
	GNU_PROPERTY_X86_FEATURE_1_AND.  If info->ibt is set, turn
	on GNU_PROPERTY_X86_FEATURE_1_IBT
	(elf_i386_link_setup_gnu_properties): If info->ibt is set,
	turn on GNU_PROPERTY_X86_FEATURE_1_IBT.  Use IBT-enabled PLT
	for info->ibtplt, info->ibt or GNU_PROPERTY_X86_FEATURE_1_IBT
	is set on all relocatable inputs.
	* elf64-x86-64.c (elf_x86_64_lazy_ibt_plt_entry): New.
	(elf_x32_lazy_ibt_plt_entry): Likewise.
	(elf_x86_64_non_lazy_ibt_plt_entry): Likewise.
	(elf_x32_non_lazy_ibt_plt_entry): Likewise.
	(elf_x86_64_eh_frame_lazy_ibt_plt): Likewise.
	(elf_x32_eh_frame_lazy_ibt_plt): Likewise.
	(elf_x86_64_lazy_ibt_plt): Likewise.
	(elf_x32_lazy_ibt_plt): Likewise.
	(elf_x86_64_non_lazy_ibt_plt): Likewise.
	(elf_x32_non_lazy_ibt_plt): Likewise.
	(elf_x86_64_get_synthetic_symtab): Support the second PLT.
	(elf_x86_64_parse_gnu_properties): Support
	GNU_PROPERTY_X86_FEATURE_1_AND.
	(elf_x86_64_merge_gnu_properties): Support
	GNU_PROPERTY_X86_FEATURE_1_AND.  If info->ibt is set, turn
	on GNU_PROPERTY_X86_FEATURE_1_IBT
	(elf_x86_64_link_setup_gnu_properties): If info->ibt is set,
	turn on GNU_PROPERTY_X86_FEATURE_1_IBT.  Use IBT-enabled PLT
	for info->ibtplt, info->ibt or GNU_PROPERTY_X86_FEATURE_1_IBT
	is set on all relocatable inputs.

binutils/

	* readelf.c (decode_x86_feature): New.
	(print_gnu_property_note): Call decode_x86_feature on
	GNU_PROPERTY_X86_FEATURE_1_AND.
	* testsuite/binutils-all/i386/empty.d: New file.
	* testsuite/binutils-all/i386/empty.s: Likewise.
	* testsuite/binutils-all/i386/ibt.d: Likewise.
	* testsuite/binutils-all/i386/ibt.s: Likewise.
	* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.s: Likewise.
	* testsuite/binutils-all/x86-64/ibt-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt.s: Likewise.

include/

	* bfdlink.h (bfd_link_info): Add ibtplt and ibt.
	* elf/common.h (GNU_PROPERTY_X86_FEATURE_1_AND): New.
	(GNU_PROPERTY_X86_FEATURE_1_IBT): Likewise.

ld/

	* Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emulparams/cet.sh.
	* Makefile.in: Regenerated.
	* NEWS: Mention GNU_PROPERTY_X86_FEATURE_1_IBT, -z ibtplt
	and -z ibt.
	* emulparams/cet.sh: New file.
	* testsuite/ld-i386/ibt-plt-1.d: Likewise.
	* testsuite/ld-i386/ibt-plt-1.s: Likewise.
	* testsuite/ld-i386/ibt-plt-2.s: Likewise.
	* testsuite/ld-i386/ibt-plt-2a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2b.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3.s: Likewise.
	* testsuite/ld-i386/ibt-plt-3a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3b.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3c.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
	* testsuite/ld-i386/plt-main-ibt.dd: Likewise.
	* testsuite/ld-i386/plt-pie-ibt.dd: Likewise.
	* testsuite/ld-i386/property-x86-empty.s: Likewise.
	* testsuite/ld-i386/property-x86-ibt.s: Likewise.
	* testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt2.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt4.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt5.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1.s: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2.s: 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.
	* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3.s: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3a.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3b-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3b.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
	* testsuite/ld-x86-64/plt-main-ibt-now.rd: Likewise.
	* testsuite/ld-x86-64/plt-main-ibt-x32.dd: Likewise.
	* testsuite/ld-x86-64/plt-main-ibt.dd: Likewise.
	* testsuite/ld-x86-64/property-x86-empty.s: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt.s: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2.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-ibt4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
	* emulparams/elf32_x86_64.sh: Source emulparams/cet.sh.
	(TINY_READONLY_SECTION): Add .plt.sec.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_x86_64.sh: Source emulparams/cet.sh.
	* ld.texinfo: Document -z ibtplt and -z ibt.
	* testsuite/ld-i386/i386.exp: Run IBT and IBT PLT tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-x86-64/pr21481b.S (check): Updated for x32.
2017-06-22 05:44:53 -07:00
Andrew Burgess 7bdf4127c3 ld: Allow section groups to be resolved as part of a relocatable link
This commit adds a new linker feature: the ability to resolve section
groups as part of a relocatable link.

Currently section groups are automatically resolved when performing a
final link, and are carried through when performing a relocatable link.
By carried through this means that one copy of each section group (from
all the copies that might be found in all the input files) is placed
into the output file.  Sections that are part of a section group will
not match input section specifiers within a linker script and are
forcibly kept as separate sections.

There is a slight resemblance between section groups and common
section.  Like section groups, common sections are carried through when
performing a relocatable link, and resolved (allocated actual space)
only at final link time.

However, with common sections there is an ability to force the linker to
allocate space for the common sections when performing a relocatable
link, there's currently no such ability for section groups.

This commit adds such a mechanism.  This new facility can be accessed in
two ways, first there's a command line switch --force-group-allocation,
second, there's a new linker script command FORCE_GROUP_ALLOCATION.  If
one of these is used when performing a relocatable link then the linker
will resolve the section groups as though it were performing a final
link, the section group will be deleted, and the members of the group
will be placed like normal input sections.  If there are multiple copies
of the group (from multiple input files) then only one copy of the group
members will be placed, the duplicate copies will be discarded.

Unlike common sections that have the --no-define-common command line
flag, and INHIBIT_COMMON_ALLOCATION linker script command there is no
way to prevent group resolution during a final link, this is because the
ELF gABI specifically prohibits the presence of SHT_GROUP sections in a
fully linked executable.  However, the code as written should make
adding such a feature trivial, setting the new resolve_section_groups
flag to false during a final link should work as you'd expect.

bfd/ChangeLog:

	* elf.c (_bfd_elf_make_section_from_shdr): Don't initially mark
	SEC_GROUP sections as SEC_EXCLUDE.
	(bfd_elf_set_group_contents): Replace use of abort with an assert.
	(assign_section_numbers): Use resolve_section_groups flag instead
	of relocatable link type.
	(_bfd_elf_init_private_section_data): Use resolve_section_groups
	flag instead of checking the final_link flag for part of the
	checks in here.  Fix white space as a result.
	* elflink.c (elf_link_input_bfd): Use resolve_section_groups flag
	instead of relocatable link type.
	(bfd_elf_final_link): Likewise.

include/ChangeLog:

	* bfdlink.h (struct bfd_link_info): Add new resolve_section_groups
	flag.

ld/ChangeLog:

	* ld.h (struct args_type): Add force_group_allocation field.
	* ldgram.y: Add support for FORCE_GROUP_ALLOCATION.
	* ldlex.h: Likewise.
	* ldlex.l: Likewise.
	* lexsup.c: Likewise.
	* ldlang.c (unique_section_p): Check resolve_section_groups flag
	not the relaxable link flag.
	(lang_add_section): Discard section groups when we're resolving
	groups.  Clear the SEC_LINK_ONCE flag if we're resolving section
	groups.
	* ldmain.c (main): Initialise resolve_section_groups flag in
	link_info based on command line flags.
	* testsuite/ld-elf/group11.d: New file.
	* testsuite/ld-elf/group12.d: New file.
	* testsuite/ld-elf/group12.ld: New file.
	* NEWS: Mention new features.
	* ld.texinfo (Options): Document --force-group-allocation.
	(Miscellaneous Commands): Document FORCE_GROUP_ALLOCATION.
2017-06-06 09:53:38 +01:00
H.J. Lu a91e1603af Support ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX
Mark an ALLOC section, which should be placed in special memory area,
with SHF_GNU_MBIND.  Its sh_info field indicates the special memory
type.  GNU_MBIND section names start with ".mbind" so that they are
placed as orphan sections by linker.  All input GNU_MBIND sections
with the same sh_type, sh_flags and sh_info are placed in one output
GNU_MBIND section.  In executable and shared object, create a
GNU_MBIND segment for each GNU_MBIND section and its segment type is
PT_GNU_MBIND_LO plus the sh_info value.  Each GNU_MBIND segment is
aligned at page boundary.

The assembler syntax:

    .section .mbind.foo,"adx",%progbits
                          ^             0: Special memory type.
                          |
                         'd' for SHF_GNU_MBIND.

    .section .mbind.foo,"adx",%progbits,0x1
                          ^             1: Special memory type.
                          |
                         'd' for SHF_GNU_MBIND.

    .section .mbind.bar,"adG",%progbits,.foo_group,comdat,0x2
                          ^                               2: Special memory type.
                          |
                         'd' for SHF_GNU_MBIND.

bfd/

	* elf.c (get_program_header_size): Add a GNU_MBIND segment for
	each GNU_MBIND section and align GNU_MBIND section to page size.
	(_bfd_elf_map_sections_to_segments): Create a GNU_MBIND
	segment for each GNU_MBIND section.
	(_bfd_elf_init_private_section_data): Copy sh_info from input
	for GNU_MBIND section.

binutils/

	* NEWS: Mention support for ELF SHF_GNU_MBIND and
	PT_GNU_MBIND_XXX.
	* readelf.c (get_segment_type): Handle PT_GNU_MBIND_XXX.
	(get_elf_section_flags): Handle SHF_GNU_MBIND.
	(process_section_headers): Likewise.
	* testsuite/binutils-all/mbind1.s: New file.
	* testsuite/binutils-all/objcopy.exp: Run readelf test on
	mbind1.s.

gas/

	* NEWS: Mention support for ELF SHF_GNU_MBIND.
	* config/obj-elf.c (section_match): New.
	(get_section): Match both sh_info and group name.
	(obj_elf_change_section): Add argument for sh_info.  Pass both
	sh_info and group name to get_section. Issue an error for
	SHF_GNU_MBIND section without SHF_ALLOC.  Set sh_info.
	(obj_elf_parse_section_letters): Set SHF_GNU_MBIND for 'd'.
	(obj_elf_section): Support SHF_GNU_MBIND section info.
	* config/obj-elf.h (obj_elf_change_section): Add argument for
	sh_info.
	* config/tc-arm.c (start_unwind_section): Pass 0 as sh_info to
	obj_elf_change_section.
	* config/tc-ia64.c (obj_elf_vms_common): Likewise.
	* config/tc-microblaze.c (microblaze_s_data): Likewise.
	(microblaze_s_sdata): Likewise.
	(microblaze_s_rdata): Likewise.
	(microblaze_s_bss): Likewise.
	* config/tc-mips.c (s_change_section): Likewise.
	* config/tc-msp430.c (msp430_profiler): Likewise.
	* config/tc-rx.c (parse_rx_section): Likewise.
	* config/tc-tic6x.c (tic6x_start_unwind_section): Likewise.
	* doc/as.texinfo: Document 'd' for SHF_GNU_MBIND.
	* testsuite/gas/elf/elf.exp: Run section12a, section12b and
	section13.
	* testsuite/gas/elf/section10.d: Updated.
	* testsuite/gas/elf/section10.s: Likewise.
	* testsuite/gas/elf/section12.s: New file.
	* testsuite/gas/elf/section12a.d: Likewise.
	* testsuite/gas/elf/section12b.d: Likewise.
	* testsuite/gas/elf/section13.l: Likewise.
	* testsuite/gas/elf/section13.d: Likewise.
	* testsuite/gas/elf/section13.s: Likewise.

include/

	* elf/common.h (PT_GNU_MBIND_NUM): New.
	(PT_GNU_MBIND_LO): Likewise.
	(PT_GNU_MBIND_HI): Likewise.
	(SHF_GNU_MBIND): Likewise.

ld/

	* NEWS: Mention support for ELF SHF_GNU_MBIND and
	PT_GNU_MBIND_XXX.
	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Place
	input GNU_MBIND sections with the same type, attributes and
	sh_info field into a single output GNU_MBIND section.
	* testsuite/ld-elf/elf.exp: Run mbind2a and mbind2b.
	* testsuite/ld-elf/mbind1.s: New file.
	* testsuite/ld-elf/mbind1a.d: Likewise.
	* testsuite/ld-elf/mbind1b.d: Likewise.
	* testsuite/ld-elf/mbind1c.d: Likewise.
	* testsuite/ld-elf/mbind2a.s: Likewise.
	* testsuite/ld-elf/mbind2b.c: Likewise.
2017-04-04 09:06:04 -07:00
H.J. Lu 46bed6796d ld: Support ELF GNU program properties
From .note.gnu.property section in each ELF input, we build a list of
GNU properties if .note.gnu.property section isn't corrupt.  The unknown
properties are ignored.  All property lists in relocatable inputs are
merged into an output property list.  When -z stack-size=N is used and
N isn't 0, the GNU_PROPERTY_STACK_SIZE property will be merged with or
added to the output property list.  .note.gnu.property section is
generated in output from the output property list.

bfd/

	* Makefile.am (BFD32_BACKENDS): Add elf-properties.lo.
	(BFD32_BACKENDS_CFILES): Add elf-properties.c.
	* configure.ac (elf): Add elf-properties.lo.
	* Makefile.in: Regenerated.
	* configure: Likewise.
	* elf-bfd.h (elf_property_kind): New.
	(elf_property): Likewise.
	(elf_property_list): Likewise.
	(elf_properties): Likewise.
	(_bfd_elf_parse_gnu_properties): Likewise.
	(_bfd_elf_get_property): Likewise.
	(_bfd_elf_link_setup_gnu_properties): Likewise.
	(elf_backend_data): Add parse_gnu_properties, merge_gnu_properties
	and setup_gnu_properties.
	(elf_obj_tdata): Add properties.
	* elf-properties.c: New file.
	* elf32-i386.c (elf_i386_parse_gnu_properties): New.
	(elf_i386_merge_gnu_properties): Likewise.
	(elf_backend_parse_gnu_properties): Likewise.
	(elf_backend_merge_gnu_properties): Likewise.
	* elf64-x86-64.c (elf_x86_64_parse_gnu_properties): Likewise.
	(elf_x86_64_merge_gnu_properties): Likewise.
	(elf_backend_parse_gnu_properties): Likewise.
	(elf_backend_merge_gnu_properties): Likewise.
	* elfxx-target.h (elf_backend_merge_gnu_properties): Likewise.
	(elf_backend_parse_gnu_properties): Likewise.
	(elf_backend_setup_gnu_properties): Likewise.
	(elfNN_bed): Add elf_backend_parse_gnu_properties,
	elf_backend_merge_gnu_properties and
	elf_backend_setup_gnu_properties.

ld/

	* ld/NEWS: Mention support for ELF GNU program properties.
	* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Call
	ELF setup_gnu_properties.
	* testsuite/ld-i386/i386.exp: Run property tests for Linux/i386.
	* testsuite/ld-i386/pass.c: New file.
	* testsuite/ld-i386/property-1.r: Likewise.
	* testsuite/ld-i386/property-2.r: Likewise.
	* testsuite/ld-i386/property-3.r: Likewise.
	* testsuite/ld-i386/property-4.r: Likewise.
	* testsuite/ld-i386/property-5.r: Likewise.
	* testsuite/ld-i386/property-6.r: Likewise.
	* testsuite/ld-i386/property-6a.c: Likewise.
	* testsuite/ld-i386/property-6b.c: Likewise.
	* testsuite/ld-i386/property-6c.S: Likewise.
	* testsuite/ld-i386/property-7.r: Likewise.
	* testsuite/ld-i386/property-no-copy.S: Likewise.
	* testsuite/ld-i386/property-stack.S: Likewise.
	* testsuite/ld-i386/property-unsorted-1.S: Likewise.
	* testsuite/ld-i386/property-unsorted-2.S: Likewise.
	* testsuite/ld-i386/property-x86-1.S: Likewise.
	* testsuite/ld-i386/property-x86-2.S: Likewise.
	* testsuite/ld-x86-64/pass.c: Likewise.
	* testsuite/ld-x86-64/property-1.r: Likewise.
	* testsuite/ld-x86-64/property-2.r: 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-6.r: Likewise.
	* testsuite/ld-x86-64/property-6a.c: Likewise.
	* testsuite/ld-x86-64/property-6b.c: Likewise.
	* testsuite/ld-x86-64/property-6c.S: Likewise.
	* testsuite/ld-x86-64/property-7.r: Likewise.
	* testsuite/ld-x86-64/property-no-copy.S: Likewise.
	* testsuite/ld-x86-64/property-stack.S: Likewise.
	* testsuite/ld-x86-64/property-unsorted-1.S: Likewise.
	* testsuite/ld-x86-64/property-unsorted-2.S: Likewise.
	* testsuite/ld-x86-64/property-x86-1.S: Likewise.
	* testsuite/ld-x86-64/property-x86-2.S: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run property tests for
	Linux/x86-64.
2017-04-03 08:08:27 -07:00
Andrew Burgess 14ea2c1b23 ld: Track changes to default region LMA even for empty sections
Given a linker script fragment like this:

   SECTIONS {
     . = 0x1000;
     .text   : AT(0x100) { *(.text)   }
     .data   : AT(0x200) { *(.data)   }
     .rodata : AT(0x300) { *(.rodata) }
   }

and an input file containing sections, '.text', '.data.1', and
'.rodata', then we'd expect the linker to place '.text' and '.rodata' in
the obvious way, and the '.data.1' orphan section would be located after
the '.data' section (assuming similar section properties).

Further, I believe that the expectation would be that the LMA for the
orphan '.data.1' section would start from 0x200 (as there is no '.data'
content).

However, right now, the LMA for '.data.1' would be 0x101, following on
from the '.text' section, this is because the change in LMA for the
'.data' section is not noticed by the linker, if there's no content in
the '.data' section.

What can be even more confusing to a user (though the cause is obvious
once you understand what's going on) is that adding some content to
'.data' will cause the orphan '.data.1' to switch to an LMA based off of
0x200.

This commit changes the behaviour so that an empty section that is in
the default lma region, and sets its lma, will adjust the lma of the
default region, this change will then be reflected in following sections
within the default lma memory region.

There's a new test to cover this issue that passes on a range of
targets, however, some targets generate additional sections, or have
stricter memory region size requirements that make it harder to come
up with a generic pass pattern, that still tests the required
features.  For now I've set the test to ignore these targets.

ld/ChangeLog:

	* ldlang.c (lang_size_sections_1): Shortcut loop only after
	tracking changes to the default regions LMA.
	* testsuite/ld-elf/orphan-9.ld: Extend header comment.
	* testsuite/ld-elf/orphan-10.d: New file.
	* testsuite/ld-elf/orphan-10.s: New file.
	* NEWS: Mention change in behaviour.
2017-03-09 21:11:06 +00:00
Andrew Burgess 77f5e65ecf ld: better handling of lma region for orphan sections
When picking an lma_region for an orphan section we currently create a
new lang_output_section_statement_type and then populate this with the
orphan section.

The problem is that the lang_output_section_statement_type has a prev
pointer that links back to the previous output section.  For non-orphan
output sections, that are created in linker script order, the prev
pointer will point to the output section that appears previous in linker
script order, as you'd probably expect.

The problem is that orphan sections are placed after processing the
linker script, and so, in the case of an output section created for an
orphan input section, the prev pointer actually points to the last
output section created.

This causes some unexpected behaviour when the orphan section is not
placed after the last non-orphan section that was created.

For example, consider this linker script:

  MEMORY {
    TEXT   : ORIGIN = 0x200,  LENGTH = 0x10
    RODATA : ORIGIN = 0x400,  LENGTH = 0x10
  }

  SECTIONS {
    .text   :           {*(.text)    } AT>TEXT
    .data   : AT(0x300) { *(.data)   }
    .rodata :           { *(.rodata) } AT>RODATA
  }

If we are processing an orphan section '.data.1' and decide to place
this after '.data', then the output section created will have a prev
pointer that references the '.rodata' output section.  The result of
this is that '.data.1' will actually be assigned to the RODATA lma
region, which is probably not the expected behaviour.

The reason why '.data.1' is placed into the lma region of the '.rodata'
section is that lma region propagation is done at the time we create the
output section, based on the previous output section pointer, which is
really just a last-output-section-created pointer at that point in time,
though the prev point is fixed up later to reflect the true order of the
output sections.

The solution I propose in this commit is to move the propagation of lma
regions into a separate pass of the linker, rather than performing this
as part of the enter/exit of output sections during linker script
parsing.

During this later phase we have all of the output sections to hand, and
the prev/next points have been fixed up by this point to reflect the
actual placement ordering.

There's a new test to cover this issue that passes on a range of
targets, however, some targets generate additional sections, or have
stricter memory region size requirements that make it harder to come
up with a generic pass pattern, that still tests the required
features.  For now I've set the test to ignore these targets.

ld/ChangeLog:

	* ldlang.c (lang_leave_output_section_statement): Move lma_region
	logic to...
	(lang_propagate_lma_regions): ...this new function.
	(lang_process): Call new function.
	* testsuite/ld-elf/orphan-9.d: New file.
	* testsuite/ld-elf/orphan-9.ld: New file.
	* testsuite/ld-elf/orphan-9.s: New file.
	* NEWS: Mention change in behaviour.
2017-03-09 21:11:05 +00:00
Andrew Burgess d7488716ee ld/arc: Change default linker emulation for nps400
If we are configuring for an arc/linux target, and --with-cpu=nps400 is
used at configure time then change the default linker emulation to the
nps specific version.  All of the alternative linker emulations are
still available using the -mNAME option for ld.

ld/ChangeLog:

	* configure.tgt (arc*-*-linux*): Change the default linker
	emulation based on --with-cpu selection.
	* NEWS: Mention new configuration option.
2017-02-08 23:47:43 +00:00
Alan Modra 2571583aed Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
Dimitar Dimitrov 0220170b4d PRU LD Port
* NEWS: Mention new PRU target.
	* Makefile.am: Add PRU target.
	* configure.tgt: Ditto.
	* emulparams/pruelf.sh: New file.
	* emultempl/pruelf.em: New file.
	* scripttempl/pru.sc: New file.
	* Makefile.in: Regenerate.
	* testsuite/ld-pru/emit-relocs-1.d: New PRU testcase file.
	* testsuite/ld-pru/emit-relocs-1.ld: Ditto.
	* testsuite/ld-pru/emit-relocs-1a.s: Ditto.
	* testsuite/ld-pru/emit-relocs-1b.s
	* testsuite/ld-pru/ldi32.d: Ditto.
	* testsuite/ld-pru/ldi32.s: Ditto.
	* testsuite/ld-pru/ldi32_symbol.s: Ditto.
	* testsuite/ld-pru/norelax_ldi32-data.d: Ditto.
	* testsuite/ld-pru/norelax_ldi32-dis.d: Ditto.
	* testsuite/ld-pru/pcrel_s10.d: Ditto.
	* testsuite/ld-pru/pcrel_s10.s: Ditto.
	* testsuite/ld-pru/pcrel_s10_label.s: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal.d: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal.s: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal2.d: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal2.s: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal3.d: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal3.s: Ditto.
	* testsuite/ld-pru/pcrel_u8.d: Ditto.
	* testsuite/ld-pru/pcrel_u8.s: Ditto.
	* testsuite/ld-pru/pcrel_u8_label.s: Ditto.
	* testsuite/ld-pru/pmem.d: Ditto.
	* testsuite/ld-pru/pmem.s: Ditto.
	* testsuite/ld-pru/pmem_symbol.s: Ditto.
	* testsuite/ld-pru/pru.exp: Ditto.
	* testsuite/ld-pru/relax_ldi32-data.d: Ditto.
	* testsuite/ld-pru/relax_ldi32-dis.d: Ditto.
	* testsuite/ld-pru/relax_ldi32.s: Ditto.
	* testsuite/ld-pru/relax_ldi32_symbol.s: Ditto.
	* testsuite/ld-pru/reloc.d: Ditto.
	* testsuite/ld-pru/reloc.s: Ditto.
	* testsuite/ld-pru/reloc_symbol.s: Ditto.
	* testsuite/ld-pru/u16.d: Ditto.
	* testsuite/ld-pru/u16.s: Ditto.
	* testsuite/ld-pru/u16_symbol.s: Ditto.

PRU does not export __end symbol because it is ambiguous for it.
Users are expected to use instead the section markers __text_end,
__data_end, __bss_end or __noinit_end.

	* testsuite/lib/ld-lib.exp (check_shared_lib_support): No shared
	libraries are supported for PRU.
	(check_gc_sections_available): Mark PRU as not supported.
	* testsuite/ld-elf/eh-frame-hdr.d: Disable for PRU.
	* testsuite/ld-elf/endsym.d: Likewise.
	* testsuite/ld-elf/group8a.d: Likewise.
	* testsuite/ld-elf/group8b.d: Likewise.
	* testsuite/ld-elf/group9a.d: Likewise.
	* testsuite/ld-elf/group9b.d: Likewise.
	* testsuite/ld-elf/merge.d: Likewise.
	* testsuite/ld-elf/pr12851.d: Likewise.
	* testsuite/ld-elf/pr14926.d: Likewise.
	* testsuite/ld-elf/sec-to-seg.exp: Likewise.
	* testsuite/ld-elf/sec64k.exp: Mark sec64k case as too big for PRU.
	* testsuite/ld-srec/srec.exp (run_srec_test): Add setup for PRU.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2016-12-31 12:04:11 +10:30
Tristan Gingold 9703a4ef4d Add marker in NEWS files
binutils/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.28.

gas/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.28.

ld/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.28.
2016-12-23 09:43:13 +01:00
Andrew Burgess 8f1732fc2a ld: Allow EXCLUDE_FILE to be used outside of the section list
Currently the EXCLUDE_FILE linker script construct can only be used
within the input section list, and applied only to the section pattern
immediately following the EXCLUDE_FILE.  For example:

    *.o (EXCLUDE_FILE (a.o) .text .rodata)

In this case all sections matching '.text' are included from all files
matching '*.o' but not from the file 'a.o'.  All sections matching
'.rodata' are also included from all files matching '*.o' (incluing from
'a.o').

If the user wants to restrict the inclusion of section '.rodata' so that
this too is not taken from the file 'a.o' then the above example must be
extended like this:

    *.o (EXCLUDE_FILE (a.o) .text EXCLUDE_FILE (a.o) .rodata)

However, due to the internal grammar of the linker script language the
snippet 'EXCLUDE_FILE (a.o) .text' is parsed by a pattern called
'wildcard_spec'.  The same 'wildcard_spec' pattern is also used to parse
the input file name snippet '*.o' in the above examples.  As a result of
this pattern reuse within the linker script grammar then the following
is also a valid linker script construct:

    EXCLUDE_FILE (a.o) *.o (.text .rodata)

However, though the linker accepts this without complaint the
EXCLUDE_FILE part is silently ignored and has no effect.

This commit takes this last example and makes it a useful, valid,
construct.  The last example now means to include sections '.text' and
'.rodata' from all files matching '*.o' except for the file 'a.o'.

If the list of input sections is long, and the user knows that the file
exclusion applies across the list then the second form might be a
clearer alternative to replicating the EXCLUDE_FILE construct.

I've added a set of tests for EXCLUDE_FILE to the linker, including
tests for the new functionality.

ld/ChangeLog:

	* ldlang.h (struct lang_wild_statement_struct): Add
	exclude_name_list field.
	* ldlang.c (walk_wild_file_in_exclude_list): New function.
	(walk_wild_consider_section): Use new
	walk_wild_file_in_exclude_list function.
	(walk_wild_file): Add call to walk_wild_file_in_exclude_list.
	(print_wild_statement): Print new exclude_name_list field.
	(lang_add_wild): Initialise new exclude_name_list field.
	* testsuite/ld-scripts/exclude-file-1.d: New file.
	* testsuite/ld-scripts/exclude-file-1.map: New file.
	* testsuite/ld-scripts/exclude-file-1.t: New file.
	* testsuite/ld-scripts/exclude-file-2.d: New file.
	* testsuite/ld-scripts/exclude-file-2.map: New file.
	* testsuite/ld-scripts/exclude-file-2.t: New file.
	* testsuite/ld-scripts/exclude-file-3.d: New file.
	* testsuite/ld-scripts/exclude-file-3.map: New file.
	* testsuite/ld-scripts/exclude-file-3.t: New file.
	* testsuite/ld-scripts/exclude-file-4.d: New file.
	* testsuite/ld-scripts/exclude-file-4.map: New file.
	* testsuite/ld-scripts/exclude-file-4.t: New file.
	* testsuite/ld-scripts/exclude-file-a.s: New file.
	* testsuite/ld-scripts/exclude-file-b.s: New file.
	* testsuite/ld-scripts/exclude-file.exp: New file.
	* ld.texinfo (Input Section Basics): Update description of
	EXCLUDE_FILE to cover the new features.
	* NEWS: Mention new EXCLUDE_FILE usage.
2016-11-04 12:04:11 +00:00