Commit Graph

93369 Commits

Author SHA1 Message Date
H.J. Lu f61f94ec1b ld: Add -z separate-code tests to frame.exp
On x86, "-z separate-code" leads to assertion fail at bfd/elf.c:5917.
Alsp skip tests if -shared isn't supported.

	PR ld/22845
	* testsuite/ld-elf/frame.exp: Skip if -shared isn't supported.
	Add tests for "-z noseparate-code" and "-z separate-code".
	Remove unsupported -shared check.
2018-02-19 05:07:47 -08:00
Thomas Preud'homme e207bc53a4 [ARM] Fix bxns mask
Bit 7 of BXNS is a fixed bit which distinguish it from BLXNS. Yet it is
not set in the disassembler entry mask. This commit fixes that.

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

opcodes/
	* arm-dis.c (thumb_opcodes): Fix BXNS mask.
2018-02-19 12:05:18 +00:00
Matthias Klose e535d0ddb3 Fix mistake in the declaration of the --include-all-whitespace option of the strings utility.
* strings.c (long_options): Include-all-whitespace does not take
        an extra agument.
2018-02-19 11:56:53 +00:00
Alan Hayward b5884fa710 Add common/ dir in build directories
gdb/
	* Makefile.in: (COMMON_SFILES): Add common/*.c files.
	(SFILES): Remove common/*.c files.
	(COMMON_OBS): Remove some *.o files built from common/*.c files.
	* common/common.host: Add common reference.
	* configure.ac: Likewise.
	* configure: Regenerate.

gdbserver/
	* Makefile.in: Add common directory in build.
	* configure.ac: Add common reference.
	* configure: Regenerate.
2018-02-19 09:37:24 +00:00
Alan Modra dbc88fc149 PT_LOAD and PT_GNU_RELRO segment overlap
Commit 325ba6fb34 excluded degenerate zero length PT_LOAD segments,
but that only fixed part of the problem, which was that the load
segment limits were not calculated properly.

	PR 22845
	* elf.c (IS_TBSS): Define.
	(_bfd_elf_map_sections_to_segments): Use IS_TBSS.
	(assign_file_positions_for_non_load_sections): Revert last change.
	Properly calculate load segment limits to compare against relro limits.
2018-02-19 10:40:25 +10:30
GDB Administrator d5c78119f7 Automatic date update in version.in 2018-02-19 00:00:26 +00:00
GDB Administrator e64676d21c Automatic date update in version.in 2018-02-18 00:00:57 +00:00
H.J. Lu d85502cffa ld-elf/ehdr_start: Pass --build-id to ld
ld-elf/ehdr_start fails with -z separate-code.  Since there is no data
LOAD segment before code LOAD segment:

There are 2 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x200000 0x0000000000600000 0x0000000000600000 0x000010 0x000010 R E 0x200000
  LOAD           0x400000 0x0000000000800000 0x0000000000800000 0x000008 0x000008 R   0x200000

 Section to Segment mapping:
  Segment Sections...
   00     .text
   01     .rodata

the program header isn't included in any LOAD segment.  As the result,
reference to __ehdr_start is resolved to zero.  Pass --build-id to ld
to add a data LOAD segment before code LOAD segment to put the program
header in the  data LOAD segment.

	PR ld/22845
	* testsuite/ld-elf/ehdr_start.d: Pass --build-id to ld.
2018-02-17 14:54:40 -08:00
H.J. Lu 34b00afa03 ld: Add -z separate-code test for zero size section
PR ld/22845
	* testsuite/ld-elf/binutils.exp (tls_opts): Add tests for
	"-z noseparate-code" and "-z separate-code".
2018-02-17 05:38:14 -08:00
H.J. Lu 92d9e363b5 ld-elf/eh4: Pass -z max-page-size=0x200000 -z noseparate-code to ld
-z separate-code creates separate code LOAD segment, aligns it to the
maximum page size and places .plt section before .text section.  But
ld-elf/eh4 passes -Ttext 0x400 to linker to place .text section at
address 0x400, which is impossible for linker to accomplish:

$ ld -shared -Ttext 0x400 -z separate-code -o x.so eh4.o
ld: section .eh_frame LMA [0000000000200000,000000000020006b] overlaps section .plt LMA [0000000000200000,000000000020001f]

Since ld-elf/eh4 also checks exact addresses, this patch passes
-z max-page-size=0x200000 -z noseparate-code to ld.

	PR ld/22845
	* ld-elf/eh4.d: Pass -z max-page-size=0x200000 -z noseparate-code
	to ld.
2018-02-17 05:31:15 -08:00
H.J. Lu 62a02d25b6 Add .nop assembler directive
Implement the '.nop SIZE[, CONTROL]' assembler directive, which emits
SIZE bytes filled with no-op instructions.  SIZE is absolute expression.
The optional CONTROL byte controls how no-op instructions should be
generated.  If the comma and @var{control} are omitted, CONTROL is
assumed to be zero.

For Intel 80386 and AMD x86-64 targets, CONTROL byte specifies the size
limit of a single no-op instruction.  The valid values of CONTROL byte
are between 0 and 8 for 16-bit mode, between 0 and 10 for 32-bit mode,
between 0 and 11 for 64-bit mode.  When 0 is used, the no-op size limit
is set to the maximum supported size.

2 new relax states, rs_space_nop and rs_fill_nop, are added to enum
_relax_state, which are similar to rs_space and rs_fill, respectively,
but they fill with no-op instructions, instead of a single byte.  A
target backend must override the default md_generate_nops to generate
proper no-op instructions.  Otherwise, an error of unimplemented .nop
directive will be issued whenever .nop directive is used.

	* NEWS: Mention .nop directive.
	* as.h (_relax_state): Add rs_space_nop and rs_fill_nop.
	* read.c (potable): Add .nop.
	(s_nop): New function.
	* read.h (s_nop): New prototype.
	* write.c (cvt_frag_to_fill): Handle rs_space_nop and
	rs_fill_nop.
	(md_generate_nops): New function.
	(relax_segment): Likewise.
	(write_contents): Use md_generate_nops for rs_fill_nop.
	* config/tc-i386.c (alt64_11): New.
	(alt64_patt): Likewise.
	(md_convert_frag): Handle rs_space_nop.
	(i386_output_nops): New function.
	(i386_generate_nops): Likewise.
	(i386_align_code): Call i386_output_nops.
	* config/tc-i386.h (i386_generate_nops): New.
	(md_generate_nops): Likewise.
	* doc/as.texinfo: Document .nop directive.
	* testsuite/gas/i386/i386.exp: Run .nop directive tests.
	* testsuite/gas/i386/nop-1.d: New file.
	* testsuite/gas/i386/nop-1.s: Likewise.
	* testsuite/gas/i386/nop-2.d: Likewise.
	* testsuite/gas/i386/nop-2.s: Likewise.
	* testsuite/gas/i386/nop-3.d: Likewise.
	* testsuite/gas/i386/nop-3.s: Likewise.
	* testsuite/gas/i386/nop-4.d: Likewise.
	* testsuite/gas/i386/nop-4.s: Likewise.
	* testsuite/gas/i386/nop-5.d: Likewise.
	* testsuite/gas/i386/nop-5.s: Likewise.
	* testsuite/gas/i386/nop-6.d: Likewise.
	* testsuite/gas/i386/nop-6.s: Likewise.
	* testsuite/gas/i386/nop-bad-1.l: Likewise.
	* testsuite/gas/i386/nop-bad-1.s: Likewise.
	* testsuite/gas/i386/x86-64-nop-1.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-2.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-3.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-4.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-5.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-6.d: Likewise.
2018-02-17 05:20:57 -08:00
GDB Administrator bb57c12e55 Automatic date update in version.in 2018-02-17 00:00:29 +00:00
Alan Modra 325ba6fb34 Ignore degenerate PT_LOAD segments
Fixes a failure triggered by -z separate-code.  p_memsz is tested
rather than p_filesz for objcopy --only-keep-debug where p_filesz is
set to zero.

	PR 22845
	* elf.c (assign_file_positions_for_non_load_sections): Ignore
	degenerate zero size PT_LOAD segments when finding one overlapping
	the PT_GNU_RELRO segment.
2018-02-17 10:15:55 +10:30
H.J. Lu c2596c4a72 x86-64: Add -z max-page-size=0x200000 -z noseparate-code to linker tests
Add -z max-page-size=0x200000 -z noseparate-code since these tests
check for exact addresses.

	* testsuite/ld-x86-64/bnd-branch-1-now.d: Add  -z
	max-page-size=0x200000 -z noseparate-code.
	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1.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-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-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/load1a.d: Likewise.
	* testsuite/ld-x86-64/load1b.d: Likewise.
	* testsuite/ld-x86-64/load1c.d: Likewise.
	* testsuite/ld-x86-64/load1d.d: Likewise.
	* testsuite/ld-x86-64/pie3.d: Likewise.
	* testsuite/ld-x86-64/pr14207.d: Likewise.
	* testsuite/ld-x86-64/pr17618.d: Likewise.
	* testsuite/ld-x86-64/pr19162.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1b.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1h.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
	* testsuite/ld-x86-64/pr20830a-now.d: Likewise.
	* testsuite/ld-x86-64/pr20830a.d: Likewise.
	* testsuite/ld-x86-64/pr20830b-now.d: Likewise.
	* testsuite/ld-x86-64/pr20830b.d: Likewise.
	* testsuite/ld-x86-64/pr21038a-now.d: Likewise.
	* testsuite/ld-x86-64/pr21038a.d: Likewise.
	* testsuite/ld-x86-64/pr21038b-now.d: Likewise.
	* testsuite/ld-x86-64/pr21038b.d: Likewise.
	* testsuite/ld-x86-64/pr21038c-now.d: Likewise.
	* testsuite/ld-x86-64/pr21038c.d: Likewise.
2018-02-16 10:03:12 -08:00
H.J. Lu c441b62343 x86-64: Update tests for -z separate-code
"-z separate-code" generates different addresses.  Update these tests
to accept any addresses.

	* testsuite/ld-x86-64/bnd-ifunc-1.d: Updated.
	* testsuite/ld-x86-64/ilp32-4.d: Likewise.
2018-02-16 09:59:39 -08:00
H.J. Lu 197741f19d mpx.exp: Add -z max-page-size=0x200000 -z noseparate-code
Add -z max-page-size=0x200000 -z noseparate-code since these tests
check for exact addresses.

	* testsuite/ld-x86-64/mpx.exp: Add -z max-page-size=0x200000
	-z noseparate-code.
2018-02-16 09:55:09 -08:00
H.J. Lu 7c9f387aef x86-64.exp: Add -z noseparate-code -z max-page-size=0x200000
Add -z noseparate-code -z max-page-size=0x200000 since these tests
check for exact addresses and don't expect extra PT_LOAD segment.  But
don't add them to nacl targets since they generate different addresses.

	* testsuite/ld-x86-64/x86-64.exp: Add -z noseparate-code
	-z max-page-size=0x200000, excluding NaCl target.
2018-02-16 09:50:05 -08:00
H.J. Lu c9d3eb5f61 x86: Add -z noseparate-code to IFUNC tests
Add -z noseparate-code since these tests check for exact addresses.

	* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-i386.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386.d: Likewise.
2018-02-16 09:45:24 -08:00
H.J. Lu 679a5bc862 x86-64: Add -z max-page-size=0x200000 -z noseparate-code to IFUNC tests
Add -z max-page-size=0x200000 -z noseparate-code since these tests
check for exact addresses.

	* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Add
	 -z max-page-size=0x200000 -z noseparate-code.
	* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
2018-02-16 09:39:22 -08:00
H.J. Lu 62e2b91b9a i386: Update IFUNC tests for PLT address
i386 generates

 161:	e8 ea ff ff ff       	call   150 <*ABS*@plt>

instead of

 1e1:	e8 ea ff ff ff       	callq  1d0 <*ABS*+0x1e0@plt>

	* testsuite/ld-ifunc/ifunc-1-local-x86.d: Update PLT address
	for i386.
	* testsuite/ld-ifunc/ifunc-1-x86.d: Likewise.
	* testsuite/ld-ifunc/ifunc-3a-x86.d: Likewise.
2018-02-16 09:32:56 -08:00
H.J. Lu 9f4aec8d97 x86: Update IFUNC tests for -z separate-code
"-z separate-code" generates different PLT addresses.  Update these tests
to accept any PLT addresses.

	* testsuite/ld-ifunc/ifunc-1-local-x86.d: Updated.
	* testsuite/ld-ifunc/ifunc-1-x86.d: Likewise.
	* testsuite/ld-ifunc/ifunc-3a-x86.d: Likewise.
2018-02-16 09:20:21 -08:00
H.J. Lu 410a69a022 i386: Add -z noseparate-code to linker tests
Add -z noseparate-code since these tests check for exact addresses.

	* testsuite/ld-i386/ibt-plt-1.d: Add -z noseparate-code.
	* 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-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/load1.d: Likewise.
	* testsuite/ld-i386/pie1.d: Likewise.
	* testsuite/ld-i386/pr20244-1a.d: Likewise.
	* testsuite/ld-i386/pr20244-1b.d: Likewise.
	* testsuite/ld-i386/pr20244-2a.d: Likewise.
	* testsuite/ld-i386/pr20244-2b.d: Likewise.
	* testsuite/ld-i386/pr20244-2c.d: Likewise.
	* testsuite/ld-i386/pr20244-4a.d: Likewise.
	* testsuite/ld-i386/pr20244-4b.d: Likewise.
	* testsuite/ld-i386/pr20830.d: Likewise.
2018-02-16 09:07:58 -08:00
H.J. Lu 75bd00e87e i386: Update tests for -z separate-code
"-z separate-code" generates:

0x00002080 00200000 00000000 00000000 00000000 . ..............

There is a space ' ', instead of '.'. Update these tests to expect ".*".

	* testsuite/ld-i386/pr19636-1a.d: Updated.
	* testsuite/ld-i386/pr19636-1b.d: Likewise.
	* testsuite/ld-i386/pr19636-1j.d: Likewise.
	* testsuite/ld-i386/pr19636-1k.d: Likewise.
	* testsuite/ld-i386/pr19636-2a.d: Likewise.
	* testsuite/ld-i386/pr19636-2b.d: Likewise.
2018-02-16 09:00:12 -08:00
H.J. Lu 760b289300 i386.exp: Add -z noseparate-code
These tests fail due to one extra PT_LOAD segment with -z separate-code.

	* testsuite/ld-i386/i386.exp: Add -z noseparate-code.
2018-02-16 08:56:43 -08:00
Yao Qi fd90ace4c1 New class allocate_on_obstack
This patch adds a new class allocate_on_obstack, and let dwarf2_per_objfile
inherit it, so that dwarf2_per_objfile is automatically allocated on
obstack, and "delete dwarf2_per_objfile" doesn't de-allocate any space.

gdb:

2018-02-16  Yao Qi  <yao.qi@linaro.org>

	* block.c (block_namespace_info): Inherit allocate_on_obstack.
	(block_initialize_namespace): Use new.
	* dwarf2read.c (dwarf2_per_objfile): Inherit allocate_on_obstack.
	(dwarf2_free_objfile): Use delete.
	* gdbtypes.c (type_pair): Inherit allocate_on_obstack.
	(copy_type_recursive): Use new.
	* gdb_obstack.h (allocate_on_obstack): New.
2018-02-16 16:20:58 +00:00
H.J. Lu 75cdede099 Add -z noseparate-code to ld-elf tests
These tests fail due to one extra PT_LOAD segment with -z separate-code.

	* testsuite/ld-elf/pr19162.d: Add -z noseparate-code.
	* testsuite/ld-elf/textaddr1.d: Likewise.
	* testsuite/ld-elf/textaddr2.d: Likewise.
	* testsuite/ld-elf/textaddr4.d: Likewise.
	* testsuite/ld-elf/textaddr6.d: Likewise.
2018-02-16 06:25:49 -08:00
Alan Modra d00dd7dc5e Remove bfd stub function casts.
This patch defines a bunch of new functions to use in the BFD target
structs rather than casting bfd_false or bfd_true and similar stub
functions.  I've also renamed the stub functions to reflect their
parameters and put "error" in the name if they set bfd_error.  The
latter change is important since there were quite a few uses of
bfd_false where setting bfd_error was inappropriate, for example in
elf_backend_allow_non_load_phdr and is_target_special_symbol.

	* libbfd.c (_bfd_bool_bfd_false_error): Rename from bfd_false.
	(_bfd_bool_bfd_true): Rename from bfd_true.
	(_bfd_ptr_bfd_null_error): Rename from bfd_nullvoidptr.
	(_bfd_int_bfd_0): Rename from bfd_0.
	(_bfd_uint_bfd_0): Rename from bfd_0u.
	(_bfd_long_bfd_0): Rename from bfd_0l.
	(_bfd_long_bfd_n1_error): Rename from _bfd_n1.
	(_bfd_void_bfd): Rename from bfd_void.
	(_bfd_bool_bfd_false, _bfd_bool_bfd_asymbol_false),
	(_bfd_bool_bfd_link_false_error),
	(_bfd_bool_bfd_link_true, _bfd_bool_bfd_bfd_true),
	(_bfd_bool_bfd_uint_true, _bfd_bool_bfd_ptr_true),
	(_bfd_bool_bfd_asection_bfd_asection_true),
	(_bfd_bool_bfd_asymbol_bfd_asymbol_true),
	(_bfd_void_bfd_link, _bfd_void_bfd_asection): New functions.
	* archive.c (_bfd_noarchive_get_elt_at_index),
	(_bfd_noarchive_openr_next_archived_file),
	(_bfd_noarchive_construct_extended_name_table),
	(_bfd_noarchive_write_ar_hdr, _bfd_noarchive_truncate_arname),
	(_bfd_noarchive_write_armap): New functions.
	* archures.c (_bfd_nowrite_set_arch_mach): New function.
	* coff-alpha.c (alpha_ecoff_swap_coff_aux_in),
	(alpha_ecoff_swap_coff_sym_in, alpha_ecoff_swap_coff_lineno_in),
	(alpha_ecoff_swap_coff_aux_out, alpha_ecoff_swap_coff_sym_out),
	(alpha_ecoff_swap_coff_lineno_out),
	(alpha_ecoff_swap_coff_reloc_out): New functions.
	* coff-mips.c (mips_ecoff_swap_coff_aux_in),
	(mips_ecoff_swap_coff_sym_in, mips_ecoff_swap_coff_lineno_in),
	(mips_ecoff_swap_coff_aux_out, mips_ecoff_swap_coff_sym_out),
	(mips_ecoff_swap_coff_lineno_out),
	(mips_ecoff_swap_coff_reloc_out): New functions.
	* coffcode.h (coff_set_alignment_hook): Replace define with
	new function.
	(symname_in_debug_hook): Likewise.
	* ecoff.c (_bfd_ecoff_set_alignment_hook): New function.
	* elfxx-target.h (elf_backend_allow_non_load_phdr): Default to 0.
	* elf.c (assign_file_positions_except_relocs): Test
	elf_backend_allow_non_load_phdr for NULL.
	* elflink.c (_bfd_elf_omit_section_dynsym_default): Rename from
	_bfd_elf_link_omit_section_dynsym.  Update uses.
	(_bfd_elf_omit_section_dynsym_all): New function.
	* elf-bfd.h (_bfd_elf_link_omit_section_dynsym): Delete.
	(_bfd_elf_omit_section_dynsym_default): Declare.
	(_bfd_elf_omit_section_dynsym_all): Declare.
	* linker.c (_bfd_nolink_sizeof_headers, _bfd_nolink_bfd_relax_section),
	(_bfd_nolink_bfd_get_relocated_section_contents),
	(_bfd_nolink_bfd_lookup_section_flags),
	(_bfd_nolink_bfd_is_group_section, _bfd_nolink_bfd_discard_group),
	(_bfd_nolink_bfd_link_hash_table_create),
	(_bfd_nolink_bfd_link_just_syms),
	(_bfd_nolink_bfd_copy_link_hash_symbol_type),
	(_bfd_nolink_bfd_link_split_section),
	(_bfd_nolink_section_already_linked),
	(_bfd_nolink_bfd_define_common_symbol),
	(_bfd_nolink_bfd_define_start_stop): New functions.
	* reloc.c (_bfd_norelocs_bfd_reloc_type_lookup),
	(_bfd_norelocs_bfd_reloc_name_lookup),
	(_bfd_nodynamic_canonicalize_dynamic_reloc): New functions.
	* section.c (_bfd_nowrite_set_section_contents): New function.
	* syms.c (_bfd_nosymbols_canonicalize_symtab),
	(_bfd_nosymbols_print_symbol, _bfd_nosymbols_get_symbol_info),
	(_bfd_nosymbols_get_symbol_version_string),
	(_bfd_nosymbols_bfd_is_local_label_name),
	(_bfd_nosymbols_get_lineno, _bfd_nosymbols_find_nearest_line),
	(_bfd_nosymbols_find_line, _bfd_nosymbols_find_inliner_info),
	(_bfd_nosymbols_bfd_make_debug_symbol),
	( _bfd_nosymbols_read_minisymbols),
	( _bfd_nosymbols_minisymbol_to_symbol),
	(_bfd_nodynamic_get_synthetic_symtab): New functions.
	* libbfd-in.h: Declare new functions.  Update existing defines,
	removing casts.
	* aix386-core.c: Update to use new hooks.  Formatting.
	* aout-adobe.c: Likewise.
	* aout-arm.c: Likewise.
	* aout-target.h: Likewise.
	* aout-tic30.c: Likewise.
	* aoutf1.h: Likewise.
	* binary.c: Likewise.
	* bout.c: Likewise.
	* cisco-core.c: Likewise.
	* coff-alpha.c: Likewise.
	* coff-i386.c: Likewise.
	* coff-i860.c: Likewise.
	* coff-i960.c: Likewise.
	* coff-ia64.c: Likewise.
	* coff-mips.c: Likewise.
	* coff-ppc.c: Likewise.
	* coff-rs6000.c: Likewise.
	* coff-sh.c: Likewise.
	* coff-tic30.c: Likewise.
	* coff-tic54x.c: Likewise.
	* coff-x86_64.c: Likewise.
	* coff64-rs6000.c: Likewise.
	* coffcode.h: Likewise.
	* elf-m10300.c: Likewise.
	* elf32-cr16.c: Likewise.
	* elf32-lm32.c: Likewise.
	* elf32-m32r.c: Likewise.
	* elf32-metag.c: Likewise.
	* elf32-score.c: Likewise.
	* elf32-score7.c: Likewise.
	* elf32-tilepro.c: Likewise.
	* elf32-xstormy16.c: Likewise.
	* elf32-xtensa.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elf64-hppa.c: Likewise.
	* elf64-ia64-vms.c: Likewise.
	* elf64-mmix.c: Likewise.
	* elf64-sh64.c: Likewise.
	* elfnn-ia64.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* elfxx-target.h: Likewise.
	* elfxx-tilegx.c: Likewise.
	* elfxx-x86.h: Likewise.
	* hp300hpux.c: Likewise.
	* hppabsd-core.c: Likewise.
	* hpux-core.c: Likewise.
	* i386msdos.c: Likewise.
	* i386os9k.c: Likewise.
	* ieee.c: Likewise.
	* ihex.c: Likewise.
	* irix-core.c: Likewise.
	* libaout.h: Likewise.
	* libecoff.h: Likewise.
	* mach-o-target.c: Likewise.
	* mach-o.c: Likewise.
	* mipsbsd.c: Likewise.
	* mmo.c: Likewise.
	* netbsd-core.c: Likewise.
	* nlm-target.h: Likewise.
	* oasys.c: Likewise.
	* osf-core.c: Likewise.
	* pdp11.c: Likewise.
	* pe-mips.c: Likewise.
	* pe-x86_64.c: Likewise.
	* pef.c: Likewise.
	* plugin.c: Likewise.
	* ppcboot.c: Likewise.
	* ptrace-core.c: Likewise.
	* sco5-core.c: Likewise.
	* som.c: Likewise.
	* sparclynx.c: Likewise.
	* srec.c: Likewise.
	* tekhex.c: Likewise.
	* trad-core.c: Likewise.
	* verilog.c: Likewise.
	* versados.c: Likewise.
	* vms-alpha.c: Likewise.
	* vms-lib.c: Likewise.
	* wasm-module.c: Likewise.
	* xsym.c: Likewise.
	* libbfd.h: Regenerate.
2018-02-16 19:09:23 +10:30
Sriraman Tallam 3281b315c8 Fix symbol resolution with linker plugins for defsym symbols.
2018-02-07  Sriraman Tallam  <tmsriram@google.com>

	* expression.cc (Symbol_expression::set_expr_sym_in_real_elf):
	New method.
	(Unary_expression::set_expr_sym_in_real_elf): New method.
	(Binary_expression::set_expr_sym_in_real_elf): New method.
	(Trinary_expression::set_expr_sym_in_real_elf): New method.
	* plugin.cc (get_symbol_resolution_info): Fix symbol resolution if
	defined or used in defsyms.
	* plugin.h (Plugin_manager::is_defsym_def): New method.
	(Plugin_manager::Plugin_manager): Initialize defsym_defines_set_.
	(Plugin_manager::defsym_defines_set_): New member.
	(Plugin_manager::Defsym_defines_set): New typedef.
	* script.cc (Script_options::set_defsym_uses_in_real_elf): New method.
	(Script_options::find_defsym_defs): New method.
	* script.h (Expression::set_expr_sym_in_real_elf): New method.
	(Symbol_assignment::is_defsym): New method.
	(Symbol_assignment::value): New method.
	(Script_options::find_defsym_defs): New method.
	(Script_options::set_defsym_uses_in_real_elf): New method.
	* testsuite/Makefile.am (plugin_test_defsym): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/plugin_test.c: Check for new symbol resolution.
	* testsuite/plugin_test_defsym.sh: New script.
	* testsuite/plugin_test_defsym.c: New test source.
2018-02-15 17:35:16 -08:00
GDB Administrator 43859909e2 Automatic date update in version.in 2018-02-16 00:00:41 +00:00
Jim Wilson 09ca4b9d9b RISC-V: Fix relocation failure with zero address sections.
bfd/
	* elfnn-riscv.c (_bfd_riscv_relax_section): Ifdef out check to ignore
	symbols whose section address is zero.
2018-02-15 13:48:38 -08:00
Jim Wilson 2a0d985349 RISC-V: Give error for ignored pcrel_lo addend.
bfd/
	* elfnn-riscv.c (riscv_elf_relocate_section): Use bfd_reloc_dangerous
	when pcrel_lo reloc has an addend.  Use reloc_dangerous callback for
	bfd_reloc_dangerous.  Use einfo instead of warning callback for errors.
	Add %X%P to error messages.

	ld/
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run pcrel-lo-addend test.
	* testsuite/ld-riscv-elf/pcrel-lo-addend.d: New.
	* testsuite/ld-riscv-elf/pcrel-lo-addend.s: New.
2018-02-15 10:53:46 -08:00
Tamar Christina 49ded53def Fix AArch32 build attributes for Armv8.4-A.
The build attribute number for Armv8.4-A is currently incorrectly set to that of Armv8-M.
This patch fixes that by setting it as part of the Armv8-A family and adds a test for it.

gas/
2018-02-15  Tamar Christina  <tamar.christina@arm.com>

	* config/tc-arm.c (cpu_arch_ver): Renumber ARM_ARCH_V8_4A.
	* testsuite/gas/arm/attr-march-armv8_4-a.d: New.
2018-02-15 17:09:07 +00:00
Eric Botcazou e513bd38a6 PR ld/22832 on SPARC.
The fix for PR ld/22727 on SPARC passed TRUE as the 'create' argument
in the call to bfd_link_hash_lookup.  It turns out this was a bad idea
because, if the symbol is created at this point, the link will abort
later in elf_link_output_extsym.  This changes the TRUE into a FALSE
and puts an assertion on the result of the call, making it easier to
debug the issue; that's exactly in keeping with what Gold does.

bfd/
	* elfxx-sparc.c (_bfd_sparc_elf_check_relocs) <R_SPARC_TLS_GD_CALL>:
	Pass FALSE instead of TRUE as 'create' argument to bfd_link_hash_lookup
	and assert that the result of the call is not NULL.
2018-02-15 15:57:50 +01:00
Yao Qi 85046ae23f Reset inferior::control on inferior exit
When we kill an inferior, the inferior is not deleted.  What is more, it
is reused when the new process is created, so we need to reset inferior's
state when it exits.

gdb:

2018-02-15  Yao Qi  <yao.qi@linaro.org>

	PR gdb/22849
	* inferior.c (exit_inferior_1): Reset inf->control.
2018-02-15 14:48:30 +00:00
Joel Brobecker 355c559b74 delete ada-lang.c::ada_to_fixed_value_create advance declaration
This advance declaration really isn't necesary, since the implementation
of this function comes before the first reference to it.

gdb/ChangeLog:

        * ada-lang.c (ada_to_fixed_value_create): Delete advance
        declaration.

Tested by rebuilding GDB.
2018-02-14 22:59:20 -05:00
GDB Administrator 074bca956e Automatic date update in version.in 2018-02-15 00:00:29 +00:00
Pedro Alves 980548fd88 Fix GDB crash after Quit thrown from unwinder sniffer
I ran into a GDB crash in gdb.base/bp-cmds-continue-ctrl-c.exp in my
multi-target branch, which turns out exposed a bug that exists in
master too.

That testcase has a breakpoint with a "continue" command associated.
Then the breakpoint is constantly being hit.  At the same time, the
testcase is continualy interrupting the program with Ctrl-C, and
re-resuming it, in a loop.

Running that testcase manually under Valgrind, after a few sequences
of 'Ctrl-C' + 'continue', I got:

 Breakpoint 1, Quit
 (gdb) ==21270== Invalid read of size 8
 ==21270==    at 0x4D8185: pyuw_this_id(frame_info*, void**, frame_id*) (py-unwind.c:461)
 ==21270==    by 0x6D426A: compute_frame_id(frame_info*) (frame.c:505)
 ==21270==    by 0x6D43B7: get_frame_id(frame_info*) (frame.c:537)
 ==21270==    by 0x84F3B8: scoped_restore_current_thread::scoped_restore_current_thread() (thread.c:1678)
 ==21270==    by 0x718E3D: fetch_inferior_event(void*) (infrun.c:4076)
 ==21270==    by 0x7067C9: inferior_event_handler(inferior_event_type, void*) (inf-loop.c:43)
 ==21270==    by 0x45BEF9: handle_target_event(int, void*) (linux-nat.c:4419)
 ==21270==    by 0x6C4255: handle_file_event(file_handler*, int) (event-loop.c:733)
 ==21270==    by 0x6C47F8: gdb_wait_for_event(int) (event-loop.c:859)
 ==21270==    by 0x6C3666: gdb_do_one_event() (event-loop.c:322)
 ==21270==    by 0x6C3712: start_event_loop() (event-loop.c:371)
 ==21270==    by 0x746801: captured_command_loop() (main.c:329)
 ==21270==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
 ==21270==
 ==21270==
 ==21270== Process terminating with default action of signal 11 (SIGSEGV): dumping core
 ==21270==  Access not within mapped region at address 0x0
 ==21270==    at 0x4D8185: pyuw_this_id(frame_info*, void**, frame_id*) (py-unwind.c:461)
 ==21270==    by 0x6D426A: compute_frame_id(frame_info*) (frame.c:505)
 ==21270==    by 0x6D43B7: get_frame_id(frame_info*) (frame.c:537)
 ==21270==    by 0x84F3B8: scoped_restore_current_thread::scoped_restore_current_thread() (thread.c:1678)
 ==21270==    by 0x718E3D: fetch_inferior_event(void*) (infrun.c:4076)
 ==21270==    by 0x7067C9: inferior_event_handler(inferior_event_type, void*) (inf-loop.c:43)
 ==21270==    by 0x45BEF9: handle_target_event(int, void*) (linux-nat.c:4419)
 ==21270==    by 0x6C4255: handle_file_event(file_handler*, int) (event-loop.c:733)
 ==21270==    by 0x6C47F8: gdb_wait_for_event(int) (event-loop.c:859)
 ==21270==    by 0x6C3666: gdb_do_one_event() (event-loop.c:322)
 ==21270==    by 0x6C3712: start_event_loop() (event-loop.c:371)
 ==21270==    by 0x746801: captured_command_loop() (main.c:329)
 ==21270==  If you believe this happened as a result of a stack
 ==21270==  overflow in your program's main thread (unlikely but
 ==21270==  possible), you can try to increase the size of the
 ==21270==  main thread stack using the --main-stacksize= flag.
 ==21270==  The main thread stack size used in this run was 8388608.
 ==21270==

Above, when we get to compute_frame_id, fi->unwind is non-NULL,
meaning, we found an unwinder, in this case the Python unwinder, but
somehow, fi->prologue_cache is left NULL.  pyuw_this_id then crashes
because it assumes fi->prologue_cache is non-NULL:

  static void
  pyuw_this_id (struct frame_info *this_frame, void **cache_ptr,
		struct frame_id *this_id)
  {
    *this_id = ((cached_frame_info *) *cache_ptr)->frame_id;
                                      ^^^^^^^^^^

'*cache_ptr' here is 'fi->prologue_cache'.

There's a quit() call in pyuw_sniffer that I believe is the one that
sometimes triggers the crash above.  The crash can be reproduced
easily with this hack to force a quit out of the python unwinder:

 --- a/gdb/python/py-unwind.c
 +++ b/gdb/python/py-unwind.c
 @@ -497,6 +497,8 @@ pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame,
    struct gdbarch *gdbarch = (struct gdbarch *) (self->unwind_data);
    cached_frame_info *cached_frame;

 +  quit ();
 +
    gdbpy_enter enter_py (gdbarch, current_language);

    TRACE_PY_UNWIND (3, "%s (SP=%s, PC=%s)\n", __FUNCTION__,

After that quit is thrown, any subsequent operation that involves
unwinding results in GDB crashing with SIGSEGV like above.

The problem is that this commit:

  commit 30a9c02fef
  CommitDate: Sun Oct 8 23:16:42 2017 -0600
  Subject: Remove cleanup from frame_prepare_for_sniffer

missed that we need to call frame_cleanup_after_sniffer before
rethrowing the exception too.

Without the fix, the "bt" added to
gdb.base/bp-cmds-continue-ctrl-c.exp in this commit makes GDB crash:

  Running src/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp ...
  ERROR: Process no longer exists

gdb/ChangeLog:
2018-02-14  Pedro Alves  <palves@redhat.com>

	* frame-unwind.c (frame_unwind_try_unwinder): Always call
	frame_cleanup_after_sniffer on exception.

gdb/testsuite/ChangeLog:
2018-02-14  Pedro Alves  <palves@redhat.com>

	* gdb.base/bp-cmds-continue-ctrl-c.exp (do_test): Test "bt" after
	getting a "Quit".
2018-02-14 18:59:00 +00:00
Tom Tromey 692d6f9760 Constify target_so_ops::bfd_open
This constifies the bfd_open method of struct target_so_ops.

gdb/ChangeLog
2018-02-14  Tom Tromey  <tom@tromey.com>

	* solist.h (struct target_so_ops) <bfd_open>: Make pathname
	const.
	(solib_bfd_open): Make pathname const.
	* solib.c (solib_bfd_open): Make pathname const.
	* solib-spu.c (spu_bfd_fopen): Make name const.
	(spu_bfd_open): Make pathname const.
	* solib-darwin.c (darwin_bfd_open): Make pathname const.
	* solib-aix.c (solib_aix_bfd_open): Make pathname const.
2018-02-14 08:09:53 -07:00
Tom Tromey e0cc99a62f Change openp et al to use a unique_xmalloc_ptr
This changes openp, source_full_path_of, and find_and_open_source to
take a unique_xmalloc_ptr, rather than a char*, as an outgoing
argument type.  This simplifies the API, ownership-wise, and allows
for the removal of some cleanups.

gdb/ChangeLog
2018-02-14  Tom Tromey  <tom@tromey.com>

	* symfile.c (symfile_bfd_open): Update.
	* source.h (openp, source_full_path_of, find_and_open_source):
	Change argument type to unique_xmalloc_ptr.
	* source.c (openp): Take a unique_xmalloc_ptr.
	(source_full_path_of, find_and_open_source): Likewise.
	(open_source_file, symtab_to_fullname): Update.
	* solist.h (struct target_so_ops) <find_and_open_solib>: Take a
	unique_xmalloc_ptr.
	* solib.c (solib_find_1): Use unique_xmalloc_ptr.
	(exec_file_find): Update.
	* psymtab.c (psymtab_to_fullname): Update.
	* nto-tdep.h (nto_find_and_open_solib): Update.
	* nto-tdep.c (nto_find_and_open_solib): Change temp_path to a
	unique_xmalloc_ptr.
	* exec.c (exec_file_attach): Update.
	* dwarf2read.c (try_open_dwop_file): Use unique_xmalloc_ptr.
	* cli/cli-cmds.c (find_and_open_script): Use unique_xmalloc_ptr.
2018-02-14 08:09:53 -07:00
Tom Tromey b46a8d7c1d Move some declarations to source.h
I noticed a few declarations in defs.h that really could be put into
source.h.  I think it's generally preferable to something out of
defs.h unless it is needed by most of the files in gdb.

gdb/ChangeLog
2018-02-14  Tom Tromey  <tom@tromey.com>

	* solib.c: Include source.h.
	* nto-tdep.c: Include source.h.
	* mi/mi-cmd-env.c: Include source.h.
	* infcmd.c: Include source.h.
	* exec.c: Include source.h.
	* defs.h (enum openp_flag, openp, source_full_path_of, mod_path)
	(add_path, directory_switch, source_path, init_source_path): Move
	declarations...
	* source.h (enum openp_flag, openp, source_full_path_of, mod_path)
	(add_path, directory_switch, source_path, init_source_path):
	...here.
2018-02-14 08:09:52 -07:00
Tom Tromey 797bc1cb25 Return unique_xmalloc_ptr from some solib.c functions
This changes a couple of solib.c functions -- exec_file_find and
solib_find -- to return a unique_xmalloc_ptr, and then fixes up the
users.  This allows the removal of some cleanups.

This also changes solib_bfd_open to not take ownership of its
argument.  I think this change is somewhat cleaner.

gdb/ChangeLog
2018-02-14  Tom Tromey  <tom@tromey.com>

	* solist.h (exec_file_find, solib_find): Return
	unique_xmalloc_ptr.
	(solib_bfd_fopen): Take a const char *.
	* solib.c (solib_find_1): Return unique_xmalloc_ptr.
	(exec_file_find, solib_find): Likewise.
	(solib_bfd_fopen): Do not take ownership of "pathname".
	(solib_bfd_open): Use unique_xmalloc_ptr.
	* solib-darwin.c (darwin_bfd_open): Use unique_xmalloc_ptr.
	* solib-aix.c (solib_aix_bfd_open): Use unique_xmalloc_ptr.
	* infrun.c (follow_exec): Use unique_xmalloc_ptr.
	* exec.c (exec_file_locate_attach): Use unique_xmalloc_ptr.
2018-02-14 08:09:52 -07:00
Nick Clifton 12ef3f5a7c Fix compilation of the BFD sub-directory with a gcc v8 compiler by adding extra casts.
GCC v8 issues warnings about mis-matching casts of function pointers.
A previous patch tried to fix this problem by adding new dummy functions
which accepted a variable number of arguments.  But this introduces serious
problems when compiled with other versions of gcc, (notably gcc 4.4).  This
patch reverts that previous solution and instead adds extra casts (to
function types without a parameter list).

For more details see: https://sourceware.org/ml/binutils/2018-02/msg00198.html

	PR 22823
	Revert previous delta.  Add extra casts to avoid compile time
	warnings instead.
	* libbfd-in.h (_bfd_generic_bfd_copy_private_bfd_data): Add extra
	cast to avoid warning from gcc v8 compiler.
	(_bfd_generic_bfd_merge_private_bfd_data): Likewise.
	(_bfd_generic_bfd_set_private_flags): Likewise.
	(_bfd_generic_bfd_copy_private_section_data): Likewise.
	(_bfd_generic_bfd_copy_private_symbol_data): Likewise.
	(_bfd_generic_bfd_copy_private_header_data): Likewise.
	(_bfd_generic_bfd_print_private_bfd_data): Likewise.
	(_bfd_noarchive_construct_extended_name_table): Likewise.
	(_bfd_noarchive_truncate_arname): Likewise.
	(_bfd_noarchive_write_ar_hdr): Likewise.
	(_bfd_noarchive_get_elt_at_index): Likewise.
	(_bfd_nosymbols_canonicalize_symtab): Likewise.
	(_bfd_nosymbols_print_symbol): Likewise.
	(_bfd_nosymbols_get_symbol_info): Likewise.
	(_bfd_nosymbols_get_symbol_version_string): Likewise.
	(_bfd_nosymbols_bfd_is_local_label_name): Likewise.
	(_bfd_nosymbols_bfd_is_target_special_symbol): Likewise.
	(_bfd_nosymbols_get_lineno): Likewise.
	(_bfd_nosymbols_find_nearest_line): Likewise.
	(_bfd_nosymbols_find_line): Likewise.
	(_bfd_nosymbols_find_inliner_info): Likewise.
	(_bfd_nosymbols_bfd_make_debug_symbol): Likewise.
	(_bfd_nosymbols_read_minisymbols): Likewise.
	(_bfd_nosymbols_minisymbol_to_symbol): Likewise.
	(_bfd_norelocs_bfd_reloc_type_lookup): Likewise.
	(_bfd_norelocs_bfd_reloc_name_lookup): Likewise.
	(_bfd_nowrite_set_arch_mach): Likewise.
	(_bfd_nowrite_set_section_contents): Likewise.
	(_bfd_nolink_sizeof_headers): Likewise.
	(_bfd_nolink_bfd_get_relocated_section_contents): Likewise.
	(_bfd_nolink_bfd_relax_section): Likewise.
	(_bfd_nolink_bfd_gc_sections): Likewise.
	(_bfd_nolink_bfd_lookup_section_flags): Likewise.
	(_bfd_nolink_bfd_merge_sections): Likewise.
	(_bfd_nolink_bfd_is_group_section): Likewise.
	(_bfd_nolink_bfd_discard_group): Likewise.
	(_bfd_nolink_bfd_link_hash_table_create): Likewise.
	(_bfd_nolink_bfd_link_add_symbols): Likewise.
	(_bfd_nolink_bfd_link_just_syms): Likewise.
	(_bfd_nolink_bfd_copy_link_hash_symbol_type): Likewise.
	(_bfd_nolink_bfd_final_link): Likewise.
	(_bfd_nolink_bfd_link_split_section): Likewise.
	(_bfd_nolink_section_already_linked): Likewise.
	(_bfd_nolink_bfd_define_common_symbol): Likewise.
	(_bfd_nolink_bfd_define_start_stop): Likewise.
	(_bfd_nodynamic_canonicalize_dynamic_symtab): Likewise.
	(_bfd_nodynamic_get_synthetic_symtab): Likewise.
	(_bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_): Likewise.
	(_bfd_nodynamic_canonicalize_dynamic_reloc): Likewise.
	* libbfd.c (bfd_false_any): Delete.
	(bfd_true_any, bfd_nullvoidptr_any, bfd_0_any): Delete.
	(bfd_0u_any, bfd_0l_any, _bfd_n1_any, bfd_void_any): Delete.
	* libbfd.h (extern): Regenerate
	* aout-target.h (MY_bfd_is_target_special_symbol): Add extra
	cast to avoid warning from gcc v8 compiler.
	* aout-tic30.c (tic30_aout_set_arch_mach): Likewise.
	* binary.c (binary_get_symbol_info): Likewise.
	* coff-alpha.c (alpha_ecoff_backend_data): Likewise.
	* coff-mips.c (mips_ecoff_backend_data): Likewise.
	* coffcode.h (coff_set_alignment_hook): Likewise.
	(symname_in_debug_hook): Likewise.
	(bfd_coff_backend_data bigobj_swap_table): Likewise.
	* elf-m10300.c (elf_backend_omit_section_dynsym): Likewise.
	* elf32-cr16.c (elf_backend_omit_section_dynsym): Likewise.
	* elf32-lm32.c (elf_backend_omit_section_dynsym): Likewise.
	* elf32-m32r.c (elf_backend_omit_section_dynsym): Likewise.
	* elf32-metag.c (elf_backend_omit_section_dynsym): Likewise.
	* elf32-score.c (elf_backend_omit_section_dynsym): Likewise.
	* elf32-score7.c (elf_backend_omit_section_dynsym): Likewise.
	* elf32-xstormy16.c (elf_backend_omit_section_dynsym): Likewise.
	* elf32-xtensa.c (elf_backend_omit_section_dynsym): Likewise.
	* elf64-alpha.c (elf_backend_omit_section_dynsym): Likewise.
	* elf64-hppa.c (elf_backend_omit_section_dynsym): Likewise.
	* elf64-ia64-vms.c (elf_backend_omit_section_dynsym): Likewise.
	* elf64-mmix.c (elf_backend_omit_section_dynsym): Likewise.
	* elf64-sh64.c (elf_backend_omit_section_dynsym): Likewise.
	* elfnn-ia64.c (elf_backend_omit_section_dynsym): Likewise.
	* elfxx-target.h (bfd_elfNN_bfd_debug_info_accumulate): Likewise.
	(bfd_elfNN_bfd_make_debug_symbol): Likewise.
	(bfd_elfNN_bfd_merge_private_bfd_data): Likewise.
	(bfd_elfNN_bfd_set_private_flags): Likewise.
	(bfd_elfNN_bfd_is_target_special_symbol): Likewise.
	(elf_backend_init_index_section): Likewise.
	(elf_backend_allow_non_load_phdr): Likewise.
	* elfxx-x86.h (elf_backend_omit_section_dynsym): Likewise.
	* i386msdos.c (msdos_bfd_is_target_special_symbol): Likewise.
	* ieee.c (ieee_construct_extended_name_table): Likewise.
	(ieee_write_armap): Likewise.
	(ieee_write_ar_hdr): Likewise.
	(ieee_bfd_is_target_special_symbol): Likewise.
	* ihex.c (ihex_canonicalize_symtab): Likewise.
	(ihex_bfd_is_target_special_symbol): Likewise.
	* libaout.h (aout_32_bfd_is_target_special_symbol): Likewise.
	* libecoff.h (_bfd_ecoff_bfd_is_target_special_symbol): Likewise.
	(_bfd_ecoff_set_alignment_hook): Likewise.
	* mach-o-target.c (bfd_mach_o_bfd_is_target_special_symbol): Likewise.
	* mmo.c (mmo_bfd_is_target_special_symbol): Likewise.
	* nlm-target.h (nlm_bfd_is_target_special_symbol): Likewise.
	* oasys.c (oasys_construct_extended_name_table): Likewise.
	(oasys_write_armap): Likewise.
	(oasys_write_ar_hdr): Likewise.
	(oasys_bfd_is_target_special_symbol): Likewise.
	* pef.c (bfd_pef_bfd_is_target_special_symbol): Likewise.
	* plugin.c (bfd_plugin_bfd_is_target_special_symbol): Likewise.
	* ppcboot.c (ppcboot_bfd_is_target_special_symbol): Likewise.
	* som.c (som_bfd_is_target_special_symbol): Likewise.
	* srec.c (srec_bfd_is_target_special_symbol): Likewise.
	* tekhex.c (tekhex_bfd_is_target_special_symbol): Likewise.
	* verilog.c (verilog_bfd_is_target_special_symbol): Likewise.
	* versados.c (versados_bfd_is_target_special_symbol): Likewise.
	(versados_bfd_reloc_name_lookup): Likewise.
	* vms-alpha.c (vms_bfd_is_target_special_symbol): Likewise.
	(vms_bfd_define_start_stop): Likewise.
	(alpha_vms_bfd_is_target_special_symbol): Likewise.
	* wasm-module.c (wasm_bfd_is_target_special_symbol): Likewise.
	* xsym.c (bfd_sym_bfd_is_target_special_symbol): Likewise.
2018-02-14 14:56:21 +00:00
H.J. Lu 451875b4f9 x86-64: Use PLT address for PC-relative reloc
Since PLT in PDE and PC-relative PLT in PIE can be used as function
address, there is no need for dynamic PC-relative relocation against
a dynamic function definition in PIE.  Linker should resolve PC-relative
reference to its PLT address.

NB: i386 has non-PIC PLT and PIC PLT.  Only non-PIC PLT in PDE can
be used as function address.  PIC PLT in PIE can't be used as
function address.

bfd/

	PR ld/22842
	* elf32-i386.c (elf_i386_check_relocs): Pass FALSE for non
	PC-relative PLT to NEED_DYNAMIC_RELOCATION_P.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Create PLT for
	R_X86_64_PC32 reloc against dynamic function in data section.
	Pass TRUE for PC-relative PLT to NEED_DYNAMIC_RELOCATION_P.
	(elf_x86_64_relocate_section): Use PLT for R_X86_64_PC32 reloc
	against dynamic function in data section.
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Use PLT in PIE as
	function address only if pcrel_plt is true.
	(_bfd_x86_elf_link_hash_table_create): Set pcrel_plt.
	* elfxx-x86.h (NEED_DYNAMIC_RELOCATION_P): Add PCREL_PLT for
	PC-relative PLT.  If PLT is PC-relative, don't generate dynamic
	PC-relative relocation against a function definition in data
	secton in PIE.  Remove the obsolete comments.
	(elf_x86_link_hash_table): Add pcrel_plt.

ld/

	PR ld/22842
	* testsuite/ld-i386/i386.exp: Run PR ld/22842 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr22842a.c: New file.
	* testsuite/ld-i386/pr22842b.S: Likewise.
	* testsuite/ld-x86-64/pr22842a.c: Likewise.
	* testsuite/ld-x86-64/pr22842a.rd: Likewise.
	* testsuite/ld-x86-64/pr22842b.S: Likewise.
	* testsuite/ld-x86-64/pr22842b.rd: Likewise.
2018-02-14 03:50:55 -08:00
Joel Brobecker f98b2e334f Remove references to ada_name_for_lookup (deleted)
This function was deleted on 2017-11-08, but its declaration and
a reference to it in a comment was left behind.  This patch just
removes those.

gdb/ChangeLog:

        * ada-lang.c (name_match_type_from_name): Remove reference to
        ada_name_for_lookup in function's documentation.
        * ada-lang.h (ada_name_for_lookup): Delete declaration.

Tested by rebuilding GDB.
2018-02-14 05:48:48 -05:00
Maciej W. Rozycki d4dd94f863 LD: Remove a stale `ldlex_command' prototype
Complement commit d4e5e3c330 ("Use getopt instead of lex and yacc to
parse the command line.") and remove a stale `ldlex_command' prototype
for an inexistent function removed back in 1994.

	ld/
	* ldlex.h (ldlex_command): Remove prototype.
2018-02-14 09:15:43 +00:00
H.J. Lu 85f2093ddc x86-64: Use pr22393-3a.so and pr22393-3a-now.so
They should be pr22393-3a.so and pr22393-3a-now.so, not pr22393-2a.so
and pr22393-2a-now.so.  Since ld-elf/shared.exp creates pr22393-2a.so
and pr22393-2a-now.so, we won't notice the problem if x86-64.exp runs
after ld-elf/shared.exp.

	* testsuite/ld-x86-64/x86-64.exp: Replace pr22393-2a.so and
	pr22393-2a-now.so with pr22393-3a.so and pr22393-3a-now.so.
2018-02-13 20:32:19 -08:00
Alan Modra 60f763ee16 PR22836 testcases
PR 22836
	* testsuite/ld-elf/pr22836-1.s: New file.
	* testsuite/ld-elf/pr22836-1a.d: Likewise.
	* testsuite/ld-elf/pr22836-1b.d: Likewise.
2018-02-14 11:40:19 +10:30
GDB Administrator 9abc632d37 Automatic date update in version.in 2018-02-14 00:00:35 +00:00
H.J. Lu 1031c264fd x86: Properly check building shared library
If a symbol is not defined in a regular file, and we are not generating
a shared library, then set the symbol to its location in the .plt.  This
is required to make function pointers compare as equal between the normal
executable and the shared library.

	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check bfd_link_dll,
	instead of bfd_link_pic, for building shared library.
2018-02-13 14:32:06 -08:00
Max Filippov db5d5ad16f gas: xtensa: fix trampoline placement
For jumps requiring multiple trampolines trampoline placement code may
place multiple sequential trampolines into the same frag. Don't do that.

gas/
2018-02-13  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (xg_find_best_trampoline): Skip trampoline
	frag that contains source address.
2018-02-13 09:32:47 -08:00