Commit Graph

16122 Commits

Author SHA1 Message Date
GDB Administrator 46dfcabeba Automatic date update in version.in 2020-06-23 00:00:06 +00:00
Saagar Jha d768f160a9 Recognize some new Mach-O load commands
bfd
	* mach-o.c: Support the new load commands by reading a linkedit data
	command for them.
binutils
	* od-macho.c: Dump linkedit data for new load commands.
include
	* mach-o/loader.h: Add declarations of two new Mach-O load
	commands.
2020-06-22 14:29:20 +01:00
Nelson Chu 39ff0b8123 RISC-V: Report warning when linking the objects with different priv specs.
We do know some conflicts among different privileged specs.  For linker,
the safest approach is that don't allow the object linked with others which
may cause conflicts.  But this may cause inconvenience since not all objects
with conflicting priv specs are linked will cause problems.  But it is hard
to know the detailed conflict cases for linker, so we probably need a option
to tell linker that we do know there are no conflicts, or we are willing to
take risks to link the objects with conflicted priv specs.  But the option
is still under discussion.

Therefore, we can report warnings rather than errors when linking the objects
with conflicted priv specs.  This not only makes the linker more flexible,
but also warns people that the conflicts may happen.  We also need to update
the output priv spec version once the input priv spec is newer.

	bfd/
	* elfxx-riscv.c (struct priv_spec_t priv_specs[]): Move them from
	opcodes/riscv-opc.c to bfd/elfxx-riscv.c, since we need it in linker.
	(riscv_get_priv_spec_class): Likewise.
	(riscv_get_priv_spec_name): Likewise.
	(riscv_get_priv_spec_class_from_numbers): New function, convert
	the version numbers into string, then call riscv_get_priv_spec_class
	to get the priv spec class.
	* elfxx-riscv.h (riscv_get_priv_spec_class): Move forward declaration
	from include/opcode/riscv.h to bfd/elfxx-riscv.h.
	(riscv_get_priv_spec_name): Likewise.
	(riscv_get_priv_spec_class_from_numbers): New forward declaration.
	(opcode/riscv.h): Include it in the header rather than elfxx-riscv.c.
	* elfnn-riscv.c (riscv_merge_attributes):  Get the priv spec classes
	of input and output objects form their priv spec attributes by
	riscv_get_priv_spec_class_from_numbers.  Report warning rather than
	errors when linking objects with differnet priv spec versions.  We do
	know v1.9.1 may have conflicts to other versions, so report the
	warning, too.  After that, update the output priv spec version to the
	newest one so far.

	gas/
	* config/tc-riscv.c (buf_size, buf): Remove the unused variables.
	(riscv_set_default_priv_spec): Get the priv spec version from the
	priv spec attributes by riscv_get_priv_spec_class_from_numbers.

	include/
	* opcode/riscv.h (riscv_get_priv_spec_class): Move the function
	forward declarations to bfd/elfxx-riscv.h.
	(riscv_get_priv_spec_name): Likewise.

	opcodes/
	* riscv-opc.c: Move the structures and functions to bfd/elfxx-riscv.c.
	* riscv-dis.c: Include elfxx-riscv.h.

	ld/
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Updated.
2020-06-22 10:01:14 +08:00
Nelson Chu cbd7581f34 RISC-V: Don't assume the priv attributes are in order when handling them.
There is no guarantee that the priv attributes should be defined in order.
Therefore, we shouldn't have the order assumption when handling them in the
riscv_merge_attributes.  Set priv_attrs_merged to TRUE if we have handled
all of the priv attributes.

	bfd/
	* elfnn-riscv.c (riscv_merge_attributes): Once we meet one of the
	priv attributes, we will check the conflicts for all of them (major,
	minor and revision), and then set the priv_attrs_merged to TRUE to
	indicate that we have handled all of the priv attributes.  Remove
	the unused boolean priv_may_conflict, in_priv_zero and out_priv_zero.
2020-06-22 09:54:02 +08:00
GDB Administrator 41ab2f9b7b Automatic date update in version.in 2020-06-22 00:00:06 +00:00
Alan Modra 1e92785005 PR26132, ar creates invalid libraries for some targets with plugins enabled
PR 26132
	* configure.ac: Disable plugins by default for some targets.
	* plugin.c: Comment typo fix.
	* configure: Regenerate.
2020-06-21 22:16:59 +09:30
GDB Administrator bfbf16ce8b Automatic date update in version.in 2020-06-21 00:00:06 +00:00
GDB Administrator 17fc27167f Automatic date update in version.in 2020-06-20 00:00:20 +00:00
Nick Clifton 13aa5ceb01 Silence warnings about incompatible plugins.
I have been looking at a Fedora bug report[1] from a user who was
receiving warning messages from the BFD library about incompatible
plugins.  It turns out that they had both 32-bit and 64-bit versions
of the same plugin installed, and the BFD library was attempting to
load all of them.

After thinking about it for a while, it seemed to me that the simplest
solution was to not warn about incompatible plugins whilst attempting
to create a list of viable plugins.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1836618

	* plugin.c (try_load_plugin): Suppress the error message about
	being unable to open a plugin if creating a list of viable
	plugins.
2020-06-19 10:25:43 +01:00
GDB Administrator 753d1583f7 Automatic date update in version.in 2020-06-19 00:00:18 +00:00
GDB Administrator 0574b47b73 Automatic date update in version.in 2020-06-18 00:00:15 +00:00
GDB Administrator 1ce22eebea Automatic date update in version.in 2020-06-17 00:00:15 +00:00
Alan Modra a435742a7f Really remove tic30-aout support
bfd/
	* aout-tic30.c: Delete file.
	* Makefile.am (BFD32_BACKENDS): Remove aout-tic30.lo.
	(BFD32_BACKENDS_CFILES): Remove aout-tic30.c.
	* config.bfd (c30-*-*aout*, tic30-*-*aout*): Remove entry.
	(xc16x-*-elf): Sort properly.
	* configure.ac: Remove tic30_aout_vec.
	* targets.c: Likewise.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
gas/
	* config/tc-tic30.h: Remove OBJ_AOUT support.
	* configure.tgt: Delete tic30-*-*aout* entry.
ld/
	* emulparams/tic30aout.sh: Delete file.
	* scripttempl/tic30aout.sc: Delete file.
	* Makefile.am: Remove etic30aout.c from ALL_EMULATION_SOURCES and
	delete dependency.
	* configure.tgt: Delete tic30-*-*aout* entry.
	* testsuite/ld-scripts/sane1.d: Delete tic30-*-aout mention.
	* testsuite/ld-scripts/segment-start.d: Likewise.
	* Makefile.in: Regenerate.
	* po/BLD-POTFILES.in: Regenerate.
2020-06-16 15:57:59 +09:30
GDB Administrator 9e790a8016 Automatic date update in version.in 2020-06-16 00:00:20 +00:00
Max Filippov 7a77f1ac2c xtensa: allow runtime ABI selection
2020-06-15  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (XSHAL_ABI, XTHAL_ABI_UNDEFINED)
	(XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New macros.
	(elf32xtensa_abi): New global variable.
	(xtensa_abi_choice): New function.
	(elf_xtensa_create_plt_entry): Use xtensa_abi_choice instead of
	XSHAL_ABI to select PLT code.

gas/
	* config/tc-xtensa.c (XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New
	macros.
	(elf32xtensa_abi): New declaration.
	(option_abi_windowed, option_abi_call0): New enum constants.
	(md_longopts): Add entries for --abi-windowed and --abi-call0.
	(md_parse_option): Add handlers for --abi-windowed and
	--abi-call0.
	(xtensa_add_config_info): Use xtensa_abi_choice instead of
	XSHAL_ABI to format ABI tag.
	* doc/as.texi (Target Xtensa options): Add --abi-windowed and
	--abi-call0 to the list of options.
	* doc/c-xtensa.texi: Add description for options --abi-windowed
	and --abi-call0.
	* testsuite/gas/xtensa/abi-call0.d: New test definition.
	* testsuite/gas/xtensa/abi-windowed.d: New test definition.
	* testsuite/gas/xtensa/abi.s: New test source.

include/
	* elf/xtensa.h (xtensa_abi_choice): New declaration.

ld/
	* emultempl/xtensaelf.em (XSHAL_ABI): Remove macro definition.
	(XTHAL_ABI_UNDEFINED, XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New
	macros.
	(elf32xtensa_abi): New declaration.
	(xt_config_info_unpack_and_check): Set elf32xtensa_abi if it is
	undefined.  Use xtensa_abi_choice instead of XSHAL_ABI to test
	ABI tag consistency.
	(xtensa_add_config_info): Use xtensa_abi_choice instead of
	XSHAL_ABI to format ABI tag.
	(PARSE_AND_LIST_PROLOGUE): Define OPTION_ABI_WINDOWED,
	OPTION_ABI_CALL0 and declare elf32xtensa_abi.
	(PARSE_AND_LIST_LONGOPTS): Add entries for --abi-windowed and
	--abi-call0.
	(PARSE_AND_LIST_OPTIONS): Add help text for --abi-windowed and
	--abi-call0.
	(PARSE_AND_LIST_ARGS_CASES): Add handlers for --abi-windowed and
	--abi-call0.
	* ld.texi: Add description for options --abi-windowed and
	--abi-call0.
2020-06-15 13:01:30 -07:00
Roland McGrath cae64165f4 gold, ld: Implement -z start-stop-visibility=... option.
gold/
	Implement -z start-stop-visibility=... option.
	* options.h (class General_options): Handle -z start-stop-visibility=.
	(General_options::start_stop_visibility_enum): New public method.
	(General_options::set_start_stop_visibility_enum): New private method.
	(General_options::start_stop_visibility_enum_): New private member.
	* options.cc (General_options::General_options): Add initializer.
	(General_options::finalize): Set this->start_stop_visibility_enum_
	from string value.
	* layout.cc (Layout::define_section_symbols): Use option setting.

bfd/
	* elflink.c (bfd_elf_define_start_stop): Use start_stop_visibility
	field of bfd_link_info.

include/
	* bfdlink.h (struct bfd_link_info): New field start_stop_visibility.

ld/
	* NEWS: Mention -z start-stop-visibility=... option for ELF.
	* ld.texi (Options): Document -z start-stop-visibility=... option.
	* ldmain.c (main): Initialize link_info.start_stop_visibility.
	* emultempl/elf.em (gld${EMULATION_NAME}_handle_option):
	Parse -z start-stop-visibility=... option.
2020-06-15 11:45:02 -07:00
Alan Modra 40be168cc4 Obsolete PowerPC PE, winnt and cygwin targets
The PowerPC PE support is so old and bitrotted that it ought to be
removed.  Test results for a cross from x86_64 with no C cross
compiler currently shows 109 fails.  I don't think anyone cares about
the target.

This FIXME in bfd/peXXigen.c has been around since 1999, git commit
277d1b5e453:

/* FIXME: This file has various tests of POWERPC_LE_PE.  Those tests
   worked when the code was in peicode.h, but no longer work now that
   the code is in peigen.c.  PowerPC NT is said to be dead.  If
   anybody wants to revive the code, you will have to figure out how
   to handle those issues.  */

and this one in gas/config/tc-ppc.c since 1995, git commit
cd557d83d61:

 * FIXME: I just noticed this. This doesn't work at all really. It it
 *        setting bits that bfd probably neither understands or uses. The
 *        correct approach (?) will have to incorporate extra fields attached
 *        to the section to hold the system specific stuff. (krk)

	* config.bfd: Obsolete powerpcle-*-pe targets.
2020-06-15 15:09:38 +09:30
Alan Modra 75cfe082c0 PR26103, Assertion failure with symbols defined in link-once sections
PR 26103
	* elflink.c (elf_link_add_archive_symbols): Exclude undefined
	symbols that were defined in discarded sections.
	* cofflink.c (coff_link_check_archive_element): Likewise.
	(coff_link_add_symbols): Set indx to -3 for symbols defined in
	discarded sections.
	(_bfd_coff_write_global_sym): Don't emit such symbols.
	libcoff-in.h (struct coff_link_hash_entry): Update indx comment.
	libcoff.h: Regenerate.
2020-06-15 12:10:06 +09:30
GDB Administrator 5d0fdfee24 Automatic date update in version.in 2020-06-15 00:00:07 +00:00
GDB Administrator 83015056b2 Automatic date update in version.in 2020-06-14 00:00:13 +00:00
GDB Administrator 10059956ee Automatic date update in version.in 2020-06-13 00:00:15 +00:00
GDB Administrator e9576b7d68 Automatic date update in version.in 2020-06-12 00:00:20 +00:00
Alan Modra f0aa30258a PR26107, Compilation failure in pdp11.c
PR 26107
	* pdp11.c (is_stab): Replace legacy "index" function with "strchr".
2020-06-11 15:50:33 +09:30
H.J. Lu 447f6d8627 ia64: Set DF_TEXTREL instead of reltext
Update ia64 ELF backend to set DF_TEXTREL for dynamic relocs against
readonly sections like other backends.

	* elfnn-ia64.c (elfNN_ia64_link_hash_table): Remove reltext.
	(allocate_dynrel_entries): Set DF_TEXTREL instead of reltext.
	(elfNN_ia64_size_dynamic_sections): Check DF_TEXTREL instead
	of reltext.
2020-06-10 18:20:36 -07:00
GDB Administrator 6cff1eab4d Automatic date update in version.in 2020-06-11 00:00:16 +00:00
H.J. Lu e1b5d517d1 ELF: Properly handle section symbols
When defining the section symbol, __start_FOO, for the section FOO:

1. Treat the common symbol, __start_FOO, in input object file as
definition.
2. Clear verinfo.verdef.

bfd/

	PR ld/26094
	* elflink.c (bfd_elf_define_start_stop): Handle common symbols.
	Clear verinfo.verdef.

ld/

	PR ld/26094
	* testsuite/ld-elf/pr26094-1.ver: New fike.
	* testsuite/ld-elf/pr26094-1a.c: Likewise.
	* testsuite/ld-elf/pr26094-1a.rd: Likewise.
	* testsuite/ld-elf/pr26094-1b.c: Likewise.
	* testsuite/ld-elf/pr26094-1b.rd: Likewise.
	* testsuite/ld-elf/pr26094-1c.c: Likewise.
	* testsuite/ld-elf/shared.exp: Run ld/26094 tests.
2020-06-10 05:31:31 -07:00
GDB Administrator f5163fdc3c Automatic date update in version.in 2020-06-10 00:00:16 +00:00
H.J. Lu cebd6b8ac1 IFUNC: Update IFUNC resolver check with DT_TEXTREL
Add ifunc_resolvers to elf_link_hash_table and use it for both x86 and
ppc64.  Before glibc commit b5c45e837, DT_TEXTREL is incompatible with
IFUNC resolvers.  Set ifunc_resolvers if there are IFUNC resolvers and
issue a warning for IFUNC resolvers with DT_TEXTREL.

bfd/

	PR ld/18801
	* elf-bfd.h (elf_link_hash_table): Add ifunc_resolvers.
	(_bfd_elf_allocate_ifunc_dyn_relocs): Remove the
	bfd_boolean * argument.  Set ifunc_resolvers if there are IFUNC
	resolvers.
	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Updated.
	Set ifunc_resolvers if there are FUNC resolvers.
	* elf64-ppc.c (ppc_link_hash_table): Remove local_ifunc_resolver.
	(build_global_entry_stubs_and_plt): Replace local_ifunc_resolver
	with elf.ifunc_resolvers.
	(write_plt_relocs_for_local_syms): Likewise.
	(ppc64_elf_relocate_section): Likewise.
	(ppc64_elf_finish_dynamic_sections): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_allocate_ifunc_dynrelocs):
	Updated.
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Likewise.
	(_bfd_x86_elf_size_dynamic_sections): Check elf.ifunc_resolvers
	instead of readonly_dynrelocs_against_ifunc.
	* elfxx-x86.h (elf_x86_link_hash_table): Remove
	readonly_dynrelocs_against_ifunc.

ld/

	PR ld/18801
	* testsuite/ld-i386/i386.exp: Run ifunc-textrel-1a,
	ifunc-textrel-1b, ifunc-textrel-2a and ifunc-textrel-2b.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/ifunc-textrel-1a.d: Likewise.
	* testsuite/ld-i386/ifunc-textrel-1b.d: Likewise.
	* testsuite/ld-i386/ifunc-textrel-2a.d: Likewise.
	* testsuite/ld-i386/ifunc-textrel-2b.d: Likewise.
	* testsuite/ld-x86-64/ifunc-textrel-1.s: Likewise.
	* testsuite/ld-x86-64/ifunc-textrel-1a.d: Likewise.
	* testsuite/ld-x86-64/ifunc-textrel-1b.d: Likewise.
	* testsuite/ld-x86-64/ifunc-textrel-2.s: Likewise.
	* testsuite/ld-x86-64/ifunc-textrel-2a.d: Likewise.
	* testsuite/ld-x86-64/ifunc-textrel-2b.d: Likewise.
	* testsuite/ld-i386/pr18801a.d: Expect warning for IFUNC
	resolvers.
	* testsuite/ld-i386/pr18801b.d: Likewise.
	* estsuite/ld-x86-64/pr18801a.d: Likewise.
	* estsuite/ld-x86-64/pr18801b.d: Likewise.
2020-06-09 06:57:25 -07:00
Alan Modra efb2a7b412 PowerPC64: Downgrade ifunc with textrel error to a warning
For ppc64 I set flags when recording the dynamic relocation rather
than when allocating space.  That allows you to distinguish three
cases:
1) The dynamic ifunc relocation is in an executable and will always be
   to an ifunc resolver in the executable.
2) The dynamic ifunc relocation is in a shared library which provides
   an ifunc resolver, but that may be overridden at runtime to use a
   resolver in another binary.
3) The dynamic ifunc relocation is not to a locally defined ifunc
   resolver.

Case (3) won't cause a segfault trying to run resolver code that is
non-exec on older glibc.

I made case (1) an error for ppc64, but since newer glibc ld.so does
allow running ifunc resolvers when segments are writable I suppose I
should downgrade that to a warning like case (2).

	* elf64-ppc.c (struct ppc_link_hash_table): Delete
	maybe_local_ifunc_resolver field.
	(build_global_entry_stubs_and_plt): Set local_ifunc_resolver in
	cases where maybe_local_ifunc_resolver was set.
	(ppc64_elf_relocate_section): Likewise.
	(ppc64_elf_finish_dynamic_sections): Downgrade ifunc with textrel
	error to a warning.
2020-06-09 09:37:23 +09:30
GDB Administrator c3cd66019e Automatic date update in version.in 2020-06-09 00:00:34 +00:00
H.J. Lu 9bcc30e417 ELF: Move tlsdesc_plt/tlsdesc_got to elf_link_hash_table
All ELF backends with TLS descriptor support have

  /* The offset into splt of the PLT entry for the TLS descriptor
     resolver.  Special values are 0, if not necessary (or not found
     to be necessary yet), and -1 if needed but not determined
     yet.  */
  bfd_vma tlsdesc_plt;

  /* The GOT offset for the lazy trampoline.  Communicated to the
     loader via DT_TLSDESC_GOT.  The magic value (bfd_vma) -1
     indicates an offset is not allocated.  */
  bfd_vma tlsdesc_got;

in symbol hash entry.  Move tlsdesc_plt/tlsdesc_got to elf_link_hash_entry
to reduce code duplication.

	* elf-bfd.h (elf_link_hash_entry): Add tlsdesc_plt and
	tlsdesc_got.
	* elf32-arm.c (elf32_arm_link_hash_table): Remove tlsdesc_plt
	and dt_tlsdesc_got.
	(elf32_arm_size_dynamic_sections): Updated.  Clear
	root.tlsdesc_plt for DF_BIND_NOW.
	(elf32_arm_finish_dynamic_sections): Updated.
	(elf32_arm_output_arch_local_syms): Likewise.
	* elf32-nds32.c (nds32_elf_size_dynamic_sections): Updated.
	Clear root.tlsdesc_plt for DF_BIND_NOW.
	(nds32_elf_finish_dynamic_sections): Updated.
	* elf32-nds32.h (elf_nds32_link_hash_table): Remove
	dt_tlsdesc_plt and dt_tlsdesc_got.
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Updated.
	* elfnn-aarch64.c (elf_aarch64_link_hash_table): Remove
	tlsdesc_plt and dt_tlsdesc_got.
	(elfNN_aarch64_allocate_dynrelocs): Updated.
	(elfNN_aarch64_finish_dynamic_sections): Likewise.
	(elfNN_aarch64_size_dynamic_sections): Updated.  Clear
	root.tlsdesc_plt for DF_BIND_NOW.  Don't check DF_BIND_NOW
	twice.
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Updated.
	(_bfd_x86_elf_size_dynamic_sections): Likewise.
	(_bfd_x86_elf_finish_dynamic_sections): Likewise.
	* elfxx-x86.h (elf_x86_link_hash_table): Remove tlsdesc_plt and
	tlsdesc_got.
2020-06-08 04:30:56 -07:00
GDB Administrator 334a017304 Automatic date update in version.in 2020-06-08 00:00:07 +00:00
H.J. Lu 845b83d7eb elf32-tic6x.c: Define the default elf32_bed to elf32_tic6x_bed
Get

00000000000007c0 d elf32_tic6x_bed
0000000000000000 d elf32_tic6x_elf_bed
00000000000003e0 d elf32_tic6x_linux_bed

instead of

00000000000007c0 d elf32_bed
0000000000000000 d elf32_tic6x_elf_bed
00000000000003e0 d elf32_tic6x_linux_bed

	* elf32-tic6x.c (elf32_bed): Defined the default to
	elf32_tic6x_bed.
2020-06-07 14:53:58 -07:00
H.J. Lu 9b8a8575b4 elf64-hppa: Replace plt_sec/plt_rel_sec with root.splt/root.srelplt
elf64-hppa should use root.splt and root.srelplt instead of plt_sec and
plt_rel_sec so that elflink.c can see splt and srelplt.  This fixed:

FAIL: ld-elf/pr19539

	* elf64-hppa.c (elf64_hppa_link_hash_table): Remove plt_sec and
	plt_rel_sec.
	(elf64_hppa_check_relocs): Replace plt_sec/plt_rel_sec with
	root.splt/root.srelplt.
	(elf64_hppa_create_dynamic_sections): Likewise.
	(elf64_hppa_size_dynamic_sections): Likewise.
	(elf64_hppa_finish_dynamic_symbol): Likewise.
	(elf_hppa_final_link): Likewise.
	(elf_hppa_final_link_relocate): Likewise.
2020-06-07 08:06:22 -07:00
H.J. Lu bcab203d31 Remove is_vxworks from _bfd_sparc_elf_link_hash_table
Replace is_vxworks with elf.target_os == is_vxworks.

	* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Updated.
	* elfxx-sparc.h (_bfd_sparc_elf_link_hash_table): Remove
	is_vxworks.
2020-06-06 17:42:31 -07:00
GDB Administrator 20955c7cb8 Automatic date update in version.in 2020-06-07 00:00:08 +00:00
H.J. Lu 90c14f0c3a ELF: Add target_os to elf_link_hash_table/elf_backend_data
Add target_os to elf_backend_data to identify target OS.  Add target_os,
to elf_link_hash_table to identify target OS for linker output.

	* elf-bfd.h (elf_target_os): New.
	(elf_link_hash_table): Add target_os.
	(elf_backend_data): Add target_os.
	* elf32-arm.c (elf32_arm_link_hash_table): Remove vxworks_p,
	symbian_p and nacl_p.
	(create_got_section): Updated.
	(elf32_arm_create_dynamic_sections): Likewise.
	(arm_type_of_stub): Likewise.
	(elf32_arm_create_or_find_stub_sec): Likewise.
	(elf32_arm_allocate_plt_entry): Likewise.
	(elf32_arm_populate_plt_entry): Likewise.
	(elf32_arm_final_link_relocate): Likewise.
	(elf32_arm_check_relocs): Likewise.
	(allocate_dynrelocs_for_symbol): Likewise.
	(elf32_arm_finish_dynamic_symbol): Likewise.
	(elf32_arm_finish_dynamic_sections): Likewise.
	(elf32_arm_output_plt_map_1): Likewise.
	(elf32_arm_output_arch_local_syms): Likewise.
	(elf32_arm_add_symbol_hook): Likewise.
	(elf32_arm_nacl_link_hash_table_create): Likewise.
	(elf32_arm_vxworks_link_hash_table_create): Likewise.
	(elf32_arm_symbian_link_hash_table_create): Likewise.
	(ELF_TARGET_OS): New.
	* elf32-i386.c (elf_i386_arch_bed): Removed.
	(elf_backend_arch_data): Likewise.
	(elf_i386_solaris_arch_bed): Likewise.
	(elf_i386_nacl_arch_bed): Likewise.
	(elf_i386_vxworks_arch_bed): Likewise.
	(elf_i386_relocate_section): Updated.
	(elf_i386_finish_dynamic_sections): Likewise.
	(elf_i386_get_synthetic_symtab): Likewise.
	(elf_i386_link_setup_gnu_properties): Likewise.
	(ELF_TARGET_OS): New.
	* elf32-mips.c (ELF_TARGET_OS): New.
	* elf32-ppc.c (ppc_elf_link_hash_table): Remove is_vxworks.
	(ppc_elf_create_got): Updated.
	(ppc_elf_create_dynamic_sections): Likewise.
	(ppc_elf_check_relocs): Likewise.
	(ppc_elf_adjust_dynamic_symbol): Likewise.
	(ppc_elf_size_dynamic_sections): Likewise.
	(ppc_elf_relocate_section): Likewise.
	(ppc_elf_finish_dynamic_sections): Likewise.
	(ppc_elf_vxworks_link_hash_table_create): Likewise.
	(ELF_TARGET_OS): New.
	* elf32-sh.c (elf_sh_link_hash_table): Remove vxworks_p.
	(sh_elf_link_hash_table_create): Updated.
	(sh_elf_create_dynamic_sections): Likewise.
	(allocate_dynrelocs): Likewise.
	(sh_elf_size_dynamic_sections): Likewise.
	(sh_elf_relocate_section): Likewise.
	(sh_elf_finish_dynamic_symbol): Likewise.
	(sh_elf_finish_dynamic_sections): Likewise.
	(ELF_TARGET_OS): New.
	* elf32-sparc.c (elf32_sparc_vxworks_link_hash_table_create):
	Removed.
	(bfd_elf32_bfd_link_hash_table_create): Likewise.
	(ELF_TARGET_OS): New.
	* elf64-x86-64.c (elf_x86_64_arch_bed): Removed.
	(elf_x86_64_solaris_arch_bed): Likewise.
	(elf_x86_64_nacl_arch_bed): Likewise.
	(elf_x86_64_finish_dynamic_sections): Updated.
	(elf_x86_64_get_synthetic_symtab): Likewise.
	(elf_x86_64_link_setup_gnu_properties): Likewise.
	(ELF_TARGET_OS): New.
	* elflink.c (_bfd_elf_link_hash_table_init): Initialize
	target_o.
	* elfxx-mips.c (mips_elf_link_hash_table): Remove is_vxworks.
	(MIPS_ELF_REL_DYN_NAME): Updated.
	(ELF_MIPS_GP_OFFSET): Likewise.
	(mips_elf_create_local_got_entry): Likewise.
	(mips_elf_allocate_dynamic_relocations): Likewise.
	(mips_elf_count_got_symbols): Likewise.
	(is_gott_symbol): Likewise.
	(mips_elf_calculate_relocation): Likewise.
	(mips_elf_create_dynamic_relocation): Likewise.
	(_bfd_mips_elf_check_relocs): Likewise.
	(allocate_dynrelocs): Likewise.
	(_bfd_mips_elf_adjust_dynamic_symbol): Likewise.
	(mips_elf_lay_out_got): Likewise.
	(mips_elf_set_plt_sym_value): Likewise.
	(_bfd_mips_elf_size_dynamic_sections): Likewise.
	(_bfd_mips_elf_finish_dynamic_symbol): Likewise.
	(_bfd_mips_elf_finish_dynamic_sections): Likewise.
	(_bfd_mips_elf_final_link): Likewise.
	(_bfd_mips_init_file_header): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_create_dynamic_sections):
	Likewise.
	(allocate_dynrelocs): Likewise.
	(_bfd_sparc_elf_size_dynamic_sections): Likewise.
	(_bfd_sparc_elf_relocate_section): Likewise.
	(_bfd_sparc_elf_finish_dynamic_symbol): Likewise.
	(sparc_finish_dyn): Likewise.
	(_bfd_sparc_elf_finish_dynamic_sections): Likewise.
	* elfxx-target.h (ELF_TARGET_OS): New.
	(elfNN_bed): Add ELF_TARGET_OS.
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Updated.
	(_bfd_x86_elf_link_hash_table_create): Likewise.
	(_bfd_x86_elf_size_dynamic_sections): Likewise.
	(_bfd_x86_elf_finish_dynamic_sections): Likewise.
	(_bfd_x86_elf_adjust_dynamic_symbol): Likewise.
	(_bfd_x86_elf_link_setup_gnu_properties): Likewise.
	* elfxx-x86.h (elf_x86_target_os): Removed.
	(elf_x86_backend_data): Likewise.
	(get_elf_x86_backend_data): Likewise.
	(elf_x86_link_hash_table): Remove target_os.
2020-06-06 06:45:38 -07:00
Alan Modra 87c69f9732 Rename PowerPC64 pcrel GOT TLS relocations
These relocations should have had REL in their names, to reflect the
fact that they are pc-relative.  Fix that now by adding _PCREL.
I've added some back-compatibility code to support anyone using
.reloc with the old relocations.

include/
	* elf/ppc64.h (elf_ppc64_reloc_type): Rename
	R_PPC64_GOT_TLSGD34 to R_PPC64_GOT_TLSGD_PCREL34,
	R_PPC64_GOT_TLSLD34 to R_PPC64_GOT_TLSLD_PCREL34,
	R_PPC64_GOT_TPREL34 to R_PPC64_GOT_TPREL_PCREL34, and
	R_PPC64_GOT_DTPREL34 to R_PPC64_GOT_DTPREL_PCREL34.
bfd/
	* reloc.c: Rename
	BFD_RELOC_PPC64_GOT_TLSGD34 to BFD_RELOC_PPC64_GOT_TLSGD_PCREL34,
	BFD_RELOC_PPC64_GOT_TLSLD34 to BFD_RELOC_PPC64_GOT_TLSLD_PCREL34,
	BFD_RELOC_PPC64_GOT_TPREL34 to BFD_RELOC_PPC64_GOT_TPREL_PCREL34,
	BFD_RELOC_PPC64_GOT_DTPREL34 to BFD_RELOC_PPC64_GOT_DTPREL_PCREL34.
	* elf64-ppc.c: Update throughout for reloc renaming.
	(ppc64_elf_reloc_name_lookup): Handle old reloc names.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Regenerate.
gas/
	* config/tc-ppc.c: Update throughout for reloc renaming.
elfcpp/
	* powerpc.h: Rename
	R_PPC64_GOT_TLSGD34 to R_PPC64_GOT_TLSGD_PCREL34,
	R_PPC64_GOT_TLSLD34 to R_PPC64_GOT_TLSLD_PCREL34,
	R_PPC64_GOT_TPREL34 to R_PPC64_GOT_TPREL_PCREL34, and
	R_PPC64_GOT_DTPREL34 to R_PPC64_GOT_DTPREL_PCREL34.
gold/
	* powerpc.cc: Update throughout for reloc renaming.
2020-06-06 14:44:32 +09:30
GDB Administrator 62b5b3d836 Automatic date update in version.in 2020-06-06 00:00:17 +00:00
H.J. Lu 8a4ba3a142 bfin: Initialize picrel to silence GCC warning 2020-06-05 06:22:56 -07:00
H.J. Lu 981f151804 bfin: Skip non SEC_ALLOC section
* elf32-bfin.c (bfinfdpic_relocate_section): Skip non SEC_ALLOC
	section.
2020-06-05 05:30:25 -07:00
Nick Clifton 9c65eeacd8 Fix a use before initialization bug in the pdp11.c source file.
* pdp11.c (aout_link_add_symbols): Fix use before initialisation
	bug.
2020-06-05 10:08:26 +01:00
Nelson Chu 412857647f RISC-V: The object without priv spec attributes can be linked with any object.
bfd/
	* elfnn-riscv.c (riscv_merge_attributes): Add new boolean
	priv_may_conflict, in_priv_zero and out_priv_zero to decide whether
	the object can be linked according to it's priv attributes.  The object
	without any priv spec attributes can be linked with others.  If the first
	input object doesn't contain any priv attributes, then we need to copy
	the setting from the next input one.  Also report more detailed error
	messages to user.

	ld/
	* testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Rename to
	attr-merge-priv-spec-01.d.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-c.s: Set priv spec
	to 1.11.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-d.s: Empty priv spec
	setting.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-02.d: New testcase.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Likewise.
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2020-06-05 12:20:53 +08:00
Stephen Casner a975c88e65 Extend pdp11-aout symbol table format and code for .stab symbols.
* bfd/pdp11.c (pdp11_external_nlist): Repurposed e_unused to e_desc.
(N_STAB, is_stab): Needed new function is_stab to disambiguate
normal vs. .stab symbol table type values, replacing N_STAB mask.
(translate_from_native_sym_flags): Determine correct section for
different .stab types.
(translate_to_native_sym_flags): Leave .stab types intact.
(translate_symbol_table): Error if symbol indicates overlay;
store desc field from .stab symbols.
(write_syms): Output desc field with symbol.
(aout_link_check_ar_symbols): Skip .stab symbols.
(aout_link_add_symbols): Correctly distinguish .stab symbols.
(aout_link_write_other_symbol): Write 0 for desk and ovly fields.
(aout_link_write_symbols): Write 0 for desk and ovly fields;
correctly distinguish .stab symbols and select calculate their
section and value; and copy desc and ovly fields from input symbol
to output symbol.
2020-06-04 18:12:32 -07:00
GDB Administrator 470e738f6d Automatic date update in version.in 2020-06-05 00:00:19 +00:00
Stephen Casner 3b9313c420 Correct a comment.
* bfd/aoutx.h (translate_symbol_table): Comment had external and
internal swapped.
* bfd/pdp11.c (translate_symbol_table): Likewise.
2020-06-04 12:34:17 -07:00
H.J. Lu add5f777de x86: Remove target_id from elf_x86_link_hash_table
Since target_id in elf_x86_link_hash_table is the same as hash_table_id
in elf_link_hash_table, we can use elf.hash_table_id instead of target_id.

	* elfxx-x86.h (elf_x86_link_hash_table): Remove target_id.
	(is_x86_elf): Check elf.hash_table_id instead of target_id.
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Updated.
2020-06-04 09:56:25 -07:00
H.J. Lu c4b126b87a ELF: Don't check relocations in non-loaded, non-alloced sections
Don't do anything special with non-loaded, non-alloced sections.
In particular, any relocs in such sections should not affect GOT
and PLT reference counting (ie. we don't allow them to create GOT
or PLT entries), there's no possibility or desire to optimize TLS
relocs, and there's not much point in propagating relocs to shared
libs that the dynamic linker won't relocate.

Since check_relocs is no longer called on non-loaded, non-alloced
sections, remove SEC_ALLOC check.  Resolve relocation in debug section
against symbol defined in shared library to 0.

bfd/

	PR ld/26080
	* elf-m10300.c (mn10300_elf_relocate_section): Resolve relocation
	in debug section against symbol defined in shared library to 0.
	* elf32-i386.c (elf_i386_check_relocs): Remove SEC_ALLOC check.
	* elf32-lm32.c (lm32_elf_check_relocs): Likewise.
	* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
	* elf32-nds32.c (nds32_elf_check_relocs): Likewise.
	* elf32-nios2.c (nios2_elf32_check_relocs): Likewise.
	* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
	* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
	* elf32-sh.c (sh_elf_check_relocs): Likewise.
	* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
	* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
	* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
	* elf32-vax.c (elf_vax_check_relocs): Set non_got_ref for non-GOT
	reference.
	(elf_vax_adjust_dynamic_symbol): Generate a copy reloc only if
	there is non-GOT reference.
	* elflink.c (_bfd_elf_link_check_relocs): Skip non-loaded,
	non-alloced sections.

ld/

	PR ld/26080
	* testsuite/ld-elf/comm-data.exp: Remove copy_reloc.
	* testsuite/ld-elf/comm-data2r.rd: Removed.
	* testsuite/ld-elf/comm-data2r.sd: Likewise.
	* testsuite/ld-elf/comm-data2r.xd: Likewise.
2020-06-04 05:58:47 -07:00
Alan Modra 7eea15c514 Correct PR number in changelog 2020-06-04 10:20:48 +09:30
Stephen Casner 31af1e68af Copy several years of fixes from bfd/aoutx.h to bfd/pdp11.c.
* pdp11.c (some_aout_object_p): 4c1534c7a2 - Don't set EXEC_P for
files with relocs.
(aout_get_external_symbols): 6b8f0fd579 - Return if count is zero.
0301ce1486 PR 22306 - Handle stringsize of zero, and error for any
other size that doesn't qcover the header word.
bf82069dce PR 23056 - Allocate an extra byte at the end of the
string table, and zero it.
(translate_symbol_table): 0d329c0a83 PR 22887 - Print an error
message and set bfd_error on finding an invalid name string offset.
(add_to_stringtab): INLINE -> inline
(pdp11_aout_swap_reloc_in): 116acb2c26 PR 22887 - Correct r_index
bound check.
(squirt_out_relocs): e2996cc315 PR 20921 - Check for and report
any relocs that could not be recognised.
92744f0580 PR 20929 - Check for relocs	without an associated symbol.
(find_nearest_line):  808346fcfc PR 23055 - Check that the symbol
name exists and is long enough, before attempting to see if it is
for a .o file.
c386442122 - Correct case for N_SO being the last symbol.
50455f1ab2 PR 20891 - Handle the case where the main file name
and the directory name are both empty.
e82ab856bb PR 20892 - Handle the case where function name is empty.
(aout_link_add_symbols): e517df3dbf PR 19629 - Check for out of
range string table offsets.
531336e3a0 PR 20909 - Fix off-by-one error in check for an
illegal string offset.
(aout_link_includes_newfunc): Add comment.
(pdp11_aout_link_input_section): ad756e3f9e - Return with an error
on unexpected relocation type rather than ASSERT.
2020-06-03 17:43:45 -07:00