aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2018-11-06elfedit: Add --enable-x86-feature/--disable-x86-featureH.J. Lu8-0/+91
Add --enable-x86-feature and --disable-x86-feature options to elfedit to set and clear the IBT and SHSTK bits in program property in ELF executables and shared objects. binutils/ * doc/binutils.texi: Document --enable-x86-feature and --disable-x86-feature options for elfedit. * elfedit.c: Include "config.h" and <sys/mman.h>. (enable_x86_features): New. (disable_x86_features): Likewise. (update_gnu_property): Likewise. (elf_x86_feature): Likewise. (process_file): Call update_gnu_property on ET_EXEC or ET_DYN file. (command_line_switch): Add OPTION_ENABLE_X86_FEATURE and OPTION_DISABLE_X86_FEATURE. (options): Add--enable-x86-feature and --disable-x86-feature. (usage): Likewise. (main): Handle OPTION_ENABLE_X86_FEATURE and OPTION_DISABLE_X86_FEATURE. ld/ * testsuite/config/default.exp (ELFEDIT): New. * testsuite/ld-elf/linux-x86.exp (elfedit_test): New proc. Run elfedit tests. * testsuite/ld-elf/x86-feature-1a.rd: New file. * testsuite/ld-elf/x86-feature-1b.rd: Likewise. * testsuite/ld-elf/x86-feature-1c.rd: Likewise. * testsuite/ld-elf/x86-feature-1d.rd: Likewise. * testsuite/ld-elf/x86-feature-1e.rd: Likewise.
2018-11-05Correct ChangeLog entries for PR gas/23854 commitH.J. Lu1-1/+1
commit e60f4d3bdac25f02875afe36b7436bc2dfbbb978 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Nov 5 09:01:26 2018 -0800 x86: Disable GOT relaxation with data prefix Since linker GOT relaxation isn't valid for 16-bit GOT access, we should disable GOT relaxation with data prefix.
2018-11-05x86: Disable GOT relaxation with data prefixH.J. Lu7-0/+135
Since linker GOT relaxation isn't valid for 16-bit GOT access, we should disable GOT relaxation with data prefix. gas/ PR gas/r23854 * config/tc-i386.c (output_disp): Disable GOT relaxation with data prefix. * testsuite/gas/i386/mixed-mode-reloc32.d: Updated. ld/ PR gas/r23854 * testsuite/ld-i386/i386.exp: Run pr23854. * testsuite/ld-x86-64/x86-64.exp: Likewwise. * testsuite/ld-i386/pr23854.d: New file. * testsuite/ld-i386/pr23854.s: Likewwise. * testsuite/ld-i386/pr23854.d: Likewwise. * testsuite/ld-x86-64/pr23854.d: Likewwise. * testsuite/ld-x86-64/pr23854.s: Likewwise.
2018-11-01Fix ld action in run_dump_testThomas Preud'homme2-17/+5
run_dump_test proposes an ld action but when trying to make use of it in a gas test it gave me some Tcl error. It turns out that it references the check_shared_lib_support procedure and ld_elf_shared_opt variable both only available in ld-lib.exp. I've thus moved the procedure in binutils-common.exp and defined the variable needed in the various default.exp of testsuite that seem to be using run_dump_test. Since check_shared_lib_support itself references the ld variable not defined in binutils-common I've defined it from LD in run_dump_test and fixed LD and LDFLAGS to be defined as expected by run_dump_test in the various default.exp of testsuite using run_dump_test. 2018-11-01 Thomas Preud'homme <thomas.preudhomme@linaro.org> binutils/ * testsuite/config/default.exp: Define LD, LDFLAGS and ld_elf_shared_opt. * testsuite/lib/binutils-common.exp (check_shared_lib_support): Moved from ld-lib.exp. (run_dump_test): Set ld to $LD. gas/ * testsuite/config/default.exp: Define LD, LDFLAGS and ld_elf_shared_opt. ld/ * testsuite/lib/ld-lib.exp (check_shared_lib_support): Moved to binutils-common.exp.
2018-10-29Report scripts and libraries searched for ld --traceAlan Modra6-14/+27
The idea of this change is to make -t output useful for users wanting to package all the object files involved in linking for a bug report. Something like the following should do the trick. gcc hello.c -save-temps -Wl,-t | xargs realpath | sort | uniq > files tar cJf test.tar.xz `cat files` * ldlang.c (load_symbols): When -t, print file names for script files and archives. * ldmain.c (trace_files): Make an int. (add_archive_element): Print archive elements only with multiple -t options, or when archive is thin. * ldmain.h (trace_files): Update. * ldmisc.c (vfinfo): Don't print both original path and path in sysroot. * lexsup.c (parse_args <t>): Increment trace_files.
2018-10-29Remove some ld --trace outputAlan Modra2-3/+9
This output really belongs in ld --verbose. * ldmain.c (main): Print emulation mode and "deleting executable" for --verbose, not --trace. (add_archive_element): Only print "no new IR symbols" for --verbose.
2018-10-29Simplify --sysroot=/Alan Modra2-9/+17
Prepending '/' to absolute paths doesn't gain us much, and results in the current implementation of --trace emitting silly path-in-sysroot output, eg. /lib/ld-linux-x86-64.so.2 (//lib/ld-linux-x86-64.so.2) * ldmain.c (get_sysroot): Return "" for "--sysroot=/".
2018-10-29ld -r script fixesAlan Modra16-35/+58
For ld -r, we generally set the VMA of sections to zero. This is done to make the output of ld -r most similar to that output by the assembler, which generally has sections starting at VMA zero. In some cases that covers for backend bugs which would mis-handle relocatable object files with non-zero section VMAs. This patch fixes a few sections that didn't have zero VMAs for ld -r. A missing zero on .note.gnu.build-id and .eh_frame_hdr doesn't matter much since these are linker generated symbols only output on final link, but it's good to be consistent. * Makefile.am (ei386beos.c, ei386go32.c): Correct dependencies. * Makefile.in: Regenerate. * scripttempl/elf.sc (.note.gnu.build-id, .eh_frame_hdr): Set address with ${RELOCATING-0}. * scripttempl/arclinux.sc: Likewise. * scripttempl/armbpabi.sc: Likewise. * scripttempl/avr.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/pru.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise, and for other sections. * scripttempl/epiphany_4x4.sc: Similarly.
2018-10-26ELF: update ld man page on `--gc-sections`Christoph Conrads2-3/+9
Commit 91ae256e33 fixes the behavior of ld when `--gc-sections` and `--gc-keep-exported` are both given on the linker command line. This updates the ld documentation to suit. * ld.texi (--gc-sections): Update.
2018-10-24ELF: Hide symbols defined in discarded input sectionsH.J. Lu6-0/+34
When assigning symbol version, we should hide debug symbols defined in discarded sections from IR objects so that they can be removed later. bfd/ PR ld/23818 * elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols defined in discarded input sections. ld/ PR ld/23818 * testsuite/ld-plugin/lto.exp: Run PR ld/23818 test. * testsuite/ld-plugin/pr23818.d: New file. * testsuite/ld-plugin/pr23818.t: Likewise. * testsuite/ld-plugin/pr23818a.c: Likewise. * testsuite/ld-plugin/pr23818b.c: Likewise.
2018-10-23alpha testsuite fixesAlan Modra3-6/+22
Fixes a couple of ERROR results due to .set difference on alpha. * testsuite/ld-elf/shared.exp: Don't build pr19073 test on alpha. * testsuite/ld-elf/pr18720b.c: Don't use .set on alpha.
2018-10-20Relax a -r --gc-sections requirementAlan Modra2-2/+9
A symbol root is not needed if --gc-keep-exported is also given. * ldlang.c (lang_end): Don't error if no --entry or --undefined is given with -r -gc-sections if --gc-keep-exported.
2018-10-15RISC-V: Adjust __global_pointer$ value to reduce code size.Jim Wilson3-2/+21
ld/ * emulparams/elf32lriscv-defs.sh (DATA_START_SYMBOLS): New. (SDATA_START_SYMBOLS): Define __SDATA_BEGIN__. Don't define __global_pointer$. (OTHER_END_SYMBOLS): New. Define __global_pointer$. * testsuite/ld-riscv-elf/pcrel-lo-addend-2.d (#ld): Add --no-relax.
2018-10-15BFD_INIT_MAGICAlan Modra2-1/+8
This patch performs a run-time test that a shared libbfd.so has been compiled with the same size bfd_vma as that of apps using the library. On a 32-bit host it is easily possible to have one libbfd.so compiled to support 64-bit targets (or configured with --enable-64-bit-bfd) while another only supports 32-bit targets. The two libraries will have differently sized bfd_vma types, and if the wrong one is loaded all sorts of weird behaviour might be seen. bfd/ PR 23534 * init.c (BFD_INIT_MAGIC): Define. (bfd_init): Return BFD_INIT_MAGIC. bfd-in2.h: Regenerate. binutils/ PR 23534 * addr2line.c (main): Exit with fatal error if bfd_init returns an unexpected value. * ar.c (main): Likewise. * dlltool.c (identify_dll_for_implib): Likewise. * nm.c (main): Likewise. * objcopy.c (main): Likewise. * objdump.c (main): Likewise. * size.c (main): Likewise. * strings.c (main): Likewise. * windmc.c (main): Likewise. * windres.c (main): Likewise. gas/ PR 23534 * as.c (main): Exit with fatal error if bfd_init returns an unexpected value. ld/ PR 23534 * ldmain.c (main): Exit with fatal error if bfd_init returns an unexpected value.
2018-10-13ELF ld -r scriptsAlan Modra75-660/+791
"ld -r" generally should not combine object file sections with different names. For example, "ld -r" should not combine ".text", ".text.hot" and ".text.cold" into an output ".text" section. An exception needs to be made for linker created sections, for example, branch trampoline sections that might be created even for ld -r. "ld -r" also should not define symbols in linker scripts. Any definitions are likely to conflict with those defined at final link. A MEMORY spec is also not needed for ld -r. * Makefile.am (eelf32btsmip_fbsd.c, eelf32btsmipn32_fbsd.c), (eelf32epiphany.c, eelf32epiphany_4x4.c, eelf32ltsmip_fbsd.c), (eelf32ltsmipn32_fbsd.c, eelf32xc16x.c, eelf32xc16xl.c), (eelf32xc16xs.c, emcorepe.c, enios2elf.c, enios2linux.c), (eelf64btsmip_fbsd.c, eelf64ltsmip_fbsd.c): Correct dependencies. * Makefile.in: Regenerate. * emulparams/aarch64cloudabi.sh, * emulparams/aarch64fbsd.sh, * emulparams/aarch64linux.sh, * emulparams/aarch64linux32.sh, * emulparams/arc-nps.sh, * emulparams/elf32_spu.sh, * emulparams/elf32_tic6x_le.sh, * emulparams/elf32bmip.sh, * emulparams/elf32btsmipn32.sh, * emulparams/elf32lr5900n32.sh, * emulparams/elf32mep.sh, * emulparams/elf32metag.sh, * emulparams/elf64btsmip.sh, * emulparams/shelf_vxworks.sh, * emulparams/shlelf_fd.sh, * scripttempl/DWARF.sc, * scripttempl/alpha.sc, * scripttempl/alphavms.sc, * scripttempl/arclinux.sc, * scripttempl/armbpabi.sc, * scripttempl/avr.sc, * scripttempl/dlx.sc, * scripttempl/elf.sc, * scripttempl/elf32cr16.sc, * scripttempl/elf32cr16c.sc, * scripttempl/elf32crx.sc, * scripttempl/elf32msp430.sc, * scripttempl/elf32msp430_3.sc, * scripttempl/elf32xc16x.sc, * scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc, * scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc, * scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc, * scripttempl/elfd10v.sc, * scripttempl/elfd30v.sc, * scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc, * scripttempl/elfmicroblaze.sc, * scripttempl/elfxgate.sc, * scripttempl/elfxtensa.sc, * scripttempl/epiphany_4x4.sc, * scripttempl/ft32.sc, * scripttempl/hppaelf.sc, * scripttempl/ia64vms.sc, * scripttempl/ip2k.sc, * scripttempl/iq2000.sc, * scripttempl/mep.sc, * scripttempl/mmo.sc, * scripttempl/nds32elf.sc, * scripttempl/pru.sc, * scripttempl/sh.sc, * scripttempl/v850.sc, * scripttempl/v850_rh850.sc, * scripttempl/visium.sc, * scripttempl/xstormy16.sc: Condition various parts of scripts on ${RELOCATABLE} in order to prevent ld -r merging sections or defining symbols. Remove MEMORY and VERSION definitions from ld -r scripts too. * testsuite/ld-elf/group2.d, * testsuite/ld-elf/group4.d, * testsuite/ld-elf/group5.d, * testsuite/ld-elf/group6.d, * testsuite/ld-elf/group7.d, * testsuite/ld-elf/group8a.d, * testsuite/ld-elf/group8b.d, * testsuite/ld-elf/group9a.d, * testsuite/ld-elf/group9b.d, * testsuite/ld-elf/pr17550a.d, * testsuite/ld-elf/pr17550b.d, * testsuite/ld-elf/pr17550d.d: Don't xfail cr16 and crx. * testsuite/ld-elf/init-fini-arrays.d, * testsuite/ld-elf/pr22677.d: Likewise, and dont' xfail mep.
2018-10-08x86: Don't add GNU_PROPERTY_X86_FEATURE_2_NEEDED for -z separate-codeH.J. Lu4-6/+10
With commit 64029e93683a266c38d19789e780f3748bd6a188 Author: Alan Modra <amodra@gmail.com> Date: Fri Oct 5 11:40:54 2018 +0930 Separate header PT_LOAD for -z separate-code there is no need to add a GNU_PROPERTY_X86_ISA_1_USED note to force program header in in non-code PT_LOAD segment when -z separate-code is used. bfd/ PR ld/23428 * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't add GNU_PROPERTY_X86_FEATURE_2_NEEDED to force program header in non-code PT_LOAD segment. ld/ PR ld/23428 * testsuite/ld-i386/property-x86-4a.d: Updated. * testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-4a.d: Likewise.
2018-10-08ELF: Properly group and place orphan note sectionsH.J. Lu5-56/+140
Properly group orphan note sections. When placing orphan note section as the first note section, place it after the section before all note sections. PR ld/23658 * ldlang.c (lang_insert_orphan): Properly group and place orphan note sections. Properly handle orphan note section before all note sections. * testsuite/ld-elf/pr23658-1.d: Renamed to ... * testsuite/ld-elf/pr23658-1a.d: This. Updated. * testsuite/ld-elf/pr23658-1b.d: New test. * testsuite/ld-elf/pr23658-1c.d: Likewise.
2018-10-08Separate header PT_LOAD for -z separate-codeAlan Modra12-20/+19
This patch, along with previous patches in the series, supports putting the ELF file header and program headers in a PT_LOAD without sections. Logic governing whether headers a loaded has changed a little: The primary reason to include headers is now the presence of SIZEOF_HEADERS in a linker script. However, to support scripts that may have reserved space for headers by hand, we continue to add headers whenever the first section address is past the end of headers modulo page size. include/ * bfdlink.h (struct bfd_link_info): Add load_phdrs field. bfd/ * elf-nacl.c (nacl_modify_segment_map): Cope with header PT_LOAD lacking sections. * elf.c (_bfd_elf_map_sections_to_segments): Assume file and program headers are required when info->load_phdrs. Reorganize code handling program headers. Generate a mapping without sections just for file and program headers when -z separate-code would indicate they should be on a different page to the first section. ld/ * ldexp.c (fold_name <SIZEOF_HEADERS>): Set link_info.load_phdrs. * testsuite/ld-elf/loadaddr1.d: Pass -z noseparate-code. * testsuite/ld-elf/loadaddr2.d: Likewise. * testsuite/ld-i386/vxworks2.sd: Adjust expected output. * testsuite/ld-powerpc/vxworks2.sd: Likewise. * testsuite/ld-elf/overlay.d: Remove spu xfail. * testsuite/ld-spu/ovl.lnk: Don't use SIZEOF_HEADERS. * testsuite/ld-tic6x/dsbt-be.ld: Likewise. * testsuite/ld-tic6x/dsbt-inrange.ld: Likewise. * testsuite/ld-tic6x/dsbt-overflow.ld: Likewise. * testsuite/ld-tic6x/dsbt.ld: Likewise.
2018-10-08ld insert_os_after ignoring first assignmentAlan Modra3-5/+15
Some time ago the pr19593 test was xfailed for alpha. This turned out to be the wrong course of action since the test exposed a bug in orphan section placement. On alpha, orphan sections were being inserted before ". = SIZEOF_HEADERS" due to the test having two assignments, and on alpha, an output section statement from -Ttext-segment being passed to ld. * ldlang.c (insert_os_after): Clear ignore_first on assignment to dot, not any assignment. Clear ignore_first on output section statement contents too. * testsuite/ld-elf/pr19539.d: Remove alpha xfail.
2018-10-08No PT_INTERP when .interp is zero sizeAlan Modra2-1/+5
Some targets don't set a default interpreter, resulting in an empty .interp section unless --dynamic-linker is passed to ld. A PT_INTERP without a path is rather useless. The testsuite change fixes a failure on microblaze-linux. bfd/ * elf.c (get_program_header_size): Don't count PT_INTERP if .interp is empty. (_bfd_elf_map_sections_to_segments): Don't create PT_INTERP if .interp is empty. ld/ * testsuite/ld-elf/pr22423.d: Pass --dynamic-linker to ld.
2018-10-05or1k: Add the l.adrp insn and supporting relocationsStafford Horne8-0/+147
This patch adds the new instruction and relocation as per proposal: https://openrisc.io/proposals/ladrp This is to be added to the spec in an upcoming revision. The new instruction l.adrp loads the page offset of the current instruction offset by a 21-bit immediate shifted left 13-bits. This is meant to be used with a 13-bit lower bit page offset. This allows us to free up the got register r16. l.adrp r3, foo l.ori r4, r3, po(foo) l.lbz r5, po(foo)(r3) l.sb po(foo)(r3), r6 The relocations we add are: - BFD_RELOC_OR1K_PLTA26 For PLT jump relocation with PLT entry asm: plta() implemented using l.ardp, meaning no need for r16 (the GOT reg) - BFD_RELOC_OR1K_GOT_PG21 Upper 21-bit Page offset got address asm: got() - BFD_RELOC_OR1K_TLS_GD_PG21 Upper 21-bit Page offset with TLS General asm: tlsgd() Dynamic calculation - BFD_RELOC_OR1K_TLS_LDM_PG21 Upper 21-bit Page offset with TLS local asm: tlsldm() dynamic calculation - BFD_RELOC_OR1K_TLS_IE_PG21 Upper 21-bit Page offset with TLS Initial asm: gottp() Executable calculation - BFD_RELOC_OR1K_PCREL_PG21 Default relocation for disp21 (l.adrp instructions) - BFD_RELOC_OR1K_LO13 low 13-bit page offset relocation asm: po() i.e. mem loads, addi etc - BFD_RELOC_OR1K_SLO13 low 13-bit page offset relocation asm: po() i.e. mem stores, with split immediate - BFD_RELOC_OR1K_GOT_LO13, low 13-bit page offset with GOT calcs asm: gotpo() - BFD_RELOC_OR1K_TLS_GD_LO13 Lower 13-bit offset with TLS GD calcs asm: tlsgdpo() - BFD_RELOC_OR1K_TLS_LDM_LO13 Lower 13-bit offset with TLS LD calcs asm: tlsldmpo() - BFD_RELOC_OR1K_TLS_IE_LO13 Lower 13-bit offset with TLS IE calcs asm: gottppo() bfd/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * bfd-in2.h: Regenerated. * elf32-or1k.c: (or1k_elf_howto_table): Fix formatting for R_OR1K_PLT26, Add R_OR1K_PCREL_PG21, R_OR1K_GOT_PG21, R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21, R_OR1K_TLS_IE_PG21, R_OR1K_LO13, R_OR1K_GOT_LO13, R_OR1K_TLS_GD_LO13, R_OR1K_TLS_LDM_LO13, R_OR1K_TLS_IE_LO13, R_OR1K_SLO13, R_OR1K_PLTA26. (or1k_reloc_map): Add BFD_RELOC_OR1K_PCREL_PG21, BFD_RELOC_OR1K_GOT_PG21, BFD_RELOC_OR1K_TLS_GD_PG21, BFD_RELOC_OR1K_TLS_LDM_PG21, BFD_RELOC_OR1K_TLS_IE_PG21, BFD_RELOC_OR1K_LO13, BFD_RELOC_OR1K_GOT_LO13, BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_LO13, BFD_RELOC_OR1K_SLO13, BFD_RELOC_OR1K_PLTA26. (elf_or1k_link_hash_table): Add field saw_plta. (or1k_final_link_relocate): Add value calculations for new relocations. (or1k_elf_relocate_section): Add section relocations for new relocations. (or1k_write_plt_entry): New function. (or1k_elf_finish_dynamic_sections): Add support for PLTA relocations using new l.adrp instruction. Cleanup PLT relocation code generation. * libbfd.h: Regenerated. * reloc.c: Add BFD_RELOC_OR1K_PCREL_PG21, BFD_RELOC_OR1K_LO13, BFD_RELOC_OR1K_SLO13, BFD_RELOC_OR1K_GOT_PG21, BFD_RELOC_OR1K_GOT_LO13, BFD_RELOC_OR1K_PLTA26, BFD_RELOC_OR1K_TLS_GD_PG21, BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_LDM_PG21, BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_PG21, BFD_RELOC_OR1K_TLS_IE_LO13. cpu/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * or1k.opc (parse_disp26): Add support for plta() relocations. (parse_disp21): New function. (or1k_rclass): New enum. (or1k_rtype): New enum. (or1k_imm16_relocs): Define new PO and SPO relocation mappings. (parse_reloc): Add new po(), gotpo() and gottppo() for LO13 relocations. (parse_imm16): Add support for the new 21bit and 13bit relocations. * or1korbis.cpu (f-disp26): Don't assume SI. (f-disp21): New pc-relative 21-bit 13 shifted to right. (insn-opcode): Add ADRP. (l-adrp): New instruction. gas/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * config/tc-or1k.c (or1k_apply_fix): Add BFD_RELOC_OR1K_TLS_GD_PG21, BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_LDM_PG21, BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_PG21, BFD_RELOC_OR1K_TLS_IE_LO13. * testsuite/gas/or1k/allinsn.s: Add test for l.adrp. * testsuite/gas/or1k/allinsn.d: Add test results for new instructions. * testsuite/gas/or1k/reloc-1.s: Add tests to generate R_OR1K_PLTA26, R_OR1K_GOT_PG21, R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21, R_OR1K_TLS_IE_PG21, R_OR1K_LO13, R_OR1K_GOT_LO13, R_OR1K_TLS_GD_LO13, R_OR1K_TLD_LDM_LO13, R_OR1K_TLS_IE_LO13, R_OR1K_LO13, R_OR1K_SLO13 relocations. * testsuite/gas/or1k/reloc-1.d: Add relocation results for tests. * testsuite/gas/or1k/reloc-2.s: Add negative tests for store to gotpo(). * testsuite/gas/or1k/reloc-2.l: Add expected error test results. ld/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * testsuite/ld-or1k/or1k.exp: Add test cases for plt generation. * testsuite/ld-or1k/plt1.dd: New file. * testsuite/ld-or1k/plt1.s: New file. * testsuite/ld-or1k/plt1.x.dd: New file. * testsuite/ld-or1k/plta1.dd: New file. * testsuite/ld-or1k/plta1.s: New file. * testsuite/ld-or1k/pltlib.s: New file. include/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * elf/or1k.h (elf_or1k_reloc_type): Add R_OR1K_PCREL_PG21, R_OR1K_GOT_PG21, R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21, R_OR1K_TLS_IE_PG21, R_OR1K_LO13, R_OR1K_GOT_LO13, R_OR1K_TLS_GD_LO13, R_OR1K_TLS_LDM_LO13, R_OR1K_TLS_IE_LO13, R_OR1K_SLO13, R_OR1K_PLTA26. opcodes/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * or1k-asm.c: Regenerated. * or1k-desc.c: Regenerated. * or1k-desc.h: Regenerated. * or1k-dis.c: Regenerated. * or1k-ibld.c: Regenerated. * or1k-opc.c: Regenerated. * or1k-opc.h: Regenerated. * or1k-opinst.c: Regenerated.
2018-10-05or1k: Add relocations for high-signed and low-storesRichard Henderson4-0/+301
This patch adds the following target relocations: - BFD_RELOC_HI16_S High 16-bit relocation, for used with signed asm: ha() lower. - BFD_RELOC_HI16_S_GOTOFF High 16-bit GOT offset relocation for local asm: gotoffha() symbols, for use with signed lower. - BFD_RELOC_OR1K_TLS_IE_AHI16 High 16-bit TLS relocation with initial asm: gottpoffha() executable calculation, for use with signed lower. - BFD_RELOC_OR1K_TLS_LE_AHI16 High 16-bit TLS relocation for local executable asm: tpoffha() variables, for use with signed lower. - BFD_RELOC_OR1K_SLO16 Split lower 16-bit relocation, used with asm: lo() OpenRISC store instructions. - BFD_RELOC_OR1K_GOTOFF_SLO16 Split lower 16-bit GOT offset relocation for asm: gotofflo() local symbols, used with OpenRISC store instructions. - BFD_RELOC_OR1K_TLS_LE_SLO16 Split lower 16-bit relocation for TLS local asm: tpofflo() executable variables, used with OpenRISC store instructions. bfd/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> Stafford Horne <shorne@gmail.com> * bfd-in2.h: Regenerated. * elf32-or1k.c (N_ONES): New macro. (or1k_elf_howto_table): Fix R_OR1K_PLT26 to complain on overflow. Add definitions for R_OR1K_TLS_TPOFF, R_OR1K_TLS_DTPOFF, R_OR1K_TLS_DTPMOD, R_OR1K_AHI16, R_OR1K_GOTOFF_AHI16, R_OR1K_TLS_IE_AHI16, R_OR1K_TLS_LE_AHI16, R_OR1K_SLO16, R_OR1K_GOTOFF_SLO16, R_OR1K_TLS_LE_SLO16. (or1k_reloc_map): Add entries for BFD_RELOC_HI16_S, BFD_RELOC_LO16_GOTOFF, BFD_RELOC_HI16_GOTOFF, BFD_RELOC_HI16_S_GOTOFF, BFD_RELOC_OR1K_TLS_IE_AHI16, BFD_RELOC_OR1K_TLS_LE_AHI16, BFD_RELOC_OR1K_SLO16, BFD_RELOC_OR1K_GOTOFF_SLO16, BFD_RELOC_OR1K_TLS_LE_SLO16. (or1k_reloc_type_lookup): Change search loop to start ad index 0 and also check results before returning. (or1k_reloc_name_lookup): Simplify loop to use R_OR1K_max as index limit. (or1k_final_link_relocate): New function. (or1k_elf_relocate_section): Add support for new AHI and SLO relocations. Use or1k_final_link_relocate instead of generic _bfd_final_link_relocate. (or1k_elf_check_relocs): Add support for new AHI and SLO relocations. * reloc.c: Add new enums for BFD_RELOC_OR1K_SLO16, BFD_RELOC_OR1K_GOTOFF_SLO16, BFD_RELOC_OR1K_TLS_IE_AHI16, BFD_RELOC_OR1K_TLS_IE_AHI16, BFD_RELOC_OR1K_TLS_LE_AHI16, BFD_RELOC_OR1K_TLS_LE_SLO16. Remove unused BFD_RELOC_OR1K_GOTOFF_HI16 and BFD_RELOC_OR1K_GOTOFF_LO16. * libbfd.h: Regenerated. cpu/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * or1k.opc: Add RTYPE_ enum. (INVALID_STORE_RELOC): New string. (or1k_imm16_relocs): New array array. (parse_reloc): New static function that just does the parsing. (parse_imm16): New static function for generic parsing. (parse_simm16): Change to just call parse_imm16. (parse_simm16_split): New function. (parse_uimm16): Change to call parse_imm16. (parse_uimm16_split): New function. * or1korbis.cpu (simm16-split): Change to use new simm16_split. (uimm16-split): Change to use new uimm16_split. gas/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * testsuite/gas/or1k/allinsn.d (l_ha): Add result for ha() relocation. * testsuite/gas/or1k/allinsn.s (l_ha): Add test for ha() relocations. * testsuite/gas/or1k/allinsn.exp: Renamed to or1k.exp. * testsuite/gas/or1k/or1k.exp: Add reloc-2 list test. * testsuite/gas/or1k/reloc-1.d: New file. * testsuite/gas/or1k/reloc-1.s: New file. * testsuite/gas/or1k/reloc-2.l: New file. * testsuite/gas/or1k/reloc-2.s: New file. include/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * elf/or1k.h (elf_or1k_reloc_type): Add R_OR1K_AHI16, R_OR1K_GOTOFF_AHI16, R_OR1K_TLS_IE_AHI16, R_OR1K_TLS_LE_AHI16, R_OR1K_SLO16, R_OR1K_GOTOFF_SLO16, R_OR1K_TLS_LE_SLO16. ld/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * testsuite/ld-or1k/offsets1.d: New file. * testsuite/ld-or1k/offsets1.s: New file. * testsuite/ld-or1k/or1k.exp: New file. opcodes/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * or1k-asm.c: Regenerate.
2018-10-04pr23658-1.d: Also xfail ft32-* and xgate-*H.J. Lu2-2/+7
Since ft32-* and xgate-* use generic linker, SHT_NOTE sections aren't grouped nor sorted. PR ld/23658 * testsuite/ld-elf/pr23658-1.d: Also xfail ft32-* and xgate-*.
2018-10-03ELF: Add testcases for PR ld/23658H.J. Lu11-0/+152
Add testcases to verify that all SHT_NOTE sections with the same section alignment are placed in a single PT_NOTE segment. PR ld/23658 * testsuite/ld-elf/pr23658-1.d: New file. * testsuite/ld-elf/pr23658-1a.s: Likewise. * testsuite/ld-elf/pr23658-1b.s: Likewise. * testsuite/ld-elf/pr23658-1c.s: Likewise. * testsuite/ld-elf/pr23658-1d.s: Likewise. * testsuite/ld-elf/pr23658-2.rd: Likewise. * testsuite/ld-elf/pr23658-3.d: Likewise. * testsuite/ld-elf/pr23658-3.s: Likewise. * testsuite/ld-elf/pr23658-3.t: Likewise. * testsuite/ld-elf/shared.exp: Run PR ld/23658 tests.
2018-10-03ELF: Group and sort output note sections by section alignmentsH.J. Lu2-1/+145
To support putting all adjacent SHT_NOTE sections with the same section alignment into a single PT_NOTE segment, lang_insert_orphan must group and sort output note sections by section alignments in both output section list as well as output section statement list. PR ld/23658 * ldlang.c (lang_insert_orphan): Group and sort output note sections by section alignments.
2018-09-25Couple of minor tweaks to the linker testsuite.Eric Botcazou3-1/+15
This gets rid of the couple of linker failures for visium-elf: FAIL: ld-elf/pr14156b FAIL: ld-elf/pr22677 by tweaking the respective testcases. The first tweak is the same as the one made to the sibling testcase ld-elf/pr14156a.d about one year ago and the second tweak adds the usual main/start/_start/__start symbols. ld/ * testsuite/ld-elf/pr14156b.d: Adjust for extra symbols. * testsuite/ld-elf/pr22677.s: Define main/start/_start/__start.
2018-09-24RISC-V: Allow pcrel_lo addends, error on addend overflow.Jim Wilson5-2/+32
bfd/ * elfnn-riscv.c (riscv_resolve_pcrel_lo_relocs): Add check for reloc overflow with addend. Use reloc_dangerous instead of reloc_overflow. Add strings for the two errors handled here. (riscv_elf_relocate_section) In case R_RISCV_PCREL_LO12_I, rewrite comment. Only give error with addend when used with section symbol. In case bfd_reloc_dangerous, update error string. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run pcrel-lo-addend-2. * testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend-2.d: New. * testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend-2.s: New. * testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend.d: Update name and error string.
2018-09-21Fix more fallout from 17f6ade235fcAlan Modra2-57/+36
gas/ * testsuite/gas/avr/large-debug-line-table.d: Update. ld/ * testsuite/ld-avr/gc-section-debugline.d: Update.
2018-09-20ld: Add the entry symbol, _main, for LynxOS targetsH.J. Lu17-0/+55
Add the entry symbol, _main, to fix: FAIL: ld-elf/64ksec FAIL: ld-elf/comm-data4 FAIL: ld-elf/comm-data5 FAIL: ld-elf/eh5 FAIL: ld-elf/empty FAIL: ld-elf/empty2 FAIL: ld-elf/endsym FAIL: ld-elf/exclude3a FAIL: ld-elf/linkonce2 FAIL: ld-elf/orphan3 FAIL: ld-elf/pr12851 FAIL: ld-elf/pr14156a FAIL: ld-elf/pr14156b FAIL: ld-elf/pr14926 FAIL: ld-elf/pr20513a FAIL: ld-elf/pr20513b FAIL: ld-elf/stab FAIL: ld-elf/var1 FAIL: ld-elf/warn3 FAIL: section size overflow for i386-lynxos target. * testsuite/ld-checks/over2.s: Add "_main" for LynxOS targets. * testsuite/ld-elf/comm-data4.s: Likewise. * testsuite/ld-elf/comm-data5.s: Likewise. * testsuite/ld-elf/eh5b.s: Likewise. * testsuite/ld-elf/empty.s: Likewise. * testsuite/ld-elf/empty2.s: Likewise. * testsuite/ld-elf/exclude3.s: Likewise. * testsuite/ld-elf/fini0.s: Likewise. * testsuite/ld-elf/init0.s: Likewise. * testsuite/ld-elf/linkonce1b.s: Likewise. * testsuite/ld-elf/orphan3a.s: Likewise. * testsuite/ld-elf/pr14926.s: Likewise. * testsuite/ld-elf/pr20513a.s: Likewise. * testsuite/ld-elf/sec64k.exp: Likewise. * testsuite/ld-elf/start.s: Likewise. * testsuite/ld-elf/var1.s: Likewise.
2018-09-20RISC-V: Fix library search path for rv32.Jim Wilson4-3/+9
2018-09-19 Kito Cheng <kito@andestech.com> ld/ * emulparams/elf32lriscv.sh: Correct the library search path. * emulparams/elf32lriscv_ilp32.sh: Likewise. * emulparams/elf32lriscv_ilp32f.sh: Likewise.
2018-09-20Andes Technology has good news for you, we plan to update the nds32 port of ↵Nick Clifton21-247/+120
binutils on upstream! We have not only removed all unsupported and obsolete code, but also supported lost of new features, including better link-time relaxations and TLS implementations. Besides, the files generated by the newly assembler and linker usually get higher performance and more optimized code size. ld * emultempl/nds32elf.em (hyper_relax): New variable. (nds32_elf_create_output_section_statements): the parameters of bfd_elf32_nds32_set_target_option (PARSE_AND_LIST_PROLOGUE, PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Add new option --mhyper-relax. * emultempl/nds32elf.em (nds32_elf_after_open): Updated. * emultempl/nds32elf.em (tls_desc_trampoline): New variable. * (nds32_elf_create_output_section_statements): Updated. * (nds32_elf_after_parse): Disable relaxations when PIC is enable. * (PARSE_AND_LIST_PROLOGUE, PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Add new option --m[no-]tlsdesc-trampoline. include * elf/nds32.h: Remove the unused target features. * dis-asm.h (disassemble_init_nds32): Declared. * elf/nds32.h (E_NDS32_NULL): Removed. (E_NDS32_HAS_DSP_INST, E_NDS32_HAS_ZOL): New. * opcode/nds32.h: Ident. (N32_SUB6, INSN_LW): New macros. (enum n32_opcodes): Updated. * elf/nds32.h: Doc fixes. * elf/nds32.h: Add R_NDS32_LSI. * elf/nds32.h: Add new relocations for TLS. gas * config/tc-nds32.c: Remove the unused target features. (nds32_relax_relocs, md_pseudo_table, nds32_elf_record_fixup_exp, nds32_set_elf_flags_by_insn, nds32_insert_relax_entry, nds32_apply_fix): Likewise. (nds32_no_ex9_begin): Removed. * config/tc-nds32.c (add_mapping_symbol_for_align, make_mapping_symbol, add_mapping_symbol): New functions. * config/tc-nds32.h (enum mstate): New. (nds32_segment_info_type): Likewise. * configure.ac (--enable-dsp-ext, --enable-zol-ext): New options. * config.in: Regenerated. * configure: Regenerated. * config/tc-nds32.c (nds32_dx_regs): Set the value according to the configuration. (nds32_perf_ext, nds32_perf_ext2, nds32_string_ext, nds32_audio_ext): Likewise. (nds32_dsp_ext): New variable. Set the value according to the configuration. (nds32_zol_ext): Likewise. (asm_desc, nds32_pseudo_opcode_table): Make them static. (nds32_set_elf_flags_by_insn): Updated. (nds32_check_insn_available): Updated. (nds32_str_tolower): New function. * config/tc-nds32.c (relax_table): Updated. (md_begin): Updated. (md_assemble): Use XNEW macro to allocate space for `insn.info', and then remember to free it. (md_section_align): Cast (-1) to ValueT. (nds32_get_align): Cast (~0U) to addressT. (nds32_relax_branch_instructions): Updated. (md_convert_frag): Add new local variable `final_r_type'. (invalid_prev_frag): Add new bfd_boolean parameter `relax'. All callers changed. * config/tc-nds32.c (struct nds32_relocs_pattern): Add `insn' field. (struct nds32_hint_map): Add `option_list' field. (struct suffix_name, suffix_table): Remove the unused `pic' field. (do_pseudo_b, do_pseudo_bal): Remove the suffix checking. (do_pseudo_la_internal, do_pseudo_pushpopm): Indent. (relax_hint_bias, relax_hint_id_current): New static variables. (reset_bias, relax_hint_begin): New variables. (nds_itoa): New function. (CLEAN_REG, GET_OPCODE): New macros. (struct relax_hint_id): New. (nds32_relax_hint): For .relax_hint directive, we can use `begin' and `end' to mark the relax pattern without giving exactly id number. (nds32_elf_append_relax_relocs): Handle the case that the .relax_hint directives are attached to pseudo instruction. (nds32_elf_save_pseudo_pattern): Change the second parameter from instruction's opcode to byte code. (nds32_elf_build_relax_relation): Add new bfd_boolean parameter `pseudo_hint'. (nds32_lookup_pseudo_opcode): Fix the overflow issue. (enum nds32_insn_type): Add N32_RELAX_ALU1 and N32_RELAX_16BIT. (nds32_elf_record_fixup_exp, relax_ls_table, hint_map, nds32_find_reloc_table, nds32_match_hint_insn, nds32_parse_name): Updated. * config/tc-nds32.h (MAX_RELAX_NUM): Extend it to 6. (enum nds32_relax_hint_type): Merge NDS32_RELAX_HINT_LA and NDS32_RELAX_HINT_LS into NDS32_RELAX_HINT_LALS. Add NDS32_RELAX_HINT_LA_PLT, NDS32_RELAX_HINT_LA_GOT and NDS32_RELAX_HINT_LA_GOTOFF. * config/tc-nds32.h (relax_ls_table): Add floating load/store to gp relax pattern. (hint_map, nds32_find_reloc_table): Likewise. * configure.ac: Define NDS32_LINUX_TOOLCHAIN. * configure: Regenerated. * config.in: Regenerated. * config/tc-nds32.h (enum nds32_ramp): Updated. (enum nds32_relax_hint_type): Likewise. * config/tc-nds32.c: Include "errno.h" and "limits.h". (relax_ls_table): Add TLS relax patterns. (nds32_elf_append_relax_relocs): Attach BFD_RELOC_NDS32_GROUP on each instructions of TLS patterns. (nds32_elf_record_fixup_exp): Updated. (nds32_apply_fix): Likewise. (suffix_table): Add TLSDESC suffix. binutils* testsuite/binutils-all/objcopy.exp: Set the unsupported reloc number from 215 to 255 for NDS32. bfd * elf32-nds32.c (nds32_elf_relax_loadstore): Remove the unused target features. (bfd_elf32_nds32_set_target_option): Remove the unused parameters. (nds32_elf_relax_piclo12, nds32_elf_relax_letlslo12, nds32_elf_relax_letlsadd, nds32_elf_relax_letlsls, nds32_elf_relax_pltgot_suff, nds32_elf_relax_got_suff nds32_elf_relax_gotoff_suff, calculate_plt_memory_address, calculate_plt_offset, calculate_got_memory_address, nds32_elf_check_dup_relocs): Removed. All callers changed. * elf32-nds32.h: Remove the unused macros and defines. (elf_nds32_link_hash_table): Remove the unused variable. (bfd_elf32_nds32_set_target_option): Update prototype. (nds32_elf_ex9_init): Removed. * elf32-nds32.c (nds32_convert_32_to_16): Updated. * elf32-nds32.c (HOWTO2, HOWTO3): Define new HOWTO macros to initialize array nds32_elf_howto_table in any order without lots of EMPTY_HOWTO. (nds32_reloc_map): Updated. * reloc.c: Add BFD_RELOC_NDS32_LSI. * bfd-in2.h: Regenerated. * bfd/libbfd.h: Regenerated. * elf32-nds32.c (nds32_elf_relax_howto_table): Add R_NDS32_LSI. (nds32_reloc_map): Likewise. (nds32_elf_relax_flsi): New function. (nds32_elf_relax_section): Support floating load/store relaxation. * elf32-nds32.c (NDS32_GUARD_SEC_P, elf32_nds32_local_gp_offset): New macro. (struct elf_nds32_link_hash_entry): New `offset_to_gp' field. (struct elf_nds32_obj_tdata): New `offset_to_gp' and `hdr_size' fields. (elf32_nds32_allocate_local_sym_info, nds32_elf_relax_guard, nds32_elf_is_target_special_symbol, nds32_elf_maybe_function_sym): New functions. (nds32_info_to_howto_rel): Add BFD_ASSERT. (bfd_elf32_bfd_reloc_type_table_lookup, nds32_elf_link_hash_newfunc, nds32_elf_link_hash_table_create, nds32_elf_relocate_section, nds32_elf_relax_loadstore, nds32_elf_relax_lo12, nds32_relax_adjust_label, bfd_elf32_nds32_set_target_option, nds32_fag_mark_relax): Updated. (nds32_elf_final_sda_base): Improve it to find the better gp value. (insert_nds32_elf_blank): Must consider `len' when inserting blanks. * elf32-nds32.h (bfd_elf32_nds32_set_target_option): Update prototype. (struct elf_nds32_link_hash_table): Add new variable `hyper_relax'. * elf32-nds32.c (elf32_nds32_allocate_dynrelocs): New function. (create_got_section): Likewise. (allocate_dynrelocs, nds32_elf_size_dynamic_sections, nds32_elf_relocate_section, nds32_elf_finish_dynamic_symbol): Updated. (nds32_elf_check_relocs): Fix the issue that the shared library may has TEXTREL entry in the dynamic section. (nds32_elf_create_dynamic_sections): Enable to call readonly_dynrelocs since the TEXTREL issue is fixed in the nds32_elf_check_relocs. (nds32_elf_finish_dynamic_sections): Update and add DT_RELASZ dynamic entry. (calculate_offset): Remove the unused parameter `pic_ext_target' and related codes. All callers changed. (elf_backend_dtrel_excludes_plt): Disable it temporarily since it will cause some errors for our test cases. * elf32-nds32.c (nds32_elf_merge_private_bfd_data): Allow to link the generic object. * reloc.c: Add TLS relocations. * libbfd.h: Regenerated. * bfd-in2.h: Regenerated. * elf32-nds32.h (struct section_id_list_t): New. (elf32_nds32_lookup_section_id, elf32_nds32_check_relax_group, elf32_nds32_unify_relax_group, nds32_elf_unify_tls_model): New prototypes. (elf32_nds32_compute_jump_table_size, elf32_nds32_local_tlsdesc_gotent): New macro. (nds32_insertion_sort, bfd_elf32_nds32_set_target_option, elf_nds32_link_hash_table): Updated. * elf32-nds32.c (enum elf_nds32_tls_type): New. (struct elf32_nds32_relax_group_t, struct relax_group_list_t): New. (elf32_nds32_add_dynreloc, patch_tls_desc_to_ie, get_tls_type, fls, ones32, list_insert, list_insert_sibling, dump_chain, elf32_nds32_check_relax_group, elf32_nds32_lookup_section_id, elf32_nds32_unify_relax_group, nds32_elf_unify_tls_model): New functions. (elf_nds32_obj_tdata): Add new fields. (elf32_nds32_relax_group_ptr, nds32_elf_local_tlsdesc_gotent): New macros. (nds32_elf_howto_table): Add TLS relocations. (nds32_reloc_map): Likewise. (nds32_elf_copy_indirect_symbol, nds32_elf_size_dynamic_sections, nds32_elf_finish_dynamic_symbol, elf32_nds32_allocate_local_sym_info, nds32_elf_relocate_section, bfd_elf32_nds32_set_target_option, nds32_elf_check_relocs, allocate_dynrelocs): Updated. (nds32_elf_relax_section): Call nds32_elf_unify_tls_model. (dtpoff_base): Rename it to `gottpof' and then update it. opcodes * nds32-asm.c (operand_fields): Remove the unused fields. (nds32_opcodes): Remove the unused instructions. * nds32-dis.c (nds32_ex9_info): Removed. (nds32_parse_opcode): Updated. (print_insn_nds32): Likewise. * nds32-asm.c (config.h, stdlib.h, string.h): New includes. (LEX_SET_FIELD, LEX_GET_FIELD): Update defines. (nds32_asm_init, build_operand_hash_table, build_keyword_hash_table, build_opcode_hash_table): New functions. (nds32_keyword_table, nds32_keyword_count_table, nds32_field_table, nds32_opcode_table): New. (hw_ktabs): Declare it to a pointer rather than an array. (build_hash_table): Removed. * nds32-asm.h (enum): Add SYN_INPUT, SYN_OUTPUT, SYN_LOPT, SYN_ROPT and upadte HW_GPR and HW_INT. * nds32-dis.c (keywords): Remove const. (match_field): New function. (nds32_parse_opcode): Updated. * disassemble.c (disassemble_init_for_target): Add disassemble_init_nds32. * nds32-dis.c (eum map_type): New. (nds32_private_data): Likewise. (get_mapping_symbol_type, is_mapping_symbol, nds32_symbol_is_valid, nds32_add_opcode_hash_table, disassemble_init_nds32): New functions. (print_insn_nds32): Updated. * nds32-asm.c (parse_aext_reg): Add new parameter. (parse_re, parse_re2, parse_aext_reg): Only reduced registers are allowed to use. All callers changed. * nds32-asm.c (keyword_usr, keyword_sr): Updated. (operand_fields): Add new fields. (nds32_opcodes): Add new instructions. (keyword_aridxi_mx): New keyword. * nds32-asm.h (enum): Add NASM_ATTR_DSP_ISAEXT, HW_AEXT_ARIDXI_MX and NASM_ATTR_ZOL. (ALU2_1, ALU2_2, ALU2_3): New macros. * nds32-dis.c (nds32_filter_unknown_insn): Updated.
2018-09-19PR23648 testcaseAlan Modra4-0/+37
PR 23648 * testsuite/ld-elf/pr23648.d, * testsuite/ld-elf/pr23648.s, * testsuite/ld-elf/pr23648.t: New test.
2018-09-19PR23648, Symbols based on MEMORY regions confuse --gc-sectionsAlan Modra3-5/+15
Running lang_do_memory_regions earlier seems a reasonable solution to gaining better values for symbols prior to lang_gc_sections. PR ld/23648 * ldlang.c (lang_process): Move lang_do_memory_regions earlier. Comment on lang_do_assignments call. * ldgram.y (origin_exp): Don't assign region->current.
2018-09-19Tweak map file output for pei386_auto_importAlan Modra2-0/+9
* ldmain.c (add_archive_element): Handle auto-inport symbols when printing map.
2018-09-17A few hppa testcase tidiesAlan Modra3-3/+5
binutils/ * testsuite/lib/binutils-common.exp (is_som_format): New proc. (run_dump_test): Correct target test for alternate .comm syntax. (get_standard_section_names): Handle som format. * testsuite/lib/utils-lib.exp (default_binutils_assemble_flags): Correct target test for alternate .comm syntax. gas/ * testsuite/gas/all/gas.exp (redef3): Don't xfail for hppa. (octa): Run for hppa. * testsuite/gas/elf/elf.exp (common1, common2): Likewise. * testsuite/gas/elf/symver.d: Delete notarget. ld/ * testsuite/ld-elf/comm-data5.d: Remove notarget for hppa. * testsuite/ld-scripts/defined6.d: Likewise.
2018-09-17Ensure that binutils test names are unique.Nick Clifton8-13/+32
binutils* testsuite/binutils-all/compress.exp: Rename second "objcopy zlib-gnu compress debug sections 3" test to "objcopy zlib-gabi compress debug sections 3" and use gabi object files instead of gnu object files. * testsuite/binutils-all/objcopy.exp: Add suffix to the names of the "ELF group" tests. * testsuite/binutils-all/readelf.exp (proc readelf_find_size): Add an iteration parameter and include it in the name of the test. Update callers to include an iteration count. gas * testuite/gas/elf/group0a.d: Add extra details to the test name. * testuite/gas/elf/group0b.d: Likewise. * testuite/gas/elf/group1a.d: Likewise. * testuite/gas/elf/group1b.d: Likewise. * testuite/gas/elf/group0b.d: Likewise. * testuite/gas/elf/section9.d: Likewise. * testuite/gas/i386/ilp32/lns/lns-common-1.d: Likewise. * testuite/gas/i386/ilp32/lns/lns-duplicate-1.d: Likewise. ld * testuite/ld/ld-elf/audit.exp: Differentiate the names of the two "Run with shared with --audit" tests. * testuite/ld/ld-elf/compress.exp: Differentiate the zlib compressed debug output test names. * testuite/ld/ld-i386/tlspie1.d: Add extra details to the test name. * testuite/ld/ld-i386/tlspie2.d: Likewise. * testuite/ld/ld-size/size.exp: Add missing escapes to the end of lines in the size-3e test. * testuite/ld/ld-unique/unique.exp: Differentiate the names of the two "Checking unique PIC object" tests. * testuite/ld/ld-x86-64/tlspie1.d: Add extra details to the test name.
2018-09-17S/390: Prevent GOT access rewrite for certain symbolsAndreas Krebbel5-24/+32
When dereferencing a GOT slot with lgrl or lg we rewrite this using larl to get rid of the extra memory access. However, we cannot do this for: - symbols marked for absolute addressing - symbols at odd addresses (larl can handle only even addresses) Fixed with the attached patch. bfd/ChangeLog: 2018-09-17 Andreas Krebbel <krebbel@linux.ibm.com> * elf64-s390.c (elf_s390_relocate_section): Prevent rewriting of GOT accesses with larl for ABS or misaligned symbols. ld/ChangeLog: 2018-09-17 Andreas Krebbel <krebbel@linux.ibm.com> * testsuite/ld-s390/gotreloc-1.s: Add tests for ABS and misaligned symbol. Move variables into data section. Make bar 8 bytes wide. * testsuite/ld-s390/gotreloc-1.ver: Make misaligned_sym resolve locally. * testsuite/ld-s390/gotreloc_31-1.dd: Adjust patterns. * testsuite/ld-s390/gotreloc_64-norelro-1.dd: Likewise. * testsuite/ld-s390/gotreloc_64-relro-1.dd: Likewise.
2018-09-16S12Z Add tests for relocs.John Darrington12-0/+137
ld/testsuite/ld-s12z/ * reloc-ext18-1.d: New file. * reloc-ext18-1.d: New file. * reloc-ext18-2.d: New file. * reloc-ext18.d: New file. * reloc-ext18.s: New file. * reloc-ext24.d: New file. * reloc-ext24.s: New file. * reloc-ext32.d: New file. * reloc-ext32.s: New file. * reloc-opr.d: New file. * reloc-opr.d: New file. * reloc-opr.s: New file. * reloc-pc-rel-7-15.d: New file. * reloc-pc-rel-7-15.s: New file.
2018-09-16Don't emit data_section_size when -r is specifiedJohn Darrington1-1/+1
* ld/scripttempl/elfm9s12z.sc (.install): Add RELOCATING+ qualifier.
2018-09-16S12Z: LD: Rename z12s.exp --> s12z.expJohn Darrington1-0/+0
* ld/testsuite/ld-s12z/z12s.exp: Delete. * ld/testsuite/ld-s12z/s12z.exp: New file.
2018-09-15Consolidate run_dump_testAlan Modra10-798/+20
This merges the three versions of run_dump_test. Improved warning handling versus the old gas version shows up a number of tests that need their disassembly updating: arm-linuxeabi +FAIL: ARM v1 instructions arm-linuxeabi +FAIL: Accepted v8-a with ARMv8.1 AdvSIMD. arm-linuxeabi +FAIL: bl local instructions for v4t. arm-linuxeabi +FAIL: UDF and some that now fail due to detecting assembly warnings: h8300-elf +FAIL: binutils-all/strip-13 h8300-elf +FAIL: binutils-all/strip-14 h8300-elf +FAIL: binutils-all/strip-15 I've generally kept the union of all run_dump_test features, except that the ld target aliases "cfi" and "shared" have disappeared, as has the binutils substitution of $srcdir as $scrdir/$subdir. binutils/ * testsuite/binutils-all/add-symbol.d: Add "section_subst: no". * testsuite/binutils-all/elfedit.exp: Don't set tempfile or copyfile. * testsuite/binutils-all/symbols-1.d, * testsuite/binutils-all/symbols-2.d, * testsuite/binutils-all/symbols-3.d, * testsuite/binutils-all/symbols-4.d: Quote '*' and '!'. * testsuite/binutils-all/add-empty-section.d, * testsuite/binutils-all/add-section.d, * testsuite/binutils-all/elfedit.exp, * testsuite/binutils-all/note-1.d, * testsuite/binutils-all/pr23633.d: Add $subdir after $srcdir. * testsuite/config/default.exp (AS, ASFLAGS): Define. * testsuite/config/hppa.sed: Handle all common symbols. * testsuite/lib/binutils-common.exp (run_dump_test): New proc, merged from three other versions. (slurp_options, file_contents, set_file_contents): Likewise. (big_or_little_endian, get_standard_section_names): Likewise. * testsuite/lib/utils-lib.exp (run_dump_test): Delete. (slurp_options, proc file_contents): Delete. (get_standard_section_names): Delete. gas/ * testsuite/config/default.exp: Make tmpdir. * testsuite/lib/gas-defs.exp (run_dump_test): Delete. (get_standard_section_names, slurp_options): Delete. ld/ * testsuite/ld-d10v/reloc-007.d, * testsuite/ld-d10v/reloc-008.d, * testsuite/ld-d10v/reloc-015.d, * testsuite/ld-d10v/reloc-016.d: Remove "error:". * testsuite/ld-elf/eh-frame-hdr.d, * testsuite/ld-elf/eh5.d, * testsuite/ld-gc/personality.d: Replace "cfi" and "shared" in target list with appropriate proc. * testsuite/ld-elf/frame.exp: Use check_shared_lib_support rather than "istarget shared". * testsuite/lib/ld-lib.exp (proc big_or_little_endian): Delete. (run_dump_test, slurp_options, file_contents): Delete. (set_file_contents, istarget): Delete.
2018-09-15run_dump_test replace PROG with DUMPPROG in gas and ldAlan Modra2-21/+27
To be compatible with the binutils version, that uses PROG for the tool under test and DUMPPROG for the dump tool. gas/ * testsuite/gas/mips/aent-2.d, * testsuite/gas/mips/aent-mdebug-2.d, * testsuite/gas/mips/attr-gnu-4-0.d, * testsuite/gas/mips/attr-gnu-4-1.d, * testsuite/gas/mips/attr-gnu-4-2.d, * testsuite/gas/mips/attr-gnu-4-3.d, * testsuite/gas/mips/attr-gnu-4-5.d, * testsuite/gas/mips/attr-gnu-4-6.d, * testsuite/gas/mips/attr-gnu-4-7.d, * testsuite/gas/mips/attr-none-double.d, * testsuite/gas/mips/attr-none-o32-fp64-nooddspreg.d, * testsuite/gas/mips/attr-none-o32-fp64.d, * testsuite/gas/mips/attr-none-o32-fpxx.d, * testsuite/gas/mips/attr-none-single-float.d, * testsuite/gas/mips/attr-none-soft-float.d, * testsuite/gas/mips/elf-rel27.d, * testsuite/gas/mips/loc-swap-2.d, * testsuite/gas/mips/loc-swap-3.d, * testsuite/gas/mips/loc-swap.d, * testsuite/gas/mips/micromips@loc-swap-2.d, * testsuite/gas/mips/micromips@loc-swap.d, * testsuite/gas/mips/micromips@stabs-symbol-type.d, * testsuite/gas/mips/mips16-intermix.d, * testsuite/gas/mips/mips16@loc-swap-2.d, * testsuite/gas/mips/mips16@loc-swap.d, * testsuite/gas/mips/mips16@stabs-symbol-type.d, * testsuite/gas/mips/mips16e@loc-swap.d, * testsuite/gas/mips/no-odd-spreg.d, * testsuite/gas/mips/odd-spreg.d, * testsuite/gas/mips/r6-attr-none-double.d, * testsuite/gas/mips/stabs-symbol-type.d, * testsuite/lib/gas-defs.exp (run_dump_test): Replace PROG with DUMPPROG. ld/ * testsuite/lib/ld-lib.exp (run_dump_test): Replace PROG with DUMPPROG.
2018-09-15Remove run_dump_test support for objcopy as a dump programAlan Modra11-28/+41
We have three copies of run_dump_test in the testsuite. This is a first step towards consolidating them. A few tests use objcopy to convert to verilog or srec output, then check that output is as expected. Those tests can just as easily use objdump, keeping the set of dump programs (addr2line, nm, objdump, readelf, size) separate from utilities under test. That in turn makes auto-detecting the dump program possible in more places. binutils/ * testsuite/binutils-all/group-7a.d, * testsuite/binutils-all/group-7b.d, * testsuite/binutils-all/group-7c.d, * testsuite/binutils-all/symbols-1.d, * testsuite/binutils-all/symbols-2.d, * testsuite/binutils-all/symbols-3.d, * testsuite/binutils-all/symbols-4.d: Remove DUMPPROG. gas/ * testsuite/gas/mri/char.d: Don't objcopy to srec, objdump instead. * testsuite/gas/mri/float.d: Likewise. * testsuite/lib/gas-defs.exp (run_dump_test): Remove support for objcopy as a dump tool. ld/ * testsuite/ld-elf/interleave-0.d, * testsuite/ld-elf/interleave-4.d: Don't objcopy to srec, objdump instead. * testsuite/ld-gc/all-debug-sections.d, * testsuite/ld-scripts/provide-4.d, * testsuite/ld-scripts/provide-5.d, * testsuite/ld-scripts/provide-6.d, * testsuite/ld-scripts/provide-7.d, * testsuite/ld-scripts/provide-8.d, * testsuite/ld-scripts/segment-start.d: Remove PROG, specify nm instead. * testsuite/lib/ld-lib.exp (run_dump_test): Remove support for objcopy as a dump tool.
2018-09-14PR ld/21375: MIPS: Add test cases for undefined weaks resolving to zeroMaciej W. Rozycki81-0/+1602
Define a new procedure, `run_mips_undefweak_test', and use it to iterate over several scenarios involving undefined weak symbols resolving to zero, verifying expected regular MIPS, MIPS16 and microMIPS code, GOT and dynamic symbol table generation, as well as the setting of the EI_ABIVERSION field in the ELF file header. In particular ensure that symbol versioning works and that `__gnu_absolute_zero' gets assigned a version (any will do) even if it has not been listed for exportation in a linker version script. ld/ PR ld/21375 * testsuite/ld-mips-elf/pr21375-abi.hd: New test. * testsuite/ld-mips-elf/pr21375-noabi.hd: New test. * testsuite/ld-mips-elf/pr21375.dd: New test. * testsuite/ld-mips-elf/pr21375h.dd: New test. * testsuite/ld-mips-elf/pr21375p.dd: New test. * testsuite/ld-mips-elf/pr21375ph.dd: New test. * testsuite/ld-mips-elf/pr21375s.dd: New test. * testsuite/ld-mips-elf/pr21375s-n32.dd: New test. * testsuite/ld-mips-elf/pr21375s-n64.dd: New test. * testsuite/ld-mips-elf/pr21375sh.dd: New test. * testsuite/ld-mips-elf/pr21375sh-n32.dd: New test. * testsuite/ld-mips-elf/pr21375sh-n64.dd: New test. * testsuite/ld-mips-elf/pr21375shg.dd: New test. * testsuite/ld-mips-elf/pr21375sx.dd: New test. * testsuite/ld-mips-elf/pr21375sxh.dd: New test. * testsuite/ld-mips-elf/pr21375sm16.dd: New test. * testsuite/ld-mips-elf/pr21375sm16h.dd: New test. * testsuite/ld-mips-elf/pr21375su.dd: New test. * testsuite/ld-mips-elf/pr21375su-n32.dd: New test. * testsuite/ld-mips-elf/pr21375su-n64.dd: New test. * testsuite/ld-mips-elf/pr21375suh.dd: New test. * testsuite/ld-mips-elf/pr21375suh-n32.dd: New test. * testsuite/ld-mips-elf/pr21375suh-n64.dd: New test. * testsuite/ld-mips-elf/pr21375sux.dd: New test. * testsuite/ld-mips-elf/pr21375suxh.dd: New test. * testsuite/ld-mips-elf/pr21375.gd: New test. * testsuite/ld-mips-elf/pr21375h.gd: New test. * testsuite/ld-mips-elf/pr21375p.gd: New test. * testsuite/ld-mips-elf/pr21375ph.gd: New test. * testsuite/ld-mips-elf/pr21375s.gd: New test. * testsuite/ld-mips-elf/pr21375s-n32.gd: New test. * testsuite/ld-mips-elf/pr21375s-n64.gd: New test. * testsuite/ld-mips-elf/pr21375sh.gd: New test. * testsuite/ld-mips-elf/pr21375sh-n32.gd: New test. * testsuite/ld-mips-elf/pr21375sh-n64.gd: New test. * testsuite/ld-mips-elf/pr21375shg.gd: New test. * testsuite/ld-mips-elf/pr21375shl.gd: New test. * testsuite/ld-mips-elf/pr21375shv.gd: New test. * testsuite/ld-mips-elf/pr21375sx.gd: New test. * testsuite/ld-mips-elf/pr21375sxh.gd: New test. * testsuite/ld-mips-elf/pr21375.sd: New test. * testsuite/ld-mips-elf/pr21375-irix.sd: New test. * testsuite/ld-mips-elf/pr21375h.sd: New test. * testsuite/ld-mips-elf/pr21375h-irix.sd: New test. * testsuite/ld-mips-elf/pr21375p.sd: New test. * testsuite/ld-mips-elf/pr21375p-irix.sd: New test. * testsuite/ld-mips-elf/pr21375ph.sd: New test. * testsuite/ld-mips-elf/pr21375ph-irix.sd: New test. * testsuite/ld-mips-elf/pr21375s.sd: New test. * testsuite/ld-mips-elf/pr21375s-irix.sd: New test. * testsuite/ld-mips-elf/pr21375s-n32.sd: New test. * testsuite/ld-mips-elf/pr21375s-n32-irix.sd: New test. * testsuite/ld-mips-elf/pr21375s-n64.sd: New test. * testsuite/ld-mips-elf/pr21375s-n64-irix.sd: New test. * testsuite/ld-mips-elf/pr21375sh.sd: New test. * testsuite/ld-mips-elf/pr21375sh-irix.sd: New test. * testsuite/ld-mips-elf/pr21375sh-n32.sd: New test. * testsuite/ld-mips-elf/pr21375sh-n32-irix.sd: New test. * testsuite/ld-mips-elf/pr21375sh-n64.sd: New test. * testsuite/ld-mips-elf/pr21375sh-n64-irix.sd: New test. * testsuite/ld-mips-elf/pr21375shg.sd: New test. * testsuite/ld-mips-elf/pr21375shg-irix.sd: New test. * testsuite/ld-mips-elf/pr21375shl.sd: New test. * testsuite/ld-mips-elf/pr21375shl-irix.sd: New test. * testsuite/ld-mips-elf/pr21375shv.sd: New test. * testsuite/ld-mips-elf/pr21375shv-irix.sd: New test. * testsuite/ld-mips-elf/pr21375sx.sd: New test. * testsuite/ld-mips-elf/pr21375sx-irix.sd: New test. * testsuite/ld-mips-elf/pr21375sxh.sd: New test. * testsuite/ld-mips-elf/pr21375sxh-irix.sd: New test. * testsuite/ld-mips-elf/pr21375.ld: New test linker script. * testsuite/ld-mips-elf/pr21375-xgot.ld: New test linker script. * testsuite/ld-mips-elf/pr21375.ver: New test version script. * testsuite/ld-mips-elf/pr21375v.ver: New test version script. * testsuite/ld-mips-elf/pr21375.s: New test source. * testsuite/ld-mips-elf/pr21375-mips16.s: New test source. * testsuite/ld-mips-elf/pr21375-n32.s: New test source. * testsuite/ld-mips-elf/pr21375-n64.s: New test source. * testsuite/ld-mips-elf/pr21375-xgot.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp (run_mips_undefweak_test): New procedure; run the new tests.
2018-09-14PR ld/21375: MIPS: Fix non-zero run-time value for undefined weaksMaciej W. Rozycki4-3/+22
We have an issue in the MIPS backend, with the handling of undefined hidden and internal weak symbols. References to such symbols are supposed to resolve to 0 according to the ELF gABI[1]: "Unresolved weak symbols have a zero value." and the 64-bit MIPS psABI[2]: "If a symbol with one of these [hidden or internal] attributes has no definition within the executable/DSO being linked, then it must be resolved to allocated space if common, resolved to zero if weak, or an error reported otherwise." however if a GOT relocation is used, then a local GOT entry is created and used to satisfy the reference. Such an entry is then (in DSO and PIE binaries) subject to the usual load-time relocation, which means a non-zero value will be returned if the base address is non-zero. This will defeat the usual run-time sequence like: void a (void) __attribute__ ((visibility ("hidden"), weak)); void x (void) { if (a) a (); } This can be reproduced with this simple code: $ cat libtest.c extern int a __attribute__ ((visibility ("hidden"), weak)); int * x (void) { return &a; } $ cat test.c int *x (void); int main (void) { printf ("a: %p\n", x ()); return 0; } $ gcc -shared -fPIC -o libtest.so libtest.c $ gcc -o test test.c -Wl,-rpath,$(pwd) libtest.so $ ./test a: 0x77184000 $ The usual approach targets take is making all the steps required to assign a GOT entry for the symbol referred, and then leave its contents at zero with no dynamic relocation attached, therefore ensuring that the value does not change at load time. However this is not going to work with the implicitly relocated GOT the MIPS psABI specifies[3]: "The dynamic linker relocates the global offset table by first adding the difference between the base where the shared object is loaded and the value of the dynamic tag DT_MIPS_BASE_ADDRESS to all local global offset table entries." and we cannot therefore use the local GOT part. And we cannot offhand use the global part either, as the symbol would then have to be exported and possibly wrongly preempt symbols in other modules involved in the dynamic load, because as per the ELF gABI[1] we are not allowed to enter a hidden or internal symbol into the dynamic symbol table (and then use its associated GOT entry): "A hidden symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object." and: "An internal symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object." So we have to choose something else. Our choice is further limited by the need for the reference associated with the GOT relocation to stay within the signed 16-bit limit from the GOT pointer base register, while being compliant with the ELF gABI and the MIPS psABI. However as Alan Modra has observed[4] one possibility is to edit (relax) the code such that the GOT reference is removed altogether. Based on these observations then modify MIPS BFD linker backend code to: 1. Interpret code associated with GOT relocations and relax the usual LW or LD instructions into a corresponding immediate load operation that places the value of 0 in the intended register, while leaving the GOT entry allocated and initialized as usually. 2. Leave any other instructions associated with GOT relocations in place and instead redirect the reference to a global GOT entry associated with a special `__gnu_absolute_zero' symbol created for this purpose, whose value is 0, SHN_ABS section marks it absolute, binding is global and export class protected, ensuring that the locally provided value is always used at load time, and that the value is not relocated by the dynamic loader. 3. Adjust any high-part GOT relocation used, typically associated with a LUI instruction, accordingly, so that run-time consistency is maintained, either by resolving to the original entry if the instruction associated with the corresponding low-part GOT relocation has been relaxed to an immediate load (in which case the value loaded with LUI will be overwritten), or by also redirecting the reference to `__gnu_absolute_zero' to complete the GOT access sequence if that symbol has been used. 4. Add a target `elf_backend_hide_symbol' hook, for the three MIPS ABIs, which prevents the `__gnu_absolute_zero' symbol from being forced local, to ensure that the redirection works and the symbol remains global/protected with existing linker scripts unchanged. 5. Observing the issue with handling SHN_ABS symbols in the GNU dynamic loader, covered by glibc PR 19818, set the EI_ABIVERSION field in the ELF file header produced to 4 (ABI_ABSOLUTE) if `__gnu_absolute_zero' symbol has been produced and the target configured indicates the GNU operating system, so that broken versions of the GNU dynamic loader gracefully reject the file in loading rather than going astray. Keep EI_ABIVERSION at the original value for other operating systems or if no `__gnu_absolute_zero' symbol has been made. The name of the special `__gnu_absolute_zero' has no meaning other than how a human reader can interpret it, as it is ignored in dynamic loading in the handling of the scenarios concerned. This is because the symbol resolves locally, and it's only the symbol's attributes that matter so that the associated GOT entry remains unchanged at load time. Therefore the name is somewhat arbitrary, observing however the need to use the name space reserved for the system so that it does not conflict with a possible user symbol, and hence the leading underscore, and also the `gnu' infix to denote a GNU feature. Other implementations wishing to address the problem in a similar way may choose a different name and have the solution still work, possibly with a mixture of modules used in a dynamic having symbols of different names provided, which will however not interact with each other due to the protected export class. The symbol can be referred explicitly, however the name is an internal implementation detail rather than a part of the ABI, and therefore no specific semantics is guaranteed. One limitation of this change is that if `__gnu_absolute_zero' has been already defined, then we do not wipe the old definition and all kinds of odd behavior can result. This is however like with other symbols we internally define, such as `_GLOBAL_OFFSET_TABLE_' or `__rld_map', and therefore left as a possible future enhancement. As an optimization the relaxation of LW and LD instructions to a load of immediate zero is always made, even SVR4 PIC code for code that will end up in a regular (non-PIE) executable, because there is a cache advantage with the avoidance of a load from the GOT, even if it is otherwise guaranteed to remain zero. It does not reliably happen though, due to a symbol exportation issue affecting executables, covered by PR ld/21805. One existing test case needs to be updated, as it triggers relaxation introduced with this change and consequently linker output does not match expectations anymore. As we want to keep the original issue covered with the test case modify it then to use the LWL instruction in place of LW, and adjust the output expected accordingly. References: [1] "System V Application Binary Interface - DRAFT - 19 October 2010", The SCO Group, Section "Symbol Table", <http://www.sco.com/developers/gabi/2012-12-31/ch4.symtab.html> [2] "64-bit ELF Object File Specification, Draft Version 2.5", MIPS Technologies / Silicon Graphics Computer Systems, Order Number 007-4658-001, Section 2.5 "Symbol Table", p. 22, <http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf> [3] "SYSTEM V APPLICATION BINARY INTERFACE, MIPS RISC Processor Supplement, 3rd Edition", Section "Global Offset Table", p. 5-10, <http://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf> [4] "Undo dynamic symbol state after regular object sym type mismatch", <https://sourceware.org/ml/binutils/2017-07/msg00265.html> bfd/ PR ld/21375 * elfxx-mips.h (_bfd_mips_elf_hide_symbol): New prototype. (_bfd_mips_elf_linker_flags): Update prototype. * elf32-mips.c (elf_backend_hide_symbol): New macro. * elf64-mips.c (elf_backend_hide_symbol): Likewise. * elfn32-mips.c (elf_backend_hide_symbol): Likewise. * elfxx-mips.c (mips_elf_link_hash_table): Add `use_absolute_zero' and `gnu_target' members. (mips_elf_record_global_got_symbol): Call `_bfd_mips_elf_hide_symbol' rather than `_bfd_elf_link_hash_hide_symbol'. (mips_use_local_got_p): Return FALSE if the symbol is absolute. (mips_elf_obtain_contents): Reorder function. (mips_elf_nullify_got_load): New function. (mips_elf_calculate_relocation): Add `contents' parameter. Nullify GOT loads or if it is not possible, then redirect GOT relocations to the `__gnu_absolute_zero' symbol, for references that are supposed to resolve to zero. (mips_elf_define_absolute_zero): New function. (_bfd_mips_elf_check_relocs): Prepare for arrangements made in `mips_elf_calculate_relocation' for references made via the GOT that are supposed to resolve to zero. (_bfd_mips_elf_hide_symbol): New function. (_bfd_mips_elf_linker_flags): Add the `gnu_target' parameter, set the `gnu_target' member of the MIPS hash table. (MIPS_LIBC_ABI_ABSOLUTE): New enumeration constant. (_bfd_mips_post_process_headers): Use it. ld/ PR ld/21375 * emultempl/mipself.em: Set `gnu_target' according to ${target}. (mips_create_output_section_statements): Update call to `_bfd_mips_elf_linker_flags'. * testsuite/ld-mips-elf/pr21334.s: Use LWL rather than LW. * testsuite/ld-mips-elf/pr21334.dd: Update accordingly.
2018-09-14LD: Always make a SEGMENT_START expression section-relativeMaciej W. Rozycki6-1/+50
Fix an issue with the SEGMENT_START builtin function where its result is absolute when taken from the default supplied, and section-relative when taken from a `-T' command-line override. This is against documentation, inconsistent and unexpected, and with PIE executables gives an incorrect result with the `__executable_start' symbol. Make the result of SEGMENT_START always section-relative then. ld/ * ldexp.c (fold_binary): Always make the result of SEGMENT_START section-relative. * testsuite/ld-scripts/segment-start.d: New test. * testsuite/ld-scripts/segment-start.ld: New test linker script. * testsuite/ld-scripts/segment-start.s: New test source. * testsuite/ld-scripts/script.exp: Run the new test.
2018-09-14LD: Avoid a division by zero page size with SEGMENT_START handlingMaciej W. Rozycki2-0/+6
Avoid a division by zero and thus a linker crash in SEGMENT_START script builtin function handling, by not checking the value supplied with a `-T' command-line override against the maximum page size if that has not been set. ld/ * ldexp.c (fold_binary): Check that `config.maxpagesize' is non-zero before using it as a divisor.
2018-09-03Updated Finnish translation for the ld sub-directory.Nick Clifton2-1093/+6641
* po/fi.po: Updated Finnish translation.
2018-09-03Re: ld: Lookup section in output with the same nameAlan Modra5-16/+28
Fixes pr23591 test failures on hppa64-hpux and score-elf, and xfails frv-linux and lm32-linux. PR ld/23591 * testsuite/ld-elf/pr23591a.s, * testsuite/ld-elf/pr23591b.s, * testsuite/ld-elf/pr23591c.s: Don't start directives in first column. * testsuite/ld-elf/pr23591.d: xfail frv-linux and lm32-linux. Allow __start___sancov_cntrs as a local symbol.
2018-08-31ld: Lookup section in output with the same nameH.J. Lu6-0/+88
When there are more than one input sections with the same section name, SECNAME, linker picks the first one to define __start_SECNAME and __stop_SECNAME symbols. When the first input section is removed by comdat group, we need to check if there is still an output section with section name SECNAME. PR ld/23591 * ldlang.c (undef_start_stop): Lookup section in output with the same name. * testsuite/ld-elf/pr23591.d: New file. * testsuite/ld-elf/pr23591a.s: Likewise. * testsuite/ld-elf/pr23591b.s: Likewise. * testsuite/ld-elf/pr23591c.s: Likewise.