Commit Graph

7124 Commits

Author SHA1 Message Date
Alan Modra 7b15fa7ac8 PR19886, --as-needed regression
This isn't perfect in checking whether libraries will be loaded since
elf_link_add_object_symbols doesn't recurse down DT_NEEDED links.
(That happens later in ld/emultempl/elf32.em after_open.)  So in
effect this recursive check really only looks one level down the
DT_NEEDED tree.  Which is enough for the most common case, and
libc.so/ld.so in particular.

	PR 19886
	* elflink.c (on_needed_list): Recursively check needed status.
	(elf_link_add_object_symbols): Adjust.
2016-04-01 23:20:12 +10:30
Senthil Kumar Selvaraj 024ea11b48 Fix a seg-fault in the AVR linker.
* elf32-avr.c (avr_elf32_load_records_from_section): Free
	internal_relocs only if they aren't cached.
2016-03-30 14:52:26 +01:00
Nick Clifton ed3056ebdb Relax assertion in BFIN linker to allow for discard GOT relocs.
PR 17334
	* elf32-bfin.c (elf32_bfinfdpic_finish_dynamic_sections): Relax
	assertion on the size of the got section to allow it to be bigger
	than the number of relocs.
2016-03-29 10:24:16 +01:00
Toni Spets e2b4fc913b PE/COFF regression in base of code and data calculation
PR 19878
	* coffcode.h (coff_write_object_contents): Revert accidental
	2014-11-10 change.
2016-03-29 16:03:07 +10:30
Alan Modra a97fbc7e3c Attribute with DW_FORM_flag_present
PR 19850
	* dwarf2.c (read_attribute_value): Skip info_ptr check for
	DW_FORM_flag_present.
2016-03-22 22:50:18 +10:30
Nick Clifton 96254e5c28 Restore v850-rh850 as a recognised v850 architecture name for backwards compatibility.
bfd	* cpu-v850_rh850.c (arch_info_struct): Restore v850-rh850 as an
	architecture name for backwards compatibility.
2016-03-22 11:34:26 +00:00
Nick Clifton 7769fa97a0 Fix possible unbounded stack use in peXXigen.c
* peXXigen.c (_bfd_XXi_write_codeview_record): Fix possible
	unbounded stack use.
2016-03-22 10:37:42 +00:00
Nick Clifton 9780e04507 Add -Wstack-usage to the gcc warning flags list, but only if using a sufficiently recent version of gcc.
bfd	* warning.m4 (GCC_WARN_CFLAGS): Only add -Wstack-usage if using a
	sufficiently recent version of GCC.
	* configure: Regenerate.

others	* configure: Regenerate.
2016-03-22 09:41:16 +00:00
Alan Modra 6f4c0a426c Binutils fails to build with -O0
PR 19851
	* plugin.c (try_load_plugin): Avoid -Wstack-usage warning.
2016-03-22 14:24:30 +10:30
Andrew Burgess 8699fc3e88 arc: Add nps400 machine type, and assembler flag.
This commit introduces the nps400 machine type as a variant of arc.
There's a new flag in the assembler to select this machine type.  All
other changes are just adding handling of the new machine type into the
relevant places.

The nps400 is an arc700 variant with some vendor specific instructions
added into the instruction set.  This commit does not add any of the new
instructions, this is just laying the groundwork for future commits.
However, in preparation for these new instructions a new opcode define for
nps400 has been added to include/opcode/arc.h, this new opcode define is
used in the assembler and disassembler along with the existing define
for arc700 such that when assembling and disassembling for nps400 the
user will have access to all arc700 instructions and all the nps400
vendor extension instructions.

bfd/ChangeLog:

	* archures.c (bfd_mach_arc_nps400): Define.
	* bfd-in2.h: Regenerate.
	* cpu-arc.c (arch_info_struct): New entry for nps400, renumber
	some existing entries to make space.
	* elf32-arc.c (arc_elf_object_p): Add nps400 case.
	(arc_elf_final_write_processing): Likewise.

binutils/ChangeLog:

	* readelf.c (decode_ARC_machine_flags): Handle nps400.

gas/ChangeLog:

	* config/tc-arc.c (cpu_types): Add nps400 entry.
	(check_zol): Handle nps400.

include/ChangeLog:

	* elf/arc.h (E_ARC_MACH_NPS400): Define.
	* opcode/arc.h (ARC_OPCODE_NPS400): Define.

opcodes/ChangeLog:

	* arc-dis.c (print_insn_arc): Handle nps400.
2016-03-21 16:44:49 +00:00
Andrew Burgess a9522a2168 arc: Remove EF_ARC_CPU_GENERIC constant.
The constant EF_ARC_CPU_GENERIC is defined in the include/elf/arc.h
file, and is used in a few places in binutils, however, this constant
should never make it into the elf header flags; we always set a valid
cpu type in the assembler, which should then be copied over during
linking.

There are some non-gnu arc compilers that don't write an architecture
type into the e_flags field, instead leaving the field as 0, which is
the EF_ARC_CPU_GENERIC value.  This non-gnu compiler uses the machine
type to distinguish between the old and newer arc architectures, setting
the machine type to EM_ARC_COMPACT for old arc600, arc601, and arc700
architectures, while using EM_ARC_COMPACT2 for newer arcem and archs
architectures.

Previously when displaying the machine flags for an older EM_ARC_COMPACT
machine, if the e_flags had not been filled in, then we relied on the
default case statement to display the message "Generic ARCompact", while
in the EM_ARC_COMPACT2 case we specifically handled EF_ARC_CPU_GENERIC
to print "ARC Generic", leaving the default case to print a message
about unrecognised cpu flag.

After this commit EF_ARC_CPU_GENERIC has been removed, for both machine
types EM_ARC_COMPACT and EM_ARC_COMPACT2 we now rely on the default case
statement to handle the situation where the e_flags has not been filled
in.  The message displayed is now "Unknown ARCompact" (for older arc
architectures) and "Unknown ARC" (for the newer architectures).  The
switch from "Generic" to "Unknown" in the message string is for clarity,
calling the file "Generic" can give the impression that the file is
compiled for a common sub-set of the architectures, and would therefore
run on any type of machine (or at least any type of new or old machine
depending on if the machine type is ARC or ARCv2).  However, this was
not what "Generic" meant, it really meant "Unknown", so that's what we
now say.

As part of the merging of the readelf flag reading code, I have unified
the strings used in displaying the ELF ABI.  This means that for older
arc machines (arc600, arc601, and arc700) the string used for the
original ABI, and ABIv2 have changed, the current ABIv3 remains the
same.  For the newer architectures (arcem and archs) the abi strings
remain unchanged in all cases.

bfd/ChangeLog:

	* elf32-arc.c (arc_elf_print_private_bfd_data): Remove use of
	EF_ARC_CPU_GENERIC.
	(arc_elf_final_write_processing): Don't bother setting cpu field
	in e_flags, this will have been set elsewhere.

binutils/ChangeLog:

	* readelf.c (get_machine_flags): Move arc processing into...
	(decode_ARC_machine_flags): ... new function.  Remove use of
	EF_ARC_CPU_GENERIC, change default case from "generic arc" to
	"unknown arc".  Merged ABI printing between two machine types.

gas/ChangeLog:

	* config/tc-arc.c (arc_select_cpu): Remove use of
	EF_ARC_CPU_GENERIC.

include/ChangeLog:

	* elf/arc.h (EF_ARC_CPU_GENERIC): Delete.  Update related comment.
2016-03-21 16:44:49 +00:00
Andrew Burgess c033458051 arc: Remove duplicated constant in include/elf/arc.h
In the include/elf/arc.h there are two constants that mask out the
machine architecture field.  One is used lots (EF_ARC_MACH_MSK), the
other is used only once (EF_ARC_MACH).  Remove EF_ARC_MACH.

bfd/ChangeLog:

	* elf32-arc.c (arc_elf_final_write_processing): Switch to using
	EF_ARC_MACH_MSK.

include/ChangeLog:

	* elf/arc.h (EF_ARC_MACH): Delete.
	(EF_ARC_MACH_MSK): Remove out of date comment.
2016-03-21 16:44:49 +00:00
Nick Clifton e1fa016350 Remove use of alloca.
bfd	* warning.m4 (GCC_WARN_CFLAGS): Add -Wstack-usage=262144
	* configure: Regenerate.
	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Replace use of
	alloca with call to xmalloc.
	* elf32-nds32.c: Likewise.
	* elf64-hppa.c: Likewise.
	* elfxx-mips.c: Likewise.
	* pef.c: Likewise.
	* pei-x86_64.c: Likewise.
	* som.c: Likewise.
	* xsym.c: Likewise.

binutils * dlltool.c: Replace use of alloca with call to xmalloc.
	* dllwrap.c: Likewise.
	* nlmconv.c: Likewise.
	* objdump.c: Likewise.
	* resrc.c: Likewise.
	* winduni.c: Likewise.
	* configure: Regenerate.

gas	* atof-generic.c: Replace use of alloca with call to xmalloc.
	* cgen.c: Likewise.
	* dwarf2dbg.c: Likewise.
	* macro.c: Likewise.
	* remap.c: Likewise.
	* stabs.c: Likewise.
	* symbols.c: Likewise.
	* config/obj-elf.c: Likewise.
	* config/tc-aarch64.c: Likewise.
	* config/tc-arc.c: Likewise.
	* config/tc-arm.c: Likewise.
	* config/tc-avr.c: Likewise.
	* config/tc-ia64.c: Likewise.
	* config/tc-mips.c: Likewise.
	* config/tc-msp430.c: Likewise.
	* config/tc-nds32.c: Likewise.
	* config/tc-ppc.c: Likewise.
	* config/tc-sh.c: Likewise.
	* config/tc-tic30.c: Likewise.
	* config/tc-tic54x.c: Likewise.
	* config/tc-xstormy16.c: Likewise.
	* config/te-vms.c: Likewise.
	* configure: Regenerate.

ld	* emultempl/msp430.em: Replace use of alloca with call to xmalloc.
	* plugin.c: Likewise.
	* pe-dll.c: Likewise.
2016-03-21 16:31:46 +00:00
H.J. Lu 4e0c91e454 Bind defined symbol locally in PIE
Symbols defined in PIE should be bound locally, the same as -shared
-Bsymbolic.

bfd/

	PR ld/19827
	* elf32-i386.c (elf_i386_check_relocs): Bind defined symbol
	locally in PIE.
	(elf_i386_relocate_section): Likewise.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
	(elf_x86_64_relocate_section): Likewise.

ld/

	PR ld/19827
	* testsuite/ld-i386/i386.exp: Run PR ld/19827 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr19827.rd: New file.
	* testsuite/ld-i386/pr19827a.S: Likewise.
	* testsuite/ld-i386/pr19827b.S: Likewise.
	* testsuite/ld-x86-64/pr19827.rd: Likewise.
	* testsuite/ld-x86-64/pr19827a.S: Likewise.
	* testsuite/ld-x86-64/pr19827b.S: Likewise.
2016-03-15 11:47:06 -07:00
H.J. Lu 4c10bbaa09 Add -z noreloc-overflow option to x86-64 ld
Add -z noreloc-overflow command-line option to the x86-64 ELF linker to
disable relocation overflow check.  This can be used to avoid relocation
overflow check if there will be no dynamic relocation overflow at
run-time.

bfd/

	PR ld/19807
	* elf64-x86-64.c (elf_x86_64_relocate_section): Check
	no_reloc_overflow_check to diable R_X86_64_32/R_X86_64_32S
	relocation overflow check.

include/

	PR ld/19807
	* bfdlink.h (bfd_link_info): Add no_reloc_overflow_check.

ld/

	PR ld/19807
	* Makefile.am (ELF_X86_DEPS): Add
	$(srcdir)/emulparams/reloc_overflow.sh.
	* Makefile.in: Regenerated.
	* NEWS: Mention -z noreloc-overflow.
	* ld.texinfo: Document -z noreloc-overflow.
	* emulparams/elf32_x86_64.sh: Source
	${srcdir}/emulparams/reloc_overflow.sh.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/reloc_overflow.sh: New file.
	* testsuite/ld-x86-64/pr19807-1.s: New file.
	* testsuite/ld-x86-64/pr19807-1a.d: Likewise.
	* testsuite/ld-x86-64/pr19807-1b.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2.s: Likewise.
	* testsuite/ld-x86-64/pr19807-2a.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2b.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2c.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2e.d: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/19807 tests.
2016-03-15 11:07:54 -07:00
H.J. Lu fbe4879820 Regenerate bfd-in2.h
* bfd-in2.h: Regenerated.
2016-03-14 13:17:22 -07:00
Dan Gissel 37b01f6a13 Fix some places where octet to byte conversions are needed.
PR 19713
	* elf.c (_bfd_elf_section_offset): Ensure that the returned offset
	uses bytes not octets.
	* elflink.c (resolve_section): Likewise.
	Add a bfd parameter.
	(eval_section): Pass the input_bfd to resolve_section.
	(bfd_elf_perform_complex_relocation): Convert byte offset to
	octets before read and writing values.
	(elf_link_input_bfd): Add byte to octet conversions.
	(elf_reloc_link_order): Likewise.
	(elf_fixup_link_order): Likewise.
	(bfd_elf_final_link): Likewise.
	* reloc.c (_bfd_final_link_relocate): Likewise.
	* syms.c (_bfd_stab_section_find_nearest_line): Likewise.
2016-03-11 09:17:28 +00:00
Nick Clifton 3ed4ff97cb Mark the i370 target as obsolete.
* config.bfd: Mark the i370 target as obsolete.
2016-03-10 15:29:42 +00:00
Pedro Alves 4b05e0a74b Fix v850 bfd arch info printable names
Currently, it's not possible to manually set some of the v850 archs in
gdb:

 (gdb) set architecture v850<TAB>
 v850 (using old gcc ABI)
 v850-rh850
 v850e
 v850e (using old gcc ABI)
 v850e1
 [...]
 (gdb) set architecture v850 (using old gcc ABI)
 Ambiguous item "v850 (using old gcc ABI)".

The problem is that "set architecture" is a GDB "enum command", and
GDB only considers an enum value to be the string up until the first
space.  So writing "v850 (using old gcc ABI)" is the same as writing
"v850", and then that's not an unambiguous arch printable name prefix.

v850 is actually the only arch that has spaces in its printable name.
One can conveniently see that with e.g.:

 (gdb) set max-completions unlimited
 (gdb) complete set architecture
 ...

Rather than hack GDB into accepting this somehow, make v850 arch
printable names more like the printable names of the other archs, and
put the abi variant in the "machine" part, after a ':'.

We now get:

 (gdb) set architecture v850<TAB>
 v850:old-gcc-abi
 v850:rh850
 v850e
 v850e1
 v850e1:old-gcc-abi
 v850e2
 v850e2:old-gcc-abi
 [...]

And now "set architecture v850:old-gcc-abi" works as expected.

I ran the binutils/gas/ld testsuites, and found no regressions.  I
don't have a cross compiler handy, but I ran the gdb tests anyway,
which covers at least some snoke testing.

I think that the OUTPUT_ARCH in ld/scripttempl/v850.sc may have got
broken with the previous 2012 change, since I hacked v850_rh850.sc to
output "v850" and ld failed to grok it.  I think it only works if the
old GCC ABI is the configured v850 default ABI.  That's now fixed by
changing to use explicit v850:old-gcc-abi.

Also, this actually "fixes" an existing GDB test, which isn't likewise
expecting spaces in arch names, when GDB is configured for
--target=v850:

  (gdb) FAIL: gdb.xml/tdesc-arch.exp: read valid architectures

bfd/ChangeLog:
2016-03-09  Pedro Alves  <palves@redhat.com>

	* cpu-v850.c (N): Append ":old-gcc-abi" instead of " (using old
	gcc ABI)" to printable name.
	* cpu-v850_rh850.c (bfd_v850_rh850_arch): Use "v850:rh850" instead
	of "v850-rh850" as printable name.

ld/ChangeLog:
2016-03-09  Pedro Alves  <palves@redhat.com>

	* scripttempl/v850.sc: Use "v850:old-gcc-abi" as OUTPUT_ARCH.
	* scripttempl/v850_rh850.sc: Use "v850:rh850" as OUTPUT_ARCH.
2016-03-09 15:43:13 +00:00
Leon Winter 26c62da040 For COFF and COFF/PE targets, skip relocations against absolute symbols.
PR ld/19623
	* cofflink.c (_bfd_coff_generic_relocate_section): Do not apply
	relocations against absolute symbols.
2016-03-09 15:26:45 +00:00
Alan Modra 03ee85837e Allow zero length archive elements
PR binutils/19775
	* coff-alpha.c (alpha_ecoff_openr_next_archived_file): Allow zero
	length elements in the archive.
2016-03-09 16:54:24 +10:30
H.J. Lu 9c1d7a0876 Don't create dynamic sections when relocatable
Since dynamic sections aren't applicable to relocatable file, don't
create dynamic sections for -E/--dynamic-list when relocatable.

bfd/

	PR ld/19789
	* elflink.c (elf_link_add_object_symbols): Create dynamic sections
	for -E/--dynamic-list only when not relocatable.

ld/

	PR ld/19789
	* testsuite/ld-elf/pr19789.d: New file.
	* testsuite/ld-elf/pr19789.s: Likewise.
2016-03-08 20:45:52 -08:00
H.J. Lu d1ed1c7d69 Handle local IFUNC symbols in shared object
Increment PLT reference count for locally defined local IFUNC symbols
in shared object since STT_GNU_IFUNC symbol must go through PLT even
if it is locally defined and undefined symbol may turn out to be a
STT_GNU_IFUNC symbol later.

bfd/

	PR ld/19784
	* elf32-i386.c (elf_i386_check_relocs): Increment PLT reference
	count for locally defined local IFUNC symbols in shared object.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.

ld/

	PR ld/19784
	* testsuite/ld-i386/i386.exp: Remove pr19636-2e-nacl test.
	* testsuite/ld-i386/pr19636-2e-nacl.d: Moved to ...
	* testsuite/ld-i386/pr19636-2e.d: Here.  Remove notarget.
	* testsuite/ld-ifunc/ifunc.exp: Run PR ld/19784 tests.
	* testsuite/ld-ifunc/pass.out: New file.
	* testsuite/ld-ifunc/pr19784a.c: Likewise.
	* testsuite/ld-ifunc/pr19784b.c: Likewise.
	* testsuite/ld-ifunc/pr19784c.c: Likewise.
2016-03-08 09:42:16 -08:00
H.J. Lu 202ac193bb Group common symbol checking together
PR ld/19579
	* elflink.c (_bfd_elf_merge_symbol): Group common symbol checking
	together.
2016-03-08 05:30:51 -08:00
Claudiu Zissulescu 72f3b6aae7 [ARC] Allow non-instruction relocations within .text sections
bfd/
2016-03-08  Cupertino Miranda  <Cupertino.Miranda@synopsys.com>
	    Andrew Burgess  <andrew.burgess@embecosm.com>

	* elf32-arc.c (arc_bfd_get_32): Becomes an alias for bfd_get_32.
	(arc_bfd_put_32): Becomes an alias for bfd_put_32.
	(arc_elf_howto_init): Added assert to validate relocations.
	(get_middle_endian_relocation): Delete.
	(middle_endian_convert): New function.
	(ME): Redefine, now does nothing.
	(IS_ME): New define.
	(arc_do_relocation): Extend the attached 'ARC_RELOC_HOWTO'
	definition to call middle_endian_convert.  Add a new local
	variable and make use of this throughout. Added call to
	arc_bfd_get_8 and arc_bfd_put_8 for 8 bit relocations.

gas/
2016-03-08  Andrew Burgess  <andrew.burgess@embecosm.com>

	* testsuite/gas/arc/inline-data-1.d: New file.
	* testsuite/gas/arc/inline-data-1.s: New file.

include/
2016-03-08  Cupertino Miranda  <Cupertino.Miranda@synopsys.com>
	    Andrew Burgess  <andrew.burgess@embecosm.com>

	* elf/arc-reloc.def: Add a call to ME within the formula for each
	relocation that requires middle-endian correction.
2016-03-08 14:19:52 +01:00
Nick Clifton 4fc874242f Allow zero length archive elements.
bfd	PR binutils/19775
	* archive.c (bfd_generic_openr_next_archived_file): Allow zero
	length elements in the archive.

binutils PR binutils/19775
	* testsuite/binutils-all/ar.exp (proc empty_archive): New proc.
	Run the new proc.
	* testsuite/binutils-all/empty: New, empty, file.
2016-03-07 17:29:25 +00:00
Jiong Wang 18f822a08f [AArch64] Create .got section if _GLOBAL_OFFSET_TABLE_ referenced
2016-03-07  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Always create .got section
  if the symbol "_GLOBAL_OFFSET_TABLE_" referenced.

ld/
  * testsuite/ld-aarch64/implicit_got_section_1.s: New test source file.
  * testsuite/ld-aarch64/implicit_got_section_1.d: New test expected result.
  * testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
2016-03-07 15:40:50 +00:00
H.J. Lu 07492f668d Treat common symbol in executable as definition
Common symbol in executable is a definition, which overrides definition
from shared objects.  When linker sees a new definition from a shared
object, the new dynamic definition should be overridden by the previous
common symbol in executable.

bfd/

	PR ld/19579
	* elflink.c (_bfd_elf_merge_symbol): Treat common symbol in
	executable as definition if the new definition comes from a
	shared library.

ld/

	PR ld/19579
	* testsuite/ld-elf/pr19579a.c: New file.
	* testsuite/ld-elf/pr19579b.c: Likewise.
	* testsuite/ld-elf/shared.exp: Run PR ld/19579 test.
2016-03-04 06:37:54 -08:00
Alan Modra 70a5df4fe3 Regenerate bfd files.
* Makefile.in: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
2016-03-02 13:37:47 +10:30
Claudiu Zissulescu 841fdfcdd9 [ARC] Local symbols relocation cleanup
bfd/
2016-02-29  Cupertino Miranda  <cmiranda@synopsys.com>

	* elf32-arc.c (elf_arc_relocate_section): Added rules to fix the
	relocation addend when sections get merged.

gas/
2016-02-29  Cupertino Miranda  <cmiranda@synopsys.com>
	    Claudiu Zissulescu  <Claudiu.Zissulescu@synopsys.com>

        * config/tc-arc.c (arc_extra_reloc): Change size to 0.
        (tc_arc_fix_adjustable): Changed default return value to 1.
        * testsuite/gas/arc/j.d: Updated expected symbol
        * testsuite/gas/arc/jl.d: Likewise
        * testsuite/gas/arc/relax-avoid1.d: Likewise
        * testsuite/gas/arc/st.d: Likewise

ld/
2016-02-29 Cupertino Miranda  <cmiranda@synopsys.com>

	* testsuite/ld-elf/merge.d: Removed xfail for ARC.
	* testsuite/ld-elf/merge2.d: Likewise.
	* testsuite/ld-elf/merge3.d: Likewise.
2016-02-29 16:51:11 +01:00
Claudiu Zissulescu 7e4588997e [ARC] General fixes.
bfd/
2016-02-29  Cupertino Miranda <Cupertino.Miranda@synopsys.com>

	* elf32-arc.c (arc_elf_final_write_processing): Add condition to
	the flag change.
        (elf_arc_relocate_section): Fixes and conditions to support PIE.
	Assert for code sections dynamic relocs.

gas/
2016-02-29  Claudiu Zissulescu  <Claudiu.Zissulescu@synopsys.com>

	* config/tc-arc.c: Enable code density instructions for ARC EM.

ld/
2016-02-29  Cupertino Miranda  <Cupertino.Miranda@synopsys.com>

	* scripttempl/arclinux.sc: Force .tdata and .tbss to always be
	generated.
2016-02-29 16:07:48 +01:00
Renlin Li c5e3a3641e [BFD][AARCH64]Fix MOVW_SABS_G(0,1,2) relocation overflow check.
For these three relocations, 17 bit signed value should be used, instead of
16 bit. The bitsize field is changed from 16 to 17, this field in aarch64
backend is used for overflow check only.

bfd/

2016-02-26  Renlin Li  <renlin.li@arm.com>

    * elfnn-aarch64.c (elfNN_aarch64_howto_table): Fix signed overflow
    check for MOVW_SABS_G0, MOVW_SABS_G1, MOVW_SABS_G2.

ld/

2016-02-26  Renlin Li  <renlin.li@arm.com>

    * testsuite/ld-aarch64/aarch64-elf.exp: Run new testcases.
    * testsuite/ld-aarch64/emit-relocs-270.d: Update to use new boundary.
    * testsuite/ld-aarch64/emit-relocs-271.d: Likewise.
    * testsuite/ld-aarch64/emit-relocs-272.d: Likewise.
    * testsuite/ld-aarch64/emit-relocs-270-overflow.d: New.
    * testsuite/ld-aarch64/emit-relocs-270-overflow.s: New.
    * testsuite/ld-aarch64/emit-relocs-271-overflow.d: New.
    * testsuite/ld-aarch64/emit-relocs-271-overflow.s: New.
    * testsuite/ld-aarch64/emit-relocs-272-overflow.d: New.
    * testsuite/ld-aarch64/emit-relocs-272-overflow.s: New.
2016-02-26 18:00:15 +00:00
H.J. Lu bae420ef26 Optimize x86 GOT32X/GOTPCRELX relocations
R_386_GOT32X, R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX relocations
retrieve the symbol address via its GOT slot.  If the symbol address is
known at the link-time, we can use it directly by changing instruction
encoding.  Indirect branch can only be converted to PC relative direct
branch.  MOV can be changed to LEA or encoded differently with signed
address.  The subset of binary operations can be encoded only with
signed address.

If undefined weak symbol is resolved to zero link-time, we can use it
as address.  Zero addresss can't used with PC relative direct branch
when PIC is true since the current PC is unknown.  In 64-bit, 32-bit
relocation for PC relatiave direct branch to zero may also overflow.

If this optimization causes relocation overflow, --no-relax can be used
to work around it.

bfd/

	PR ld/19609
	* elf32-i386.c (elf_i386_convert_load): Convert to R_386_32 for
	load with locally bound symbols if PIC is false or there is no
	base register.  Optimize branch to 0 if PIC is false.
	(elf_i386_relocate_section): Don't generate dynamic relocations
	against undefined weak symbols if PIC is false.
	* elf64-x86-64.c (elf_x86_64_convert_load): Disable optimization
	if we can't estimate relocation overflow with --no-relax.
	Convert to R_X86_64_32S/R_X86_64_32 for load with locally bound
	symbols if PIC is false.  Optimize branch to 0 if PIC is false.
	(elf_x86_64_relocate_section): Don't generate dynamic relocations
	against undefined weak symbols if PIC is false.

ld/

	PR ld/19609
	* testsuite/ld-i386/got1.dd: Updated.
	* testsuite/ld-i386/lea1c.d: Likewise.
	* testsuite/ld-i386/load1-nacl.d: Likewise.
	* testsuite/ld-i386/load1.d: Likewise.
	* testsuite/ld-i386/load4b.d: Likewise.
	* testsuite/ld-i386/load5b.d: Likewise.
	* testsuite/ld-i386/mov1b.d: Likewise.
	* testsuite/ld-x86-64/mov1b.d: Likewise.
	* testsuite/ld-x86-64/mov1d.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
	* testsuite/ld-x86-64/gotpcrel1.dd: Likewise.
	* testsuite/ld-x86-64/lea1a.d: Likewise.
	* testsuite/ld-x86-64/lea1b.d: Likewise.
	* testsuite/ld-x86-64/lea1c.d: Likewise.
	* testsuite/ld-x86-64/lea1d.d: Likewise.
	* testsuite/ld-x86-64/lea1e.d: Likewise.
	* testsuite/ld-x86-64/lea1f.d: Likewise.
	* testsuite/ld-x86-64/mov1b.d: Likewise.
	* testsuite/ld-x86-64/mov1d.d: Likewise.
	* testsuite/ld-x86-64/pr13082-3b.d: Likewise.
	* testsuite/ld-x86-64/pr13082-4b.d: Likewise.
	* testsuite/ld-x86-64/lea1.s: Add tests for 32-bit registers.
	* testsuite/ld-i386/pr19609-1.s: New file.
	* testsuite/ld-i386/pr19609-1a.d: Likewise.
	* testsuite/ld-i386/pr19609-1b.d: Likewise.
	* testsuite/ld-i386/pr19609-1c.d: Likewise.
	* testsuite/ld-i386/pr19609-1d.d: Likewise.
	* testsuite/ld-i386/pr19609-1e.d: Likewise.
	* testsuite/ld-i386/pr19609-1f.d: Likewise.
	* testsuite/ld-i386/pr19609-1g.d: Likewise.
	* testsuite/ld-i386/pr19609-1h.d: Likewise.
	* testsuite/ld-i386/pr19609-1i.d: Likewise.
	* testsuite/ld-i386/pr19609-2.s: Likewise.
	* testsuite/ld-i386/pr19609-2a.d: Likewise.
	* testsuite/ld-i386/pr19609-2b.d: Likewise.
	* testsuite/ld-i386/pr19609-2c.d: Likewise.
	* testsuite/ld-i386/undefweak.s: Likewise.
	* testsuite/ld-i386/undefweaka.d: Likewise.
	* testsuite/ld-i386/undefweakb.d: Likewise.
	* testsuite/ld-x86-64/pr13082-3c.d: Likewise.
	* testsuite/ld-x86-64/pr13082-3d.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1.s: Likewise.
	* testsuite/ld-x86-64/pr19609-1a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1c.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1d.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1e.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1f.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1g.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1h.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1i.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1j.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1k.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1l.d: Likewise.
	* testsuite/ld-x86-64/pr19609-1m.d: Likewise.
	* testsuite/ld-x86-64/pr19609-2.s: Likewise.
	* testsuite/ld-x86-64/pr19609-2a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-2b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-2c.d: Likewise.
	* testsuite/ld-x86-64/pr19609-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19609-3.s: Likewise.
	* testsuite/ld-x86-64/pr19609-3a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-3b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-4.s: Likewise.
	* testsuite/ld-x86-64/pr19609-4a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-4b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-4c.d: Likewise.
	* testsuite/ld-x86-64/pr19609-4d.d: Likewise.
	* testsuite/ld-x86-64/pr19609-4e.d: Likewise.
	* testsuite/ld-x86-64/pr19609-5.s: Likewise.
	* testsuite/ld-x86-64/pr19609-5a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-5b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-5c.d: Likewise.
	* testsuite/ld-x86-64/pr19609-5d.d: Likewise.
	* testsuite/ld-x86-64/pr19609-5e.d: Likewise.
	* testsuite/ld-x86-64/pr19609-6.s: Likewise.
	* testsuite/ld-x86-64/pr19609-6a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-6b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-6c.d: Likewise.
	* testsuite/ld-x86-64/pr19609-6d.d: Likewise.
	* testsuite/ld-x86-64/pr19609-7.s: Likewise.
	* testsuite/ld-x86-64/pr19609-7a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-7b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-7c.d: Likewise.
	* testsuite/ld-x86-64/pr19609-7d.d: Likewise.
	* testsuite/ld-i386/i386.exp: Run undefweak tests and tests for
	PR ld/19609.
	* testsuite/ld-x86-64/x86-64.exp: Run pr13082-3c, pr13082-3d
	and tests for PR ld/19609.
2016-02-26 09:39:24 -08:00
H.J. Lu 11e5f1ec54 Add ChangeLog entries for PR ld/19645 2016-02-26 06:44:03 -08:00
H.J. Lu aec6b87e0b [x86] Resolve non-PIC undefweak symbols in executable
For i386 and x86-64, non-PIC references to undefined weak symbols are
resolved without dynamic relocation when creating executable.  Resolved
undefined weak symbols are removed from the dynamic symbol table in
executable.  One exception is on i386, we need resolved undefined weak
symbols in the dynamic symbol table in PIE if input relocatable files
contain branchs without PLT so that we can branch to 0 with dynamic
relocation in text section.

This makes behaviors of dynamic executable and position independent
executable predictable with mixed PIC and non-PIC references to undefined
weak symbols.  If all references to undefined weak symbols are PIC,
dynamic relocations against undefined weak symbols will be generated
in executable unless -z nodynamic-undefined-weak is passed to linker.

bfd/

	PR ld/19636
	PR ld/19704
	PR ld/19719
	* elf32-i386.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): New.
	(elf_i386_link_hash_entry): Add has_got_reloc and
	has_non_got_reloc.
	(elf_i386_link_hash_table): Add interp.
	(elf_i386_link_hash_newfunc): Initialize has_got_reloc and
	has_non_got_reloc.
	(elf_i386_copy_indirect_symbol): Copy has_got_reloc and
	has_non_got_reloc.
	(elf_i386_check_relocs): Set has_got_reloc and has_non_got_reloc.
	(elf_i386_fixup_symbol): New function.
	(elf_i386_pie_finish_undefweak_symbol): Likewise.
	(elf_i386_allocate_dynrelocs): Don't allocate space for dynamic
	relocations and discard relocations against resolved undefined
	weak symbols in executable.  Don't make resolved undefined weak
	symbols in executable dynamic.  Keep dynamic non-GOT/non-PLT
	relocation against undefined weak symbols in PIE.
	(elf_i386_size_dynamic_sections): Set interp to .interp section.
	(elf_i386_relocate_section): Don't generate dynamic relocations
	against resolved undefined weak symbols in PIE, except for
	R_386_PC32.
	(elf_i386_finish_dynamic_symbol): Keep PLT/GOT entries without
	dynamic PLT/GOT relocations for resolved undefined weak symbols.
	Don't generate dynamic relocation against resolved undefined weak
	symbol in executable.
	(elf_i386_finish_dynamic_sections): Call
	elf_i386_pie_finish_undefweak_symbol on all symbols in PIE.
	(elf_backend_fixup_symbol): New.
	* elf64-x86-64.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): New.
	(elf_x86_64_link_hash_entry): Add has_got_reloc and
	has_non_got_reloc.
	(elf_x86_64_link_hash_table): Add interp.
	(elf_x86_64_link_hash_newfunc): Initialize has_got_reloc and
	has_non_got_reloc.
	(elf_x86_64_copy_indirect_symbol): Copy has_got_reloc and
	has_non_got_reloc.
	(elf_x86_64_check_relocs): Set has_got_reloc and
	has_non_got_reloc.
	(elf_x86_64_fixup_symbol): New function.
	(elf_x86_64_pie_finish_undefweak_symbol): Likewise.
	(elf_x86_64_allocate_dynrelocs): Don't allocate space for dynamic
	relocations and discard relocations against resolved undefined
	weak symbols in executable.  Don't make resolved undefined weak
	symbols in executable dynamic.
	(elf_x86_64_size_dynamic_sections): Set interp to .interp section.
	(elf_x86_64_relocate_section): Check relocation overflow for
	dynamic relocations against unresolved weak undefined symbols.
	Don't generate dynamic relocations against resolved weak
	undefined symbols in PIE.
	(elf_x86_64_finish_dynamic_symbol): Keep PLT/GOT entries without
	dynamic PLT/GOT relocations for resolved undefined weak symbols.
	Don't generate dynamic relocation against resolved undefined weak
	symbol in executable.
	(elf_x86_64_finish_dynamic_sections): Call
	elf_x86_64_pie_finish_undefweak_symbol on all symbols in PIE.
	(elf_backend_fixup_symbol): New.

include/

	PR ld/19636
	PR ld/19704
	PR ld/19719
	* bfdlink.h (bfd_link_info): Add dynamic_undefined_weak.

ld/

	PR ld/19636
	PR ld/19704
	PR ld/19719
	* Makefile.am (ELF_X86_DEPS): Add dynamic_undefined_weak.sh.
	* Makefile.in: Regenerated.
	* NEWS: Mention -z nodynamic-undefined-weak.
	* ld.texinfo: Document -z nodynamic-undefined-weak.
	* ldmain.c (main): Initialize dynamic_undefined_weak to -1.
	* emulparams/dynamic_undefined_weak.sh: New file.
	* emulparams/elf32_x86_64.sh: Source dynamic_undefined_weak.sh.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_i386_be.sh: Likewise.
	* emulparams/elf_i386_chaos.sh: Likewise.
	* emulparams/elf_i386_ldso.sh: Likewise.
	* emulparams/elf_i386_vxworks.sh: Likewise.
	* emulparams/elf_iamcu.sh: Likewise.
	* emulparams/elf_k1om.sh: Likewise.
	* emulparams/elf_l1om.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/extern_protected_data.sh (PARSE_AND_LIST_OPTIONS):
	Append.
	(PARSE_AND_LIST_ARGS_CASE_Z): Likewise.
	* testsuite/ld-elf/pr19719a.c: New file.
	* testsuite/ld-elf/pr19719b.c: Likewise.
	* testsuite/ld-elf/pr19719c.c: Likewise.
	* testsuite/ld-elf/pr19719d.c: Likewise.
	* testsuite/ld-i386/pr19636-1.s: Likewise.
	* testsuite/ld-i386/pr19636-1a.d: Likewise.
	* testsuite/ld-i386/pr19636-1b.d: Likewise.
	* testsuite/ld-i386/pr19636-1c.d: Likewise.
	* testsuite/ld-i386/pr19636-1d-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-1d.d: Likewise.
	* testsuite/ld-i386/pr19636-1e.d: Likewise.
	* testsuite/ld-i386/pr19636-1f.d: Likewise.
	* testsuite/ld-i386/pr19636-1g.d: Likewise.
	* testsuite/ld-i386/pr19636-1h.d: Likewise.
	* testsuite/ld-i386/pr19636-1i.d: Likewise.
	* testsuite/ld-i386/pr19636-2.s: Likewise.
	* testsuite/ld-i386/pr19636-2a.d: Likewise.
	* testsuite/ld-i386/pr19636-2b.d: Likewise.
	* testsuite/ld-i386/pr19636-2c-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2c.d: Likewise.
	* testsuite/ld-i386/pr19636-2d-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2d.d: Likewise.
	* testsuite/ld-i386/pr19636-2e-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2e.d: Likewise.
	* testsuite/ld-i386/pr19636-3.s: Likewise.
	* testsuite/ld-i386/pr19636-3a.d: Likewise.
	* testsuite/ld-i386/pr19636-3b.d: Likewise.
	* testsuite/ld-i386/pr19636-3c.d: Likewise.
	* testsuite/ld-i386/pr19636-3d.d: Likewise.
	* testsuite/ld-i386/pr19636-3e.d: Likewise.
	* testsuite/ld-i386/pr19636-3f.d: Likewise.
	* testsuite/ld-i386/pr19636-3g.d: Likewise.
	* testsuite/ld-i386/pr19636-4.s: Likewise.
	* testsuite/ld-i386/pr19636-4a.d: Likewise.
	* testsuite/ld-i386/pr19636-4b.d: Likewise.
	* testsuite/ld-i386/pr19636-4c.d: Likewise.
	* testsuite/ld-i386/pr19636-4d.d: Likewise.
	* testsuite/ld-i386/pr19704.out: Likewise.
	* testsuite/ld-i386/pr19704a.c: Likewise.
	* testsuite/ld-i386/pr19704b.c: Likewise.
	* testsuite/ld-x86-64/pr19636-1.s: Likewise.
	* testsuite/ld-x86-64/pr19636-1a.d: Likewise.
	* testsuite/ld-x86-64/pr19636-1b.d: Likewise.
	* testsuite/ld-x86-64/pr19636-1c.d: Likewise.
	* testsuite/ld-x86-64/pr19636-1d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-1e.d: Likewise.
	* testsuite/ld-x86-64/pr19636-1f.d: Likewise.
	* testsuite/ld-x86-64/pr19636-1g.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2.s: Likewise.
	* testsuite/ld-x86-64/pr19636-2a.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2b.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2c.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2e.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2f.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2g.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2h.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2i.d: Likewise.
	* testsuite/ld-x86-64/pr19636-3.s: Likewise.
	* testsuite/ld-x86-64/pr19636-3a.d: Likewise.
	* testsuite/ld-x86-64/pr19636-3b.d: Likewise.
	* testsuite/ld-x86-64/pr19636-3c.d: Likewise.
	* testsuite/ld-x86-64/pr19636-3d.d: Likewise.
	* testsuite/ld-x86-64/pr19704.out: Likewise.
	* testsuite/ld-x86-64/pr19704a.c: Likewise.
	* testsuite/ld-x86-64/pr19704b.c: Likewise.
	* testsuite/ld-elf/shared.exp (mix_pic_and_non_pic): New.
	Run mix_pic_and_non_pic.
	* testsuite/ld-i386/i386.exp (undefined_weak): New.
	Run undefined_weak and PR ld/19636 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-x86-64/pr13082-3b.d: Updated.
	* testsuite/ld-x86-64/pr13082-4b.d: Likewise.
2016-02-26 04:55:57 -08:00
Alan Modra b32547cd11 Fix powerpc64 -r --save-restore-funcs
* elf64-ppc.c (create_linkage_sections): Create sfpr when
	save_restore_funcs, rest of sections when not relocatable.
	(ppc64_elf_init_stub_bfd): Always call create_linkage_sections.
	(sfpr_define): Define all symbols on emitted code.
	(ppc64_elf_func_desc_adjust): Adjust for sfpr now being created
	when relocatable.  Move sfpr_define loop earlier.
2016-02-26 23:03:23 +10:30
H.J. Lu ef77d6af7c Add elf_x86_64_need_pic
Add elf_x86_64_need_pic and replace x86_64_elf_howto_table[r_type].name
with howto->name.

	* elf64-x86-64.c (elf_x86_64_need_pic): New function.
	(elf_x86_64_relocate_section): Use it.  Replace
	x86_64_elf_howto_table[r_type] with howto.
2016-02-25 04:13:42 -08:00
H.J. Lu 0f550b3df1 Update symbol version for symbol from linker script
We need to update symbol version for symbols from linker script.

bfd/

	PR ld/19698
	* elflink.c (bfd_elf_record_link_assignment): Set versioned if
	symbol version is unknown.

ld/

	PR ld/19698
	* testsuite/ld-elf/pr19698.d: New file.
	* testsuite/ld-elf/pr19698.s: Likewise.
	* testsuite/ld-elf/pr19698.t: Likewise.
2016-02-24 15:13:48 -08:00
H.J. Lu 13f422778f Set plt_got.offset to (bfd_vma) -1
Since plt_got.offset may be updated in x86 allocate_dynrelocs, set
plt_got.offset to (bfd_vma) -1 when setting needs_plt to 0.

	* elf32-i386.c (elf_i386_allocate_dynrelocs): Set plt_got.offset
	to (bfd_vma) -1 when setting needs_plt to 0.
	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise.
2016-02-24 05:49:48 -08:00
H.J. Lu 6b3b0ab896 Make linker assigned symbol dynamic only for shared object
Linker assigned symbols should be made dynamic by default only when
creating shared object or relocatable executable.

bfd/

	* elflink.c (bfd_elf_record_link_assignment): Check for shared
	library, instead of PIC, and don't check PDE when making linker
	assigned symbol dynamic.

ld/

	* testsuite/ld-frv/fdpic-pie-6.d: Updated.
	* testsuite/ld-mips-elf/pie-n32.d: Likewise.
	* testsuite/ld-mips-elf/pie-n64.d: Likewise.
	* testsuite/ld-mips-elf/pie-o32.d: Likewise.
2016-02-23 05:19:03 -08:00
Faraz Shahbazker 17733f5be9 Increment the ABIVERSION to 5 for MIPS objects with non-executable stacks.
* bfd/elfxx-mips.c (_bfd_mips_post_process_headers): Increment
	ABIVERSION for non-executable stack.
2016-02-23 12:58:03 +00:00
Rich Felker 47993b4af1 Fix the genetation of GOT entries for the Microblaze target.
PR target/19516
	* elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol):
	Always produce a RELATIVE reloc for a local symbol.
2016-02-23 10:37:24 +00:00
Hans-Peter Nilsson 2d8dcb8135 Fix test-case ld-elf/pr19617b
* elf32-cris.c (elf_cris_discard_excess_program_dynamics): Don't
	discard unused non-function symbols when --dynamic-list-data.
2016-02-23 02:06:45 +01:00
H.J. Lu 1a6e6083b6 Always create dynsym section with dynamic sections
We should always create the dynsym section, even if it is empty, with
dynamic sections.

	* elflink.c (_bfd_elf_link_renumber_dynsyms): Always create the
	dynsym section, even if it is empty, with dynamic sections.
2016-02-22 16:30:30 -08:00
H.J. Lu 75c1920bb0 Remove BSF_COMMON from comments
BSF_COMMON isn't defined in BFD.

	* syms.c: Remove BSF_COMMON from comments.
	* bfd-in2.h: Regenerated.
2016-02-22 04:39:43 -08:00
Jiong Wang 9a22846790 [AArch64] Remove redundant calculation of plt stub destination for veneer
elfNN_aarch64_size_stubs, the caller of aarch64_type_stub has redirected
the final destination of long branch veneer to plt stub if the call
should go through it.

It's redundant to do the same check and redirect again from scratch
inside aarch64_type_stub.

bfd/
  * elfnn-aarch64. (aarch64_type_of_stub): Remove redundation calcuation
  for destination.  Remove useless function parameters.
  (elfNN_aarch64_size_stubs): Update parameters for aarch64_type_of_stub.
2016-02-22 12:16:06 +00:00
Nick Clifton e517df3dbf Prevent a seg-fault in the linker when accessing a specially crafted, corrupt, aout binary.
PR ld/19629
	* aoutx.h (aout_link_add_symbols): Check for out of range string
	table offsets.
2016-02-19 15:55:06 +00:00
Nick Clifton 737684142b Fix a seg-fault in the linker when it encounters a corrupt binary containing a reloc with no associated symbol.
PR ld/19628
	* reloc.c (bfd_generic_get_relocated_section_contents): Stop
	processing if we encounter a reloc without an associated symbol.
2016-02-19 15:20:30 +00:00
H.J. Lu bf89386a86 Always create dynamic sections for -E/--dynamic-list
In embedded environments, including boot loaders, the non-PIC executable
needs to export its symbols to modules loaded in the future.  We should
always create dynamic sections for -E/--dynamic-list.

bfd/

	PR ld/19617
	* elflink.c (elf_link_add_object_symbols): Always create dynamic
	sections for -E/--dynamic-list.

ld/

	PR ld/19617
	* testsuite/ld-elf/pr19617.s: New file.
	* testsuite/ld-elf/pr19617a.d: Likewise.
	* testsuite/ld-elf/pr19617b.d: Likewise.
	* testsuite/ld-elf/pr19617c.d: Likewise.
2016-02-18 03:13:51 -08:00
H.J. Lu 8f79b794ce [x86-64] Omit dynamic sections symbols
Define elf_backend_omit_section_dynsym to bfd_true for x86-64, similar
to i386, x86-64 doesn't need dynamic sections symbols.

bfd/

	* elf64-x86-64.c (elf_backend_omit_section_dynsym): New.  Defined
	to bfd_true.

ld/

	* testsuite/ld-ifunc/ifunc-1-local-x86.d: Updated.
	* testsuite/ld-ifunc/ifunc-1-x86.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-3a-x86.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-1.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.
	* testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise.
	* testsuite/ld-x86-64/ilp32-4.d: Likewise.
	* testsuite/ld-x86-64/load1c-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1c.d: Likewise.
	* testsuite/ld-x86-64/load1d-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1d.d: Likewise.
	* testsuite/ld-x86-64/pr14207.d: Likewise.
	* testsuite/ld-x86-64/pr19162.d: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsdesc.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc.rd: Likewise.
	* testsuite/ld-x86-64/tlspic-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic.rd: Likewise.
2016-02-17 11:19:04 -08:00