Commit Graph

14631 Commits

Author SHA1 Message Date
GDB Administrator 639eff9357 Automatic date update in version.in 2018-07-12 00:00:31 +00:00
Maciej W. Rozycki 1cb83cac9a MIPS/BFD: Fix TLS relocation resolution for regular executables
Correct an issue with commit 0f20cc3522 ("TLS support for MIPS"),
<https://sourceware.org/ml/binutils/2005-02/msg00607.html>, where a
condition used to determine whether to use a dynamic symbol for GD, LD
and IE TLS dynamic relocations against a symbol that has been defined
locally has been incorrectly reversed.

It's executables rather than dynamic shared objects where no symbol is
required, because such symbols cannot be preempted and therefore their
values (thread pointer offsets) are fixed at the static link time as is
the associated module ID of the main executable, so the original
condition should have been `shared' instead of `!shared'.  This wrong
condition was then later converted from `!shared' to `!bfd_link_pic',
with commit 0e1862bb40 ("Add output_type to bfd_link_info").

Use the correct `bfd_link_dll' condition then, and adjust code for the
dynamic symbol index possibly being -1 as with symbols that have been
forced local, removing unnecessary dynamic relocations from dynamic
regular executables.  PIE executables are unaffected as the existing
condition excluded them by chance due to the conversion mentioned above.

Adjust test cases accordingly.

	bfd/
	* elfxx-mips.c (mips_tls_got_relocs): Use `bfd_link_dll' rather
	than `!bfd_link_pic' in determining the dynamic symbol index.
	Avoid the index of -1.
	(mips_elf_initialize_tls_slots): Likewise.  Flatten code by
	moving `dyn' to the beginning of the function block.

	ld/
	* testsuite/ld-mips-elf/tlsdyn-o32.d: Update test for dynamic
	relocation removal.
	* testsuite/ld-mips-elf/tlsdyn-o32.got: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-1.d: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.
2018-07-11 17:44:45 +01:00
Maciej W. Rozycki 9143e72c6d PR ld/22570: MIPS/BFD: Fix TLS relocation resolution for PIE executables
Correct a commit 0e1862bb40 ("Add output_type to bfd_link_info") issue
and use `bfd_link_dll' rather than `bfd_link_pic' in determining whether
to fully resolve GD, LD and IE TLS relocations referring to symbols
locally defined rather than deferring them to the load time by means of
dynamic relocations.

Such symbols cannot be preempted in PIE executables, which are
necessarily PIC, and therefore their values (thread pointer offsets) are
fixed at the static link time as is the associated module ID of the main
executable.

Given the `tlsbin-o32.s' and `tlsdyn-o32.s' sources from our test suite
this removes the absolute TLS relocations from the static:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
1000002c R_MIPS_TLS_TPREL32  *ABS*
10000030 R_MIPS_TLS_DTPMOD32  *ABS*
10000038 R_MIPS_TLS_DTPMOD32  *ABS*

and the dynamic:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
1000002c R_MIPS_TLS_TPREL32  *ABS*
10000038 R_MIPS_TLS_DTPMOD32  *ABS*
10000044 R_MIPS_TLS_DTPMOD32  *ABS*
10000030 R_MIPS_TLS_DTPMOD32  tlsvar_gd
10000034 R_MIPS_TLS_DTPREL32  tlsvar_gd
10000040 R_MIPS_TLS_TPREL32  tlsvar_ie

PIE executable respectively, as reported by `objdump -R', and fills the
corresponding GOT slots with the values expected, as recorded with the
test cases added.  The new output from `objdump -R' is:

DYNAMIC RELOCATION RECORDS (none)

and:

DYNAMIC RELOCATION RECORDS
OFFSET   TYPE              VALUE
00000000 R_MIPS_NONE       *ABS*
10000030 R_MIPS_TLS_DTPMOD32  tlsvar_gd
10000034 R_MIPS_TLS_DTPREL32  tlsvar_gd
10000040 R_MIPS_TLS_TPREL32  tlsvar_ie

for the static and the dynamic executable respectively.

2018-07-11  Maciej W. Rozycki  <macro@mips.com>
            Rich Felker  <bugdal@aerifal.cx>

	bfd/
	PR ld/22570
	* elfxx-mips.c (mips_tls_got_relocs): Use `bfd_link_dll' rather
	than `bfd_link_pic' to determine whether dynamic relocations are
	to be produced.
	(mips_elf_initialize_tls_slots): Likewise.

	ld/
	PR ld/22570
	* testsuite/ld-mips-elf/tlsbin-pie-o32.d: New test.
	* testsuite/ld-mips-elf/tlsbin-pie-o32.got: New test.
	* testsuite/ld-mips-elf/tlsdyn-pie-o32.d: New test.
	* testsuite/ld-mips-elf/tlsdyn-pie-o32.got: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2018-07-11 17:44:45 +01:00
GDB Administrator 71feec8213 Automatic date update in version.in 2018-07-11 00:00:50 +00:00
Maciej W. Rozycki 5270eddc6e BFD/ELF: Correct a `remove' global shadowing error for pre-4.8 GCC
Remove `-Wshadow' compilation errors:

cc1: warnings being treated as errors
.../bfd/elflink.c: In function 'bfd_elf_final_link':
.../bfd/elflink.c:11722: error: declaration of 'remove' shadows a global declaration
/usr/include/stdio.h:154: error: shadowed declaration is here

which for versions of GCC before 4.8 prevent support for ELF targets
from being built.  See also GCC PR c/53066.

	bfd/
	* elflink.c (bfd_elf_final_link): Rename `remove' local variable
	to `remove_section'.
2018-07-11 00:42:43 +01:00
Alan Modra 1594e052d4 xgate cleanup
elf32-xgate.c contains many functions that are only stubs and
elf32-xgate.h contains unused declarations.  While this might be
reasonable for the initial commit of a port with subsequent work
fleshing out the stubs, xgate has only had two minor target specific
patches since the initial commit over six years ago.  The rest of the
changes have been general maintenance work applied to all ELF targets,
and some of this work could have been avoided if the stubs hadn't been
there.  So this patch removes all the stubs.

I've kept the functionality of the old elf32_xgate_add_symbol_hook,
implemented in elf32_xgate_backend_symbol_processing.  Presumably,
that's to set the symbol st_target_internal flag for use in
elf32-m68hc1x.c:elf32_m68hc11_relocate_section.

The empty elf32_xgate_relocate_section meant that xgate had no linker.
Or at least, no linker relocation processing.  Deleting the
elf_backend_relocate_section define means the target will now use the
generic linker reloc processing.  How good that is will depend on the
accuracy of the reloc howtos..

I haven't updated the ld testsuite to xfail tests expected to fail
for generic elf targets.

bfd/
	* elf32-xgate.h: Delete.
	* elf32-xgate.c: Delete unnecessary forward declarations, add two
	that are now needed.
	(xgate_elf_bfd_link_hash_table_create)
	(xgate_elf_bfd_link_hash_table_free)
	(xgate_elf_set_mach_from_flags, struct xgate_scan_param)
	(stub_hash_newfunc, elf32_xgate_add_symbol_hook)
	(elf32_xgate_setup_section_lists, elf32_xgate_size_stubs)
	(elf32_xgate_build_stubs, elf32_xgate_check_relocs)
	(elf32_xgate_relocate_section, _bfd_xgate_elf_set_private_flags)
	(elf32_xgate_post_process_headers): Delete.
	(elf32_xgate_backend_symbol_processing): New function.
	(xgate_elf_ignore_reloc, xgate_elf_special_reloc)
	(_bfd_xgate_elf_print_private_bfd_data): Make static.
	(ELF_TARGET_ID, elf_info_to_howto, elf_backend_check_relocs)
	(elf_backend_relocate_section, elf_backend_object_p)
	(elf_backend_final_write_processing, elf_backend_can_gc_sections)
	(elf_backend_post_process_headers, elf_backend_add_symbol_hook)
	(bfd_elf32_bfd_link_hash_table_create)
	(bfd_elf32_bfd_set_private_flags)
	(xgate_stub_hash_lookup): Don't define.
	(elf_backend_symbol_processing): Define.
	* elf-bfd.h (elf_target_id): Delete XGATE_ELF_DATA.
ld/
	* emulparams/xgateelf.sh (TEMPLATE_NAME) Set to generic.
	(EXTRA_EM_FILE): Set to genelf.
2018-07-10 23:59:07 +09:30
GDB Administrator aa4bd7e6ae Automatic date update in version.in 2018-07-10 00:00:35 +00:00
Maciej W. Rozycki 4b8377e7db MIPS/BFD: Do not redirect to discarded lazy binding stubs
Correct a MIPS/BFD linker issue with dynamic symbol and corresponding
GOT entry values being redirected to lazy binding stubs where the stubs
section has been discarded by assigning to the `/DISCARD/' output
section in the linker script used.  The issue manifests itself by the
values entered being relative to the absolute section, which is what any
discarded sections are internally assigned in the linker.

For the `stub-dynsym-2.s' piece of code included as a test case with
this change this issue results in the dynamic symbol table and the GOT
looking like:

Symbol table '.dynsym' contains 3 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000010     0 FUNC    GLOBAL DEFAULT  UND bar
     2: 00000000     0 FUNC    GLOBAL DEFAULT  UND foo

Primary GOT:
 Canonical gp value: 00097ff0

 Reserved entries:
   Address     Access  Initial Purpose
  00090000 -32752(gp) 00000000 Lazy resolver
  00090004 -32748(gp) 80000000 Module pointer (GNU extension)

 Global entries:
   Address     Access  Initial Sym.Val. Type    Ndx Name
  00090008 -32744(gp) 00000010 00000010 FUNC    UND bar
  0009000c -32740(gp) 00000000 00000000 FUNC    UND foo

if assembled to regular MIPS code, or:

Symbol table '.dynsym' contains 3 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000d     0 FUNC    GLOBAL DEFAULT  UND bar
     2: 00000001     0 FUNC    GLOBAL DEFAULT  UND foo

Primary GOT:
 Canonical gp value: 00097ff0

 Reserved entries:
   Address     Access  Initial Purpose
  00090000 -32752(gp) 00000000 Lazy resolver
  00090004 -32748(gp) 80000000 Module pointer (GNU extension)

 Global entries:
   Address     Access  Initial Sym.Val. Type    Ndx Name
  00090008 -32744(gp) 0000000d 0000000d FUNC    UND bar
  0009000c -32740(gp) 00000001 00000001 FUNC    UND foo

if assembled to microMIPS code.  Symbol values and GOT entries record
the offset into the inexistent stubs section and the ISA bit rather than
zero, which would be the case if a lazy binding stub was not used for
other reasons, such as the value of the symbol being taken for a purpose
other than making a function call (e.g. an R_MIPS_GOT16 relocation).

Correct the issue by refraining from redirecting symbols to lazy binding
stubs if the stubs section is going to be discarded.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Don't set
	`->needs_lazy_stub' if the stubs output section is the absolute
	section.

	ld/
	* testsuite/ld-mips-elf/stub-dynsym-2.dd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-2.gd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-2.sd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-discard-2.gd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-discard-2.sd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-2.dd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-2.gd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-2.sd: New test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.dd: New
	test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.gd: New
	test.
	* testsuite/ld-mips-elf/stub-dynsym-micromips-insn32-2.sd: New
	test.
	* testsuite/ld-mips-elf/stub-dynsym-2.ld: New test linker
	script.
	* testsuite/ld-mips-elf/stub-dynsym-discard-2.ld: New test
	linker script.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2018-07-09 21:30:44 +01:00
H.J. Lu 872899f1ef bfd: Use changequote for "i[3-7]86-*-linux-*"
Use changequote to match "i[3-7]86-*-linux-*", instead of
"i3-786-*-linux-*".

	PR ld/23388
	* configure.ac: Use changequote for "i[3-7]86-*-linux-*".
	* configure: Regenerated.
2018-07-09 06:51:17 -07:00
Alan Modra 61658d78f0 m68hc1* fixes
With config.sub now properly returning m68hc12-unknown-elf rather than
m68hc12-unknown-none, more ELF tests run.  This patch enables
STB_GNU_UNIQUE processing fixing some testsuite failures that probably
no m68hc12 user cares about, and removes some XPASSes.

bfd/
	* elf32-m68hc1x.c (elf32_m68hc11_post_process_headers): Call
	_bfd_elf_post_process_headers.
ld/
	* testsuite/ld-discard/extern.d: Remove m68hc12 xfail.
	* testsuite/ld-discard/start.d: Likewise.
	* testsuite/ld-discard/static.d: Likewise.
2018-07-09 17:27:35 +09:30
GDB Administrator dc7fc9ab5d Automatic date update in version.in 2018-07-09 00:00:48 +00:00
GDB Administrator a47a3dc8fb Automatic date update in version.in 2018-07-08 00:01:00 +00:00
GDB Administrator 674e55f7b1 Automatic date update in version.in 2018-07-07 00:00:46 +00:00
Max Filippov c451bb34ae xtensa: don't emit dynamic relocation for weak undefined symbol
Resolved reference to a weak undefined symbol in PIE must not have
a dynamic relative relocation against itself, otherwise the value of a
reference will be changed from 0 to the base of executable, breaking
code like the following:

  void weak_function (void);
  if (weak_function)
    weak_function ();

This fixes tests for PR ld/22269 and a number of PIE tests in xtensa gcc
testsuite.

bfd/
2018-07-06  Max Filippov  <jcmvbkbc@gmail.com>

	* elf32-xtensa.c (elf_xtensa_allocate_dynrelocs): Don't allocate
	space for dynamic relocation for undefined weak symbol.
	(elf_xtensa_relocate_section): Don't emit R_XTENSA_RELATIVE
	relocation for undefined weak symbols.
	(shrink_dynamic_reloc_sections): Don't shrink dynamic relocation
	section for relocations against undefined weak symbols.
2018-07-06 16:05:49 -07:00
Alan Hayward ad1cc4e492 Add checks for the NT_ARM_SVE section in a core file.
The NT_ARM_SVE section is documented here:
  https://github.com/torvalds/linux/blob/master/Documentation/arm64/sve.txt
  * A NT_ARM_SVE note will be added to each coredump for each thread of the
   dumped process.  The contents will be equivalent to the data that would have
   been read if a PTRACE_GETREGSET of NT_ARM_SVE were executed for each thread
   when the coredump was generated.

	* elf.c (elfcore_grok_aarch_sve): New function.
	(elfcore_grok_note): Check for Aarch64 SVE.
	(elfcore_write_aarch_sve): New function.
	(elfcore_write_register_note): Check for Aarch64 SVE.
	* elf-bfd.h(elfcore_grok_aarch_sve): New declaration.
2018-07-06 16:25:21 +01:00
Alan Modra fe75810f8e Fix diagnostic errors
Fixes a number of build errors like the following
.../elf32-arm.c: In function 'elf32_arm_nabi_write_core_note':
.../elf32-arm.c:2177: error: #pragma GCC diagnostic not allowed inside functions
.../elf32-arm.c:2186: error: #pragma GCC diagnostic not allowed inside functions
See the comment in diagnostics.h.

include/
	* diagnostics.h: Comment on macro usage.
bfd/
	* elf32-arm.c (elf32_arm_nabi_write_core_note): Don't use
	DIAGNOTIC_PUSH and DIAGNOSTIC_POP unconditionally.
	* elf32-ppc.c (ppc_elf_write_core_note): Likewise.
	* elf32-s390.c (elf_s390_write_core_note): Likewise.
	* elf64-ppc.c (ppc64_elf_write_core_note): Likewise.
	* elf64-s390.c (elf_s390_write_core_note): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_write_core_note): Likewise.
2018-07-06 15:18:59 +09:30
Jim Wilson bb11866d6a RISC-V: Add riscv-*-* configure support, and minor cleanup.
bfd/
	* config.bfd (riscv32*-*-*): Renamed from riscv32-*-*.
	(riscv64*-*-*): Likewise.
	(riscv-*-*): Add as an alias for riscv32*-*-*.

	ld/
	* configure.tgt (riscv-*-*): Add as an alias for riscv32*-*-*.
2018-07-05 17:49:11 -07:00
GDB Administrator 01b5d12f28 Automatic date update in version.in 2018-07-06 00:00:41 +00:00
H.J. Lu 56ad703d56 x86: Remove x86 ISA properties with empty bits
There is no need to generate x86 ISA properties with empty bits in
linker output.

bfd/

	PR ld/23372
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove x86
	ISA properties with empty bits.

ld/

	PR ld/23372
	* testsuite/ld-i386/i386.exp: Run pr23372a and pr23372b.
	* testsuite/ld-i386/pr23372a.d: New file.
	* testsuite/ld-i386/pr23372a.s: Likewise.
	* testsuite/ld-i386/pr23372b.d: Likewise.
	* testsuite/ld-i386/pr23372b.s: Likewise.
	* testsuite/ld-i386/pr23372c.s: Likewise.
	* testsuite/ld-x86-64/pr23372a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372a.d: Likewise.
	* testsuite/ld-x86-64/pr23372a.s: Likewise.
	* testsuite/ld-x86-64/pr23372b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372b.d: Likewise.
	* testsuite/ld-x86-64/pr23372b.s: Likewise.
	* testsuite/ld-x86-64/pr23372c.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr23372a, pr23372a-x32,
	pr23372b and pr23372b-x32.
2018-07-05 09:24:18 -07:00
Nick Clifton d8dab05495 Updated Russian, Bulgarian, and Brazilian Portuguese translations for various components of the binutuls.
ld	* po/bg.po: Updated Bulgarian translation.
	* po/pt_BR.po: Updated Brazilian Portuguese translation.

binutils* po/bg.po: Updated Bulgarian translation.

bfd,gas	* po/ru.po: Updated Russian translation.
2018-07-05 12:16:56 +01:00
Alan Modra 4a91d0ba30 Error for mismatched powerpc ABI tags
And report the two input files that are incompatible rather than
reporting that an input file is incompatible with the output.

bfd/
	* elf-bfd.h (_bfd_elf_ppc_merge_fp_attributes): Update prototype.
	* elf32-ppc.c (_bfd_elf_ppc_merge_fp_attributes): Return error
	on mismatch.  Remove "warning: " from messages.  Track last bfd
	used to set tags.
	(ppc_elf_merge_obj_attributes): Likewise.  Handle status from
	_bfd_elf_ppc_merge_fp_attributes.
	* elf64-ppc.c (ppc64_elf_merge_private_bfd_data): Handle status
	from _bfd_elf_ppc_merge_fp_attributes.
ld/
	* testsuite/ld-powerpc/attr-gnu-4-12.d: Update expected output.
	* testsuite/ld-powerpc/attr-gnu-4-13.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-21.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-23.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-31.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-32.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-8-23.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-12-21.d: Likewise.
2018-07-05 10:21:37 +09:30
GDB Administrator 4423fa9672 Automatic date update in version.in 2018-07-05 00:00:45 +00:00
H.J. Lu db40acb0be Also install diagnostics.h
Since bfd.h is an installed header, also install diagnostics.h.

	* Makefile.am (bfdinclude_HEADERS): Add $(INCDIR)/diagnostics.h.
	* Makefile.in: Regenerated.
2018-07-04 06:18:34 -07:00
GDB Administrator 9b960ba18c Automatic date update in version.in 2018-07-04 00:01:24 +00:00
Alan Modra b8a6ced796 Correct removal of .gnu.attributes
Setting SEC_EXCLUDE for empty .gnu.attributes is too late in the link
process for the linker to remove the section.  That must be done in
bfd_elf_final_link, as we do for removed group sections.

	* elflink.c (bfd_elf_final_link): Remove zero size .gnu.attributes
	sections.
2018-07-03 18:52:52 +09:30
Alan Modra 8d2c8c3d17 GNU attribute output on errors
.gnu.attributes entries from linker input files are merged to the
output file, the output having the union of compatible input
attributes.  Incompatible attributes generally cause a linker error
and no output.  However in some cases only a warning is emitted, and
one of the incompatible input attributes is passed on to the output.

PowerPC tends to emit warnings rather than errors, and the output
takes the first input attribute.  For example, if we have two input
files with Tag_GNU_Power_ABI_FP, the first with a value signifying
"double-precision hard float, IBM long double", the second with a
value signifying "double-precision hard float, IEEE long double",
we'll get a warning about incompatible long double types and the
output will say "double-precision hard float, IBM long double".
The output attribute of course isn't correct.  It would be correct to
specify "IBM and IEEE long double", but we don't have a way to
represent that currently.  While it would be possible to extend the
encoding, there isn't much gain in doing so.  A shared library
providing support for both long double types should link against
objects using either long double type without warning or error.  That
is what you'd get if such a shared library had no Tag_GNU_Power_ABI_FP
attribute.

So this patch provides a way for the backend to omit .gnu.attributes
tags from the output.

	* elf-bfd.h (ATTR_TYPE_FLAG_ERROR, ATTR_TYPE_HAS_ERROR): Define.
	* elf-attrs.c (is_default_attr): Handle ATTR_TYPE_HAS_ERROR.
	* elf32-ppc.c (_bfd_elf_ppc_merge_fp_attributes): Use
	ATTR_TYPE_FLAG_INT_VAL.  Set ATTR_TYPE_HAS_ERROR on finding
	incompatible attribute.
	(ppc_elf_merge_obj_attributes): Likewise.  Return
	_bfd_elf_merge_object_attributes result.
	* elf64-ppc.c (ppc64_elf_merge_private_bfd_data): Return
	_bfd_elf_merge_object_attributes result.
2018-07-03 16:46:54 +09:30
Alan Modra af0bfb9c42 Hide dynamic symbols in discarded sections
This is a followup to git commit 97196564c7 "Strip global symbol
defined in discarded section".  If a symbol defined in a discarded
section was dynamic, that patch left .dynsym with holes (ie. all zero
entries).  For example, the following from libstdc++.so:

Symbol table '.dynsym' contains 6090 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000000a74e0     0 SECTION LOCAL  DEFAULT   10
     2: 0000000000264180     0 SECTION LOCAL  DEFAULT   17
     3: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_addUserCommitAction
     4: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_memcpyRtWn
     5: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
readelf: Warning: local symbol 5 found at index >= .dynsym's sh_info value of 3
     6: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
readelf: Warning: local symbol 6 found at index >= .dynsym's sh_info value of 3
[snip]

This patch removes the symbols from .dynsym too.

	PR 17550
	* elflink.c (_bfd_elf_fix_symbol_flags): Hide dynamic symbols
	in discarded sections.
2018-07-03 12:31:34 +09:30
GDB Administrator 1825c89e22 Automatic date update in version.in 2018-07-03 00:00:55 +00:00
Maciej W. Rozycki 12f09816ce MIPS/BFD: Make section GC work with `ict_irix5' targets
Prevent runtime procedure table symbols, produced with `ict_irix5' MIPS
targets, from being swept in section GC, fixing linker errors like:

./ld-new: tmpdir/dump: protected symbol `_procedure_table_size' isn't defined
./ld-new: final link failed: bad value

triggered whenever section GC is enabled with those targets and
consequently removing the following test suite failures:

FAIL: Build pr22649-2a.so
FAIL: Build pr22649-2c.so
FAIL: PR ld/20828 dynamic symbols with section GC (auxiliary shared library)
FAIL: PR ld/20828 dynamic symbols with section GC (plain)
FAIL: PR ld/20828 dynamic symbols with section GC (version script)
FAIL: PR ld/20828 dynamic symbols with section GC (versioned shared library)
FAIL: PR ld/20828 dynamic symbols with section GC (versioned)
FAIL: --gc-sections with .text._init
FAIL: pr20022

observed with `mips-elf', `tx39-elf', `mipsisa32-elf', `mipsisa64-elf',
`mipsel-elf', `mipsisa32el-elf', `mipsisa64el-elf', `mips64vr-elf',
`mips64vrel-elf', `mips64vr4300-elf', `mips64vr4300el-elf',
`mips-sgi-irix5' and `mips-rtems' targets, among others.  This fix makes
section GC usable with the affected targets.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Set
	`mark' for symbols created from `mips_elf_dynsym_rtproc_names'
	list.
2018-07-02 23:57:22 +01:00
Maciej W. Rozycki 156f2c001e microMIPS/BFD: Add missing NewABI TLS and miscellaneous relocations
Complement commit df58fc944d ("MIPS: microMIPS ASE support"),
<https://sourceware.org/ml/binutils/2011-07/msg00198.html>, and add TLS
and a few miscellaneous relocations to NewABI microMIPS support, fixing
GAS assertion failures:

.../gas/testsuite/gas/mips/elf-rel28.s: Assembler messages:
.../gas/testsuite/gas/mips/elf-rel28.s:19: Internal error in append_insn at .../gas/config/tc-mips.c:7660.
Please report this bug.

observed if an attempt is made to assemble the `elf-rel28.s' test case
to microMIPS code.  The relocations are the same as with o32 support,
except for `partial_inplace' and `src_mask' updates for the respective
RELA variants.

	bfd/
	* elf64-mips.c (micromips_elf64_howto_table_rel): Add
	R_MICROMIPS_HI0_LO16, R_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_LDM,
	R_MICROMIPS_TLS_DTPREL_HI16, R_MICROMIPS_TLS_DTPREL_LO16,
	R_MICROMIPS_TLS_GOTTPREL, R_MICROMIPS_TLS_TPREL_HI16,
	R_MICROMIPS_TLS_TPREL_LO16, R_MICROMIPS_GPREL7_S2 and
	R_MICROMIPS_PC23_S2 relocation entries.
	(micromips_elf64_howto_table_rela): Likewise.
	(micromips_reloc_map): Likewise.
	* elfn32-mips.c (elf_micromips_howto_table_rel): Likewise.
	(elf_micromips_howto_table_rela): Likewise.
	(micromips_reloc_map): Likewise.

	gas/
	* testsuite/gas/mips/elf-rel28-micromips-n32.d: New test.
	* testsuite/gas/mips/elf-rel28-micromips-n64.d: New test.
	* testsuite/gas/mips/mips.exp: Run the new tests.
2018-07-02 23:57:22 +01:00
H.J. Lu b638b5d57f x86-64: Clear the R_X86_64_converted_reloc_bit bit
We need to clear the R_X86_64_converted_reloc_bit bit after setting it
to avoid leaking it out by --emit-relocs.

bfd/

	PR ld/23324
	* elf64-x86-64.c (elf_x86_64_relocate_section): Clear the
	R_X86_64_converted_reloc_bit bit.

ld/

	PR ld/23324
	* testsuite/ld-x86-64/pr23324.s: New file.
	* testsuite/ld-x86-64/pr23324a.d: Likewise.
	* testsuite/ld-x86-64/pr23324b.d: Likewise.
2018-07-02 13:08:09 -07:00
Tom Tromey eac61af65b Allow BFD to recognize macOS universal libraries
Bug #13157 is about a gdb regression, where previously it could handle
universal libraries, but now cannot.

gdb isn't working for me on macOS for other reasons, so I wrote this
small test program to show the problem:

    #include <config.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <bfd.h>

    void
    die (const char *what)
    {
      fprintf (stderr, "die: %s\n", what);
      exit (1);
    }

    int
    main (int argc, char **argv)
    {
      bfd *file = bfd_openr (argv[1], NULL);
      if (file == NULL)
	die ("couldn't open");

      if (!bfd_check_format (file, bfd_archive))
	die ("not an archive");

      printf ("yay\n");

      bfd_close (file);
      return 0;
    }

Then I built a simple universal binary.  With git master BFD, I get:

    $ ./doit ./universal-exe
    die: not an archive

Jeff Muizelaar tracked this down to the BFD change for PR binutils/21787.
This patch changed bfd_generic_archive_p to sometimes reset the BFD's
"format" field.

However, simply changing bfd_generic_archive_p regressed the test case
in that bug.

Debugging PR binutils/21787 again, what I saw is that the mach-o
universal binary support acts like a bfd_archive but does not provide
a _close_and_cleanup function.  However, if a BFD appears as an
archive member, it must always remove its own entry from its parent's
map.  Otherwise, when the parent is destroyed, the already-destroyed
child BFD will be referenced.  mach-o does not use the usual archive
member support, so simply using _bfd_archive_close_and_cleanup (as
other targets do) will not work.

This patch fixes the problem by introducing a new
_bfd_unlink_from_archive_parent function, then arranging for it to be
called in the mach-o case.

Ok?

bfd/ChangeLog
2018-07-02  Jeff Muizelaar  <jrmuizel@gmail.com>
	    Tom Tromey  <tom@tromey.com>

	PR 13157
	PR 21787
	* mach-o.c (bfd_mach_o_fat_close_and_cleanup): New function.
	(bfd_mach_o_close_and_cleanup): Redefine.
	* archive.c (_bfd_unlink_from_archive_parent): New function,
	extracted from..
	(_bfd_archive_close_and_cleanup): ..here.
	(bfd_generic_archive_p): Do not clear archive's format.
	* libbfd-in.h (_bfd_unlink_from_archive_parent): Declare.
	* libbfd.h: Regenerate.
2018-07-02 08:24:32 -06:00
Thomas Preud'homme c0c468d562 [ARM] Update bfd's Tag_CPU_arch knowledge
BFD's bfd_get_mach () function returns a bfd specific value representing
the architecture of the target which is populated from the Tag_CPU_arch
build attribute value of that target. Among other users of that
interfacem, objdump which uses it to print the architecture version of
the binary being examinated and to decide what instruction is available
if run with "-m arm" via its own mapping from bfd_mach_arm_X values to
feature bits available.

However, both BFD and objdump's most recent known architecture is
Armv5TE. When encountering a newer architecture bfd_get_mach will return
bfd_mach_arm_unknown. This is unfortunate since objdump uses that value
to allow all instructions on all architectures which is already what it
does by default, making the "-m arm" trick useless.

This patch updates BFD and objdump's knowledge of Arm architecture
versions up to the latest Armv8-M Baseline and Mainline, Armv8-R and
Armv8.4-A architectures. Since several architecture versions (eg. 8.X-A)
share the same Tag_CPU_arch build attribute value and
bfd_mach_arm values, the mapping from bfd machine value to feature bits
need to return the most featureful feature bits that would yield the
given bfd machine value otherwise some instruction would not disassemble
under "-m arm" mode. The patch rework that mapping to make this clearer
and simplify writing the mapping rules. In particular, for simplicity
all FPU instructions are allowed in all cases.

Finally, the patch also rewrite the cpu_arch_ver table in GAS to use the
TAG_CPU_ARCH_X macros rather than hardcode their value.

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

bfd/
	* archures.c (bfd_mach_arm_5TEJ, bfd_mach_arm_6, bfd_mach_arm_6KZ,
	bfd_mach_arm_6T2, bfd_mach_arm_6K, bfd_mach_arm_7, bfd_mach_arm_6M,
	bfd_mach_arm_6SM, bfd_mach_arm_7EM, bfd_mach_arm_8, bfd_mach_arm_8R,
	bfd_mach_arm_8M_BASE, bfd_mach_arm_8M_MAIN): Define.
	* bfd-in2.h: Regenerate.
	* cpu-arm.c (arch_info_struct): Add entries for above new
	bfd_mach_arm values.
	* elf32-arm.c (bfd_arm_get_mach_from_attributes): Add Tag_CPU_arch to
	bfd_mach_arm mapping logic for pre Armv4 and Armv5TEJ and later
	architectures.  Force assert failure for any new Tag_CPU_arch value.

gas/
	* config/tc-arm.c (cpu_arch_ver): Use symbolic TAG_CPU_ARCH macros
	rather than hardcode their values.

ld/
	* arm-dis.c (select_arm_features): Fix typo in heading comment.  Allow
	all FPU features and add mapping from new bfd_mach_arm values to
	allowed CPU feature bits.

opcodes/
	* testsuite/ld-arm/tls-descrelax-be8.d: Add architecture version in
	expected result.
	* testsuite/ld-arm/tls-descrelax-v7.d: Likewise.
	* testsuite/ld-arm/tls-longplt-lib.d: Likewise.
	* testsuite/ld-arm/tls-longplt.d: Likewise.
2018-07-02 11:22:20 +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
GDB Administrator f2075844e2 Automatic date update in version.in 2018-07-02 00:00:53 +00:00
GDB Administrator 3e4ce31cb8 Automatic date update in version.in 2018-07-01 00:01:04 +00:00
GDB Administrator 6d3c495640 Automatic date update in version.in 2018-06-30 00:00:50 +00:00
Maciej W. Rozycki 262e07d011 MIPS/BFD: Remove extraneous undefined weak symbol visibility check
Remove an extraneous symbol visibility check made for undefined weak
symbols in determination whether an R_MIPS_REL32 dynamic relocation has
to be placed in output, complementing commit ad95120309 ("mips: Check
UNDEFWEAK_NO_DYNAMIC_RELOC").  That check duplicates one already made by
the UNDEFWEAK_NO_DYNAMIC_RELOC macro as a part of a broader condition
used to decide if to enter undefined weak symbols to the dynamic symbol
table or not.

	bfd/
	* elfxx-mips.c (allocate_dynrelocs): Remove extraneous symbol
	visibility check made for undefined weak symbols.
2018-06-29 15:45:28 +01:00
GDB Administrator fd1ae90587 Automatic date update in version.in 2018-06-29 00:00:39 +00:00
GDB Administrator 1b47b6a218 Automatic date update in version.in 2018-06-28 00:00:42 +00:00
GDB Administrator ac0734dea7 Automatic date update in version.in 2018-06-27 00:00:41 +00:00
Nick Clifton 30aa13067f Updated translations.
gas	* po/uk.po: Updated Ukranian translation.
bfd	* po/uk.po: Updated Ukranian translation.
ld	* po/uk.po: Updated Ukranian translation.
gold	* po/uk.po: Updated Ukranian translation.

opcodes	* po/uk.po: Updated Ukranian translation.
	* po/de.po: Updated German translation.
	* po/pt_BR.po: Updated Brazilian Portuguese translation.

binutils* po/sv.po: Updated Swedish translation.
	* po/uk.po: Updated Ukranian translation.
2018-06-26 14:03:16 +01:00
GDB Administrator e4a882f4b0 Automatic date update in version.in 2018-06-26 00:00:44 +00:00
Nick Clifton bb69498c61 Fix compile time warning message for the AArch64 BFD backend, about a possible attempt to call sprintf on a NULL buffer pointer.
* elfnn-aarch64.c (_bfd_aarch64_erratum_835769_stub_name): Check
	for malloc returning NULL.
	(_bfd_aarch64_erratum_843419_fixup): Check for
	_bfd_aarch64_erratum_835769_stub_name returning NULL.
2018-06-25 12:49:14 +01:00
GDB Administrator c1080aae0f Automatic date update in version.in 2018-06-25 00:00:52 +00:00
Nick Clifton 71300e2c0c Regenerate configure and pot files with updated binutils version number. 2018-06-24 19:13:01 +01:00
Nick Clifton 5127f20732 Update version number on development (aka HEAD) branch. 2018-06-24 18:46:33 +01:00
Nick Clifton 719d828850 Add 2.30 branch notes to ChangeLogs and NEWS files. 2018-06-24 18:36:15 +01:00
GDB Administrator 6706f77062 Automatic date update in version.in 2018-06-24 00:01:17 +00:00
GDB Administrator 2e7a29d570 Automatic date update in version.in 2018-06-23 00:00:50 +00:00