bfd * elf32-arc.c (PR_DEBUG): Delete.
Fix printing of debug information. Fix formatting of debug
statements.
(debug_arc_reloc): Handle symbols that are not from an input file.
(arc_do_relocation): Remove excessive exclamation points.
(elf_arc_relocate_section): Print an informative message if the
relocation fails, even if debugging is not enabled.
* arc-got.h: Fix formatting. Fix printing of debug information.
(new_got_entry_to_list): Use xmalloc.
* config.bfd: use the big-endian arc vector as the default vector
for big-endian arc targets.
ld * testsuite/ld-arc/arc.exp: Always run the sda-relocs test in
little endian mode.
Fix a generic BFD issue with relocations against absolute symbols, which
are installed without using any individual relocation handler provided
by the backend. This causes any absolute section's addend to be lost on
REL targets such as o32 MIPS, and also relocation-specific calculation
adjustments are not made.
As an example assembling this program:
$ cat test.s
.text
foo:
b bar
b baz
.set bar, 0x1234
$ as -EB -32 -o test-o32.o test.s
$ as -EB -n32 -o test-n32.o test.s
produces this binary code:
$ objdump -dr test-o32.o test-n32.o
test-o32.o: file format elf32-tradbigmips
Disassembly of section .text:
00000000 <foo>:
0: 10000000 b 4 <foo+0x4>
0: R_MIPS_PC16 *ABS*
4: 00000000 nop
8: 1000ffff b 8 <foo+0x8>
8: R_MIPS_PC16 baz
c: 00000000 nop
test-n32.o: file format elf32-ntradbigmips
Disassembly of section .text:
00000000 <foo>:
0: 10000000 b 4 <foo+0x4>
0: R_MIPS_PC16 *ABS*+0x1230
4: 00000000 nop
8: 10000000 b c <foo+0xc>
8: R_MIPS_PC16 baz-0x4
c: 00000000 nop
$
where it is clearly visible in `test-o32.o', which uses REL relocations,
that the absolute section's addend equivalent to the value of `bar' -- a
reference to which cannot be fully resolved at the assembly time,
because the reference is PC-relative -- has been lost, as has been the
relocation-specific adjustment of -4, required to take into account the
PC+4-relative calculation made by hardware with branches and seen in the
external symbol reference to `baz' as the `ffff' addend encoded in the
instruction word. In `test-n32.o', which uses RELA relocations, the
absolute section's addend has been correctly retained.
Give precedence then in `bfd_perform_relocation' and
`bfd_install_relocation' to any individual relocation handler the
backend selected may have provided, while still resorting to the generic
calculation otherwise. This retains the semantics which we've had since
forever or before the beginning of our repository history, and is at the
very least compatible with `bfd_elf_generic_reloc' being used as the
handler.
Retain the `bfd_is_und_section' check unchanged at the beginning of
`bfd_perform_relocation' since this does not affect the semantics of the
function. The check returns the same `bfd_reloc_undefined' code the
check for a null `howto' does, so swapping the two does not matter.
Also the check is is mutually exclusive with the `bfd_is_abs_section'
check, since a section cannot be absolute and undefined both at once, so
swapping the two does not matter either.
With this change applied the program quoted above now has the in-place
addend correctly calculated and installed in the field being relocated:
$ objdump -dr fixed-o32.o
fixed-o32.o: file format elf32-tradbigmips
Disassembly of section .text:
00000000 <foo>:
0: 1000048c b 1234 <bar>
0: R_MIPS_PC16 *ABS*
4: 00000000 nop
8: 1000ffff b 8 <foo+0x8>
8: R_MIPS_PC16 baz
c: 00000000 nop
$
Add a set of MIPS tests to cover the relevant cases, including absolute
symbols with addends, and verifying that PC-relative relocations against
symbols concerned resolve to the same value in the final link regardless
of whether the REL or the RELA relocation form is used. Exclude linker
tests though which would overflow the in-place addend on REL targets and
use them as dump patterns for RELA targets only.
bfd/
* reloc.c (bfd_perform_relocation): Try the `howto' handler
first with relocations against absolute symbols.
(bfd_install_relocation): Likewise.
gas/
* testsuite/gas/mips/mips16-branch-absolute.d: Update patterns.
* testsuite/gas/mips/branch-absolute.d: New test.
* testsuite/gas/mips/branch-absolute-n32.d: New test.
* testsuite/gas/mips/branch-absolute-n64.d: New test.
* testsuite/gas/mips/branch-absolute-addend-n32.d: New test.
* testsuite/gas/mips/branch-absolute-addend-n64.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-n32.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-n64.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-addend-n32.d: New
test.
* testsuite/gas/mips/mips16-branch-absolute-addend-n64.d: New
test.
* testsuite/gas/mips/micromips-branch-absolute.d: New test.
* testsuite/gas/mips/micromips-branch-absolute-n32.d: New test.
* testsuite/gas/mips/micromips-branch-absolute-n64.d: New test.
* testsuite/gas/mips/micromips-branch-absolute-addend-n32.d: New
test.
* testsuite/gas/mips/micromips-branch-absolute-addend-n64.d: New
test.
* testsuite/gas/mips/branch-absolute.s: New test source.
* testsuite/gas/mips/branch-absolute-addend.s: New test source.
* testsuite/gas/mips/mips16-branch-absolute-addend.s: New test
source.
* testsuite/gas/mips/micromips-branch-absolute.s: New test
source.
* testsuite/gas/mips/micromips-branch-absolute-addend.s: New
test source.
* testsuite/gas/mips/mips.exp: Run the new tests.
ld/
* testsuite/ld-mips-elf/branch-absolute.d: New test.
* testsuite/ld-mips-elf/branch-absolute-n32.d: New test.
* testsuite/ld-mips-elf/branch-absolute-n64.d: New test.
* testsuite/ld-mips-elf/branch-absolute-addend.d: New test.
* testsuite/ld-mips-elf/branch-absolute-addend-n32.d: New test.
* testsuite/ld-mips-elf/branch-absolute-addend-n64.d: New test.
* testsuite/ld-mips-elf/micromips-branch-absolute.d: New test.
* testsuite/ld-mips-elf/micromips-branch-absolute-n32.d: New
test.
* testsuite/ld-mips-elf/micromips-branch-absolute-n64.d: New
test.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend.d: New
test.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend-n32.d:
New test.
* testsuite/ld-mips-elf/micromips-branch-absolute-addend-n64.d:
New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests, except
from `branch-absolute-addend' and
`micromips-branch-absolute-addend', referred indirectly only.
Align x86-64 .got and .got.plt sections to their entry size.
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Align
.got/.got.plt sections to 8 bytes.
TLS relocations did not support multiple TLS modes for the same
symbol in a single object file.
Refactored how GOT and TLS is implemented. Removed code duplications between
local and global symbols conditioning.
bfd/ChangeLog:
2016-06-14 Cupertino Miranda <cmiranda@synopsys.com>
* arc-got.h: Moved got related structures from elf32-arc.c to
this file. More precisely, tls_type_e, tls_got_entries, got_entry.
* (arc_get_local_got_ents,
got_entry_for_type,
new_got_entry_to_list,
tls_type_for_reloc,
symbol_has_entry_of_type,
get_got_entry_list_for_symbol,
arc_got_entry_type_for_reloc,
ADD_SYMBOL_REF_SEC_AND_RELOC,
arc_fill_got_info_for_reloc,
relocate_fix_got_relocs_for_got_info,
create_got_dynrelocs_for_single_entry,
create_got_dynrelocs_for_got_info): Added to file.
* elf32-arc.c: Removed GOT & TLS related structs and functions to
arc-got.h.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
The reloc for BFD_RELOC_32 was using the the 20-bit. This hack causes
problems in gdb. Fixed it to be the proper 32-bit reloc, R_FT32_32.
bfd/ChangeLog:
* elf32-ft32.c (ft32_reloc_map): Use R_FT32_32 for BFD_RELOC_32.
2016-07-05 Andre Vieria <andre.simoesdiasvieira@arm.com>
* elf32-arm.c (THUMB32_MOVT): New veneer macro.
(THUMB32_MOVW): Likewise.
(elf32_arm_stub_long_branch_thumb2_only_pure): New.
(DEF_STUBS): Define long_branch_thumb2_only_pure.
(arm_stub_is_thumb): Add new veneer stub.
(arm_type_of_stub): Use new veneer.
(arm_stub_required_alignment): Add new veneer.
2016-07-05 Andre Vieria <andre.simoesdiasvieira@arm.com>
* testsuite/ld-arm/farcall-thumb2-purecode.d: New test result.
* testsuite/ld-arm/farcall-thumb2-purecode.s: New test.
* testsuite/ld-arm/arm-elf.exp: Run it.
2016-07-01 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
* elf32-arm.c (using_thumb2_bl): New function.
(arm_type_of_stub): Declare thumb2 variable together and change type
to bfd_boolean. Use using_thumb2_bl () to determine whether
THM_MAX_FWD_BRANCH_OFFSET or THM2_MAX_FWD_BRANCH_OFFSET should be
checked for BL range.
(elf32_arm_final_link_relocate): Use using_thumb2_bl () to determine
the bit size of BL offset.
ld/
* testsuite/ld-arm/arm-elf.exp (Thumb-2 BL): Assemble for ARMv7.
(Thumb-2 BL on ARMv6-M): New testcase.
* testsuite/ld-arm/thumb2-bl.d: Do not try to match testcase filename.
* testsuite/ld-arm/thumb2-bl.s: Do not select architecture.
bfd * elfnn-aarch64.c (is_aarch64_mapping_symbol): New function.
Returns TRUE for AArch64 mapping symbols.
(elfNN_aarch64_backend_symbol_processing): New function. Marks
mapping symbols as precious in object files so that they will not
be stripped.
(elf_backend_symbol_processing): Define.
* elf32-arm.c (is_arm_mapping_symbol): New function. Returns TRUE
for ARM mapping symbols.
(elf32_arm_backend_symbol_processing): Make use of the new function.
No need to check version if symbol is unreferenced and undefined.
bfd/
PR ld/20306
* elflink.c (elf_link_check_versioned_symbol): Return false
for unreferenced undefined symbol.
ld/testsuite/
* testsuite/ld-gc/gc.exp: Run pr20306 test.
* ld-gc/pr20306.c: New file.
* ld-gc/pr20306.d: Likewise.
bfin * elf32-bfin.c (bfin_adjust_dynamic_symbol): Fail if a COPY reloc
is needed.
ld * testsuite/ld-elf/comm-data.exp: Expect comm-data2 test to fail
for bfin.
* testsuite/ld-elf/elf.exp: Expect pr14170 and symbolic function
tests to fail for bfin.
* testsuite/ld-elf/endsym.d: Expect to fail with cr16, crx, dlx,
nds32 and visium.
* testsuite/ld-elf/var1.d: Expect to fail with d30v, dlx, ft32 and
microblaze.
* testsuite/ld-pe/pe.exp: Expect foreign symbol test to fail for
mcore-pe.
* elf32-arm.c (elf32_arm_backend_symbol_processing): New
function. Marks mapping symbols in object files as precious, so
that strip will not remove them.
(elf_backend_symbol_processing): Define.
bfd * elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Don't convert
R_SPARC_32 to R_SPARC_RELATIVE if class is ELFCLASS64.
gold * sparc.cc (Target_sparc::Scan::local): Don't convert R_SPARC_32
to R_SPARC_RELATIVE if class is ELFCLASS64.
(Target_sparc::Scan::global): Likewise.
ld * testsuite/ld-elf/symbolic-func.r: Allow non-zero offsets from
.text.
b399102 fixed the testcase in this PR but it may be possible to
trigger the problem in other ways.
PR ld/19264
* elf64-ppc.c (STUB_SHRINK_ITER): Define.
(ppc64_elf_size_stubs): Exit stub sizing loop past STUB_SHRINK_ITER
if shrinking stubs.
(ppc64_elf_size_stubs): Adjust to suit.
The procstat AUXV core dump note in FreeBSD consists of 32-bit integer
followed by an array of auxiliary vector entries.
bfd/ChangeLog:
* elf.c (elfcore_grok_freebsd_note): Handle NT_FREEBSD_PROCSTAT_AUXV
notes.
Move parsing of FreeBSD-specific ELF core notes out of elfcore_grok_note
into a new elfcore_grok_freebsd_note function. Add core note grok routines
for FreeBSD's psinfo and prstatus notes while here rather than depending
on the native handling in elfcore_grok_note.
bfd/ChangeLog:
* elf.c (elfcore_grok_note): Remove handling of NT_X86_XSTATE for
FreeBSD. Remove case for NT_FREEBSD_THRMISC.
(elfcore_grok_freebsd_psinfo): New function.
(elfcore_grok_freebsd_prstatus): New function.
(elfcore_grok_freebsd_note): New function.
(elf_parse_notes): Use "elfcore_grok_freebsd_note" for "FreeBSD"
notes.
When configured with the default options, GDB currently fails to link,
due to an undefined reference to bfd_link_plugin_object_p, coming from
elflink.c:
#ifdef BFD_SUPPORTS_PLUGINS
|| (abfd->plugin_format == bfd_plugin_unknown
&& bfd_link_plugin_object_p (abfd))
#endif
This is because BFD_SUPPORTS_PLUGINS is always defined. It is its value
that determines whether plugin support is enabled or not.
bfd/ChangeLog:
* elflink.c: Check the value of BFD_SUPPORTS_PLUGINS rather
than its existance.
Some MIPS targets use a named section symbol rather than a symbol with
no name as is used with most ELF targets. When renaming sections, the
named section symbol needs to be renamed too.
Rather than fix this bug, I'd originally intended to just correct the
xfail added recently for update-1.o vs update4.o in update-section.exp,
using the same set of targets for the localize-hidden-1 mips xfail.
I'd extracted that target test into a new function, is_bad_symtab. It
turns out to be useful in readelf.exp too.
bfd/
* config.bfd: Delete mips vxworks patterns matched earlier.
Combine mips*-*-none with mips*-*-elf*.
binutils/
* objcopy.c (find_section_rename): Forward declare. Remove
ibfd and sec_ptr param. Add old_name param. Allow for NULL
returned_flags. Move read of section name and flags to..
(setup_section): ..here. Update find_section_rename call.
(filter_symbols): Rename section symbols for renamed sections.
(copy_object): Call filter_symbols when renamed sections.
* testsuite/lib/binutils-common.exp (is_bad_symtab): New.
* testsuite/binutils-all/update-section.exp: Revert 96037eb0
mips xfail.
* testsuite/binutils-all/objcopy.exp (copy_executable): Use
is_bad_symtab.
(localize-hidden-1): xfail if is_bad_symtab.
* testsuite/binutils-all/readelf.exp: Use is_bad_symtab to select
between mips/tmips.